Class TrafficLightManager
java.lang.Object
real_time_traffic_simulation_with_java.wrapper.TrafficLightManager
Wrapper class for TraaS to manage traffic lights in the simulation
-
Constructor Summary
ConstructorsConstructorDescriptionTrafficLightManager(it.polito.appeal.traci.SumoTraciConnection connection) Wrapper class for TraaS to manage traffic lights in the simulation -
Method Summary
Modifier and TypeMethodDescriptionintgetCount()Get number of traffic light in the simulationdoublegetDuration(String tlId) Get the duration of the current phase of the traffic light (second)Get list of traffic light IDsList<de.tudresden.sumo.objects.SumoLink> getLinksTraffic(String tlID) Method to get links controlled by the traffic lightdoublegetNextSwitch(String tlId) Get remaining time of the current phase of the traffic light (second)intgetPhaseCount(String tlId) Get number of phases of the traffic lightintgetPhaseID(String tlId) Get the current phase index of the traffic lightgetPhasesDuration(String tlId) Get initial list of durations for each phase of the traffic light set in net fileGet the current state of the traffic light ('r', 'y', 'g' sequence)Initiate a List of TrafficLightData for all traffic lightsvoidToggle traffic light to next phase: get the current phase index and then add 1 to convert to next phasevoidsetPhaseDuration(String tlId, List<Integer> durations) Set new duration for each phase of the traffic light and update TrafficLightData phasesDurationvoidUpdate mapping data of the TrafficLightData List with current states from simulation
-
Constructor Details
-
TrafficLightManager
public TrafficLightManager(it.polito.appeal.traci.SumoTraciConnection connection) Wrapper class for TraaS to manage traffic lights in the simulation- Parameters:
connection- connection to Sumo
-
-
Method Details
-
getIDList
-
getCount
public int getCount()Get number of traffic light in the simulation- Returns:
- a int number of traffic lights
-
getState
-
getNextSwitch
Get remaining time of the current phase of the traffic light (second)- Parameters:
tlId- ID of the traffic light- Returns:
- double of remaining time in seconds
-
getDuration
Get the duration of the current phase of the traffic light (second)- Parameters:
tlId- ID of the traffic light- Returns:
- double of duration of the current phase in seconds
-
getPhaseID
Get the current phase index of the traffic light- Parameters:
tlId- ID of the traffic light- Returns:
- int of current phase index
-
getPhaseCount
-
getPhasesDuration
-
setPhaseDuration
-
nextPhase
Toggle traffic light to next phase: get the current phase index and then add 1 to convert to next phase- Parameters:
tlId- ID of the traffic light
-
getLinksTraffic
-
getTrafficLightDataList
Initiate a List of TrafficLightData for all traffic lights- Returns:
- a List of TrafficLightData for all traffic lights
- Throws:
Exception
-
updateTrafficLightDataList
-