Class 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.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.openlcb.Connection

        org.openlcb.Connection.ConnectionListener
    • 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* method
      java.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 message
      void 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
      • Methods inherited from class org.openlcb.AbstractConnection

        registerStartNotification
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • 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 class org.openlcb.MessageDecoder
      • handleProducerIdentified

        public void handleProducerIdentified​(@Nonnull
                                             org.openlcb.ProducerIdentifiedMessage msg,
                                             org.openlcb.Connection sender)
        Overrides:
        handleProducerIdentified in class org.openlcb.MessageDecoder
      • handleConsumerIdentified

        public void handleConsumerIdentified​(@Nonnull
                                             org.openlcb.ConsumerIdentifiedMessage msg,
                                             org.openlcb.Connection sender)
        Overrides:
        handleConsumerIdentified in class org.openlcb.MessageDecoder
      • handleIdentifyEventsAddressed

        public void handleIdentifyEventsAddressed​(@Nonnull
                                                  org.openlcb.IdentifyEventsAddressedMessage msg,
                                                  org.openlcb.Connection sender)
        Overrides:
        handleIdentifyEventsAddressed in class org.openlcb.MessageDecoder
      • handleIdentifyEventsGlobal

        public void handleIdentifyEventsGlobal​(@Nonnull
                                               org.openlcb.IdentifyEventsGlobalMessage msg,
                                               org.openlcb.Connection sender)
        Overrides:
        handleIdentifyEventsGlobal in class org.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 class org.openlcb.MessageDecoder
      • handleIdentifyConsumers

        public void handleIdentifyConsumers​(@Nonnull
                                            org.openlcb.IdentifyConsumersMessage msg,
                                            org.openlcb.Connection sender)
        Overrides:
        handleIdentifyConsumers in class org.openlcb.MessageDecoder