Package jmri.jmrix.loconet.uhlenbrock
Class UhlenbrockPacketizer
- java.lang.Object
-
- jmri.jmrix.loconet.LnTrafficController
-
- jmri.jmrix.loconet.LnPacketizer
-
- jmri.jmrix.loconet.uhlenbrock.UhlenbrockPacketizer
-
- All Implemented Interfaces:
LocoNetInterface
public class UhlenbrockPacketizer extends LnPacketizer
Converts Stream-based I/O to/from LocoNet messages. The "LocoNetInterface" side sends/receives LocoNetMessage objects. The connection to a LnPortController is via a pair of *Streams, which then carry sequences of characters for transmission.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)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
UhlenbrockPacketizer.RcvHandler
Captive class to handle incoming characters.(package private) class
UhlenbrockPacketizer.XmtHandler
Captive class to handle transmission
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
defaultWaitTimer
(package private) LocoNetMessage
lastMessage
protected int
mCurrentState
static int
NOTIFIEDSTATE
static int
WAITMSGREPLYSTATE
java.util.concurrent.ConcurrentLinkedQueue<LocoNetMessage>
xmtLocoNetList
Synchronized list used as a transmit queue.-
Fields inherited from class jmri.jmrix.loconet.LnPacketizer
controller, echo, istream, ostream, rcvHandler, rcvThread, threadStopRequest, xmtHandler, xmtList, xmtThread
-
Fields inherited from class jmri.jmrix.loconet.LnTrafficController
listeners, receivedByteCount, receivedMsgCount, transmittedMsgCount
-
Fields inherited from interface jmri.jmrix.loconet.LocoNetInterface
ALL, POWER, PROGRAMMING, SENSORS, SLOTINFO, TURNOUTS
-
-
Constructor Summary
Constructors Constructor Description UhlenbrockPacketizer(LocoNetSystemConnectionMemo m)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
sendLocoNetMessage(LocoNetMessage m)
Forward a preformatted LocoNetMessage to the actual interface.void
startThreads()
Invoked at startup to start the threads needed here.protected void
transmitWait(int waitTime, int state)
-
Methods inherited from class jmri.jmrix.loconet.LnPacketizer
connectPort, disconnectPort, dispose, isXmtBusy, messageTransmitted, readByteProtected, status, terminateThreads
-
Methods inherited from class jmri.jmrix.loconet.LnTrafficController
addLocoNetListener, getReceivedByteCount, getReceivedMsgCount, getSystemConnectionMemo, getTransmittedMsgCount, notify, removeLocoNetListener, resetStatistics, setSystemConnectionMemo
-
-
-
-
Field Detail
-
NOTIFIEDSTATE
public static final int NOTIFIEDSTATE
- See Also:
- Constant Field Values
-
WAITMSGREPLYSTATE
public static final int WAITMSGREPLYSTATE
- See Also:
- Constant Field Values
-
defaultWaitTimer
static int defaultWaitTimer
-
xmtLocoNetList
public java.util.concurrent.ConcurrentLinkedQueue<LocoNetMessage> xmtLocoNetList
Synchronized list used as a transmit queue.This is public to allow access from the internal class(es) when compiling with Java 1.1
-
lastMessage
LocoNetMessage lastMessage
-
mCurrentState
protected volatile int mCurrentState
-
-
Constructor Detail
-
UhlenbrockPacketizer
public UhlenbrockPacketizer(LocoNetSystemConnectionMemo m)
-
-
Method Detail
-
sendLocoNetMessage
public void sendLocoNetMessage(LocoNetMessage m)
Forward a preformatted LocoNetMessage to the actual interface. Checksum is computed and overwritten here, then the message is converted to a byte array and queued for transmission.- Specified by:
sendLocoNetMessage
in interfaceLocoNetInterface
- Overrides:
sendLocoNetMessage
in classLnPacketizer
- Parameters:
m
- Message to send; will be updated with CRC
-
transmitWait
protected void transmitWait(int waitTime, int state)
-
startThreads
public void startThreads()
Invoked at startup to start the threads needed here.- Overrides:
startThreads
in classLnPacketizer
-
-