Class SE8cSignalHead
- All Implemented Interfaces:
VetoableChangeListener
,Comparable<NamedBean>
,EventListener
,PropertyChangeProvider
,NamedBean
,Signal
,SignalHead
public class SE8cSignalHead extends DefaultSignalHead
This implementation writes out to the physical signal when it's commanded to change appearance, and updates its internal state when it hears commands from other places.
To get a complete set of aspects, we assume that the SE8C board has been configured such that the 4th aspect is "dark". We then do flashing aspects by commanding the lit appearance to change.
We can't assume any form of numbering for Turnouts to address the digits, so we take two turnout names as arguments. As a convenience, we manage the user names if they're not already set.
Only the DARK, RED, GREEN and YELLOW appearances will be properly tracked when they occur on the LocoNet. The FLASHING aspects won't be, nor will the Held or Lit states.
The algorithms in this class are a collaborative effort of Digitrax, Inc and Bob Jacobsen.
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.NamedBean
NamedBean.BadNameException, NamedBean.BadSystemNameException, NamedBean.BadUserNameException, NamedBean.DisplayOptions, NamedBean.DuplicateSystemNameException
-
Field Summary
Fields Modifier and Type Field Description (package private) NamedBeanHandle<Turnout>
highTurnout
(package private) NamedBeanHandle<Turnout>
lowTurnout
Fields inherited from class jmri.implementation.DefaultSignalHead
delay, masterDelay, mFlashOn, timer
Fields inherited from class jmri.implementation.AbstractNamedBean
listenerRefs, mSystemName, register
Fields inherited from interface jmri.NamedBean
DISPLAY_NAME_FORMAT, INCONSISTENT, PROPERTY_STATE, QUOTED_NAME_FORMAT, UNKNOWN
Fields inherited from interface jmri.SignalHead
DARK, FLASHGREEN, FLASHLUNAR, FLASHRED, FLASHYELLOW, GREEN, HELD, LUNAR, RED, YELLOW
-
Constructor Summary
Constructors Constructor Description SE8cSignalHead(int pNumber)
Compatibility ctorSE8cSignalHead(int pNumber, String userName)
Compatibility ctor.SE8cSignalHead(String sname, NamedBeanHandle<Turnout> lowTO, NamedBeanHandle<Turnout> highTO)
Ctor specifying system name.SE8cSignalHead(String sname, NamedBeanHandle<Turnout> lowTO, NamedBeanHandle<Turnout> highTO, String userName)
Ctor specifying system name and user name.SE8cSignalHead(NamedBeanHandle<Turnout> lowTO, NamedBeanHandle<Turnout> highTO)
Primary ctor without user name.SE8cSignalHead(NamedBeanHandle<Turnout> lowTO, NamedBeanHandle<Turnout> highTO, String userName)
Primary ctor. -
Method Summary
Modifier and Type Method Description void
dispose()
Deactivate this object, so that it releases as many resources as possible and no longer effects others.NamedBeanHandle<Turnout>
getHigh()
NamedBeanHandle<Turnout>
getLow()
(package private) void
init()
(package private) boolean
isTurnoutUsed(Turnout t)
Check if a given turnout is used on this head.(package private) static NamedBeanHandle<Turnout>
makeHandle(int i)
Create a handle from a raw number.(package private) static String
makeSystemName(NamedBeanHandle<Turnout> lowTO, NamedBeanHandle<Turnout> highTO)
Implement convention for making a system name.protected void
updateOutput()
Type-specific routine to handle output to the layout hardware.Methods inherited from class jmri.implementation.DefaultSignalHead
appearanceSetsFlashTimer, getValidStateKeys, getValidStateNames, getValidStates, setAppearance, setHeld, setLit, startFlash, stopFlash
Methods inherited from class jmri.implementation.AbstractSignalHead
getAppearance, getAppearanceKey, getAppearanceKey, getAppearanceName, getAppearanceName, getBeanType, getDefaultStateName, getDefaultValidStateNames, getDefaultValidStates, getHeld, getLit, getState, isAtStop, isCleared, isShowingRestricting, setState, vetoableChange
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, equals, firePropertyChange, getComment, getDisplayName, getDisplayName, getFullyFormattedDisplayName, getFullyFormattedDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUserName, hashCode, removeProperty, removePropertyChangeListener, removePropertyChangeListener, setComment, setProperty, setUserName, toString, toStringSuffix, updateListenerRef
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface jmri.NamedBean
addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, compareTo, describeState, getComment, getDisplayName, getDisplayName, getFullyFormattedDisplayName, getFullyFormattedDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getSystemName, getUsageReport, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
Constructor Details
-
SE8cSignalHead
public SE8cSignalHead(NamedBeanHandle<Turnout> lowTO, NamedBeanHandle<Turnout> highTO, String userName)Primary ctor.- Parameters:
lowTO
- lower-numbered Turnout referencehighTO
- higher-numbered Turnout referenceuserName
- user name for mast
-
SE8cSignalHead
Primary ctor without user name.- Parameters:
lowTO
- lower-numbered Turnout referencehighTO
- higher-numbered Turnout reference
-
SE8cSignalHead
public SE8cSignalHead(String sname, NamedBeanHandle<Turnout> lowTO, NamedBeanHandle<Turnout> highTO, String userName)Ctor specifying system name and user name.- Parameters:
sname
- system name for mastlowTO
- lower-numbered Turnout referencehighTO
- higher-numbered Turnout referenceuserName
- user name for mast
-
SE8cSignalHead
public SE8cSignalHead(String sname, NamedBeanHandle<Turnout> lowTO, NamedBeanHandle<Turnout> highTO)Ctor specifying system name.- Parameters:
sname
- system name for mastlowTO
- lower-numbered Turnout referencehighTO
- higher-numbered Turnout reference
-
SE8cSignalHead
Compatibility ctor.- Parameters:
pNumber
- number (address) of low turnoutuserName
- name to use for this signal head
-
SE8cSignalHead
Compatibility ctor- Parameters:
pNumber
- number (address) of low turnout
-
-
Method Details
-
makeSystemName
Implement convention for making a system name.Must pass arguments, as it is used before object is complete.
- Parameters:
lowTO
- lower-numbered Turnout referencehighTO
- higher-numbered Turnout reference- Returns:
- system name with fixed elements, i.e. IH:SE8c:to1\to2
-
makeHandle
Create a handle from a raw number.Static, so can be referenced before ctor complete.
- Parameters:
i
- index number (address) of a turnout on the signal head- Returns:
- NamedBeanHandle<Turnout> object to use as output for head
- Throws:
IllegalArgumentException
- when creation from i fails
-
init
void init() -
updateOutput
Type-specific routine to handle output to the layout hardware. Implemented to handle a request to change state by sending a LocoNet command.Does not notify listeners of changes; that's done elsewhere. Should consider the following variables to determine what to send:
- mAppearance
- mLit
- mFlashOn
- Specified by:
updateOutput
in classDefaultSignalHead
-
getLow
-
getHigh
-
dispose
Description copied from interface:NamedBean
Deactivate this object, so that it releases as many resources as possible and no longer effects others.For example, if this object has listeners, after a call to this method it should no longer notify those listeners. Any native or system-wide resources it maintains should be released, including threads, files, etc.
It is an error to invoke any other methods on this object once dispose() has been called. Note, however, that there is no guarantee about behavior in that case.
Afterwards, references to this object may still exist elsewhere, preventing its garbage collection. But it's formally dead, and shouldn't be keeping any other objects alive. Therefore, this method should null out any references to other objects that this NamedBean contained.
- Specified by:
dispose
in interfaceNamedBean
- Overrides:
dispose
in classAbstractNamedBean
-
isTurnoutUsed
Description copied from class:AbstractSignalHead
Check if a given turnout is used on this head.- Overrides:
isTurnoutUsed
in classDefaultSignalHead
- Parameters:
t
- Turnout object to check- Returns:
- true if turnout is configured as output or driver of head
-