public class TrafCOD extends nl.tudelft.simulation.event.EventProducer implements TrafficController, nl.tudelft.simulation.event.EventListenerInterface
Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
TrafCOD.ParserState
States of the rule parser.
|
(package private) static class |
TrafCOD.Token
Types of TrafCOD tokens.
|
Modifier and Type | Field and Description |
---|---|
(package private) static String |
COMMENT_PREFIX
Comment starter in TrafCOD.
|
(package private) String |
controllerName
Name of this TrafCod controller.
|
(package private) Map<String,Variable> |
detectors
The detectors.
|
(package private) static org.djunits.value.vdouble.scalar.Duration |
EVALUATION_INTERVAL
The evaluation interval of TrafCOD.
|
(package private) int |
numberOfConflictGroups
Number of conflict groups in the control program.
|
(package private) List<Object[]> |
tokenisedRules
The tokenized rules.
|
(package private) static int |
TRAFCOD_VERSION
Version of the supported TrafCOD files.
|
(package private) List<String> |
trafcodRules
The original rules.
|
(package private) Map<String,Variable> |
variables
The TrafCOD variables.
|
(package private) List<Variable> |
variablesInDefinitionOrder
The TrafCOD variables in order of definition.
|
NO_STREAM, OFF, RUNNING, SHUTTING_DOWN, STARTING_UP, TRAFFIC_LIGHT_CHANGED, TRAFFICCONTROL_CONFLICT_GROUP_CHANGED, TRAFFICCONTROL_CONTROLLER_CREATED, TRAFFICCONTROL_CONTROLLER_EVALUATING, TRAFFICCONTROL_CONTROLLER_WARNING, TRAFFICCONTROL_SET_TRACING, TRAFFICCONTROL_STATE_CHANGED, TRAFFICCONTROL_TRACED_VARIABLE_UPDATED, TRAFFICCONTROL_VARIABLE_CREATED
Constructor and Description |
---|
TrafCOD(String controllerName,
URL trafCodURL,
Set<org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLight> trafficLights,
Set<org.opentrafficsim.road.network.lane.object.sensor.TrafficLightSensor> sensors,
nl.tudelft.simulation.dsol.simulators.DEVSSimulator<org.djunits.value.vdouble.scalar.Time,org.djunits.value.vdouble.scalar.Duration,org.opentrafficsim.core.dsol.OTSSimTimeDouble> simulator,
Container display)
Construct a new TrafCOD traffic light controller.
|
Modifier and Type | Method and Description |
---|---|
void |
checkConsistency()
Check the consistency of the traffic control program.
|
(package private) void |
fireTrafCODEvent(nl.tudelft.simulation.event.EventType eventType,
Object[] payload)
Fire an event on behalf of this TrafCOD engine (used for tracing variable changes).
|
String |
getId()
Retrieve the Id of the traffic light controller.
|
nl.tudelft.simulation.dsol.simulators.SimulatorInterface<org.djunits.value.vdouble.scalar.Time,org.djunits.value.vdouble.scalar.Duration,org.opentrafficsim.core.dsol.OTSSimTimeDouble> |
getSimulator()
Retrieve the simulator.
|
int |
getStructureNumber()
Retrieve the structure number.
|
void |
notify(nl.tudelft.simulation.event.EventInterface event) |
(package private) static String |
printRule(Object[] tokens,
boolean printValues)
Print a tokenized rule.
|
void |
traceVariable(String variableName,
int stream,
boolean trace)
Switch tracing of one variable on or off.
|
void |
traceVariablesOfStream(int stream,
boolean trace)
Switch tracing of all variables of a particular traffic stream, or all variables that do not have an associated traffic
stream on or off.
|
void |
updateDetector(String detectorId,
boolean detectingGTU)
Tell the traffic controller that the state of a detector has changed.
|
addListener, addListener, addListener, addListener, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, removeAllListeners, removeAllListeners, removeListener
final String controllerName
static final int TRAFCOD_VERSION
static final org.djunits.value.vdouble.scalar.Duration EVALUATION_INTERVAL
final List<Variable> variablesInDefinitionOrder
static final String COMMENT_PREFIX
int numberOfConflictGroups
public TrafCOD(String controllerName, URL trafCodURL, Set<org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLight> trafficLights, Set<org.opentrafficsim.road.network.lane.object.sensor.TrafficLightSensor> sensors, nl.tudelft.simulation.dsol.simulators.DEVSSimulator<org.djunits.value.vdouble.scalar.Time,org.djunits.value.vdouble.scalar.Duration,org.opentrafficsim.core.dsol.OTSSimTimeDouble> simulator, Container display) throws TrafficControlException, nl.tudelft.simulation.dsol.SimRuntimeException
controllerName
- String; name of this TrafCOD traffic light controllertrafCodURL
- URL; the URL of the TrafCOD rulestrafficLights
- Set<TrafficLight>; the traffic lights. The ids of the traffic lights must end with two digits
that match the stream numbers as used in the traffic control programsensors
- Set<TrafficLightSensor>; the traffic sensors. The ids of the traffic sensors must end with three
digits; the first two of those must match the stream and sensor numbers used in the traffic control programsimulator
- DEVSSimulator<Time, Duration, OTSSimTimeDouble>; the simulation enginedisplay
- Container; if non-null, a controller display is constructed and shown in the supplied containerTrafficControlException
- when a rule cannot be parsednl.tudelft.simulation.dsol.SimRuntimeException
- when scheduling the first evaluation event failspublic void checkConsistency()
static String printRule(Object[] tokens, boolean printValues) throws TrafficControlException
tokens
- Object[]; the tokensprintValues
- boolean; if true; print the values of all encountered variable; if false; do not print the values of
all encountered variableTrafficControlException
- when tokens does not match the expected grammarpublic nl.tudelft.simulation.dsol.simulators.SimulatorInterface<org.djunits.value.vdouble.scalar.Time,org.djunits.value.vdouble.scalar.Duration,org.opentrafficsim.core.dsol.OTSSimTimeDouble> getSimulator()
public int getStructureNumber()
public void updateDetector(String detectorId, boolean detectingGTU)
updateDetector
in interface TrafficController
detectorId
- String; id of the detectordetectingGTU
- boolean;public void traceVariablesOfStream(int stream, boolean trace)
stream
- int; the traffic stream number, or TrafCOD.NO_STREAM
to affect all variables that do not have
an associated traffic streamtrace
- boolean; if true; switch on tracing; if false; switch off tracingpublic void traceVariable(String variableName, int stream, boolean trace)
variableName
- String; name of the variablestream
- int; traffic stream of the variable, or TrafCOD.NO_STREAM
to select a variable that does not
have an associated traffic streamtrace
- boolean; if true; switch on tracing; if false; switch off tracingpublic void notify(nl.tudelft.simulation.event.EventInterface event) throws RemoteException
notify
in interface nl.tudelft.simulation.event.EventListenerInterface
RemoteException
void fireTrafCODEvent(nl.tudelft.simulation.event.EventType eventType, Object[] payload)
eventType
- EventType; the type of the eventpayload
- Object[]; the payload of the eventpublic String getId()
getId
in interface TrafficController
Copyright © 2014–2017 Delft University of Technology. All rights reserved.