Hi,
please post your sumo config and the file where you define the
detector as well. Do you open a TraCI socket at all? The traffic light
program looks also fishy. You should rather continue with this
tutorial http://sumo-sim.org/userdoc/Tutorials/TraCI4Traffic_Lights.html
after starting with hello and base your TraCI script on this one.

Best regards,
Michael

2013/12/24 Moritz Schwarzkopf, BBT-71 <[email protected]>:
> Hello,
>
> I wrote a little script but the traffic light does not switch to red when the 
> car enters the entryExitDetector.
>
> #!/usr/bin/env python
> """
> @file    runner.py
> @author  Daniel Krajzewicz
> @author  Michael Behrisch
> @date    2007-10-25
> @version $Id: runner.py 14678 2013-09-11 08:53:06Z behrisch $
>
> This script is a test runner for the "Hello SUMO" Tutorial.
>
> SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
> Copyright (C) 2008-2013 DLR (http://www.dlr.de/) and contributors
>
> This file is part of SUMO.
> SUMO is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> the Free Software Foundation; either version 3 of the License, or
> (at your option) any later version.
> """
>
>
> import os,subprocess,sys,shutil
> try:
>     sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', 
> '..', "tools")) # tutorial in tests
>     sys.path.append(os.path.join(os.environ.get("SUMO_HOME", 
> os.path.join(os.path.dirname(__file__), "..", "..", "..")), "tools")) # 
> tutorial in docs
>     from sumolib import checkBinary
> except ImportError:
>     sys.exit("please declare environment variable 'SUMO_HOME' as the root 
> directory of your sumo installation (it should contain folders 'bin', 'tools' 
> and 'docs')")
>
> import traci
>
> PORT = 8813
>
>
> RED = "r"
> GREEN = "g"
>
> PROGRAM = [RED, GREEN]
>
> def generate_routefile():
>     with open("hello.rou.xml", "w") as routes:
>         print >> routes,"""<routes>
> <vType accel="1.0" decel="5.0" id="Car" length="5.0" minGap="2.0" 
> maxSpeed="50.0" sigma="0" />
>
> <route id="route0" edges="1totraffic_light traffic_lightto2 out" />
>
> <flow id="type1" color="1,1,1"  begin="0"   vehsPerHour="6" type="Car" 
> route="route0"  >
>    <stop busStop="BusStop1" duration="1000"/>
> </flow>
> """
>
>         print >> routes, "</routes>"
>
> def run():
>     traci.init(PORT)
>     programPointer = len(PROGRAM)-1;
>     step = 0;
>     while traci.simulation.getMinExpectedNumber() > 0:
>         traci.simulationStep()
>         programPointer = min(programPointer+1, len(PROGRAM)-1)
>         no = traci.multientryexit.getLastStepVehicleNumber("test")
>         if no > 0:
>             programPointer = (0 if programPointer == len(PROGRAM)-1 else 3)
>         traci.trafficlights.setRedYellowGreenState("traffic_light", 
> PROGRAM[programPointer])
>         step += 1
>     traci.close()
>     sys.stdout.flush()
>
>
> netconvertBinary = checkBinary('netconvert')
> sumoBinary = checkBinary('sumo-gui')
> # build/check network
> retcode = subprocess.call([netconvertBinary, "-c", "hello.netccfg"], 
> stdout=sys.stdout, stderr=sys.stderr)
> try: shutil.copy("hello.net.xml", "net.net.xml")
> except: print "Missing 'hello.net.xml'"
> print ">> Netbuilding closed with status %s" % retcode
> sys.stdout.flush()
> # run simulation
> generate_routefile()
> retcode = subprocess.call([sumoBinary, "-c", 
> "hello.sumocfg","--no-step-log"], stdout=sys.stdout, stderr=sys.stderr)
> print ">> Simulation closed with status %s" % retcode
> run()
> sys.stdout.flush()
>
> I used the “hello” tutorial to learn TraCI.
>
> Can anybody see the problem?
>
> Thanks and Merry Christmas,
>
> Moritz
>
>
> ---------------------------------------------------------------
> Moritz Schwarzkopf
> International Intern
> BBT-71, Plant Structure Development Dadong
> BMW Brilliance Automotive Ltd. / 华晨宝马汽车有限公司
> Mobile : +86 155 2447 2481
> Mail to / 邮箱: 
> [email protected]<mailto:[email protected]>
> ---------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Rapidly troubleshoot problems before they affect your business. Most IT
> organizations don't have a clear picture of how application performance
> affects their revenue. With AppDynamics, you get 100% visibility into your
> Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
> http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
> _______________________________________________
> sumo-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sumo-user

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user

Reply via email to