Package jmri

Interface Route

All Superinterfaces:
Comparable<NamedBean>, NamedBean, PropertyChangeProvider
All Known Implementing Classes:
DefaultRoute

public interface Route extends NamedBean
Routes represent a collection of Turnouts that may be set at the same time.

When a user adds a Turnout to a Route, the user specifies whether the Turnout state is to be set to CLOSED or THROWN when the Route is invoked (set).

Initially, Routes will have a fixed maximum number of sensors for simplicity of implementation. We can revise this later to use Java Collections if this becomes a problem.

To allow control via fascia panel pushbuttons, Routes may optionally be invoked by one or more Sensors (up to the maximum allowed).

A route can be enabled or not. By default it is enabled, and will act when its specified input conditions become satisfied. When not enabled (the enabled parameter is false), the route will not act even if the specified input conditions are satisfied. When the route transitions from disabled to enabled, it may act, depending on the conditions: Edge triggered conditions will not be satisfied, but level-conditions may be.


This file is part of JMRI.

JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

  • Field Details

  • Method Details

    • setEnabled

      void setEnabled(boolean state)
      Set enabled status.
      Parameters:
      state - true if enabled; false otherwise
    • getEnabled

      boolean getEnabled()
      Get enabled status.
      Returns:
      true if enabled; false otherwise
    • setLocked

      void setLocked(boolean state)
      Set locked status.
      Parameters:
      state - true if locked; false otherwise
    • getLocked

      boolean getLocked()
      Get locked status.
      Returns:
      true if locked; false otherwise
    • canLock

      boolean canLock()
      Has at least one lockable turnout.
      Returns:
      true if lockable; false otherwise
    • addOutputTurnout

      boolean addOutputTurnout(String systemName, int state)
      Add an output Turnout to this Route.
      Parameters:
      systemName - The turnout system name
      state - 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.
    • getNumOutputTurnouts

    • isOutputTurnoutIncluded

      boolean isOutputTurnoutIncluded(String systemName)
      Inquire if a Turnout is included in this Route as an output.
      Parameters:
      systemName - the system name of the turnout
      Returns:
      true if the named turnout is an output; false otherwise
    • getOutputTurnoutSetState

      get the Set State of an output Turnout.
      Parameters:
      systemName - the system name of the turnout
      Returns:
      the state or -1 if the Turnout is not found
    • getOutputTurnoutByIndex

      Get an output Turnout system name by index.
      Parameters:
      index - the index of the turnout
      Returns:
      the turnout system name or null if no turnout exists at index
    • getOutputTurnout

      Get the output Turnout by index.
      Parameters:
      index - the index of the turnout
      Returns:
      the turnout or null if no turnout exists at index
    • getOutputTurnoutState

      int getOutputTurnoutState(int index)
      Get the desired state of the Turnout by index.
      Parameters:
      index - the index of the turnout
      Returns:
      the turnout state or -1 if no turnout exists at index
    • addOutputSensor

      boolean addOutputSensor(String systemName, int state)
      Add an output Sensor to this Route.
      Parameters:
      systemName - the sensor system name
      state - 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.
    • getNumOutputSensors

    • isOutputSensorIncluded

      boolean isOutputSensorIncluded(String systemName)
      Inquire if a Sensor is included in this Route as an output.
      Parameters:
      systemName - the Sensor system name
      Returns:
      true if the sensor is an output in this Route
    • getOutputSensorSetState

      Get the Set State of an output Sensor.
      Parameters:
      systemName - the system name of the Sensor
      Returns:
      -1 if the Sensor is not found
    • getOutputSensorByIndex

      Get an output Sensor system name by index.
      Parameters:
      index - the index of the sensor
      Returns:
      the sensor or null if no sensor exists at index
    • getOutputSensor

      Get the output Sensor by index.
      Parameters:
      index - the index of the sensor
      Returns:
      the sensor or null if no sensor exists at index
    • getOutputSensorState

      int getOutputSensorState(int index)
      Get the desired state of an output Sensor by index.
      Parameters:
      index - the index of the sensor
      Returns:
      the sensor state or -1 if no sensor exists at index
    • setOutputScriptName

      void setOutputScriptName(String filename)
      Set name of script file to be run when Route is fired.
      Parameters:
      filename - path to script
    • getOutputScriptName

      Get name of script file to be run when Route is fired.
      Returns:
      script path or null if not defined
    • setOutputSoundName

      void setOutputSoundName(String filename)
      Set name of sound file to be played when Route is fired.
      Parameters:
      filename - path to sound
    • getOutputSoundName

      Get name of sound file to be played when Route is fired.
      Returns:
      sound file path or null if not defined
    • setTurnoutsAlignedSensor

      Set a sensor to be the turnouts aligned sensor.
      Parameters:
      sensorSystemName - the system name of the sensor; pass null to disassociate any sensor from this route
    • getTurnoutsAlignedSensor

      Get the system name of the turnouts aligned sensor.
      Returns:
      the name or null if not defined
    • getTurnoutsAlgdSensor

      Get the turnouts aligned sensor.
      Returns:
      the sensor or null if not defined
    • addSensorToRoute

      boolean addSensorToRoute(String sensorSystemName, int mode)
      Add a Sensor to the list of control Sensors for this Route.
      Parameters:
      sensorSystemName - system name of the sensor
      mode - the default state of the sensor
      Returns:
      true if added; false otherwise
    • clearRouteSensors

      Delete all control Sensors from this Route.
    • getRouteSensorName

      Get the SystemName of a control Sensor in this Route.
      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.
      Parameters:
      index - The index in the Sensor array of the requested Sensor
      Returns:
      null If there is no Sensor with at index
    • getRouteSensorMode

      int getRouteSensorMode(int index)
      Get the state of a particular Sensor in this Route.
      Parameters:
      index - The index in the Sensor array of the requested Sensor
      Returns:
      ONACTIVE if there is no Sensor with at index
    • setControlTurnout

      void setControlTurnout(String turnoutSystemName)
      Set the control Turnout for this Route.
      Parameters:
      turnoutSystemName - the system name of a turnout
    • getControlTurnout

      Get the SystemName of the control Turnout for this Route.
      Returns:
      the name of the control turnout or null if not set
    • getCtlTurnout

      Get the Turnout of a control Turnout for this Route.
      Returns:
      the control turnout or null if not set
    • setControlTurnoutState

      void setControlTurnoutState(int turnoutState)
      Set the State of control Turnout that fires this Route.
      Parameters:
      turnoutState - the turnout state
    • getControlTurnoutState

      Get the State of control Turnout that fires this Route.
      Returns:
      the turnout state
    • setControlTurnoutFeedback

      void setControlTurnoutFeedback(boolean turnoutFeedbackIsCommanded)
      Set the feedback to use when checking the control turnout state
      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
      Returns:
      true if commanded state is to be checked; false is known state
    • setLockControlTurnout

      void setLockControlTurnout(@CheckForNull String turnoutSystemName)
      Set the lock control Turnout for this Route.
      Parameters:
      turnoutSystemName - the system name of the turnout
    • getLockControlTurnout

      Get the SystemName of the lock control Turnout for this Route.
      Returns:
      the system name or null if not defined
    • getLockCtlTurnout

      Get the Turnout of a lock control Turnout for this Route.
      Returns:
      the turnout or null if not defined
    • setLockControlTurnoutState

      void setLockControlTurnoutState(int turnoutState)
      Set the State of the lock control Turnout for this Route.
      Parameters:
      turnoutState - the turnout state
    • getLockControlTurnoutState

      Get the State of the lock control Turnout that locks this Route.
      Returns:
      the turnout state
    • setRouteCommandDelay

      void setRouteCommandDelay(int delay)
      Set the delay between issuing Turnout commands on this route.
      Parameters:
      delay - the delay in milliseconds
    • getRouteCommandDelay

      Get the delay between issuing Turnout commands on this route.
      Returns:
      the delay in milliseconds
    • setRoute

      void setRoute()
      Set the Route.

      Sets all Route Turnouts to the directed state in the Route definition.

    • activateRoute

      Activate the Route.

      This starts route processing by connecting to inputs, etc. A Route must be activated before it will 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.