|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.jmrix.AbstractMRTrafficController
jmri.jmrix.AbstractMRNodeTrafficController
jmri.jmrix.oaktree.SerialTrafficController
public class SerialTrafficController
Converts Stream-based I/O to/from Oak Tree 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 int |
currentAddr
|
protected int |
incomingLength
|
protected static SerialTrafficController |
self
|
| Fields inherited from class jmri.jmrix.AbstractMRNodeTrafficController |
|---|
maxNode, minNode |
| Constructor Summary | |
|---|---|
SerialTrafficController()
|
|
| Method Summary | |
|---|---|
protected int |
addHeaderToOutput(byte[] msg,
AbstractMRMessage m)
Add header to the outgoing byte stream. |
void |
addSerialListener(SerialListener l)
|
protected void |
addTrailerToOutput(byte[] msg,
int offset,
AbstractMRMessage m)
Although this protocol doesn't use a trailer, we implement this method to set the expected reply length and address for this message. |
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 |
handleTimeout(AbstractMRMessage m,
AbstractMRListener l)
|
void |
initializeSerialNode(SerialNode node)
Public method to set up for initialization of a Serial node |
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 Oak Tree from within the running thread |
protected AbstractMRListener |
pollReplyHandler()
|
void |
removeSerialListener(SerialListener l)
|
protected void |
resetTimeout(AbstractMRMessage m)
|
void |
sendSerialMessage(SerialMessage m,
SerialListener reply)
Forward a preformatted message to the actual interface. |
protected void |
setInstance()
|
void |
setSensorManager(SerialSensorManager m)
|
void |
setSerialOutput(String systemName,
boolean state)
Public method to set a Oak Tree Serial Output bit Note: systemName is of format CNnnnBxxxx where "nnn" is the serial node number (0 - 127) "xxxx' is the bit number within that node (1 thru number of defined bits) state is 'true' for 0, 'false' for 1 The bit is transmitted to the Oak Tree hardware immediately before the next poll packet is sent. |
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 jmri.jmrix.AbstractMRNodeTrafficController |
|---|
deleteNode, getMustInit, getNode, getNodeFromAddress, getNumNodes, init, registerNode, setMustInit, setMustInit |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface jmri.jmrix.oaktree.SerialInterface |
|---|
status |
| Field Detail |
|---|
protected static volatile SerialTrafficController self
protected int currentAddr
protected int incomingLength
| Constructor Detail |
|---|
public SerialTrafficController()
| Method Detail |
|---|
public void addSerialListener(SerialListener l)
addSerialListener in interface SerialInterfacepublic void removeSerialListener(SerialListener l)
removeSerialListener in interface SerialInterface
public void setSerialOutput(String systemName,
boolean state)
public void initializeSerialNode(SerialNode node)
protected 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 AbstractMRTrafficControllerpublic void setSensorManager(SerialSensorManager m)
protected AbstractMRMessage pollMessage()
pollMessage in class AbstractMRTrafficController
protected void handleTimeout(AbstractMRMessage m,
AbstractMRListener l)
handleTimeout in class AbstractMRTrafficControllerprotected void resetTimeout(AbstractMRMessage m)
resetTimeout 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 usedm - the original messageprotected int lengthOfByteStream(AbstractMRMessage m)
lengthOfByteStream in class AbstractMRTrafficControllerm - The message to be sent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||