Package jmri.jmrix.openlcb
Class OlcbSignalMast
- java.lang.Object
-
- jmri.implementation.AbstractNamedBean
-
- jmri.implementation.AbstractSignalMast
-
- jmri.jmrix.openlcb.OlcbSignalMast
-
- All Implemented Interfaces:
java.beans.VetoableChangeListener
,java.lang.Comparable<NamedBean>
,java.util.EventListener
,PropertyChangeProvider
,NamedBean
,Signal
,SignalMast
public class OlcbSignalMast extends AbstractSignalMast
This class implements a SignalMast that use OpenLCB Events to set aspects.This implementation writes out to the OpenLCB when it's commanded to change appearance, and updates its internal state when it hears Events from the network (including its own events).
System name specifies the creation information:
IF$dsm:basic:one-searchlight(123)
The name is a colon-separated series of terms:- I - system prefix
- F$olm - defines signal masts of this type
- basic - name of the signaling system
- one-searchlight - name of the particular aspect map
- ($123) - number distinguishing this from others
EventIDs are returned in format in which they were provided.
To keep OpenLCB distributed state consistent,
setAspect(java.lang.String)
does not immediately change the local aspect. Instead, it produces the relevant EventId on the network, waiting for that to return and do the local state change, notification, etc.Needs to have held/unheld, lit/unlit state completed - those need to Produce and Consume events as above Based upon
DccSignalMast
by Kevin Dickerson
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
OlcbSignalMast.StateMachine<T>
Implement a general state machine where state transitions are associated with the production and consumption of specific events.-
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) OlcbSignalMast.StateMachine<java.lang.String>
aspectMachine
(package private) Connection
connection
(package private) OlcbSignalMast.StateMachine<java.lang.Boolean>
heldMachine
protected static int
lastRef
(package private) OlcbSignalMast.StateMachine<java.lang.Boolean>
litMachine
(package private) int
mastNumber
protected java.lang.String
mastType
(package private) NodeID
node
(package private) CanSystemConnectionMemo
systemMemo
(package private) java.lang.String
systemPrefix
-
Fields inherited from class jmri.implementation.AbstractSignalMast
aspect, disabledAspects, map, speed
-
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
-
-
Constructor Summary
Constructors Constructor Description OlcbSignalMast(java.lang.String sys)
OlcbSignalMast(java.lang.String sys, java.lang.String user)
OlcbSignalMast(java.lang.String sys, java.lang.String user, java.lang.String mastSubType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
configureFromName(java.lang.String systemName)
boolean
getHeld()
"Held" property is just tracked and notified.java.lang.String
getHeldEventId()
static int
getLastRef()
Provide the last used sequence number of all OlcbSignalMasts in use.boolean
getLit()
Default behavior for "lit" property is to track value and return it.java.lang.String
getLitEventId()
java.lang.String
getNotHeldEventId()
java.lang.String
getNotLitEventId()
java.lang.String
getOutputForAppearance(java.lang.String appearance)
java.lang.String
getSystemPrefix()
void
handleMessage(Message msg)
Handle incoming messages.boolean
isOutputConfigured(java.lang.String appearance)
void
setAspect(java.lang.String aspect)
Set aspect to a valid name in the current signal system definition.void
setHeld(boolean newHeld)
Always communicates via OpenLCBvoid
setHeldEventId(java.lang.String event)
protected static void
setLastRef(int newVal)
void
setLit(boolean newLit)
Always communicates via OpenLCBvoid
setLitEventId(java.lang.String event)
void
setNotHeldEventId(java.lang.String event)
void
setNotLitEventId(java.lang.String event)
void
setOutputForAppearance(java.lang.String appearance, java.lang.String event)
-
Methods inherited from class jmri.implementation.AbstractSignalMast
allowUnLit, configureAspectTable, configureSignalSystemDefinition, getAllKnownAspects, getAppearanceMap, getAspect, getBeanType, getDisabledAspects, getMastType, getSignalSystem, getSpeed, getState, getUsageReport, getValidAspects, isAspectDisabled, isAtStop, isCleared, isPermissiveSmlDisabled, isShowingRestricting, setAllowUnLit, setAspectDisabled, setAspectEnabled, setMastType, setPermissiveSmlDisabled, setState, vetoableChange
-
Methods inherited from class jmri.implementation.AbstractNamedBean
addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListener, compareSystemNameSuffix, describeState, 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, 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, dispose, getComment, getDisplayName, getDisplayName, getListenerRef, getListenerRefs, getNumPropertyChangeListeners, getProperty, getPropertyChangeListenersByReference, getPropertyKeys, getRecommendedToolTip, getSystemName, getUserName, removeProperty, setComment, setProperty, setUserName, toString, updateListenerRef
-
Methods inherited from interface jmri.beans.PropertyChangeProvider
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
-
-
-
Field Detail
-
mastType
protected java.lang.String mastType
-
litMachine
OlcbSignalMast.StateMachine<java.lang.Boolean> litMachine
-
heldMachine
OlcbSignalMast.StateMachine<java.lang.Boolean> heldMachine
-
aspectMachine
OlcbSignalMast.StateMachine<java.lang.String> aspectMachine
-
connection
Connection connection
-
systemPrefix
java.lang.String systemPrefix
-
systemMemo
CanSystemConnectionMemo systemMemo
-
mastNumber
int mastNumber
-
lastRef
protected static volatile int lastRef
-
-
Constructor Detail
-
OlcbSignalMast
public OlcbSignalMast(java.lang.String sys, java.lang.String user)
-
OlcbSignalMast
public OlcbSignalMast(java.lang.String sys)
-
OlcbSignalMast
public OlcbSignalMast(java.lang.String sys, java.lang.String user, java.lang.String mastSubType)
-
-
Method Detail
-
getSystemPrefix
public java.lang.String getSystemPrefix()
-
configureFromName
protected void configureFromName(java.lang.String systemName)
-
setOutputForAppearance
public void setOutputForAppearance(java.lang.String appearance, java.lang.String event)
-
isOutputConfigured
public boolean isOutputConfigured(java.lang.String appearance)
-
getOutputForAppearance
public java.lang.String getOutputForAppearance(java.lang.String appearance)
-
setAspect
public void setAspect(@Nonnull java.lang.String aspect)
Description copied from interface:SignalMast
Set aspect to a valid name in the current signal system definition.- Specified by:
setAspect
in interfaceSignalMast
- Overrides:
setAspect
in classAbstractSignalMast
- Parameters:
aspect
- the new aspect shown
-
handleMessage
public void handleMessage(Message msg)
Handle incoming messages.- Parameters:
msg
- the message to handle.
-
setLit
public void setLit(boolean newLit)
Always communicates via OpenLCB- Specified by:
setLit
in interfaceSignal
- Specified by:
setLit
in interfaceSignalMast
- Overrides:
setLit
in classAbstractSignalMast
- Parameters:
newLit
- the new value of lit
-
getLit
public boolean getLit()
Description copied from class:AbstractSignalMast
Default behavior for "lit" property is to track value and return it.- Specified by:
getLit
in interfaceSignal
- Specified by:
getLit
in interfaceSignalMast
- Overrides:
getLit
in classAbstractSignalMast
- Returns:
- true if lit; false if dark
-
setHeld
public void setHeld(boolean newHeld)
Always communicates via OpenLCB- Specified by:
setHeld
in interfaceSignal
- Specified by:
setHeld
in interfaceSignalMast
- Overrides:
setHeld
in classAbstractSignalMast
- Parameters:
newHeld
- the new value of the help property
-
getHeld
public boolean getHeld()
Description copied from class:AbstractSignalMast
"Held" property is just tracked and notified.- Specified by:
getHeld
in interfaceSignal
- Specified by:
getHeld
in interfaceSignalMast
- Overrides:
getHeld
in classAbstractSignalMast
- Returns:
- true if held; false otherwise
-
setLastRef
protected static void setLastRef(int newVal)
- Parameters:
newVal
- for ordinal of all OlcbSignalMasts in use
-
getLastRef
public static int getLastRef()
Provide the last used sequence number of all OlcbSignalMasts in use.- Returns:
- last used OlcbSignalMasts sequence number
-
setLitEventId
public void setLitEventId(java.lang.String event)
-
getLitEventId
public java.lang.String getLitEventId()
-
setNotLitEventId
public void setNotLitEventId(java.lang.String event)
-
getNotLitEventId
public java.lang.String getNotLitEventId()
-
setHeldEventId
public void setHeldEventId(java.lang.String event)
-
getHeldEventId
public java.lang.String getHeldEventId()
-
setNotHeldEventId
public void setNotHeldEventId(java.lang.String event)
-
getNotHeldEventId
public java.lang.String getNotHeldEventId()
-
-