Class SerialDCCppPacketizer

All Implemented Interfaces:
DCCppInterface
Direct Known Subclasses:
DCCppEthernetPacketizer

This is an extension of the DCCppPacketizer to handle the device specific requirements of the DCC++.

In particular, SerialDCCppPacketizer adds functions to add and remove the "<" and ">" bytes that appear around any message read in. Note that the bracket-adding could be pushed up to DCCppPacketizer, as it is a protocol thing, not an interface implementation thing. We'll come back to that later. What is however interface specific is the background refresh of functions. DCC++ sends the DCC commands exactly once. A background thread will repeat the last seen function commands to compensate for any momentary power loss or to recover from power off / power on events. It only makes sense to do this on the actual serial interface as it will be transparent for the network clients.

  • Field Details

  • Constructor Details

  • Method Details

    • lengthOfByteStream

      Determine how many bytes the entire message will take, including space for header and trailer
      Overrides:
      lengthOfByteStream in class DCCppTrafficController
      Parameters:
      m - The message to be sent
      Returns:
      Number of bytes
    • sendDCCppMessage

      public void sendDCCppMessage(DCCppMessage m, DCCppListener reply)
      Description copied from class: DCCppPacketizer
      Forward a preformatted DCCppMessage to the actual interface. The message is converted to a byte array and queue for transmission
      Specified by:
      sendDCCppMessage in interface DCCppInterface
      Overrides:
      sendDCCppMessage in class DCCppPacketizer
      Parameters:
      m - Message to send
      reply - Listener to notify when the reply to the message is received
    • clearRefreshQueue

      public void clearRefreshQueue()
      Clear the background refresh queue. The state is still kept in JMRI.
    • getQueueLength

      public int getQueueLength()
      Check how many entries are in the background refresh queue
      Returns:
      number of queued function groups
    • setActiveRefresh

      public boolean setActiveRefresh(boolean activeState)
      Enable or disable the background refresh thread
      Parameters:
      activeState - true to keep refreshing the functions, false to disable this functionality.
      Returns:
      the previous active state of the background refresh thread
    • isActiveRefresh

      public boolean isActiveRefresh()
      Check if the background function refresh thread is active or not
      Returns:
      the background refresh status, true for active, false if disabled.