import os,sys
sys.path.append(os.path.join(os.environ['SUMO_HOME'],'tools'))
import traci

traci.start(['sumo',
    '-c', '10_disturbed.sumocfg',
    '-l', 'train_cancelation.log',
    '--stop-output', 'stopinfos_train_cancelation.xml',
    '--time-to-teleport', '-1',
    '--tripinfo-output.write-unfinished',
    ])

for i in range(4000):
    traci.simulationStep()

    canceled = 'flow_2.2' 
    if canceled in traci.simulation.getDepartedIDList():
        print("cancled train %s at time %s" % (canceled, traci.simulation.getTime()))
        traci.vehicle.remove(canceled)

traci.close()
