Class DefaultSignalGroup

java.lang.Object
jmri.implementation.AbstractNamedBean
jmri.implementation.DefaultSignalGroup
All Implemented Interfaces:
Comparable<NamedBean>, PropertyChangeProvider, NamedBean, SignalGroup

public class DefaultSignalGroup extends AbstractNamedBean implements SignalGroup
A Conditional type to provide Signal Groups (n Signal Heads w/Conditionals for a main Mast).
See Also:
  • Field Details

  • Constructor Details

    • DefaultSignalGroup

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

      public DefaultSignalGroup(String systemName)
      Constructor for SignalGroup instance.
      Parameters:
      systemName - suggested system name
  • Method Details

    • getBeanType

      public 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(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, 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
    • getSignalMast

      Description copied from interface: SignalGroup
      Get the main Signal Mast in a group.
      Specified by:
      getSignalMast in interface SignalGroup
      Returns:
      The main Signal Mast as bean
    • getSignalMastName

      Description copied from interface: SignalGroup
      Get the name of the main Signal Mast in a group.
      Specified by:
      getSignalMastName in interface SignalGroup
      Returns:
      Name of the mast as string
    • addSignalMastAspect

      public void addSignalMastAspect(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(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
    • deleteSignalMastAspect

      public void deleteSignalMastAspect(String aspect)
      Description copied from interface: SignalGroup
      Remove a SignalMast Aspect from the set of triggers.
      Specified by:
      deleteSignalMastAspect in interface SignalGroup
      Parameters:
      aspect - Name of the Aspect, i.e. "Clear"
    • getNumSignalMastAspects

      Description copied from interface: SignalGroup
      Get the total number of Signal Mast Aspects available in this group.
      Specified by:
      getNumSignalMastAspects in interface SignalGroup
      Returns:
      the number of Aspects on the main Signal Mast, null if no Main Mast is assigned
    • getSignalMastAspectByIndex

      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
    • clearSignalMastAspect

      public void clearSignalMastAspect()
      Description copied from interface: SignalGroup
      Clear the list of SignalMast Aspects that may trigger the group. Causes the Aspect list to be rebuilt next time it is called
      Specified by:
      clearSignalMastAspect in interface SignalGroup
    • addSignalHead

      public void addSignalHead(NamedBeanHandle<SignalHead> headBean)
      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:
      headBean - The Signal Head as a Named Bean
    • addSignalHead

      public void addSignalHead(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

      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
    • getHeadItemBeanByIndex

      Description copied from interface: SignalGroup
      Get a Signal Head by Index.
      Specified by:
      getHeadItemBeanByIndex 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
    • getNumHeadItems

      public int getNumHeadItems()
      Description copied from interface: SignalGroup
      Get the number of Signal Heads configured as items in this group.
      Specified by:
      getNumHeadItems in interface SignalGroup
      Returns:
      the number of Signal Heads
    • 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
    • deleteSignalHead

      public void deleteSignalHead(SignalHead sh)
      Description copied from interface: SignalGroup
      Remove the Signal Head item for this Signal Head from the group by Name.
      Specified by:
      deleteSignalHead in interface SignalGroup
      Parameters:
      sh - The Signal Head to be deleted from the group.
    • deleteSignalHead

      public void deleteSignalHead(NamedBeanHandle<SignalHead> headBean)
      Description copied from interface: SignalGroup
      Remove the Signal Head item for this Signal Head from the group by NamedBean
      Specified by:
      deleteSignalHead in interface SignalGroup
      Parameters:
      headBean - The Named Bean to be removed from the group.
    • 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 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 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
    • getSensorTurnoutOper

      public boolean getSensorTurnoutOper(SignalHead signalHead)
      Description copied from interface: SignalGroup
      Get the AND/OR conditional operand set for a Signal Head in the group.
      Specified by:
      getSensorTurnoutOper in interface SignalGroup
      Parameters:
      signalHead - The Signal Head Bean
      Returns:
      true when set to AND, false for OR
    • getSensorTurnoutOperByIndex

      public boolean getSensorTurnoutOperByIndex(int x)
      Description copied from interface: SignalGroup
      Get the state of the AND/OR conditional operand for Signal Head at Index.
      Specified by:
      getSensorTurnoutOperByIndex in interface SignalGroup
      Parameters:
      x - Index of the SignalHead in Group
      Returns:
      true when set to AND, false for OR
    • 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
    • getUsageReport

      Description copied from interface: NamedBean
      Get a list of references for the specified bean.
      Specified by:
      getUsageReport in interface NamedBean
      Parameters:
      bean - The bean to be checked.
      Returns:
      a list of NamedBeanUsageReports or an empty ArrayList.