jmri.implementation
Class DefaultRoute

java.lang.Object
  extended by jmri.implementation.AbstractNamedBean
      extended by jmri.implementation.DefaultRoute
All Implemented Interfaces:
Serializable, NamedBean, Route

public class DefaultRoute
extends AbstractNamedBean
implements Route, Serializable

See Also:
Serialized Form

Field Summary
protected  NamedBeanHandle<Turnout> mControlNamedTurnout
           
protected  String mControlTurnout
          Persistant instance variables (saved between runs)
protected  int mControlTurnoutState
           
protected  int mDelay
           
protected  NamedBeanHandle<Turnout> mLockControlNamedTurnout
           
protected  String mLockControlTurnout
           
protected  int mLockControlTurnoutState
           
protected  PropertyChangeListener mLockTurnoutListener
           
protected  PropertyChangeListener mTurnoutListener
           
protected  NamedBeanHandle<Sensor> mTurnoutsAlignedNamedSensor
           
protected  String mTurnoutsAlignedSensor
           
protected  NamedBeanHandleManager nbhm
           
protected  String scriptFilename
           
protected  String soundFilename
           
 
Fields inherited from class jmri.implementation.AbstractNamedBean
mSystemName, mUserName
 
Fields inherited from interface jmri.Route
MAX_CONTROL_SENSORS, ONACTIVE, ONCHANGE, ONCLOSED, ONINACTIVE, ONTHROWN, TOGGLE, VETOACTIVE, VETOCLOSED, VETOINACTIVE, VETOTHROWN
 
Fields inherited from interface jmri.NamedBean
INCONSISTENT, UNKNOWN
 
Constructor Summary
DefaultRoute(String systemName)
           
DefaultRoute(String systemName, String userName)
           
 
Method Summary
 void activateRoute()
          Method to activate the Route via Sensors and control Turnout Sets up for Route activation based on a list of Sensors and a control Turnout Registers to receive known state changes for output turnouts
 boolean addOutputSensor(String sensorName, int state)
          Add an output Sensor to this Route
 boolean addOutputTurnout(String turnoutName, int turnoutState)
          Add an output Turnout to this Route
 boolean addSensorToRoute(String sensorName, int mode)
          Method to add a Sensor to the list of control Sensors for this Route.
 boolean canLock()
          Determine if route can be locked.
protected  void checkSensor(int newState, int oldState, Sensor sensor)
          Handle sensor update event to see if that will set the route.
 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()
          Method to delete all control Sensors from this Route
 void deActivateRoute()
          Method to deactivate the Route Deactivates Route based on a list of Sensors and two control Turnouts
 String getControlTurnout()
          Method to get the Name of a control Turnout for this Route
 int getControlTurnoutState()
          Method to get the State of control Turnout that fires this Route
 boolean getEnabled()
          Get enabled status
 String getLockControlTurnout()
          Method to get the Name of a lock control Turnout for this Route
 int getLockControlTurnoutState()
          Method to get the State of lock control Turnout
 boolean getLocked()
          Get locked status.
 int getNumOutputSensors()
           
 int getNumOutputTurnouts()
           
 String getOutputScriptName()
          Get name of script file to be run when Route is fired
 Sensor getOutputSensor(int k)
          Method to return the 'k'th Sensor of the Route.
 String getOutputSensorByIndex(int index)
          Method to get an ouput Sensor name by Index Returns null if there is no sensor with that index
 int getOutputSensorSetState(String name)
          Method to get the Set State of a Sensor included in this Route If the Sensor is not found, -1 is returned.
 int getOutputSensorState(int k)
          Method to get the desired state of 'k'th Sensor of the Route.
 String getOutputSoundName()
          Get name of sound file to be played when Route is fired
 Turnout getOutputTurnout(int k)
          Method to return the 'k'th Turnout of the Route.
 String getOutputTurnoutByIndex(int index)
          Method to get a Route Turnout Name by Index Returns null if there is no turnout with that index
 int getOutputTurnoutSetState(String name)
          Method to get the Set State of a Turnout included in this Route Noth the input and internal names can be either a user or system name
 int getOutputTurnoutState(int k)
          Method to get the desired state of 'k'th Turnout of the Route.
 int getRouteCommandDelay()
          Method to get delay (milliseconds) between issuing Turnout commands
 Sensor getRouteSensor(int index)
          Method to get the control Sensor in this Route 'index' is the index in the Sensor array of the requested Sensor.
 int getRouteSensorMode(int index)
          Method to get the mode associated with a control Sensor in this Route 'index' is the index in the Sensor array of the requested Sensor.
 String getRouteSensorName(int index)
          Method to get the Name of a control Sensor in this Route 'index' is the index in the Sensor array of the requested Sensor.
 int getState()
          Not needed for Routes - included to complete implementation of the NamedBean interface.
 String getTurnoutsAlignedSensor()
          Method to get turnouts aligned sensor
 boolean isOutputSensorIncluded(String sensorName)
          Method to inquire if a Sensor is included in this Route
 boolean isOutputTurnoutIncluded(String turnoutName)
          Method to inquire if a Turnout is included in this Route.
 boolean isRouteBusy()
          Method to query if Route is busy (returns true if commands are being issued to Route turnouts)
 void setControlTurnout(String turnoutName)
          Method to set the Name of a control Turnout for this Route
 void setControlTurnoutState(int turnoutState)
          Method to set the State of control Turnout that fires this Route
 void setEnabled(boolean v)
          Set enabled status.
 void setLockControlTurnout(String turnoutName)
          Method to set the Name of a lock control Turnout for this Route
 void setLockControlTurnoutState(int turnoutState)
          Method to set the State of lock control Turnout
 void setLocked(boolean v)
          Set locked status.
 void setOutputScriptName(String filename)
          Set name of script file to be run when Route is fired
 void setOutputSoundName(String filename)
          Set name of sound file to be played when Route is fired
 void setRoute()
          Method to set the Route Sets all Route Turnouts to the state shown in the Route definition This call is ignored if the Route is 'busy', i.e., if there is a thread currently sending commands to this Route's turnouts.
 void setRouteBusy()
          Method to set Route busy when commands are being issued to Route turnouts
 void setRouteCommandDelay(int delay)
          Method to set delay (milliseconds) between issuing Turnout commands
 void setRouteNotBusy()
          Method to set Route not busy when all commands have been issued to Route turnouts
 void setState(int state)
          Not needed for Routes - included to complete implementation of the NamedBean interface.
 void setTurnoutsAlignedSensor(String sensorName)
          Method to set turnouts aligned sensor
 
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, dispose, firePropertyChange, getComment, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setUserName, updateListenerRef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, dispose, getComment, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyKeys, getSystemName, getUserName, removePropertyChangeListener, setComment, setProperty, setUserName, updateListenerRef
 

