|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.jmrix.AbstractMRTrafficController
jmri.jmrix.tmcc.SerialTrafficController
public class SerialTrafficController
Converts Stream-based I/O to/from TMCC serial messages.
The "SerialInterface" side sends/receives message objects.
The connection to a SerialPortController is via a pair of *Streams, which then carry sequences of characters for transmission. Note that this processing is handled in an independent thread.
This handles the state transistions, based on the necessary state in each message.
Handles initialization, polling, output, and input for multiple Serial Nodes.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController |
|---|
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier |
| Field Summary | |
|---|---|
protected static SerialTrafficController |
self
|
| Constructor Summary | |
|---|---|
SerialTrafficController()
|
|
| Method Summary | |
|---|---|
protected int |
addHeaderToOutput(byte[] msg,
AbstractMRMessage m)
No header needed |
void |
addSerialListener(SerialListener l)
|
protected void |
addTrailerToOutput(byte[] msg,
int offset,
AbstractMRMessage m)
Add trailer to the outgoing byte stream. |
protected boolean |
endOfMessage(AbstractMRReply msg)
|
protected AbstractMRMessage |
enterNormalMode()
|
protected AbstractMRMessage |
enterProgMode()
|
protected void |
forwardMessage(AbstractMRListener client,
AbstractMRMessage m)
Forward a SerialMessage to all registered SerialInterface listeners. |
protected void |
forwardReply(AbstractMRListener client,
AbstractMRReply m)
Forward a SerialReply to all registered SerialInterface listeners. |
protected void |
forwardToPort(AbstractMRMessage m,
AbstractMRListener reply)
Actually transmits the next message to the port |
static SerialTrafficController |
instance()
static function returning the SerialTrafficController instance to use. |
protected int |
lengthOfByteStream(AbstractMRMessage m)
Determine how much many bytes the entire message will take, including space for header and trailer |
protected void |
loadChars(AbstractMRReply msg,
DataInputStream istream)
Get characters from the input source, and file a message. |
protected AbstractMRReply |
newReply()
|
protected AbstractMRMessage |
pollMessage()
Handles initialization, output and polling for TMCC from within the running thread |
protected AbstractMRListener |
pollReplyHandler()
|
void |
removeSerialListener(SerialListener l)
|
void |
sendSerialMessage(SerialMessage m,
SerialListener reply)
Forward a preformatted message to the actual interface. |
protected void |
setInstance()
|
protected void |
waitForStartOfReply(DataInputStream istream)
Dummy routine, to be filled by protocols that have to skip some start-of-message characters. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface jmri.jmrix.tmcc.SerialInterface |
|---|
status |
| Field Detail |
|---|
protected static volatile SerialTrafficController self
| Constructor Detail |
|---|
public SerialTrafficController()
| Method Detail |
|---|
public void addSerialListener(SerialListener l)
addSerialListener in interface SerialInterfacepublic void removeSerialListener(SerialListener l)
removeSerialListener in interface SerialInterfaceprotected AbstractMRMessage enterProgMode()
enterProgMode in class AbstractMRTrafficControllerprotected AbstractMRMessage enterNormalMode()
enterNormalMode in class AbstractMRTrafficController
protected void forwardMessage(AbstractMRListener client,
AbstractMRMessage m)
forwardMessage in class AbstractMRTrafficController
protected void forwardReply(AbstractMRListener client,
AbstractMRReply m)
forwardReply in class AbstractMRTrafficControllerprotected AbstractMRMessage pollMessage()
pollMessage in class AbstractMRTrafficControllerprotected AbstractMRListener pollReplyHandler()
pollReplyHandler in class AbstractMRTrafficController
public void sendSerialMessage(SerialMessage m,
SerialListener reply)
sendSerialMessage in interface SerialInterfacepublic static SerialTrafficController instance()
protected void setInstance()
setInstance in class AbstractMRTrafficControllerprotected AbstractMRReply newReply()
newReply in class AbstractMRTrafficControllerprotected boolean endOfMessage(AbstractMRReply msg)
endOfMessage in class AbstractMRTrafficController
protected void loadChars(AbstractMRReply msg,
DataInputStream istream)
throws IOException
AbstractMRTrafficControllerReturns only when the message is complete.
Only used in the Receive thread.
Handles timeouts on read by ignoring zero-length reads.
loadChars in class AbstractMRTrafficControllermsg - message to fillistream - character source.
IOException - when presented by the input source.
protected void waitForStartOfReply(DataInputStream istream)
throws IOException
AbstractMRTrafficController
waitForStartOfReply in class AbstractMRTrafficControllerIOException
protected int addHeaderToOutput(byte[] msg,
AbstractMRMessage m)
addHeaderToOutput in class AbstractMRTrafficControllermsg - The output byte stream
protected void addTrailerToOutput(byte[] msg,
int offset,
AbstractMRMessage m)
addTrailerToOutput in class AbstractMRTrafficControllermsg - The output byte streamoffset - the first byte not yet usedprotected int lengthOfByteStream(AbstractMRMessage m)
lengthOfByteStream in class AbstractMRTrafficControllerm - The message to be sent
protected void forwardToPort(AbstractMRMessage m,
AbstractMRListener reply)
forwardToPort in class AbstractMRTrafficController
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||