|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjmri.jmrix.AbstractMRTrafficController
jmri.jmrix.tchtech.serial.SerialTrafficController
public class SerialTrafficController
Converts Stream-based I/O to/from "!"TCH Technology"!" 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
|
| Fields inherited from class jmri.jmrix.AbstractMRTrafficController |
|---|
allowUnexpectedReply, cmdListeners, controller, flushReceiveChars, IDLESTATE, istream, mCurrentMode, mCurrentState, mLastSender, mWaitBeforePoll, NORMALMODE, NOTIFIEDSTATE, OKSENDMSGSTATE, ostream, PROGRAMINGMODE, replyInDispatch, WAITMSGREPLYSTATE, WAITREPLYINNORMMODESTATE, WAITREPLYINPROGMODESTATE, xmtRunnable |
| Constructor Summary | |
|---|---|
SerialTrafficController()
|
|
| Method Summary | |
|---|---|
protected int |
addHeaderToOutput(byte[] msg,
AbstractMRMessage m)
Add header to the outgoing byte stream. |
void |
addSerialListener(SerialListener l)
|
void |
deleteSerialNode(int nodeAddress)
Public method to delete a Serial node by node address |
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. |
SerialNode |
getNodeFromAddress(int Addr)
Public method to identify a SerialNode from its node address Note: 'na' is the node address, numbered from 0. |
SerialNode |
getSerialNode(int index)
Public method to return the Serial node with a given index Note: To cycle through all nodes, begin with index=0, and increment your index at each call. |
protected void |
handleTimeout(AbstractMRMessage m)
|
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 "!" |
protected AbstractMRListener |
pollReplyHandler()
|
void |
registerSerialNode(SerialNode node)
Public method to register a Serial node |
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 TCH Technology Serial Output bit Note: systemName is of format HNnnnBxxxx where "nnn" is the serial node number (0 - 255) "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 TCH Technology 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 java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface jmri.jmrix.tchtech.serial.SerialInterface |
|---|
status |
| Field Detail |
|---|
protected static SerialTrafficController self
| 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 registerSerialNode(SerialNode node)
public void initializeSerialNode(SerialNode node)
public SerialNode getNodeFromAddress(int Addr)
public void deleteSerialNode(int nodeAddress)
public SerialNode getSerialNode(int index)
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 AbstractMRTrafficControllerprotected void handleTimeout(AbstractMRMessage m)
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 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 | |||||||||