Field Detail

mControlTurnout

protected String mControlTurnout
Persistant instance variables (saved between runs)


mControlNamedTurnout

protected NamedBeanHandle<Turnout> mControlNamedTurnout

mControlTurnoutState

protected int mControlTurnoutState

mDelay

protected int mDelay

mLockControlTurnout

protected String mLockControlTurnout

mLockControlNamedTurnout

protected NamedBeanHandle<Turnout> mLockControlNamedTurnout

mLockControlTurnoutState

protected int mLockControlTurnoutState

mTurnoutsAlignedSensor

protected String mTurnoutsAlignedSensor

mTurnoutsAlignedNamedSensor

protected NamedBeanHandle<Sensor> mTurnoutsAlignedNamedSensor

soundFilename

protected String soundFilename

scriptFilename

protected String scriptFilename

nbhm

protected NamedBeanHandleManager nbhm

mTurnoutListener

protected transient PropertyChangeListener mTurnoutListener

mLockTurnoutListener

protected transient PropertyChangeListener mLockTurnoutListener
Constructor Detail

DefaultRoute

public DefaultRoute(String systemName,
                    String userName)

DefaultRoute

public DefaultRoute(String systemName)
Method Detail

getEnabled

public boolean getEnabled()
Description copied from interface: Route
Get enabled status

Specified by:
getEnabled in interface Route

setEnabled

public void setEnabled(boolean v)
Description copied from interface: Route
Set enabled status.

Specified by:
setEnabled in interface Route

getLocked

public boolean getLocked()
Description copied from interface: Route
Get locked status.

Specified by:
getLocked in interface Route

setLocked

public void setLocked(boolean v)
Description copied from interface: Route
Set locked status.

Specified by:
setLocked in interface Route

canLock

public boolean canLock()
Determine if route can be locked. Requres at least one turnout that can be locked

Specified by:
canLock in interface Route

addOutputTurnout

public boolean addOutputTurnout(String turnoutName,
                                int turnoutState)
Add an output Turnout to this Route

Specified by:
addOutputTurnout in interface Route
Parameters:
turnoutName - The turnout system name
turnoutState - must be Turnout.CLOSED, Turnout.THROWN, or Route.TOGGLE, which determines how the Turnout is to be switched when this Route is set

clearOutputTurnouts

public void clearOutputTurnouts()
Delete all output Turnouts from this Route

Specified by:
clearOutputTurnouts in interface Route

