Class MrcPacketizer

  • All Implemented Interfaces:
    MrcInterface

    public class MrcPacketizer
    extends MrcTrafficController
    Converts Stream-based I/O to/from Mrc messages. The "MrcInterface" side sends/receives MrcMessage objects. The connection to a MrcPortController is via a pair of *Streams, which then carry sequences of characters for transmission.

    This is based upon the Packetizer used for LocoNet Connections due to its speed and efficiency to handle messages. This also takes some code from the AbstractMRTrafficController, when dealing with handling replies to messages sent. The MRC Command Station sends out a poll message to each handset which then has approximately 20ms to initially respond with a request. Otherwise the Command Station will poll the next handset.

    Messages come to this via the main GUI thread, and are forwarded back to listeners in that same thread. Reception and transmission are handled in dedicated threads by RcvHandler and XmtHandler objects. Those are internal classes defined here. The thread priorities are:

    • RcvHandler - at highest available priority
    • XmtHandler - down one, which is assumed to be above the GUI
    • (everything else)

    Some of the message formats used in this class are Copyright MRC, Inc. and used with permission as part of the JMRI project. That permission does not extend to uses in other software products. If you wish to use this code, algorithm or these message formats outside of JMRI, please contact Mrc Inc for separate permission.