Package jmri

Interface SignalHead

  • All Superinterfaces:
    java.lang.Comparable<NamedBean>, NamedBean, PropertyChangeProvider, Signal
    All Known Implementing Classes:
    AbstractSignalHead, AcelaSignalHead, DccSignalHead, DefaultSignalHead, DoubleTurnoutSignalHead, LsDecSignalHead, MergSD2SignalHead, QuadOutputSignalHead, SE8cSignalHead, SE8cSignalHead, SerialSignalHead, SingleTurnoutSignalHead, TripleOutputSignalHead, TripleTurnoutSignalHead, VirtualSignalHead

    public interface SignalHead
    extends Signal
    Represent a single signal head. (Try saying that ten times fast!) A signal may have more than one of these (e.g. a signal mast consisting of several heads) when needed to represent more complex aspects, e.g. Diverging Approach etc.

    This allows access to explicit appearance information. We don't call this an Aspect, as that's a composite of the appearance of several heads.

    This class has three bound parameters:

    Appearance
    The specific color being shown. Values are the various color constants defined in the class.

    The appearance constants form a bit mask, so they can be used with hardware that can display e.g. more than one lit color at a time. Individual implementations may not be able to handle that, however; most of the early ones probably won't. If a particular implementation can't display a commanded color, it doesn't try to replace it, but rather just leaves that color off the resulting display.

    Lit
    Whether the head's lamps are lit or left dark.

    This differs from the DARK color defined for the appearance parameter, in that it's independent of that. Lit is intended to allow you to extinguish a signal head for approach lighting, while still allowing it's color to be set to a definite value for e.g. display on a panel or evaluation in higher level logic.

    Held
    Whether the head's lamps should be forced to a specific appearance, e.g. RED in higher-level logic.

    For use in signaling systems, this is a convenient way of storing whether a higher-level of control (e.g. non-vital system or dispatcher) has "held" the signal at stop. It does not effect how this signal head actually works; any appearance can be set and will be displayed even when "held" is set.


    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

      • getAppearance

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

        void setAppearance​(int newAppearance)
        Set the Signal Head Appearance.
        Parameters:
        newAppearance - integer representing a valid Appearance for this head
      • getAppearanceKey

        @Nonnull
        java.lang.String getAppearanceKey()
        Get the current Signal Head Appearance Key.
        Returns:
        Key, or empty String if no valid appearance set.
      • getAppearanceKey

        @Nonnull
        java.lang.String getAppearanceKey​(int appearance)
        Get the Appearance Key for a particular Appearance.
        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))
      • getAppearanceName

        @Nonnull
        java.lang.String getAppearanceName()
        Get the current appearance name.
        Returns:
        Name of the Appearance, e.g. "Dark" or "Flashing Red"
      • getAppearanceName

        @Nonnull
        java.lang.String getAppearanceName​(int appearance)
        Get the Appearance Name for a particular Appearance.
        Parameters:
        appearance - id for the Name.
        Returns:
        the Appearance Name, or empty String if unknown.
      • getLit

        boolean getLit()
        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
        Returns:
        true if lit; false if dark
      • getHeld

        boolean getHeld()
        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
        Returns:
        true if held; false otherwise
      • getValidStates

        int[] getValidStates()
        Get an array of appearance indexes valid for the mast type.
        Returns:
        array of appearance state values available on this mast type
      • getValidStateKeys

        java.lang.String[] getValidStateKeys()
        Get an array of non-localized appearance keys valid for the mast type. For GUI application consider using (capitalized) getValidStateNames()
        Returns:
        array of translated appearance names available on this mast type
      • getValidStateNames

        java.lang.String[] getValidStateNames()
        Get an array of localized appearance descriptions valid for the mast type. For persistance and comparison consider using getValidStateKeys()
        Returns:
        array of translated appearance names