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 TrafficLightColor
currentColor
the current light in the current phase.protected int
currentPhase
the current phase.protected DEVSSimulatorInterface.TimeDoubleUnit
simulator
the 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 void
addTrafficLightToPhase(int phaseId, TrafficLight trafficLight)
Add a traffic light to a phase.int
getCurrentPhase()
java.lang.String
getId()
int
getNumberOfPhases()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
getNumberOfPhases
in interfaceTrafficLightController
- Returns:
- the number of phases.
-
getCurrentPhase
public final int getCurrentPhase()- Specified by:
getCurrentPhase
in interfaceTrafficLightController
- Returns:
- the phase id.
-
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.
-