Class AbstractSignalHead

    • Field Detail

      • mLit

        protected boolean mLit
        By default, signals are lit.
      • mHeld

        protected boolean mHeld
        By default, signals are not held.
    • Constructor Detail

      • AbstractSignalHead

        public AbstractSignalHead​(java.lang.String systemName,
                                  java.lang.String userName)
    • Method Detail

      • getAppearanceName

        @Nonnull
        public java.lang.String getAppearanceName​(int appearance)
        Get the Appearance Name for a particular Appearance.
        Specified by:
        getAppearanceName in interface SignalHead
        Parameters:
        appearance - id for the Name.
        Returns:
        the Appearance Name, or empty String if unknown.
      • getAppearanceKey

        @Nonnull
        public java.lang.String getAppearanceKey​(int appearance)
        Get the Appearance Key for a particular Appearance.
        Specified by:
        getAppearanceKey in interface SignalHead
        Parameters:
        appearance - id for the key, e.g. SignalHead.GREEN
        Returns:
        the Appearance Key, e.g. "Green" or empty String if unknown. The key can be used as a Bundle String, e.g. Bundle.getMessage(getAppearanceKey(SignalHead.RED))
      • getAppearance

        public int getAppearance()
        Get the Signal Head Appearance. Changes in this value can be listened to using the Appearance property.
        Specified by:
        getAppearance in interface SignalHead
        Returns:
        the appearance, e.g. SignalHead.YELLOW
      • isCleared

        public boolean isCleared()
        Determine whether this signal shows an aspect or appearance that allows travel past it, e.g. it's "been cleared". This might be a yellow or green appearance, or an Approach or Clear aspect
        Specified by:
        isCleared in interface Signal
        Returns:
        true if the signal is showing a clear indication; false otherwise
      • isShowingRestricting

        public boolean isShowingRestricting()
        Determine whether this signal shows an aspect or appearance that allows travel past it only at restricted speed. This might be a flashing red appearance, or a Restricting aspect.
        Specified by:
        isShowingRestricting in interface Signal
        Returns:
        true if the signal is showing a restricting indication; false otherwise
      • isAtStop

        public boolean isAtStop()
        Determine whether this signal shows an aspect or appearance that forbid travel past it. This might be a red appearance, or a Stop aspect. Stop-and-Proceed or Restricting would return false here.
        Specified by:
        isAtStop in interface Signal
        Returns:
        true if the signal is showing a stop indication; false otherwise
      • getLit

        public boolean getLit()
        Default behavior for "lit" parameter is to track value and return it. Get whether the signal is lit or dark. Changes to this value can be listened to using the Lit property.
        Specified by:
        getLit in interface Signal
        Specified by:
        getLit in interface SignalHead
        Returns:
        is lit
      • getHeld

        public boolean getHeld()
        "Held" parameter is just tracked and notified. Get whether the signal is held. Changes to this value can be listened to using the Held property. It controls what mechanisms can control the signal's appearance. The actual semantics are defined by those external mechanisms.
        Specified by:
        getHeld in interface Signal
        Specified by:
        getHeld in interface SignalHead
        Returns:
        is held
      • setState

        public void setState​(int s)
        Implement a shorter name for setAppearance.

        This generally shouldn't be used by Java code; use setAppearance instead. The is provided to make Jython script access easier to read.

        Specified by:
        setState in interface NamedBean
        Parameters:
        s - new state
      • getState

        public int getState()
        Implement a shorter name for getAppearance.

        This generally shouldn't be used by Java code; use getAppearance instead. The is provided to make Jython script access easier to read.

        Specified by:
        getState in interface NamedBean
        Returns:
        current state
      • getDefaultStateName

        @Nonnull
        public static java.lang.String getDefaultStateName​(int appearance)
        Get a localized text describing appearance from the corresponding state index.
        Parameters:
        appearance - the index of the appearance
        Returns:
        translated name for appearance
      • getValidStates

        public int[] getValidStates()
        Get an array of appearance indexes valid for the mast type.
        Specified by:
        getValidStates in interface SignalHead
        Returns:
        array of appearance state values available on this mast type
      • isTurnoutUsed

        public abstract boolean isTurnoutUsed​(Turnout t)
        Check if a given turnout is used on this head.
        Parameters:
        t - Turnout object to check
        Returns:
        true if turnout is configured as output or driver of head
      • vetoableChange

        public void vetoableChange​(java.beans.PropertyChangeEvent evt)
                            throws java.beans.PropertyVetoException
        Specified by:
        vetoableChange in interface NamedBean
        Specified by:
        vetoableChange in interface java.beans.VetoableChangeListener
        Overrides:
        vetoableChange in class AbstractNamedBean
        Throws:
        java.beans.PropertyVetoException
      • getBeanType

        @Nonnull
        public java.lang.String getBeanType()
        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