Package jmri

Interface Route

  • All Superinterfaces:
    java.lang.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.

    • Method Detail

      • 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​(java.lang.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
      • isOutputTurnoutIncluded

        boolean isOutputTurnoutIncluded​(java.lang.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

        int getOutputTurnoutSetState​(java.lang.String systemName)
        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

        java.lang.String getOutputTurnoutByIndex​(int index)
        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

        Turnout getOutputTurnout​(int index)
        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​(java.lang.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

        void clearOutputSensors()
        Delete all output Sensors from this Route.
      • isOutputSensorIncluded

        boolean isOutputSensorIncluded​(java.lang.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

        int getOutputSensorSetState​(java.lang.String systemName)
        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

        java.lang.String getOutputSensorByIndex​(int index)
        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

        Sensor getOutputSensor​(int index)
        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​(java.lang.String filename)
        Set name of script file to be run when Route is fired.
        Parameters:
        filename - path to script
      • getOutputScriptName

        java.lang.String getOutputScriptName()
        Get name of script file to be run when Route is fired.
        Returns:
        script path or null if not defined
      • setOutputSoundName

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

        java.lang.String getOutputSoundName()
        Get name of sound file to be played when Route is fired.
        Returns:
        sound file path or null if not defined
      • setTurnoutsAlignedSensor

        void setTurnoutsAlignedSensor​(java.lang.String sensorSystemName)
        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

        java.lang.String getTurnoutsAlignedSensor()
        Get the system name of the turnouts aligned sensor.
        Returns:
        the name or null if not defined
      • addSensorToRoute

        boolean addSensorToRoute​(java.lang.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

        void clearRouteSensors()
        Delete all control Sensors from this Route.
      • getRouteSensorName

        java.lang.String getRouteSensorName​(int index)
        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

        Sensor getRouteSensor​(int index)
        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​(java.lang.String turnoutSystemName)
        Set the control Turnout for this Route.
        Parameters:
        turnoutSystemName - the system name of a turnout
      • getControlTurnout

        java.lang.String getControlTurnout()
        Get the SystemName of the control Turnout for this Route.
        Returns:
        the name of the control turnout or null if not set
      • getCtlTurnout

        Turnout 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

        int 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

        boolean 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​(java.lang.String turnoutSystemName)
        Set the lock control Turnout for this Route.
        Parameters:
        turnoutSystemName - the system name of the turnout
      • getLockControlTurnout

        java.lang.String getLockControlTurnout()
        Get the SystemName of the lock control Turnout for this Route.
        Returns:
        the system name or null if not defined
      • getLockCtlTurnout

        Turnout 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

        int 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

        int 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

        void activateRoute()
        Activate the Route.

        This starts route processing by connecting to inputs, etc. A Route must be activated before it will fire.

      • deActivateRoute

        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.