Class DefaultRoute
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.DefaultRoute
-
- All Implemented Interfaces:
java.beans.VetoableChangeListener
,java.lang.Comparable<NamedBean>
,java.util.EventListener
,PropertyChangeProvider
,NamedBean
,Route
public class DefaultRoute extends AbstractNamedBean implements Route, java.beans.VetoableChangeListener
Class providing the basic logic of the Route interface.- See Also:
Route
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
DefaultRoute.SetRouteThread
Class providing a thread to set route turnouts.-
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.ArrayList<jmri.implementation.DefaultRoute.ControlSensor>
_controlSensorList
(package private) java.util.ArrayList<jmri.implementation.DefaultRoute.OutputSensor>
_outputSensorList
Operational instance variables (not saved between runs).(package private) java.util.ArrayList<jmri.implementation.DefaultRoute.OutputTurnout>
_outputTurnoutList
protected NamedBeanHandle<Turnout>
mControlNamedTurnout
protected java.lang.String
mControlTurnout
Persistant instance variables (saved between runs).protected int
mControlTurnoutState
protected int
mDelay
protected NamedBeanHandle<Turnout>
mLockControlNamedTurnout
protected java.lang.String
mLockControlTurnout
protected int
mLockControlTurnoutState
protected java.beans.PropertyChangeListener
mLockTurnoutListener
protected boolean
mTurnoutFeedbackIsCommanded
protected java.beans.PropertyChangeListener
mTurnoutListener
protected NamedBeanHandle<Sensor>
mTurnoutsAlignedNamedSensor
protected java.lang.String
mTurnoutsAlignedSensor
protected NamedBeanHandleManager
nbhm
protected java.lang.String
scriptFilename
protected java.lang.String
soundFilename
-
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
-
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
-
Fields inherited from interface jmri.Route
MAX_CONTROL_SENSORS, ONACTIVE, ONCHANGE, ONCLOSED, ONINACTIVE, ONTHROWN, TOGGLE, VETOACTIVE, VETOCLOSED, VETOINACTIVE, VETOTHROWN
-
-
Constructor Summary
Constructors Constructor Description DefaultRoute(java.lang.String systemName)
Constructor for a Route instance.DefaultRoute(java.lang.String systemName, java.lang.String userName)
Constructor for a Route instance with a given userName.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateRoute()
Activate the Route.boolean
addOutputSensor(java.lang.String sensorName, int state)
Add an output Sensor to this Route.boolean
addOutputTurnout(java.lang.String turnoutName, int turnoutState)
Add an output Turnout to this Route.boolean
addSensorToRoute(java.lang.String sensorName, int mode)
Add a Sensor to the list of control Sensors for this Route.boolean
canLock()
Has at least one lockable turnout.(package private) void
checkLockTurnout(int newState, int oldState, Turnout t)
Turnout has changed, check to see if this will lock or unlock route.protected void
checkSensor(int newState, int oldState, Sensor sensor)
Handle sensor update event to see if it will set the route.(package private) void
checkTurnout(int newState, int oldState, Turnout t)
Turnout has changed, check to see if this fires.void
checkTurnoutAlignment()
Method to check if the turnouts for this route are correctly aligned.void
clearOutputSensors()
Delete all output Sensors from this Route.void
clearOutputTurnouts()
Delete all output Turnouts from this Route.void
clearRouteSensors()
Delete all control Sensors from this Route.void
deActivateRoute()
Deactivate the Route.(package private) void
deleteOutputTurnout(Turnout t)
java.lang.String
getBeanType()
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.java.lang.String
getControlTurnout()
Get the SystemName of the control Turnout for this Route.boolean
getControlTurnoutFeedback()
Get the feedback to use when checking the control turnout stateint
getControlTurnoutState()
Get the State of control Turnout that fires this Route.Turnout
getCtlTurnout()
Get the Turnout of a control Turnout for this Route.boolean
getEnabled()
Get enabled status.java.lang.String
getLockControlTurnout()
Get the SystemName of the lock control Turnout for this Route.int
getLockControlTurnoutState()
Get the State of the lock control Turnout that locks this Route.Turnout
getLockCtlTurnout()
Get the Turnout of a lock control Turnout for this Route.boolean
getLocked()
Get locked status.int
getNumOutputSensors()
int
getNumOutputTurnouts()
java.lang.String
getOutputScriptName()
Get name of script file to be run when Route is fired.Sensor
getOutputSensor(int k)
Get the output Sensor by index.java.lang.String
getOutputSensorByIndex(int index)
Get an output Sensor system name by index.int
getOutputSensorSetState(java.lang.String name)
Get the Set State of an output Sensor.int
getOutputSensorState(int k)
Get the desired state of an output Sensor by index.java.lang.String
getOutputSoundName()
Get name of sound file to be played when Route is fired.Turnout
getOutputTurnout(int k)
Get the output Turnout by index.java.lang.String
getOutputTurnoutByIndex(int index)
Get an output Turnout system name by index.int
getOutputTurnoutSetState(java.lang.String name)
get the Set State of an output Turnout.int
getOutputTurnoutState(int k)
Get the desired state of the Turnout by index.int
getRouteCommandDelay()
Get the delay between issuing Turnout commands on this route.Sensor
getRouteSensor(int index)
Get the Sensor of a control Sensor in this Route.int
getRouteSensorMode(int index)
Get the state of a particular Sensor in this Route.java.lang.String
getRouteSensorName(int index)
Get the SystemName of a control Sensor in this Route.int
getState()
Provide generic access to internal state.Sensor
getTurnoutsAlgdSensor()
Get the turnouts aligned sensor.java.lang.String
getTurnoutsAlignedSensor()
Get the system name of the turnouts aligned sensor.java.util.List<NamedBeanUsageReport>
getUsageReport(NamedBean bean)
Get a list of references for the specified bean.boolean
isOutputSensorIncluded(java.lang.String sensorName)
Inquire if a Sensor is included in this Route as an output.(package private) boolean
isOutputSensorIncluded(Sensor s1)
boolean
isOutputTurnoutIncluded(java.lang.String turnoutName)
Inquire if a Turnout is included in this Route as an output.(package private) boolean
isOutputTurnoutIncluded(Turnout t1)
protected boolean
isRouteBusy()
Method to query if Route is busy (returns true if commands are being issued to Route turnouts)(package private) boolean
isRouteSensorIncluded(Sensor s)
(package private) boolean
isVetoed()
Internal method to check whether operation of the route has been vetoed by a sensor or turnout setting.(package private) void
removeOutputSensor(Sensor s)
(package private) void
removeRouteSensor(Sensor s)
void
setControlTurnout(java.lang.String turnoutName)
Set the control Turnout for this Route.void
setControlTurnoutFeedback(boolean turnoutFeedbackIsCommanded)
Set the feedback to use when checking the control turnout statevoid
setControlTurnoutState(int turnoutState)
Set the State of control Turnout that fires this Route.void
setEnabled(boolean v)
Set enabled status.void
setLockControlTurnout(java.lang.String turnoutName)
Set the lock control Turnout for this Route.void
setLockControlTurnoutState(int turnoutState)
Set the State of the lock control Turnout for this Route.void
setLocked(boolean v)
Set locked status.void
setOutputScriptName(java.lang.String filename)
Set name of script file to be run when Route is fired.void
setOutputSoundName(java.lang.String filename)
Set name of sound file to be played when Route is fired.void
setRoute()
Set the Route.protected void
setRouteBusy(boolean busy)
Mark the Route as transistioning to anSensor.ACTIVE
state.void
setRouteCommandDelay(int delay)
Set the delay between issuing Turnout commands on this route.void
setState(int state)
Provide generic access to internal state.void
setTurnoutsAlignedSensor(java.lang.String sensorName)
Set a sensor to be the turnouts aligned sensor.void
vetoableChange(java.beans.PropertyChangeEvent evt)
-
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, dispose, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRef
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, dispose, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
mControlTurnout
protected java.lang.String mControlTurnout
Persistant instance variables (saved between runs).
-
mControlNamedTurnout
protected NamedBeanHandle<Turnout> mControlNamedTurnout
-
mControlTurnoutState
protected int mControlTurnoutState
-
mDelay
protected int mDelay
-
mTurnoutFeedbackIsCommanded
protected boolean mTurnoutFeedbackIsCommanded
-
mLockControlTurnout
protected java.lang.String mLockControlTurnout
-
mLockControlNamedTurnout
protected NamedBeanHandle<Turnout> mLockControlNamedTurnout
-
mLockControlTurnoutState
protected int mLockControlTurnoutState
-
mTurnoutsAlignedSensor
protected java.lang.String mTurnoutsAlignedSensor
-
mTurnoutsAlignedNamedSensor
protected NamedBeanHandle<Sensor> mTurnoutsAlignedNamedSensor
-
soundFilename
protected java.lang.String soundFilename
-
scriptFilename
protected java.lang.String scriptFilename
-
nbhm
protected NamedBeanHandleManager nbhm
-
_outputSensorList
java.util.ArrayList<jmri.implementation.DefaultRoute.OutputSensor> _outputSensorList
Operational instance variables (not saved between runs).
-
_controlSensorList
java.util.ArrayList<jmri.implementation.DefaultRoute.ControlSensor> _controlSensorList
-
mTurnoutListener
protected transient java.beans.PropertyChangeListener mTurnoutListener
-
mLockTurnoutListener
protected transient java.beans.PropertyChangeListener mLockTurnoutListener
-
_outputTurnoutList
java.util.ArrayList<jmri.implementation.DefaultRoute.OutputTurnout> _outputTurnoutList
-
-
Constructor Detail
-
DefaultRoute
public DefaultRoute(java.lang.String systemName, java.lang.String userName)
Constructor for a Route instance with a given userName.- Parameters:
systemName
- suggested system nameuserName
- provided user name
-
DefaultRoute
public DefaultRoute(java.lang.String systemName)
Constructor for a Route instance.- Parameters:
systemName
- suggested system name
-
-
Method Detail
-
getBeanType
public java.lang.String getBeanType()
For instances in the code where we are dealing with just a bean and a message needs to be passed to the user or in a log.- Specified by:
getBeanType
in interfaceNamedBean
- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
getEnabled
public boolean getEnabled()
Get enabled status.- Specified by:
getEnabled
in interfaceRoute
- Returns:
- true if enabled; false otherwise
-
setEnabled
public void setEnabled(boolean v)
Set enabled status.- Specified by:
setEnabled
in interfaceRoute
- Parameters:
v
- true if enabled; false otherwise
-
getLocked
public boolean getLocked()
Get locked status.
-
setLocked
public void setLocked(boolean v)
Set locked status.
-
canLock
public boolean canLock()
Has at least one lockable turnout.
-
addOutputTurnout
public boolean addOutputTurnout(java.lang.String turnoutName, int turnoutState)
Add an output Turnout to this Route.- Specified by:
addOutputTurnout
in interfaceRoute
- Parameters:
turnoutName
- The turnout system nameturnoutState
- must be Turnout.CLOSED, Turnout.THROWN, or Route.TOGGLE, which determines how the Turnout is to be switched when this Route is set- Returns:
- true if the output turnout was added
-
clearOutputTurnouts
public void clearOutputTurnouts()
Delete all output Turnouts from this Route.- Specified by:
clearOutputTurnouts
in interfaceRoute
-
getNumOutputTurnouts
public int getNumOutputTurnouts()
- Specified by:
getNumOutputTurnouts
in interfaceRoute
-
getOutputTurnoutByIndex
public java.lang.String getOutputTurnoutByIndex(int index)
Get an output Turnout system name by index.- Specified by:
getOutputTurnoutByIndex
in interfaceRoute
- Parameters:
index
- the index of the turnout- Returns:
- the turnout system name or null if no turnout exists at index
-
isOutputTurnoutIncluded
public boolean isOutputTurnoutIncluded(java.lang.String turnoutName) throws java.lang.IllegalArgumentException
Inquire if a Turnout is included in this Route as an output.- Specified by:
isOutputTurnoutIncluded
in interfaceRoute
- Parameters:
turnoutName
- the system name of the turnout- Returns:
- true if the named turnout is an output; false otherwise
- Throws:
java.lang.IllegalArgumentException
-
isOutputTurnoutIncluded
boolean isOutputTurnoutIncluded(Turnout t1)
-
deleteOutputTurnout
void deleteOutputTurnout(Turnout t)
-
getOutputTurnoutSetState
public int getOutputTurnoutSetState(java.lang.String name) throws java.lang.IllegalArgumentException
get the Set State of an output Turnout.- Specified by:
getOutputTurnoutSetState
in interfaceRoute
- Parameters:
name
- the system name of the turnout- Returns:
- the state or -1 if the Turnout is not found
- Throws:
java.lang.IllegalArgumentException
-
getOutputTurnout
public Turnout getOutputTurnout(int k)
Get the output Turnout by index.- Specified by:
getOutputTurnout
in interfaceRoute
- Parameters:
k
- the index of the turnout- Returns:
- the turnout or null if no turnout exists at index
-
getOutputTurnoutState
public int getOutputTurnoutState(int k)
Get the desired state of the Turnout by index.- Specified by:
getOutputTurnoutState
in interfaceRoute
- Parameters:
k
- the index of the turnout- Returns:
- the turnout state or -1 if no turnout exists at index
-
addOutputSensor
public boolean addOutputSensor(java.lang.String sensorName, int state)
Add an output Sensor to this Route.- Specified by:
addOutputSensor
in interfaceRoute
- Parameters:
sensorName
- the sensor system namestate
- the state the sensor switches to when the Route is set; must be one of Sensor.ACTIVE, Sensor.INACTIVE, or Route.TOGGLE- Returns:
- true if the sensor was added; false otherwise
-
clearOutputSensors
public void clearOutputSensors()
Delete all output Sensors from this Route.- Specified by:
clearOutputSensors
in interfaceRoute
-
getNumOutputSensors
public int getNumOutputSensors()
- Specified by:
getNumOutputSensors
in interfaceRoute
-
getOutputSensorByIndex
public java.lang.String getOutputSensorByIndex(int index)
Get an output Sensor system name by index.- Specified by:
getOutputSensorByIndex
in interfaceRoute
- Parameters:
index
- the index of the sensor- Returns:
- the sensor or null if no sensor exists at index
-
isOutputSensorIncluded
public boolean isOutputSensorIncluded(java.lang.String sensorName) throws java.lang.IllegalArgumentException
Inquire if a Sensor is included in this Route as an output.- Specified by:
isOutputSensorIncluded
in interfaceRoute
- Parameters:
sensorName
- the Sensor system name- Returns:
- true if the sensor is an output in this Route
- Throws:
java.lang.IllegalArgumentException
-
isOutputSensorIncluded
boolean isOutputSensorIncluded(Sensor s1)
-
getOutputSensorSetState
public int getOutputSensorSetState(java.lang.String name) throws java.lang.IllegalArgumentException
Get the Set State of an output Sensor.- Specified by:
getOutputSensorSetState
in interfaceRoute
- Parameters:
name
- the system name of the Sensor- Returns:
- -1 if the Sensor is not found
- Throws:
java.lang.IllegalArgumentException
-
getOutputSensor
public Sensor getOutputSensor(int k)
Get the output Sensor by index.- Specified by:
getOutputSensor
in interfaceRoute
- Parameters:
k
- the index of the sensor- Returns:
- the sensor or null if no sensor exists at index
-
getOutputSensorState
public int getOutputSensorState(int k)
Get the desired state of an output Sensor by index.- Specified by:
getOutputSensorState
in interfaceRoute
- Parameters:
k
- the index of the sensor- Returns:
- the sensor state or -1 if no sensor exists at index
-
removeOutputSensor
void removeOutputSensor(Sensor s)
-
setOutputScriptName
public void setOutputScriptName(java.lang.String filename)
Set name of script file to be run when Route is fired.- Specified by:
setOutputScriptName
in interfaceRoute
- Parameters:
filename
- path to script
-
getOutputScriptName
public java.lang.String getOutputScriptName()
Get name of script file to be run when Route is fired.- Specified by:
getOutputScriptName
in interfaceRoute
- Returns:
- script path or null if not defined
-
setOutputSoundName
public void setOutputSoundName(java.lang.String filename)
Set name of sound file to be played when Route is fired.- Specified by:
setOutputSoundName
in interfaceRoute
- Parameters:
filename
- path to sound
-
getOutputSoundName
public java.lang.String getOutputSoundName()
Get name of sound file to be played when Route is fired.- Specified by:
getOutputSoundName
in interfaceRoute
- Returns:
- sound file path or null if not defined
-
setTurnoutsAlignedSensor
public void setTurnoutsAlignedSensor(java.lang.String sensorName) throws java.lang.IllegalArgumentException
Set a sensor to be the turnouts aligned sensor.- Specified by:
setTurnoutsAlignedSensor
in interfaceRoute
- Parameters:
sensorName
- the system name of the sensor; pass null to disassociate any sensor from this route- Throws:
java.lang.IllegalArgumentException
-
getTurnoutsAlignedSensor
public java.lang.String getTurnoutsAlignedSensor()
Get the system name of the turnouts aligned sensor.- Specified by:
getTurnoutsAlignedSensor
in interfaceRoute
- Returns:
- the name or null if not defined
-
getTurnoutsAlgdSensor
@CheckForNull public Sensor getTurnoutsAlgdSensor() throws java.lang.IllegalArgumentException
Get the turnouts aligned sensor.- Specified by:
getTurnoutsAlgdSensor
in interfaceRoute
- Returns:
- the sensor or null if not defined
- Throws:
java.lang.IllegalArgumentException
-
clearRouteSensors
public void clearRouteSensors()
Delete all control Sensors from this Route.- Specified by:
clearRouteSensors
in interfaceRoute
-
addSensorToRoute
public boolean addSensorToRoute(java.lang.String sensorName, int mode)
Add a Sensor to the list of control Sensors for this Route.- Specified by:
addSensorToRoute
in interfaceRoute
- Parameters:
sensorName
- system name of the sensormode
- the default state of the sensor- Returns:
- true if added; false otherwise
-
getRouteSensorName
public java.lang.String getRouteSensorName(int index)
Get the SystemName of a control Sensor in this Route.- Specified by:
getRouteSensorName
in interfaceRoute
- Parameters:
index
- The index in the Sensor array of the requested Sensor- Returns:
- null If there is no Sensor at index
-
getRouteSensor
public Sensor getRouteSensor(int index)
Get the Sensor of a control Sensor in this Route.- Specified by:
getRouteSensor
in interfaceRoute
- Parameters:
index
- The index in the Sensor array of the requested Sensor- Returns:
- null If there is no Sensor with at index
-
getRouteSensorMode
public int getRouteSensorMode(int index)
Get the state of a particular Sensor in this Route.- Specified by:
getRouteSensorMode
in interfaceRoute
- Parameters:
index
- The index in the Sensor array of the requested Sensor- Returns:
- ONACTIVE if there is no Sensor with at index
-
isRouteSensorIncluded
boolean isRouteSensorIncluded(Sensor s)
-
removeRouteSensor
void removeRouteSensor(Sensor s)
-
setControlTurnout
public void setControlTurnout(java.lang.String turnoutName) throws java.lang.IllegalArgumentException
Set the control Turnout for this Route.- Specified by:
setControlTurnout
in interfaceRoute
- Parameters:
turnoutName
- the system name of a turnout- Throws:
java.lang.IllegalArgumentException
-
getControlTurnout
public java.lang.String getControlTurnout()
Get the SystemName of the control Turnout for this Route.- Specified by:
getControlTurnout
in interfaceRoute
- Returns:
- the name of the control turnout or null if not set
-
getCtlTurnout
@CheckForNull public Turnout getCtlTurnout() throws java.lang.IllegalArgumentException
Get the Turnout of a control Turnout for this Route.- Specified by:
getCtlTurnout
in interfaceRoute
- Returns:
- the control turnout or null if not set
- Throws:
java.lang.IllegalArgumentException
-
setLockControlTurnout
public void setLockControlTurnout(@CheckForNull java.lang.String turnoutName) throws java.lang.IllegalArgumentException
Set the lock control Turnout for this Route.- Specified by:
setLockControlTurnout
in interfaceRoute
- Parameters:
turnoutName
- the system name of the turnout- Throws:
java.lang.IllegalArgumentException
-
getLockControlTurnout
public java.lang.String getLockControlTurnout()
Get the SystemName of the lock control Turnout for this Route.- Specified by:
getLockControlTurnout
in interfaceRoute
- Returns:
- the system name or null if not defined
-
getLockCtlTurnout
@CheckForNull public Turnout getLockCtlTurnout() throws java.lang.IllegalArgumentException
Get the Turnout of a lock control Turnout for this Route.- Specified by:
getLockCtlTurnout
in interfaceRoute
- Returns:
- the turnout or null if not defined
- Throws:
java.lang.IllegalArgumentException
-
setRouteCommandDelay
public void setRouteCommandDelay(int delay)
Set the delay between issuing Turnout commands on this route.- Specified by:
setRouteCommandDelay
in interfaceRoute
- Parameters:
delay
- the delay in milliseconds
-
getRouteCommandDelay
public int getRouteCommandDelay()
Get the delay between issuing Turnout commands on this route.- Specified by:
getRouteCommandDelay
in interfaceRoute
- Returns:
- the delay in milliseconds
-
setControlTurnoutState
public void setControlTurnoutState(int turnoutState)
Set the State of control Turnout that fires this Route.- Specified by:
setControlTurnoutState
in interfaceRoute
- Parameters:
turnoutState
- the turnout state
-
getControlTurnoutState
public int getControlTurnoutState()
Get the State of control Turnout that fires this Route.- Specified by:
getControlTurnoutState
in interfaceRoute
- Returns:
- the turnout state
-
setControlTurnoutFeedback
public void setControlTurnoutFeedback(boolean turnoutFeedbackIsCommanded)
Set the feedback to use when checking the control turnout state- Specified by:
setControlTurnoutFeedback
in interfaceRoute
- Parameters:
turnoutFeedbackIsCommanded
- true if commanded state is to be checked; default is false
-
getControlTurnoutFeedback
public boolean getControlTurnoutFeedback()
Get the feedback to use when checking the control turnout state- Specified by:
getControlTurnoutFeedback
in interfaceRoute
- Returns:
- true if commanded state is to be checked; false is known state
-
setLockControlTurnoutState
public void setLockControlTurnoutState(int turnoutState)
Set the State of the lock control Turnout for this Route.- Specified by:
setLockControlTurnoutState
in interfaceRoute
- Parameters:
turnoutState
- the turnout state
-
getLockControlTurnoutState
public int getLockControlTurnoutState()
Get the State of the lock control Turnout that locks this Route.- Specified by:
getLockControlTurnoutState
in interfaceRoute
- Returns:
- the turnout state
-
setRoute
public void setRoute()
Set the Route.Sets all Route Turnouts to the directed state in the Route definition.
-
checkSensor
protected void checkSensor(int newState, int oldState, Sensor sensor)
Handle sensor update event to see if it will set the route.Called when a "KnownState" event is received, it assumes that only one sensor is changing right now, so can use state calls for everything other than this sensor.
This will fire the Route if the conditions are correct.
Returns nothing explicitly, but has the side effect of firing route.
- Parameters:
newState
- new state of control sensoroldState
- former statesensor
- Sensor used as Route control sensor
-
checkTurnout
void checkTurnout(int newState, int oldState, Turnout t)
Turnout has changed, check to see if this fires.Will fire Route if appropriate.
- Parameters:
newState
- new state of control turnoutoldState
- former statet
- Turnout used as Route control turnout
-
checkLockTurnout
void checkLockTurnout(int newState, int oldState, Turnout t)
Turnout has changed, check to see if this will lock or unlock route.- Parameters:
newState
- new state of lock turnoutoldState
- former turnout statet
- Turnout used for locking the Route
-
checkTurnoutAlignment
public void checkTurnoutAlignment()
Method to check if the turnouts for this route are correctly aligned. Sets turnouits aligned sensor (if there is one) to active if the turnouts are aligned. Sets the sensor to inactive if they are not aligned
-
activateRoute
public void activateRoute()
Activate the Route.This starts route processing by connecting to inputs, etc. A Route must be activated before it will fire.
- Specified by:
activateRoute
in interfaceRoute
-
isVetoed
boolean isVetoed()
Internal method to check whether operation of the route has been vetoed by a sensor or turnout setting.- Returns:
- true if veto, i.e. don't fire route; false if no veto, OK to fire
-
deActivateRoute
public void deActivateRoute()
Deactivate the Route.This disconnects the Route from all other objects and stops it from processing. A Route must be deactivated before its input and output definitions are changed.
- Specified by:
deActivateRoute
in interfaceRoute
-
setRouteBusy
protected void setRouteBusy(boolean busy)
Mark the Route as transistioning to anSensor.ACTIVE
state.- Parameters:
busy
- true if Route should be busy.
-
isRouteBusy
protected boolean isRouteBusy()
Method to query if Route is busy (returns true if commands are being issued to Route turnouts)- Returns:
- true if the Route is transistioning to an
Sensor.ACTIVE
state, false otherwise.
-
getState
public int getState()
Provide generic access to internal state.This generally shouldn't be used by Java code; use the class-specific form instead (e.g. getCommandedState in Turnout). This is provided to make scripts easier to read.
-
setState
public void setState(int state)
Provide generic access to internal state.This generally shouldn't be used by Java code; use the class-specific form instead (e.g. setCommandedState in Turnout). This is provided to make scripts access easier to read.
-
vetoableChange
public void vetoableChange(java.beans.PropertyChangeEvent evt) throws java.beans.PropertyVetoException
- Specified by:
vetoableChange
in interfaceNamedBean
- Specified by:
vetoableChange
in interfacejava.beans.VetoableChangeListener
- Overrides:
vetoableChange
in classAbstractNamedBean
- Throws:
java.beans.PropertyVetoException
-
getUsageReport
public java.util.List<NamedBeanUsageReport> getUsageReport(NamedBean bean)
Description copied from interface:NamedBean
Get a list of references for the specified bean.- Specified by:
getUsageReport
in interfaceNamedBean
- Parameters:
bean
- The bean to be checked.- Returns:
- a list of NamedBeanUsageReports or an empty ArrayList.
-
-