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:
org.openlcb.Connection
- Enclosing class:
- OlcbSignalMast
static class OlcbSignalMast.StateMachine<T> extends org.openlcb.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.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) org.openlcb.Connection
connection
protected java.util.HashMap<org.openlcb.EventID,T>
eventToState
(package private) boolean
initizalized
(package private) org.openlcb.NodeID
node
(package private) T
state
protected java.util.HashMap<T,org.openlcb.EventID>
stateToEventID
protected java.util.HashMap<T,java.lang.String>
stateToEventString
-
Constructor Summary
Constructors Constructor Description StateMachine(org.openlcb.Connection connection, org.openlcb.NodeID node, T start)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.openlcb.EventID
getEventIDForState(T key)
(package private) org.openlcb.EventState
getEventIDState(org.openlcb.EventID event)
Internal method to determine the EventState for a reply to an Identify* methodjava.lang.String
getEventStringForState(T key)
T
getState()
void
handleConsumerIdentified(org.openlcb.ConsumerIdentifiedMessage msg, org.openlcb.Connection sender)
void
handleIdentifyConsumers(org.openlcb.IdentifyConsumersMessage msg, org.openlcb.Connection sender)
void
handleIdentifyEventsAddressed(org.openlcb.IdentifyEventsAddressedMessage msg, org.openlcb.Connection sender)
void
handleIdentifyEventsGlobal(org.openlcb.IdentifyEventsGlobalMessage msg, org.openlcb.Connection sender)
void
handleIdentifyProducers(org.openlcb.IdentifyProducersMessage msg, org.openlcb.Connection sender)
void
handleProducerConsumerEventReport(org.openlcb.ProducerConsumerEventReportMessage msg, org.openlcb.Connection sender)
void
handleProducerIdentified(org.openlcb.ProducerIdentifiedMessage msg, org.openlcb.Connection sender)
void
sendAllIdentifiedMessages()
Used at start up to emit the required messages, and in response to a IdentifyEvents messagevoid
setEventForState(T key, java.lang.String value)
void
setState(T newState)
-
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
-
-
-
-
Field Detail
-
connection
final org.openlcb.Connection connection
-
node
final org.openlcb.NodeID node
-
initizalized
boolean initizalized
-
stateToEventString
protected final java.util.HashMap<T,java.lang.String> stateToEventString
-
stateToEventID
protected final java.util.HashMap<T,org.openlcb.EventID> stateToEventID
-
eventToState
protected final java.util.HashMap<org.openlcb.EventID,T> eventToState
-
-
Constructor Detail
-
StateMachine
public StateMachine(@Nonnull org.openlcb.Connection connection, @Nonnull org.openlcb.NodeID node, @Nonnull T start)
-
-
Method Detail
-
setEventForState
public void setEventForState(@Nonnull T key, @Nonnull java.lang.String value)
-
getEventIDForState
@CheckForNull public org.openlcb.EventID getEventIDForState(@Nonnull T key)
-
getEventStringForState
@CheckForNull public java.lang.String getEventStringForState(@Nonnull T key)
-
getEventIDState
org.openlcb.EventState getEventIDState(org.openlcb.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 org.openlcb.ProducerConsumerEventReportMessage msg, org.openlcb.Connection sender)
- Overrides:
handleProducerConsumerEventReport
in classorg.openlcb.MessageDecoder
-
handleProducerIdentified
public void handleProducerIdentified(@Nonnull org.openlcb.ProducerIdentifiedMessage msg, org.openlcb.Connection sender)
- Overrides:
handleProducerIdentified
in classorg.openlcb.MessageDecoder
-
handleConsumerIdentified
public void handleConsumerIdentified(@Nonnull org.openlcb.ConsumerIdentifiedMessage msg, org.openlcb.Connection sender)
- Overrides:
handleConsumerIdentified
in classorg.openlcb.MessageDecoder
-
handleIdentifyEventsAddressed
public void handleIdentifyEventsAddressed(@Nonnull org.openlcb.IdentifyEventsAddressedMessage msg, org.openlcb.Connection sender)
- Overrides:
handleIdentifyEventsAddressed
in classorg.openlcb.MessageDecoder
-
handleIdentifyEventsGlobal
public void handleIdentifyEventsGlobal(@Nonnull org.openlcb.IdentifyEventsGlobalMessage msg, org.openlcb.Connection sender)
- Overrides:
handleIdentifyEventsGlobal
in classorg.openlcb.MessageDecoder
-
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 org.openlcb.IdentifyProducersMessage msg, org.openlcb.Connection sender)
- Overrides:
handleIdentifyProducers
in classorg.openlcb.MessageDecoder
-
handleIdentifyConsumers
public void handleIdentifyConsumers(@Nonnull org.openlcb.IdentifyConsumersMessage msg, org.openlcb.Connection sender)
- Overrides:
handleIdentifyConsumers
in classorg.openlcb.MessageDecoder
-
-