class Variable extends Object
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 | 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)
Construct a new Variable.
|
Modifier and Type | Method and Description |
---|---|
void |
addFlag(Flags flag)
Set a flag of this Variable.
|
void |
clearChangedFlag()
Clear the CHANGED flag of this Variable.
|
void |
clearFlag(Flags flag)
Clear one flag.
|
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 |
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.
|
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.
|
String |
selectedFieldsToString(EnumSet<PrintFlags> printFlags)
Print selected fields.
|
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,
Set<org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLight> trafficLights)
Make this variable an output variable and set the output 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.
|
void |
setValue(int newValue,
int timeStamp10) |
String |
toString() |
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 Variable(String name, short stream)
name
- String; name of the new variable (without the stream number)stream
- short; stream number to which the new Variable is associatedpublic org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLightColor getColor() throws Exception
Exception
- if this Variable is not an outputpublic boolean isOutput()
public boolean isDetector()
public void setValue(int newValue, int timeStamp10)
newValue
- int; the new value of this VariabletimeStamp10
- int; the time stamp of this updatepublic int getTimerMax() throws Exception
Exception
public 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 addFlag(Flags flag)
flag
- Flags; the flag to setpublic void setOutput(int colorValue, Set<org.opentrafficsim.road.network.lane.object.trafficlight.TrafficLight> trafficLights) throws Exception
colorValue
- int; the output valuetrafficLights
- Set<TrafficLight>; the traffic light that must be update when this output becomes activeException
- when the colorValue is invalidpublic void setTimerMax(int value10) throws Exception
value10
- int; the maximum time in 0.1 sException
- when this Variable is not a timerpublic String getStartSource()
public void setStartSource(String startSource) throws Exception
startSource
- String; description of the rule that starts this variableException
- when a start source has already been setpublic String getEndSource()
public void setEndSource(String endSource) throws Exception
endSource
- String; description of the rule that ends this variableException
- when an end source has already been setpublic short getStream()
public String selectedFieldsToString(EnumSet<PrintFlags> printFlags)
printFlags
- EnumSet<PrintFlags>; the set of fields to printCopyright © 2014–2016 Delft University of Technology. All rights reserved.