Class LnTrafficController

    • Method Detail

      • status

        public abstract boolean status()
        Check whether an implementation is operational. Returns true if operational.
        Specified by:
        status in interface LocoNetInterface
        true if implementation is operational.
      • sendLocoNetMessage

        public abstract void sendLocoNetMessage​(LocoNetMessage m)
        Forward a preformatted LocoNetMessage to the actual interface.

        Implementations should update the transmit count statistic.

        Specified by:
        sendLocoNetMessage in interface LocoNetInterface
        m - message to send; will be updated with CRC
      • addLocoNetListener

        public void addLocoNetListener​(int mask,
                                       LocoNetListener l)
        Description copied from interface: LocoNetInterface
        Request notification of things happening on the LocoNet.

        The same listener can register multiple times with different masks. (Multiple registrations with a single mask value are equivalent to a single registration) Mask values are defined as class constants. Note that these are bit masks, and should be OR'd, not added, if multiple values are desired.

        The event notification contains the received message as source, not this object, so that we can notify of an incoming message to multiple places and then move on.

        Specified by:
        addLocoNetListener in interface LocoNetInterface
        mask - The OR of the key values of messages to be reported (to reduce traffic, provide for listeners interested in different things)
        l - Object to be notified of new messages as they arrive.
      • notify

        public void notify​(LocoNetMessage m)
        Forward a LocoNetMessage to all registered listeners.

        Needs to have public access, as LnOverTcpPacketizer and IBLnPacketizer invoke it, but don't inherit from it.

        m - message to forward. Listeners should not modify it!
      • isXmtBusy

        public abstract boolean isXmtBusy()
        Is there a backlog of information for the outbound link? This includes both in the program (e.g. the outbound queue) and in the Command Station interface (e.g. flow control from the port).
        true if busy, false if nothing waiting to send
      • resetStatistics

        public void resetStatistics()
        Reset statistics (received message count, transmitted message count, received byte count).
      • dispose

        public void dispose()
        Clean up any resources, particularly threads.

        The object can't be used after this.

      • getReceivedMsgCount

        public int getReceivedMsgCount()
        Monitor the number of LocoNet messages received across the interface. This includes the messages this client has sent.
        the number of messages received
      • getReceivedByteCount

        public int getReceivedByteCount()
        Monitor the number of bytes in LocoNet messages received across the interface. This includes the bytes in messages this client has sent.
        the number of bytes received
      • getTransmittedMsgCount

        public int getTransmittedMsgCount()
        Monitor the number of LocoNet messages transmitted across the interface.
        the number of messages transmitted