getNumOutputTurnouts

public int getNumOutputTurnouts()
Specified by:
getNumOutputTurnouts in interface Route

getOutputTurnoutByIndex

public String getOutputTurnoutByIndex(int index)
Method to get a Route Turnout Name by Index Returns null if there is no turnout with that index

Specified by:
getOutputTurnoutByIndex in interface Route
Returns:
null if there is no turnout with that index

isOutputTurnoutIncluded

public boolean isOutputTurnoutIncluded(String turnoutName)
Method to inquire if a Turnout is included in this Route.

Complicated by the fact that either the argument or the internal names might be user or system names

Specified by:
isOutputTurnoutIncluded in interface Route

getOutputTurnoutSetState

public int getOutputTurnoutSetState(String name)
Method to get the Set State of a Turnout included in this Route

Noth the input and internal names can be either a user or system name

Specified by:
getOutputTurnoutSetState in interface Route
Returns:
-1 if there are less than 'k' Turnouts defined

getOutputTurnout

public Turnout getOutputTurnout(int k)
Method to return the 'k'th Turnout of the Route.

Specified by:
getOutputTurnout in interface Route
Returns:
null if there are less than 'k' Turnouts defined

getOutputTurnoutState

public int getOutputTurnoutState(int k)
Method to get the desired state of 'k'th Turnout of the Route. Returns -1 if there are less than 'k' Turnouts defined

Specified by:
getOutputTurnoutState in interface Route
Returns:
-1 if there are less than 'k' Turnouts defined

addOutputSensor

public boolean addOutputSensor(String sensorName,
                               int state)
Add an output Sensor to this Route

Specified by:
addOutputSensor in interface Route
Parameters:
sensorName - The sensor name either system or user
state - must be Sensor.ACTIVE, Sensor.INACTIVE, or Route.TOGGLE, which determines how the Sensor is to be set when this Route is set

clearOutputSensors

public void clearOutputSensors()
Delete all output Sensors from this Route

Specified by:
clearOutputSensors in interface Route

getNumOutputSensors

public int getNumOutputSensors()
Specified by:
getNumOutputSensors in interface Route

getOutputSensorByIndex

public String getOutputSensorByIndex(int index)
Method to get an ouput Sensor name by Index Returns null if there is no sensor with that index

Specified by:
getOutputSensorByIndex in interface Route
Returns:
null if there is no sensor with that index

isOutputSensorIncluded

public boolean isOutputSensorIncluded(String sensorName)
Method to inquire if a Sensor is included in this Route

Specified by:
isOutputSensorIncluded in interface Route

getOutputSensorSetState

public int getOutputSensorSetState(String name)
Method to get the Set State of a Sensor included in this Route If the Sensor is not found, -1 is returned.

Both the input or internal names can be either system or user names

Specified by:
getOutputSensorSetState in interface Route
Returns:
-1 if the Sensor is not found

getOutputSensor

public Sensor getOutputSensor(int k)
Method to return the 'k'th Sensor of the Route.

Specified by:
getOutputSensor in interface Route
Returns:
null if there are less than 'k' Sensors defined

getOutputSensorState

public int getOutputSensorState(int k)
Method to get the desired state of 'k'th Sensor of the Route. Returns -1 if there are less than 'k' Sensors defined

Specified by:
getOutputSensorState in interface Route
Returns:
-1 if there are less than 'k' Sensors defined

setOutputScriptName

public void setOutputScriptName(String filename)
Set name of script file to be run when Route is fired

Specified by:
setOutputScriptName in interface Route

getOutputScriptName

public String getOutputScriptName()
Get name of script file to be run when Route is fired

Specified by:
getOutputScriptName in interface Route

setOutputSoundName

public void setOutputSoundName(String filename)
Set name of sound file to be played when Route is fired

Specified by:
setOutputSoundName in interface Route

getOutputSoundName

public String getOutputSoundName()
Get name of sound file to be played when Route is fired

Specified by:
getOutputSoundName in interface Route

setTurnoutsAlignedSensor

public void setTurnoutsAlignedSensor(String sensorName)
Method to set turnouts aligned sensor

Specified by:
setTurnoutsAlignedSensor in interface Route

getTurnoutsAlignedSensor

public String getTurnoutsAlignedSensor()
Method to get turnouts aligned sensor

Specified by:
getTurnoutsAlignedSensor in interface Route

clearRouteSensors

public void clearRouteSensors()
Method to delete all control Sensors from this Route

Specified by:
clearRouteSensors in interface Route

addSensorToRoute

public boolean addSensorToRoute(String sensorName,
                                int mode)
Method to add a Sensor to the list of control Sensors for this Route.

