Package jmri.implementation
Class AbstractSignalHead
java.lang.Object
jmri.implementation.AbstractNamedBean
jmri.implementation.AbstractSignalHead
- All Implemented Interfaces:
VetoableChangeListener,Comparable<NamedBean>,EventListener,PropertyChangeProvider,NamedBean,Signal,SignalHead
- Direct Known Subclasses:
DccSignalHead,DefaultSignalHead
public abstract class AbstractSignalHead
extends AbstractNamedBean
implements SignalHead, VetoableChangeListener
Abstract class providing the basic logic of the SignalHead interface.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected booleanBy default, signals are not held.protected booleanBy default, signals are lit.Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, registerFields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_COMMENT, PROPERTY_ENABLED, PROPERTY_KNOWN_STATE, PROPERTY_STATE, PROPERTY_USERNAME, QUOTED_NAME_FORMAT, UNKNOWNFields inherited from interface jmri.Signal
PROPERTY_HELD, PROPERTY_LITFields inherited from interface jmri.SignalHead
DARK, FLASHGREEN, FLASHLUNAR, FLASHRED, FLASHYELLOW, GREEN, HELD, LUNAR, PROPERTY_APPEARANCE, RED, YELLOW -
Constructor Summary
ConstructorsConstructorDescriptionAbstractSignalHead(String systemName) AbstractSignalHead(String systemName, String userName) -
Method Summary
Modifier and TypeMethodDescriptiondescribeState(int state) Describe SignalHead state.intGet the Signal Head Appearance.Get the current Signal Head Appearance Key.getAppearanceKey(int appearance) Get the Appearance Key for a particular Appearance.Get the current appearance name.getAppearanceName(int appearance) Get the Appearance Name for a particular Appearance.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.static StringgetDefaultStateName(int appearance) Get a localized text describing appearance from the corresponding state index.static String[]static int[]booleangetHeld()"Held" parameter is just tracked and notified.booleangetLit()Default behavior for "lit" parameter is to track value and return it.intgetState()Implement a shorter name for getAppearance.String[]Get an array of non-localized appearance keys valid for the mast type.String[]Get an array of localized appearance descriptions valid for the mast type.int[]Get an array of appearance indexes valid for the mast type.booleanisAtStop()Determine whether this signal shows an aspect or appearance that forbid travel past it.booleanDetermine whether this signal shows an aspect or appearance that allows travel past it, e.g. it's "been cleared".booleanDetermine whether this signal shows an aspect or appearance that allows travel past it only at restricted speed.abstract booleanCheck if a given turnout is used on this head.voidsetState(int s) Implement a shorter name for setAppearance.voidMethods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, dispose, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRefMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, dispose, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRefMethods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerMethods inherited from interface jmri.SignalHead
setAppearance, setHeld, setLit
-
Field Details
-
mAppearance
-
mLit
By default, signals are lit. -
mHeld
By default, signals are not held.
-
-
Constructor Details
-
AbstractSignalHead
-
AbstractSignalHead
-
-
Method Details
-
getAppearanceName
Get the Appearance Name for a particular Appearance.- Specified by:
getAppearanceNamein interfaceSignalHead- Parameters:
appearance- id for the Name.- Returns:
- the Appearance Name, or empty String if unknown.
-
getAppearanceName
Get the current appearance name.- Specified by:
getAppearanceNamein interfaceSignalHead- Returns:
- Name of the Appearance, e.g. "Dark" or "Flashing Red"
-
getAppearanceKey
Get the Appearance Key for a particular Appearance.- Specified by:
getAppearanceKeyin interfaceSignalHead- 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))
-
getAppearanceKey
Get the current Signal Head Appearance Key.- Specified by:
getAppearanceKeyin interfaceSignalHead- Returns:
- Key, or empty String if no valid appearance set.
-
getAppearance
Get the Signal Head Appearance. Changes in this value can be listened to using the Appearance property.- Specified by:
getAppearancein interfaceSignalHead- Returns:
- the appearance, e.g. SignalHead.YELLOW
-
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 -
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:
isShowingRestrictingin interfaceSignal- Returns:
- true if the signal is showing a restricting indication; false otherwise
-
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. -
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:
getLitin interfaceSignal- Specified by:
getLitin interfaceSignalHead- Returns:
- is lit
-
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:
getHeldin interfaceSignal- Specified by:
getHeldin interfaceSignalHead- Returns:
- is held
-
setState
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.
-
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.
-
getDefaultValidStates
-
getDefaultValidStateNames
-
getDefaultStateName
Get a localized text describing appearance from the corresponding state index.- Parameters:
appearance- the index of the appearance- Returns:
- translated name for appearance
-
getValidStates
Get an array of appearance indexes valid for the mast type.- Specified by:
getValidStatesin interfaceSignalHead- Returns:
- array of appearance state values available on this mast type
-
getValidStateKeys
Get an array of non-localized appearance keys valid for the mast type. For GUI application consider using (capitalized)SignalHead.getValidStateNames()- Specified by:
getValidStateKeysin interfaceSignalHead- Returns:
- array of translated appearance names available on this mast type
-
getValidStateNames
Get an array of localized appearance descriptions valid for the mast type. For persistance and comparison consider usingSignalHead.getValidStateKeys()- Specified by:
getValidStateNamesin interfaceSignalHead- Returns:
- array of translated appearance names
-
describeState
Describe SignalHead state. Does not have to be a valid state for this SignalHead instance hence suitable for state error logging. Can include multiple head states, with exception of DARK, the only state which must exist on its own. Includes the HELD state if present.- Specified by:
describeStatein interfaceNamedBean- Overrides:
describeStatein classAbstractNamedBean- Parameters:
state- the state to describe.- Returns:
- description of state from Bundle.
- See Also:
-
isTurnoutUsed
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
- Specified by:
vetoableChangein interfaceNamedBean- Specified by:
vetoableChangein interfaceVetoableChangeListener- Overrides:
vetoableChangein classAbstractNamedBean- Throws:
PropertyVetoException
-
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:
getBeanTypein interfaceNamedBean- Returns:
- a string of the bean type, eg Turnout, Sensor etc
-