Class AbstractTrafficLightController
java.lang.Object
org.opentrafficsim.road.network.lane.object.trafficlight.AbstractTrafficLightController
- All Implemented Interfaces:
Identifiable,TrafficLightController
public abstract class AbstractTrafficLightController extends java.lang.Object implements TrafficLightController
Standard fields and methods for traffic light controllers.
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
-
Field Summary
Fields Modifier and Type Field Description protected TrafficLightColorcurrentColorthe current light in the current phase.protected intcurrentPhasethe current phase.protected DEVSSimulatorInterface.TimeDoubleUnitsimulatorthe simulator. -
Constructor Summary
Constructors Constructor Description AbstractTrafficLightController(java.lang.String id, DEVSSimulatorInterface.TimeDoubleUnit simulator)Create a fixed time controller. -
Method Summary
Modifier and Type Method Description voidaddTrafficLightToPhase(int phaseId, TrafficLight trafficLight)Add a traffic light to a phase.intgetCurrentPhase()java.lang.StringgetId()intgetNumberOfPhases()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLightController
getClearanceDurationToNextPhase
-
Field Details
-
simulator
the simulator. -
currentPhase
protected int currentPhasethe current phase. -
currentColor
the current light in the current phase.
-
-
Constructor Details
-
AbstractTrafficLightController
public AbstractTrafficLightController(java.lang.String id, DEVSSimulatorInterface.TimeDoubleUnit simulator)Create a fixed time controller.- Parameters:
id- String; the controller idsimulator- DEVSSimulatorInterface.TimeDoubleUnit; the simulator
-
-
Method Details
-
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.
-
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.
-