From 27ecd5c78035e6b751a75d6576e093072baf0ff6 Mon Sep 17 00:00:00 2001 From: Ahp06 Date: Thu, 29 Nov 2018 17:00:13 +0100 Subject: [PATCH] Added logic program list into trafic lights --- sumo_project/actions.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sumo_project/actions.py b/sumo_project/actions.py index 739a8cb..b21cba4 100644 --- a/sumo_project/actions.py +++ b/sumo_project/actions.py @@ -6,10 +6,11 @@ Created on 17 oct. 2018 from typing import Iterable import traci +import inspect from shapely.geometry.linestring import LineString from model import Area, Vehicle -from traci._trafficlight import Logic +from traci._trafficlight import Logic, Phase def remove_vehicle(veh_id): @@ -36,12 +37,13 @@ def limit_speed_into_area(area: Area, vehicles: Iterable[Vehicle], max_speed): def adjust_traffic_light_phase_duration(area,reduction_factor): - tl_first = area._tls[0] + #attributes = inspect.getmembers(Phase, lambda a:not(inspect.isroutine(a))) + #print ([a[0] for a in attributes]) + for tl in area._tls: + for logic in tl._logics: + phases = traci.trafficlight.Logic.getPhases(logic) + for phase in phases: + print(phase) + #phaseDuration = traci.trafficlight.getPhaseDuration(tl.tl_id) - #traci.trafficlight.setPhaseDuration(tl.tl_id, phaseDuration*reduction_factor) - first_logic = tl_first._logics[0] - print('first logic of tl_first : ' + first_logic) - - first_logic = Logic() - - \ No newline at end of file + #traci.trafficlight.setPhaseDuration(tl.tl_id, phaseDuration*reduction_factor) \ No newline at end of file