Package jmri.jmrix

Class AbstractMRTrafficController

Direct Known Subclasses:
AbstractCanTrafficController, AbstractMRNodeTrafficController, Dcc4PcTrafficController, DCCppTrafficController, EasyDccTrafficController, EcosTrafficController, JMRIClientTrafficController, MarklinTrafficController, NceTrafficController, RfidTrafficController, SerialTrafficController, SerialTrafficController, SRCPTrafficController, TamsTrafficController, XNetTrafficController, Z21TrafficController

public abstract class AbstractMRTrafficController
extends Object
Abstract base for TrafficControllers in a Message/Reply protocol.

Two threads are used for the actual communication. The "Transmit" thread handles pushing characters to the port, and also changing the mode. The "Receive" thread converts characters from the input stream into replies.

The constructor registers a shutdown task to trigger the necessary cleanup code

The internal state machine handles changes of mode, automatic retry of certain messages, time outs, and sending poll messages when otherwise idle.

"Mode" refers to the state of the command station communications. "Normal" and "Programming" are the two modes, used if the command station requires messages to go back and forth between them.
UML State diagram

The key methods for the basic operation are:

If your command station requires messages to go in and out of "programming mode", those should be provided by enterProgMode() and enterNormalMode().

If you want to poll for information when the line is otherwise idle, implement pollMessage() and pollReplyHandler().