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 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()StringgetId()intgetNumberOfPhases()voidsetClearanceDuration(Duration clearanceDuration)StringtoString()
-
-
-
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 TrafficLightExceptionChange 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
public final Duration 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 String getId()
- Specified by:
getIdin interfaceIdentifiable- Specified by:
getIdin interfaceTrafficLightController- Returns:
- the controller id.
-
setClearanceDuration
public final void setClearanceDuration(Duration clearanceDuration)
- Parameters:
clearanceDuration- Duration; set clearanceDuration
-
-