Class TrafficLightControllerFixedDuration
- java.lang.Object
-
- org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLightControllerFixedDuration
-
- All Implemented Interfaces:
Identifiable
,TrafficLightController
public class TrafficLightControllerFixedDuration extends 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.
$LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Oct 4, 2016
BSD-style license. See OpenTrafficSim License.- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
-
Constructor Summary
Constructors Constructor Description TrafficLightControllerFixedDuration(String id, DEVSSimulatorInterface.TimeDoubleUnit simulator)
Create a fixed time controller.
-
Method Summary
All Methods Instance Methods Concrete Methods 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()
String
getId()
int
getNumberOfPhases()
void
setClearanceDuration(Duration clearanceDuration)
String
toString()
-
-
-
Constructor Detail
-
TrafficLightControllerFixedDuration
public TrafficLightControllerFixedDuration(String id, DEVSSimulatorInterface.TimeDoubleUnit simulator) throws TrafficLightException
Create a fixed time controller.- Parameters:
id
- String; the controller idsimulator
- DEVSSimulatorInterface.TimeDoubleUnit; the simulator- Throws:
TrafficLightException
- when scheduling of thhe start event fails
-
-
Method Detail
-
changePhase
protected final void changePhase() throws TrafficLightException
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
public final Duration getClearanceDurationToNextPhase()
- Specified by:
getClearanceDurationToNextPhase
in interfaceTrafficLightController
- Returns:
- the time between phases.
-
addPhase
public final void addPhase(int phaseId, Duration yellowDuration, Duration greenDuration) throws TrafficLightException
Add 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 TrafficLightException
Add 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 String getId()
- Specified by:
getId
in interfaceIdentifiable
- Specified by:
getId
in interfaceTrafficLightController
- Returns:
- the controller id.
-
setClearanceDuration
public final void setClearanceDuration(Duration clearanceDuration)
- Parameters:
clearanceDuration
- Duration; set clearanceDuration
-
-