Пример #1
0
def runSingle(traciEndTime):
    step = 0
    sumoProcess = subprocess.Popen("%s -c used.sumo.cfg %s" % (sumoBinary, addOption), shell=True, stdout=sys.stdout)
    traciControl.initTraCI(PORT)
    while not step>traciEndTime:
        traciControl.cmdSimulationStep2(DELTA_T)
        step += 1
    print "Print ended at step %s" % (traciControl.cmdGetSimulationVariable_currentTime() / DELTA_T)
    traciControl.cmdClose()
    sys.stdout.flush()
Пример #2
0
def runSingle(addOption):
    step = 0
    timeline = []
    sumoProcess = subprocess.Popen("%s -c %s %s" % (sumoBinary, "sumo.sumo.cfg", addOption), shell=True, stdout=sys.stdout)
    traciControl.initTraCI(PORT)
    while not step>10000:
        try:
            traciControl.cmdSimulationStep2(DELTA_T)
            vehs = traciControl.cmdGetVehicleVariable_idList()
            timeline.append({})
            for v in vehs:
                timeline[-1][v] = traciControl.cmdGetVehicleVariable_speed(v)
            step += 1
        except traciControl.FatalTraCIError:
            print "Closed by SUMO"
            break
    traciControl.cmdClose()
    sys.stdout.flush()
    return timeline
Пример #3
0
def runSingle(sumoEndTime, traciEndTime):
    fdi = open("sumo.sumo.cfg")
    fdo = open("used.sumo.cfg", "w")
    for line in fdi:
        line = line.replace("%end%", str(sumoEndTime))
        fdo.write(line)
    fdi.close()
    fdo.close()
    doClose = True
    step = 0
    sumoProcess = subprocess.Popen("%s -c used.sumo.cfg %s" % (sumoBinary, addOption), shell=True, stdout=sys.stdout)
    traciControl.initTraCI(PORT)
    while not step>traciEndTime:
        traciControl.cmdSimulationStep2(DELTA_T)
        vehs = traciControl.cmdGetVehicleVariable_idList()
        if vehs.index("horiz")<0 or len(vehs)>1:
            print "Something is false"
        step += 1
    print "Print ended at step %s" % (traciControl.cmdGetSimulationVariable_currentTime()/DELTA_T)
    traciControl.cmdClose()
    sys.stdout.flush()
Пример #4
0
def runSingle(addOption):
    step = 0
    timeline = []
    sumoProcess = subprocess.Popen("%s -c %s %s" %
                                   (sumoBinary, "sumo.sumo.cfg", addOption),
                                   shell=True,
                                   stdout=sys.stdout)
    traciControl.initTraCI(PORT)
    while not step > 10000:
        try:
            traciControl.cmdSimulationStep2(DELTA_T)
            vehs = traciControl.cmdGetVehicleVariable_idList()
            timeline.append({})
            for v in vehs:
                timeline[-1][v] = traciControl.cmdGetVehicleVariable_speed(v)
            step += 1
        except traciControl.FatalTraCIError:
            print "Closed by SUMO"
            break
    traciControl.cmdClose()
    sys.stdout.flush()
    return timeline