Class AbstractTrafficLightController
- java.lang.Object
-
- org.opentrafficsim.road.network.lane.object.trafficlight.AbstractTrafficLightController
-
- All Implemented Interfaces:
Identifiable
,TrafficLightController
public abstract class AbstractTrafficLightController extends 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.
$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
-
-
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(String id, DEVSSimulatorInterface.TimeDoubleUnit simulator)
Create a fixed time controller.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTrafficLightToPhase(int phaseId, TrafficLight trafficLight)
Add a traffic light to a phase.int
getCurrentPhase()
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 Detail
-
simulator
protected final DEVSSimulatorInterface.TimeDoubleUnit simulator
the simulator.
-
currentPhase
protected int currentPhase
the current phase.
-
currentColor
protected TrafficLightColor currentColor
the current light in the current phase.
-
-
Constructor Detail
-
AbstractTrafficLightController
public AbstractTrafficLightController(String id, DEVSSimulatorInterface.TimeDoubleUnit simulator)
Create a fixed time controller.- Parameters:
id
- String; the controller idsimulator
- DEVSSimulatorInterface.TimeDoubleUnit; the simulator
-
-
Method Detail
-
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 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.
-
-