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 void
addPhase(int phaseId, Duration yellowDuration, Duration greenDuration)
Add a new phase.void
addTrafficLightToPhase(int phaseId, TrafficLight trafficLight)
Add a traffic light to a phase.protected void
changePhase()
Change the phase and/or color of the traffic lights.Duration
getClearanceDurationToNextPhase()
int
getCurrentPhase()
java.lang.String
getId()
int
getNumberOfPhases()
void
setClearanceDuration(Duration clearanceDuration)
java.lang.String
toString()
-
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:
getNumberOfPhases
in interfaceTrafficLightController
- Returns:
- the number of phases.
-
getCurrentPhase
public final int getCurrentPhase()- Specified by:
getCurrentPhase
in interfaceTrafficLightController
- Returns:
- the phase id.
-
getClearanceDurationToNextPhase
- Specified by:
getClearanceDurationToNextPhase
in 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:
addTrafficLightToPhase
in 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:
getId
in interfaceIdentifiable
- Specified by:
getId
in interfaceTrafficLightController
- Returns:
- the controller id.
-
setClearanceDuration
- Parameters:
clearanceDuration
- Duration; set clearanceDuration
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-