Class TrafficLightControllerFixedDuration
java.lang.Object
org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLightControllerFixedDuration
- All Implemented Interfaces:
Identifiable,TrafficLightController
public class TrafficLightControllerFixedDuration extends java.lang.Object implements TrafficLightController
A traffic light controller with fixed durations. Red, yellow and green times of each phase can be set, as well as the time
between phases.
Copyright (c) 2013-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Constructor Summary
Constructors Constructor Description TrafficLightControllerFixedDuration(java.lang.String id, DEVSSimulatorInterface.TimeDoubleUnit simulator)Create a fixed time controller. -
Method Summary
Modifier and Type Method Description voidaddPhase(int phaseId, Duration yellowDuration, Duration greenDuration)Add a new phase.voidaddTrafficLightToPhase(int phaseId, TrafficLight trafficLight)Add a traffic light to a phase.protected voidchangePhase()Change the phase and/or color of the traffic lights.DurationgetClearanceDurationToNextPhase()intgetCurrentPhase()java.lang.StringgetId()intgetNumberOfPhases()voidsetClearanceDuration(Duration clearanceDuration)java.lang.StringtoString()
-
Constructor Details
-
TrafficLightControllerFixedDuration
public TrafficLightControllerFixedDuration(java.lang.String id, DEVSSimulatorInterface.TimeDoubleUnit simulator) throws TrafficLightExceptionCreate a fixed time controller.- Parameters:
id- String; the controller idsimulator- DEVSSimulatorInterface.TimeDoubleUnit; the simulator- Throws:
TrafficLightException- when scheduling of thhe start event fails
-
-
Method Details
-
changePhase
Change the phase and/or color of the traffic lights.- Throws:
TrafficLightException- when scheduling of thhe start event fails
-
getNumberOfPhases
public final int getNumberOfPhases()- Specified by:
getNumberOfPhasesin interfaceTrafficLightController- Returns:
- the number of phases.
-
getCurrentPhase
public final int getCurrentPhase()- Specified by:
getCurrentPhasein interfaceTrafficLightController- Returns:
- the phase id.
-
getClearanceDurationToNextPhase
- Specified by:
getClearanceDurationToNextPhasein interfaceTrafficLightController- Returns:
- the time between phases.
-
addPhase
public final void addPhase(int phaseId, Duration yellowDuration, Duration greenDuration) throws TrafficLightExceptionAdd a new phase.- Parameters:
phaseId- int; the id of the phase to be added.yellowDuration- Duration; the yellow timegreenDuration- Duration; the green time- Throws:
TrafficLightException- when the phase already existed
-
addTrafficLightToPhase
public final void addTrafficLightToPhase(int phaseId, TrafficLight trafficLight) throws TrafficLightExceptionAdd a traffic light to a phase.- Specified by:
addTrafficLightToPhasein interfaceTrafficLightController- Parameters:
phaseId- int; the id of the phase.trafficLight- TrafficLight; the traffic light to add- Throws:
TrafficLightException- when the phase was not created
-
getId
public final java.lang.String getId()- Specified by:
getIdin interfaceIdentifiable- Specified by:
getIdin interfaceTrafficLightController- Returns:
- the controller id.
-
setClearanceDuration
- Parameters:
clearanceDuration- Duration; set clearanceDuration
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-