class Variable extends Object implements nl.tudelft.simulation.event.EventListenerInterface
Modifier and Type | Field and Description |
---|---|
(package private) org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLightColor |
color
Output color (if this is an export variable).
|
(package private) String |
endSource
Source of end rule.
|
(package private) EnumSet<Flags> |
flags
Flags.
|
(package private) char |
listPos
Position in the debugging list.
|
(package private) String |
name
Name of this variable (without the traffic stream).
|
(package private) int |
refCount
Number of rules that refer to this variable.
|
(package private) String |
startSource
Source of start rule.
|
(package private) short |
stream
Traffic stream number
|
(package private) int |
timerMax10
Limit value (if this is a timer variable).
|
(package private) int |
updateTime10
Time of last update in tenth of second.
|
(package private) int |
value
The current value.
|
Constructor and Description |
---|
Variable(String name,
short stream,
TrafCOD trafCOD)
Construct a new Variable.
|
Modifier and Type | Method and Description |
---|---|
void |
addOutput(org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLight trafficLight)
Add a traffic light to this variable.
|
void |
clearChangedFlag()
Clear the CHANGED flag of this Variable.
|
void |
clearFlag(Flags flag)
Clear one flag.
|
int |
conflictGroupRank()
Retrieve the rank of the conflict group that this Variable represents.
|
boolean |
decrementTimer(int timeStamp10)
Decrement the value of a timer.
|
org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLightColor |
getColor()
Retrieve the color for an output Variable.
|
String |
getEndSource()
Describe the rule that ends this variable.
|
EnumSet<Flags> |
getFlags()
Return a safe copy of the flags.
|
String |
getName()
Retrieve the name of this variable.
|
String |
getStartSource()
Describe the rule that starts this variable.
|
short |
getStream()
Retrieve the stream to which this variable belongs.
|
int |
getTimerMax()
Retrieve the start value of this timer in units of 0.1 seconds (1 second is represented by the value 10).
|
int |
getValue()
Retrieve the current value of this Variable.
|
void |
incrementReferenceCount()
Increment the reference counter of this variable.
|
void |
initialize()
Initialize this variable if it has the INITED flag set.
|
boolean |
isConflictGroup()
Report of this Variable identifies the current conflict group.
|
boolean |
isDetector()
Report if this Variable is a detector.
|
boolean |
isOutput()
Report whether a change in this variable must be published.
|
boolean |
isTimer()
Report whether this Variable is a timer.
|
void |
notify(nl.tudelft.simulation.event.EventInterface event) |
void |
setEndSource(String endSource)
Set the description of the rule that ends this variable.
|
void |
setFlag(Flags flag)
Set one flag.
|
void |
setOutput(int colorValue)
Make this variable an output variable and set the color value.
|
void |
setStartSource(String startSource)
Set the description of the rule that starts this variable.
|
void |
setTimerMax(int value10)
Set the maximum time of this timer.
|
boolean |
setValue(int newValue,
int timeStamp10,
CausePrinter cause,
TrafCOD trafCOD) |
void |
subscribeToDetector(org.opentrafficsim.road.network.lane.object.sensor.TrafficLightSensor sensor)
Link a detector variable to a sensor.
|
String |
toString() |
String |
toString(EnumSet<PrintFlags> printFlags)
Convert selected fields to a String.
|
int value
int timerMax10
org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLightColor color
final String name
char listPos
final short stream
int refCount
int updateTime10
String startSource
String endSource
public String getName()
public void subscribeToDetector(org.opentrafficsim.road.network.lane.object.sensor.TrafficLightSensor sensor) throws TrafficControlException
sensor
- TrafficLightSensor; the sensorTrafficControlException
- when this variable is not a detectorpublic void initialize()
public boolean decrementTimer(int timeStamp10) throws TrafficControlException
timeStamp10
- int; the current simulator time in tenths of a secondTrafficControlException
- when this Variable is not a timerpublic org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLightColor getColor() throws TrafficControlException
TrafficControlException
- if this Variable is not an outputpublic boolean isOutput()
public boolean isConflictGroup()
public int conflictGroupRank() throws TrafficControlException
TrafficControlException
- if this Variable is not a conflict group identifierpublic boolean isDetector()
public boolean setValue(int newValue, int timeStamp10, CausePrinter cause, TrafCOD trafCOD)
newValue
- int; the new value of this VariabletimeStamp10
- int; the time stamp of this updatecause
- CausePrinter; rule, timer, or detector that caused the changetrafCOD
- TrafCOD; the TrafCOD controllerpublic int getTimerMax() throws TrafficControlException
TrafficControlException
- when this class is not a Timerpublic int getValue()
public void setFlag(Flags flag)
flag
- Flagspublic void clearFlag(Flags flag)
flag
- Flags; the flag to clearpublic boolean isTimer()
public void clearChangedFlag()
public void incrementReferenceCount()
public void setOutput(int colorValue) throws TrafficControlException
colorValue
- int; the output value (as used in the TrafCOD file)TrafficControlException
- when the colorValue is invalid, or this method is called more than once for this variablepublic void addOutput(org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLight trafficLight) throws TrafficControlException
trafficLight
- TrafficLight; the traffic light to addTrafficControlException
- when this variable is not an outputpublic void setTimerMax(int value10) throws TrafficControlException
value10
- int; the maximum time in 0.1 sTrafficControlException
- when this Variable is not a timerpublic String getStartSource()
public void setStartSource(String startSource) throws TrafficControlException
startSource
- String; description of the rule that starts this variableTrafficControlException
- when a start source has already been setpublic String getEndSource()
public void setEndSource(String endSource) throws TrafficControlException
endSource
- String; description of the rule that ends this variableTrafficControlException
- when an end source has already been setpublic short getStream()
public String toString(EnumSet<PrintFlags> printFlags)
printFlags
- EnumSet<PrintFlags>; the set of fields to convertpublic void notify(nl.tudelft.simulation.event.EventInterface event) throws RemoteException
notify
in interface nl.tudelft.simulation.event.EventListenerInterface
RemoteException
Copyright © 2014–2017 Delft University of Technology. All rights reserved.