Class SerialDCCppPacketizer

  • All Implemented Interfaces:
    DCCppInterface
    Direct Known Subclasses:
    DCCppEthernetPacketizer

    public class SerialDCCppPacketizer
    extends DCCppPacketizer
    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.

    • Method Detail

      • 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.