Package jmri.jmrix.openlcb
Class OlcbSignalMast.StateMachine<T>
- java.lang.Object
-
- org.openlcb.AbstractConnection
-
- org.openlcb.MessageDecoder
-
- jmri.jmrix.openlcb.OlcbSignalMast.StateMachine<T>
-
- All Implemented Interfaces:
Connection
- Enclosing class:
- OlcbSignalMast
static class OlcbSignalMast.StateMachine<T> extends MessageDecoder
Implement a general state machine where state transitions are associated with the production and consumption of specific events. There's a one-to-one mapping between transitions and events. EventID storage is via Strings, so that the user-visible eventID string is preserved.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openlcb.Connection
Connection.ConnectionListener
-
-
Field Summary
Fields Modifier and Type Field Description (package private) Connection
connection
protected java.util.HashMap<EventID,T>
eventToState
(package private) boolean
initizalized
(package private) NodeID
node
(package private) T
state
protected java.util.HashMap<T,EventID>
stateToEventID
protected java.util.HashMap<T,java.lang.String>
stateToEventString
-
Constructor Summary
Constructors Constructor Description StateMachine(Connection connection, NodeID node, T start)
-
Method Summary
-
Methods inherited from class org.openlcb.MessageDecoder
defaultHandler, handleConsumerRangeIdentified, handleDatagram, handleDatagramAcknowledged, handleDatagramRejected, handleInitializationComplete, handleLearnEvent, handleOptionalIntRejected, handleProducerRangeIdentified, handleProtocolIdentificationReply, handleProtocolIdentificationRequest, handleSimpleNodeIdentInfoReply, handleSimpleNodeIdentInfoRequest, handleStreamDataComplete, handleStreamDataProceed, handleStreamDataSend, handleStreamInitiateReply, handleStreamInitiateRequest, handleTractionControlReply, handleTractionControlRequest, handleTractionProxyReply, handleTractionProxyRequest, handleUnknownMTI, handleVerifiedNodeIDNumber, handleVerifyNodeIDNumberAddressed, handleVerifyNodeIDNumberGlobal, put
-
Methods inherited from class org.openlcb.AbstractConnection
registerStartNotification
-
-
-
-
Field Detail
-
connection
final Connection connection
-
initizalized
boolean initizalized
-
stateToEventString
protected final java.util.HashMap<T,java.lang.String> stateToEventString
-
stateToEventID
protected final java.util.HashMap<T,EventID> stateToEventID
-
eventToState
protected final java.util.HashMap<EventID,T> eventToState
-
-
Constructor Detail
-
StateMachine
public StateMachine(@Nonnull Connection connection, @Nonnull NodeID node, @Nonnull T start)
-
-
Method Detail
-
setEventForState
public void setEventForState(@Nonnull T key, @Nonnull java.lang.String value)
-
getEventIDForState
@CheckForNull public EventID getEventIDForState(@Nonnull T key)
-
getEventStringForState
@CheckForNull public java.lang.String getEventStringForState(@Nonnull T key)
-
getEventIDState
EventState getEventIDState(EventID event)
Internal method to determine the EventState for a reply to an Identify* method- Parameters:
event
- Method returns the underlying state for this EventID- Returns:
- State corresponding to the given EventID
-
handleProducerConsumerEventReport
public void handleProducerConsumerEventReport(@Nonnull ProducerConsumerEventReportMessage msg, Connection sender)
- Overrides:
handleProducerConsumerEventReport
in classMessageDecoder
-
handleProducerIdentified
public void handleProducerIdentified(@Nonnull ProducerIdentifiedMessage msg, Connection sender)
- Overrides:
handleProducerIdentified
in classMessageDecoder
-
handleConsumerIdentified
public void handleConsumerIdentified(@Nonnull ConsumerIdentifiedMessage msg, Connection sender)
- Overrides:
handleConsumerIdentified
in classMessageDecoder
-
handleIdentifyEventsAddressed
public void handleIdentifyEventsAddressed(@Nonnull IdentifyEventsAddressedMessage msg, Connection sender)
- Overrides:
handleIdentifyEventsAddressed
in classMessageDecoder
-
handleIdentifyEventsGlobal
public void handleIdentifyEventsGlobal(@Nonnull IdentifyEventsGlobalMessage msg, Connection sender)
- Overrides:
handleIdentifyEventsGlobal
in classMessageDecoder
-
sendAllIdentifiedMessages
public void sendAllIdentifiedMessages()
Used at start up to emit the required messages, and in response to a IdentifyEvents message
-
handleIdentifyProducers
public void handleIdentifyProducers(@Nonnull IdentifyProducersMessage msg, Connection sender)
- Overrides:
handleIdentifyProducers
in classMessageDecoder
-
handleIdentifyConsumers
public void handleIdentifyConsumers(@Nonnull IdentifyConsumersMessage msg, Connection sender)
- Overrides:
handleIdentifyConsumers
in classMessageDecoder
-
-