Specified by:
addSensorToRoute in interface Route
Parameters:
sensorName - either a system or username of a sensor

getRouteSensorName

public String getRouteSensorName(int index)
Method to get the Name of a control Sensor in this Route 'index' is the index in the Sensor array of the requested Sensor. If there is no Sensor with that 'index', or if 'index' is not in the range 0 thru MAX_SENSORS-1, null is returned.

Specified by:
getRouteSensorName in interface Route
Parameters:
index - The index in the Sensor array of the requested Sensor.
Returns:
null If there is no Sensor with that 'index', or if 'index' is not in the range 0 thru MAX_SENSORS-1.

getRouteSensor

public Sensor getRouteSensor(int index)
Method to get the control Sensor in this Route 'index' is the index in the Sensor array of the requested Sensor. If there is no Sensor with that 'index', or if 'index' is not in the range 0 thru MAX_SENSORS-1, null is returned.


getRouteSensorMode

public int getRouteSensorMode(int index)
Method to get the mode associated with a control Sensor in this Route 'index' is the index in the Sensor array of the requested Sensor. If there is no Sensor with that 'index', or if 'index' is not in the range 0 thru MAX_SENSORS-1, ONACTIVE is returned

Specified by:
getRouteSensorMode in interface Route
Parameters:
index - The index in the Sensor array of the requested Sensor.
Returns:
ONACTIVE if there is no Sensor with that 'index', or if 'index' is not in the range 0 thru MAX_SENSORS-1

setControlTurnout

public void setControlTurnout(String turnoutName)
Method to set the Name of a control Turnout for this Route

Specified by:
setControlTurnout in interface Route

getControlTurnout

public String getControlTurnout()
Method to get the Name of a control Turnout for this Route

Specified by:
getControlTurnout in interface Route

setLockControlTurnout

public void setLockControlTurnout(String turnoutName)
Method to set the Name of a lock control Turnout for this Route

Specified by:
setLockControlTurnout in interface Route

getLockControlTurnout

public String getLockControlTurnout()
Method to get the Name of a lock control Turnout for this Route

Specified by:
getLockControlTurnout in interface Route

setRouteCommandDelay

public void setRouteCommandDelay(int delay)
Method to set delay (milliseconds) between issuing Turnout commands

Specified by:
setRouteCommandDelay in interface Route

getRouteCommandDelay

public int getRouteCommandDelay()
Method to get delay (milliseconds) between issuing Turnout commands

Specified by:
getRouteCommandDelay in interface Route

setControlTurnoutState

public void setControlTurnoutState(int turnoutState)
Method to set the State of control Turnout that fires this Route

Specified by:
setControlTurnoutState in interface Route

getControlTurnoutState

public int getControlTurnoutState()
Method to get the State of control Turnout that fires this Route

Specified by:
getControlTurnoutState in interface Route

setLockControlTurnoutState

public void setLockControlTurnoutState(int turnoutState)
Method to set the State of lock control Turnout

Specified by:
setLockControlTurnoutState in interface Route

getLockControlTurnoutState

public int getLockControlTurnoutState()
Method to get the State of lock control Turnout

Specified by:
getLockControlTurnoutState in interface Route

setRoute

public void setRoute()
Method to set the Route Sets all Route Turnouts to the state shown in the Route definition This call is ignored if the Route is 'busy', i.e., if there is a thread currently sending commands to this Route's turnouts.

Specified by:
setRoute in interface Route

checkSensor

protected void checkSensor(int newState,
                           int oldState,
                           Sensor sensor)
Handle sensor update event to see if that 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 noting explicitly, but has the side effect of firing 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()
Method to activate the Route via Sensors and control Turnout Sets up for Route activation based on a list of Sensors and a control Turnout Registers to receive known state changes for output turnouts

Specified by:
activateRoute in interface Route

deActivateRoute

public void deActivateRoute()
Method to deactivate the Route Deactivates Route based on a list of Sensors and two control Turnouts

Specified by:
deActivateRoute in interface Route

setRouteBusy

public void setRouteBusy()
Method to set Route busy when commands are being issued to Route turnouts


setRouteNotBusy

public void setRouteNotBusy()
Method to set Route not busy when all commands have been issued to Route turnouts


isRouteBusy

public boolean isRouteBusy()
Method to query if Route is busy (returns true if commands are being issued to Route turnouts)


getState

public int getState()
Not needed for Routes - included to complete implementation of the NamedBean interface.

Specified by:
getState in interface NamedBean

setState

public void setState(int state)
Not needed for Routes - included to complete implementation of the NamedBean interface.

Specified by:
setState in interface NamedBean


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads