Class DefaultSignalGroup

    • Field Detail

      • _signalHeadItem

        java.util.ArrayList<jmri.implementation.DefaultSignalGroup.SignalHeadItem> _signalHeadItem
    • Constructor Detail

      • DefaultSignalGroup

        public DefaultSignalGroup​(java.lang.String systemName,
                                  java.lang.String userName)
        Constructor for SignalGroup instance.
        Parameters:
        systemName - suggested system name
        userName - provided user name
      • DefaultSignalGroup

        public DefaultSignalGroup​(java.lang.String systemName)
        Constructor for SignalGroup instance.
        Parameters:
        systemName - suggested system name
    • Method Detail

      • getBeanType

        public java.lang.String getBeanType()
        Description copied from interface: NamedBean
        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 interface NamedBean
        Returns:
        a string of the bean type, eg Turnout, Sensor etc
      • setEnabled

        public void setEnabled​(boolean boo)
        Description copied from interface: SignalGroup
        Set enabled status of the signal group.
        Specified by:
        setEnabled in interface SignalGroup
        Parameters:
        boo - true if signal group should be enabled; false otherwise
      • getEnabled

        public boolean getEnabled()
        Description copied from interface: SignalGroup
        Get enabled status of the signal group.
        Specified by:
        getEnabled in interface SignalGroup
        Returns:
        true if signal group is enabled; false otherwise
      • setSignalMast

        public void setSignalMast​(java.lang.String pName)
        Description copied from interface: SignalGroup
        Set the main Signal Mast for the Group by name.
        Specified by:
        setSignalMast in interface SignalGroup
        Parameters:
        pName - Name of the (existing) Signal Mast to set as main mast for the group
      • setSignalMast

        public void setSignalMast​(SignalMast signalMast,
                                  java.lang.String mastName)
        Description copied from interface: SignalGroup
        Set the main Signal Mast for the Group.
        Specified by:
        setSignalMast in interface SignalGroup
        Parameters:
        signalMast - Mast object to attach
        mastName - Name of the (existing) Signal Mast to set as main mast for the group
      • addSignalMastAspect

        public void addSignalMastAspect​(java.lang.String aspect)
        Description copied from interface: SignalGroup
        Add an Aspect that can trigger the group activation.
        Specified by:
        addSignalMastAspect in interface SignalGroup
        Parameters:
        aspect - Name of an aspect for the Main Signal Mast in the Group, must be valid for the Mast type
      • isSignalMastAspectIncluded

        public boolean isSignalMastAspectIncluded​(java.lang.String aspect)
        Description copied from interface: SignalGroup
        Inquire if a Signal Mast Aspect is included in the group.
        Specified by:
        isSignalMastAspectIncluded in interface SignalGroup
        Parameters:
        aspect - name of the Aspect, i.e. "Clear"
        Returns:
        true if aspect is included in group
      • getSignalMastAspectByIndex

        public java.lang.String getSignalMastAspectByIndex​(int x)
        Description copied from interface: SignalGroup
        Get a SignalMast Aspect for the Main Signal Mast by its Index.
        Specified by:
        getSignalMastAspectByIndex in interface SignalGroup
        Parameters:
        x - index of the Signal Mast Aspect in the list
        Returns:
        the aspect or null if there are no aspects with that index
      • addSignalHead

        public void addSignalHead​(java.lang.String pName)
        Add a new Signal Head to the group by name.
        Parameters:
        pName - system or username of existing signal head to add to group
      • addSignalHead

        public void addSignalHead​(SignalHead signalHead)
        Description copied from interface: SignalGroup
        Add a Signal Head item for this Signal Head to the list in the Group.
        Specified by:
        addSignalHead in interface SignalGroup
        Parameters:
        signalHead - The Signal Head object
      • setHeadAlignTurnout

        public void setHeadAlignTurnout​(SignalHead signalHead,
                                        Turnout turnout,
                                        int state)
        Description copied from interface: SignalGroup
        Add a Turnout and its On state to a Signal Head.
        Specified by:
        setHeadAlignTurnout in interface SignalGroup
        Parameters:
        signalHead - SignalHead we are adding the turnout to
        turnout - Turnout Bean
        state - Value for the turnout On state (Turnout.THROWN or Turnout.CLOSED).
      • setHeadAlignSensor

        public void setHeadAlignSensor​(SignalHead signalHead,
                                       Sensor sensor,
                                       int state)
        Description copied from interface: SignalGroup
        Add a Sensor and its On state to a Signal Head.
        Specified by:
        setHeadAlignSensor in interface SignalGroup
        Parameters:
        signalHead - Signal Head we are adding the sensor to
        sensor - Sensor Bean
        state - Value for the Sensor On state (Sensor.ACTIVE or Sensor.INACTIVE).
      • getHeadItemNameByIndex

        public java.lang.String getHeadItemNameByIndex​(int x)
        Description copied from interface: SignalGroup
        Get the name of a Signal Head by Index.
        Specified by:
        getHeadItemNameByIndex in interface SignalGroup
        Parameters:
        x - Index of the SignalHead in the Group
        Returns:
        null if there are no Signal Heads with that index in the group
      • getHeadOffState

        public int getHeadOffState​(SignalHead headBean)
        Description copied from interface: SignalGroup
        Get the Off (conditions NOT met) State of a Signal Head item in the group.
        Specified by:
        getHeadOffState in interface SignalGroup
        Parameters:
        headBean - The Signal Head Bean object we are querying
        Returns:
        state value for the Off state (appearance)
      • getHeadOnState

        public int getHeadOnState​(SignalHead headBean)
        Description copied from interface: SignalGroup
        Get the On (conditions met) State of a Signal Head item in the group.
        Specified by:
        getHeadOnState in interface SignalGroup
        Parameters:
        headBean - The Signal Head object we are querying
        Returns:
        state value for the On state (appearance)
      • getHeadOnStateByIndex

        public int getHeadOnStateByIndex​(int x)
        Description copied from interface: SignalGroup
        Get the On State for the Signal Head item at Index x in the group.
        Specified by:
        getHeadOnStateByIndex in interface SignalGroup
        Parameters:
        x - Index of the SignalHead in Group
        Returns:
        -1 if there are less than 'x' Signal Heads defined
      • getHeadOffStateByIndex

        public int getHeadOffStateByIndex​(int x)
        Description copied from interface: SignalGroup
        Get the Off State for the Signal Head item at Index x in the group.
        Specified by:
        getHeadOffStateByIndex in interface SignalGroup
        Parameters:
        x - Index of the SignalHead in Group
        Returns:
        -1 if there are less than 'x' Signal Heads defined
      • setHeadOnState

        public void setHeadOnState​(SignalHead head,
                                   int state)
        Description copied from interface: SignalGroup
        Set the On (conditions met) State of a Signal Head item in the Group.
        Specified by:
        setHeadOnState in interface SignalGroup
        Parameters:
        head - The SignalHead Bean
        state - The Appearance that the SignalHead will change to when the conditions are met.
      • setHeadOffState

        public void setHeadOffState​(SignalHead head,
                                    int state)
        Description copied from interface: SignalGroup
        Set the Off (conditions NOT met) State of a Signal Head item in the Group.
        Specified by:
        setHeadOffState in interface SignalGroup
        Parameters:
        head - The SignalHead Bean
        state - The Apperance that the SignalHead will change to when the conditions are NOT met.
      • isHeadIncluded

        public boolean isHeadIncluded​(SignalHead signalHead)
        Description copied from interface: SignalGroup
        Inquire if a Signal Head item for this head is included in this Group.
        Specified by:
        isHeadIncluded in interface SignalGroup
        Parameters:
        signalHead - The Signal Head object we are querying
        Returns:
        true if the signal head is included in the group; false otherwise
      • isTurnoutIncluded

        public boolean isTurnoutIncluded​(SignalHead signalHead,
                                         Turnout turnout)
        Description copied from interface: SignalGroup
        Inquire if a Turnout is included in the Signal Head Calculation.
        Specified by:
        isTurnoutIncluded in interface SignalGroup
        Parameters:
        signalHead - signalHead that may consider turnout
        turnout - turnout to consider
        Returns:
        true if turnout state is considered; false otherwise
      • getTurnoutState

        public int getTurnoutState​(SignalHead signalHead,
                                   Turnout turnout)
        Description copied from interface: SignalGroup
        Get the On state of the Turnout for the given Signal Head in the group.
        Specified by:
        getTurnoutState in interface SignalGroup
        Parameters:
        signalHead - Signal Head Bean
        turnout - The Turnout within the Group
        Returns:
        -1 if the Turnout or Signal Head is invalid
      • getTurnoutStateByIndex

        public int getTurnoutStateByIndex​(int x,
                                          Turnout turnout)
        Description copied from interface: SignalGroup
        Get the On state of a given Turnout for the Signal Head at index x.
        Specified by:
        getTurnoutStateByIndex in interface SignalGroup
        Parameters:
        x - Index for the Signal Head in the group
        turnout - Name of the Turnout configured for the head
        Returns:
        -1 if the Turnout or Signal Head is invalid
      • getTurnoutStateByIndex

        public int getTurnoutStateByIndex​(int x,
                                          int pTurnout)
        Description copied from interface: SignalGroup
        Get the On state of the Turnout at index pTurnout, for the Signal Head at index x in the group.
        Specified by:
        getTurnoutStateByIndex in interface SignalGroup
        Parameters:
        x - Index for the Signal Head in the group
        pTurnout - Index of the Turnout configured for the head
        Returns:
        -1 if the Turnout or Signal Head is invalid
      • getTurnoutNameByIndex

        public java.lang.String getTurnoutNameByIndex​(int x,
                                                      int pTurnout)
        Description copied from interface: SignalGroup
        Get the Name of the Turnout at index pTurnout, for the Signal Head at index x in the group.
        Specified by:
        getTurnoutNameByIndex in interface SignalGroup
        Parameters:
        x - Index for the Signal Head in the group
        pTurnout - Index for the turnout in the signal head item
        Returns:
        null if the Turnout or Signal Head is invalid
      • getTurnoutByIndex

        public Turnout getTurnoutByIndex​(int x,
                                         int pTurnout)
        Description copied from interface: SignalGroup
        Get the Turnout at index x, for the Signal Head at index x in the group.
        Specified by:
        getTurnoutByIndex in interface SignalGroup
        Parameters:
        x - Index for the Signal Head in the group
        pTurnout - Index for the turnout in the signal head item
        Returns:
        null if the Turnout or Signal Head is invalid
      • getSensorStateByIndex

        public int getSensorStateByIndex​(int x,
                                         int pSensor)
        Description copied from interface: SignalGroup
        Get the On state of the Sensor at index pSensor for the Signal Head at index x.
        Specified by:
        getSensorStateByIndex in interface SignalGroup
        Parameters:
        x - Index for the Signal Head in the group
        pSensor - Index of the Sensor in the head item
        Returns:
        -1 if the Sensor or Signal Head is invalid
      • getSensorNameByIndex

        public java.lang.String getSensorNameByIndex​(int x,
                                                     int pSensor)
        Description copied from interface: SignalGroup
        Get the name of the Sensor at index pSensor for the Signal Head at index x.
        Specified by:
        getSensorNameByIndex in interface SignalGroup
        Parameters:
        x - Index for the Signal Head in the group
        pSensor - Index of the Sensor in the head item
        Returns:
        null if the Sensor or Signal Head is invalid
      • getSensorByIndex

        public Sensor getSensorByIndex​(int x,
                                       int pSensor)
        Description copied from interface: SignalGroup
        Get the Sensor at index pSensor, for the Signal Head at index x.
        Specified by:
        getSensorByIndex in interface SignalGroup
        Parameters:
        x - Index for the Signal Head in the group
        pSensor - Index of the Sensor in the head item
        Returns:
        null if the Sensor or Signal Head is invalid
      • isSensorIncluded

        public boolean isSensorIncluded​(SignalHead signalHead,
                                        Sensor sensor)
        Description copied from interface: SignalGroup
        Inquire if a Sensor is included in the Signal Head Calculation.
        Specified by:
        isSensorIncluded in interface SignalGroup
        Parameters:
        signalHead - Signal Head Bean
        sensor - Sensor Bean
        Returns:
        true if sensor is considered for signalHead state; false otherwise
      • getSensorState

        public int getSensorState​(SignalHead signalHead,
                                  Sensor sensor)
        Description copied from interface: SignalGroup
        Get the On state of the Sensor for the Signal Head in the group.
        Specified by:
        getSensorState in interface SignalGroup
        Parameters:
        signalHead - The Signal Head Bean
        sensor - Name of the Sensor in the head item
        Returns:
        -1 if the Sensor or Signal Head is invalid
      • setSensorTurnoutOper

        public void setSensorTurnoutOper​(SignalHead signalHead,
                                         boolean boo)
        Description copied from interface: SignalGroup
        Set whether the sensors and turnouts should be treated as separate calculations (OR) or as one (AND) when determining if the Signal Head should be On or Off.
        Specified by:
        setSensorTurnoutOper in interface SignalGroup
        Parameters:
        signalHead - The SignalHead Bean
        boo - Provide true for AND, false for OR
      • clearHeadTurnout

        public void clearHeadTurnout​(SignalHead signalHead)
        Description copied from interface: SignalGroup
        Delete all Turnouts for a given Signal Head in the group.
        Specified by:
        clearHeadTurnout in interface SignalGroup
        Parameters:
        signalHead - The Signal Head Bean from which the Turnouts will be removed
      • clearHeadSensor

        public void clearHeadSensor​(SignalHead signalHead)
        Description copied from interface: SignalGroup
        Delete all Sensors for a given Signal Head in the group.
        Specified by:
        clearHeadSensor in interface SignalGroup
        Parameters:
        signalHead - The Signal Head Bean from which the Turnouts will be removed
      • getNumHeadSensorsByIndex

        public int getNumHeadSensorsByIndex​(int x)
        Description copied from interface: SignalGroup
        Get the number of Sensors configured for the Signal Head at index x.
        Specified by:
        getNumHeadSensorsByIndex in interface SignalGroup
        Parameters:
        x - Index for the Signal Head in the group
        Returns:
        -1 if there are less than 'x' Signal Heads defined
      • getNumHeadTurnoutsByIndex

        public int getNumHeadTurnoutsByIndex​(int x)
        Description copied from interface: SignalGroup
        Get the number of turnouts configured for the Signal Head at index x.
        Specified by:
        getNumHeadTurnoutsByIndex in interface SignalGroup
        Parameters:
        x - Index of the SignalHead in Group
        Returns:
        -1 if there are less than 'x' Signal Heads defined
      • getState

        public int getState()
        Description copied from interface: NamedBean
        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.

        Specified by:
        getState in interface NamedBean
        Specified by:
        getState in interface SignalGroup
        Returns:
        the state
      • setState

        public void setState​(int state)
        Description copied from interface: NamedBean
        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.

        Specified by:
        setState in interface NamedBean
        Specified by:
        setState in interface SignalGroup
        Parameters:
        state - the state