Class DefaultRoute
- All Implemented Interfaces:
VetoableChangeListener,Comparable<NamedBean>,EventListener,PropertyChangeProvider,NamedBean,Route
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException -
Field Summary
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, registerFields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWNFields inherited from interface jmri.Route
MAX_CONTROL_SENSORS, ONACTIVE, ONCHANGE, ONCLOSED, ONINACTIVE, ONTHROWN, PROPERTY_ROUTE_LOCKED, TOGGLE, VETOACTIVE, VETOCLOSED, VETOINACTIVE, VETOTHROWN -
Constructor Summary
ConstructorsConstructorDescriptionDefaultRoute(String systemName) Constructor for a Route instance.DefaultRoute(String systemName, String userName) Constructor for a Route instance with a given userName. -
Method Summary
Modifier and TypeMethodDescriptionvoidActivate the Route.booleanaddOutputSensor(String sensorName, int state) Add an output Sensor to this Route.booleanaddOutputTurnout(String turnoutName, int turnoutState) Add an output Turnout to this Route.booleanaddSensorToRoute(String sensorName, int mode) Add a Sensor to the list of control Sensors for this Route.booleancanLock()Has at least one lockable turnout.(package private) voidcheckLockTurnout(int newState, int oldState, Turnout t) Turnout has changed, check to see if this will lock or unlock route.protected voidcheckSensor(int newState, int oldState, Sensor sensor) Handle sensor update event to see if it will set the route.(package private) voidcheckTurnout(int newState, int oldState, Turnout t) Turnout has changed, check to see if this fires.voidMethod to check if the turnouts for this route are correctly aligned.voidDelete all output Sensors from this Route.voidDelete all output Turnouts from this Route.voidDelete all control Sensors from this Route.voidDeactivate the Route.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.Get the SystemName of the control Turnout for this Route.booleanGet the feedback to use when checking the control turnout stateintGet the State of control Turnout that fires this Route.Get the Turnout of a control Turnout for this Route.booleanGet enabled status.Get the SystemName of the lock control Turnout for this Route.intGet the State of the lock control Turnout that locks this Route.Get the Turnout of a lock control Turnout for this Route.booleanGet locked status.intintGet name of script file to be run when Route is fired.getOutputSensor(int k) Get the output Sensor by index.getOutputSensorByIndex(int index) Get an output Sensor system name by index.intGet the Set State of an output Sensor.intgetOutputSensorState(int k) Get the desired state of an output Sensor by index.Get name of sound file to be played when Route is fired.getOutputTurnout(int k) Get the output Turnout by index.getOutputTurnoutByIndex(int index) Get an output Turnout system name by index.intget the Set State of an output Turnout.intgetOutputTurnoutState(int k) Get the desired state of the Turnout by index.intGet the delay between issuing Turnout commands on this route.getRouteSensor(int index) Get the Sensor of a control Sensor in this Route.intgetRouteSensorMode(int index) Get the state of a particular Sensor in this Route.getRouteSensorName(int index) Get the SystemName of a control Sensor in this Route.intgetState()Provide generic access to internal state.Get the turnouts aligned sensor.Get the system name of the turnouts aligned sensor.getUsageReport(NamedBean bean) Get a list of references for the specified bean.booleanisOutputSensorIncluded(String sensorName) Inquire if a Sensor is included in this Route as an output.booleanisOutputTurnoutIncluded(String turnoutName) Inquire if a Turnout is included in this Route as an output.protected booleanMethod to query if Route is busy (returns true if commands are being issued to Route turnouts)(package private) boolean(package private) booleanisVetoed()Internal method to check whether operation of the route has been vetoed by a sensor or turnout setting.(package private) voidvoidsetControlTurnout(String turnoutName) Set the control Turnout for this Route.voidsetControlTurnoutFeedback(boolean turnoutFeedbackIsCommanded) Set the feedback to use when checking the control turnout statevoidsetControlTurnoutState(int turnoutState) Set the State of control Turnout that fires this Route.voidsetEnabled(boolean v) Set enabled status.voidsetLockControlTurnout(String turnoutName) Set the lock control Turnout for this Route.voidsetLockControlTurnoutState(int turnoutState) Set the State of the lock control Turnout for this Route.voidsetLocked(boolean v) Set locked status.voidsetOutputScriptName(String filename) Set name of script file to be run when Route is fired.voidsetOutputSoundName(String filename) Set name of sound file to be played when Route is fired.voidsetRoute()Set the Route.protected voidsetRouteBusy(boolean busy) Mark the Route as transitioning to anSensor.ACTIVEstate.voidsetRouteCommandDelay(int delay) Set the delay between issuing Turnout commands on this route.voidsetState(int state) Provide generic access to internal state.voidsetTurnoutsAlignedSensor(String sensorName) Set a sensor to be the turnouts aligned sensor.voidMethods 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, updateListenerRefMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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, updateListenerRefMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Constructor Details
-
DefaultRoute
Constructor for a Route instance with a given userName.- Parameters:
systemName- suggested system nameuserName- provided user name
-
DefaultRoute
Constructor for a Route instance.- Parameters:
systemName- suggested system name
-
-
Method Details
-
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:
getBeanTypein interfaceNamedBean- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-
getEnabled
Get enabled status.- Specified by:
getEnabledin interfaceRoute- Returns:
- true if enabled; false otherwise
-
setEnabled
Set enabled status.- Specified by:
setEnabledin interfaceRoute- Parameters:
v- true if enabled; false otherwise
-
getLocked
Get locked status. -
setLocked
Set locked status. -
canLock
Has at least one lockable turnout. -
addOutputTurnout
Add an output Turnout to this Route.- Specified by:
addOutputTurnoutin 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
Delete all output Turnouts from this Route.- Specified by:
clearOutputTurnoutsin interfaceRoute
-
getNumOutputTurnouts
- Specified by:
getNumOutputTurnoutsin interfaceRoute
-
getOutputTurnoutByIndex
Get an output Turnout system name by index.- Specified by:
getOutputTurnoutByIndexin interfaceRoute- Parameters:
index- the index of the turnout- Returns:
- the turnout system name or null if no turnout exists at index
-
isOutputTurnoutIncluded
Inquire if a Turnout is included in this Route as an output.- Specified by:
isOutputTurnoutIncludedin interfaceRoute- Parameters:
turnoutName- the system name of the turnout- Returns:
- true if the named turnout is an output; false otherwise
- Throws:
IllegalArgumentException
-
getOutputTurnoutSetState
get the Set State of an output Turnout.- Specified by:
getOutputTurnoutSetStatein interfaceRoute- Parameters:
name- the system name of the turnout- Returns:
- the state or -1 if the Turnout is not found
- Throws:
IllegalArgumentException
-
getOutputTurnout
Get the output Turnout by index.- Specified by:
getOutputTurnoutin interfaceRoute- Parameters:
k- the index of the turnout- Returns:
- the turnout or null if no turnout exists at index
-
getOutputTurnoutState
Get the desired state of the Turnout by index.- Specified by:
getOutputTurnoutStatein interfaceRoute- Parameters:
k- the index of the turnout- Returns:
- the turnout state or -1 if no turnout exists at index
-
addOutputSensor
Add an output Sensor to this Route.- Specified by:
addOutputSensorin 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
Delete all output Sensors from this Route.- Specified by:
clearOutputSensorsin interfaceRoute
-
getNumOutputSensors
- Specified by:
getNumOutputSensorsin interfaceRoute
-
getOutputSensorByIndex
Get an output Sensor system name by index.- Specified by:
getOutputSensorByIndexin interfaceRoute- Parameters:
index- the index of the sensor- Returns:
- the sensor or null if no sensor exists at index
-
isOutputSensorIncluded
Inquire if a Sensor is included in this Route as an output.- Specified by:
isOutputSensorIncludedin interfaceRoute- Parameters:
sensorName- the Sensor system name- Returns:
- true if the sensor is an output in this Route
- Throws:
IllegalArgumentException
-
getOutputSensorSetState
Get the Set State of an output Sensor.- Specified by:
getOutputSensorSetStatein interfaceRoute- Parameters:
name- the system name of the Sensor- Returns:
- -1 if the Sensor is not found
- Throws:
IllegalArgumentException
-
getOutputSensor
Get the output Sensor by index.- Specified by:
getOutputSensorin interfaceRoute- Parameters:
k- the index of the sensor- Returns:
- the sensor or null if no sensor exists at index
-
getOutputSensorState
Get the desired state of an output Sensor by index.- Specified by:
getOutputSensorStatein interfaceRoute- Parameters:
k- the index of the sensor- Returns:
- the sensor state or -1 if no sensor exists at index
-
setOutputScriptName
Set name of script file to be run when Route is fired.- Specified by:
setOutputScriptNamein interfaceRoute- Parameters:
filename- path to script
-
getOutputScriptName
Get name of script file to be run when Route is fired.- Specified by:
getOutputScriptNamein interfaceRoute- Returns:
- script path or null if not defined
-
setOutputSoundName
Set name of sound file to be played when Route is fired.- Specified by:
setOutputSoundNamein interfaceRoute- Parameters:
filename- path to sound
-
getOutputSoundName
Get name of sound file to be played when Route is fired.- Specified by:
getOutputSoundNamein interfaceRoute- Returns:
- sound file path or null if not defined
-
setTurnoutsAlignedSensor
public void setTurnoutsAlignedSensor(@CheckForNull String sensorName) throws IllegalArgumentException Set a sensor to be the turnouts aligned sensor.- Specified by:
setTurnoutsAlignedSensorin interfaceRoute- Parameters:
sensorName- the system name of the sensor; pass null to disassociate any sensor from this route- Throws:
IllegalArgumentException
-
getTurnoutsAlignedSensor
Get the system name of the turnouts aligned sensor.- Specified by:
getTurnoutsAlignedSensorin interfaceRoute- Returns:
- the name or null if not defined
-
getTurnoutsAlgdSensor
Get the turnouts aligned sensor.- Specified by:
getTurnoutsAlgdSensorin interfaceRoute- Returns:
- the sensor or null if not defined
- Throws:
IllegalArgumentException
-
clearRouteSensors
Delete all control Sensors from this Route.- Specified by:
clearRouteSensorsin interfaceRoute
-
addSensorToRoute
Add a Sensor to the list of control Sensors for this Route.- Specified by:
addSensorToRoutein interfaceRoute- Parameters:
sensorName- system name of the sensormode- the default state of the sensor- Returns:
- true if added; false otherwise
-
getRouteSensorName
Get the SystemName of a control Sensor in this Route.- Specified by:
getRouteSensorNamein interfaceRoute- Parameters:
index- The index in the Sensor array of the requested Sensor- Returns:
- null If there is no Sensor at index
-
getRouteSensor
Get the Sensor of a control Sensor in this Route.- Specified by:
getRouteSensorin interfaceRoute- Parameters:
index- The index in the Sensor array of the requested Sensor- Returns:
- null If there is no Sensor with at index
-
getRouteSensorMode
Get the state of a particular Sensor in this Route.- Specified by:
getRouteSensorModein interfaceRoute- Parameters:
index- The index in the Sensor array of the requested Sensor- Returns:
- ONACTIVE if there is no Sensor with at index
-
isRouteSensorIncluded
-
removeRouteSensor
-
setControlTurnout
Set the control Turnout for this Route.- Specified by:
setControlTurnoutin interfaceRoute- Parameters:
turnoutName- the system name of a turnout- Throws:
IllegalArgumentException
-
getControlTurnout
Get the SystemName of the control Turnout for this Route.- Specified by:
getControlTurnoutin interfaceRoute- Returns:
- the name of the control turnout or null if not set
-
getCtlTurnout
Get the Turnout of a control Turnout for this Route.- Specified by:
getCtlTurnoutin interfaceRoute- Returns:
- the control turnout or null if not set
- Throws:
IllegalArgumentException
-
setLockControlTurnout
Set the lock control Turnout for this Route.- Specified by:
setLockControlTurnoutin interfaceRoute- Parameters:
turnoutName- the system name of the turnout- Throws:
IllegalArgumentException
-
getLockControlTurnout
Get the SystemName of the lock control Turnout for this Route.- Specified by:
getLockControlTurnoutin interfaceRoute- Returns:
- the system name or null if not defined
-
getLockCtlTurnout
Get the Turnout of a lock control Turnout for this Route.- Specified by:
getLockCtlTurnoutin interfaceRoute- Returns:
- the turnout or null if not defined
- Throws:
IllegalArgumentException
-
setRouteCommandDelay
Set the delay between issuing Turnout commands on this route.- Specified by:
setRouteCommandDelayin interfaceRoute- Parameters:
delay- the delay in milliseconds
-
getRouteCommandDelay
Get the delay between issuing Turnout commands on this route.- Specified by:
getRouteCommandDelayin interfaceRoute- Returns:
- the delay in milliseconds
-
setControlTurnoutState
Set the State of control Turnout that fires this Route.- Specified by:
setControlTurnoutStatein interfaceRoute- Parameters:
turnoutState- the turnout state
-
getControlTurnoutState
Get the State of control Turnout that fires this Route.- Specified by:
getControlTurnoutStatein interfaceRoute- Returns:
- the turnout state
-
setControlTurnoutFeedback
Set the feedback to use when checking the control turnout state- Specified by:
setControlTurnoutFeedbackin interfaceRoute- Parameters:
turnoutFeedbackIsCommanded- true if commanded state is to be checked; default is false
-
getControlTurnoutFeedback
Get the feedback to use when checking the control turnout state- Specified by:
getControlTurnoutFeedbackin interfaceRoute- Returns:
- true if commanded state is to be checked; false is known state
-
setLockControlTurnoutState
Set the State of the lock control Turnout for this Route.- Specified by:
setLockControlTurnoutStatein interfaceRoute- Parameters:
turnoutState- the turnout state
-
getLockControlTurnoutState
Get the State of the lock control Turnout that locks this Route.- Specified by:
getLockControlTurnoutStatein interfaceRoute- Returns:
- the turnout state
-
setRoute
Set the Route.Sets all Route Turnouts to the directed state in the Route definition.
-
checkSensor
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
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
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
Method to check if the turnouts for this route are correctly aligned. Sets turnouts aligned sensor (if there is one) to active if the turnouts are aligned. Sets the sensor to inactive if they are not aligned -
activateRoute
Activate the Route.This starts route processing by connecting to inputs, etc. A Route must be activated before it will fire.
- Specified by:
activateRoutein 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
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:
deActivateRoutein interfaceRoute
-
setRouteBusy
Mark the Route as transitioning to anSensor.ACTIVEstate.- Parameters:
busy- true if Route should be busy.
-
isRouteBusy
Method to query if Route is busy (returns true if commands are being issued to Route turnouts)- Returns:
- true if the Route is transitioning to an
Sensor.ACTIVEstate, false otherwise.
-
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
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
- Specified by:
vetoableChangein interfaceNamedBean- Specified by:
vetoableChangein interfaceVetoableChangeListener- Overrides:
vetoableChangein classAbstractNamedBean- Throws:
PropertyVetoException
-
getUsageReport
Description copied from interface:NamedBeanGet a list of references for the specified bean.- Specified by:
getUsageReportin interfaceNamedBean- Parameters:
bean- The bean to be checked.- Returns:
- a list of NamedBeanUsageReports or an empty ArrayList.
-