Package jmri.jmrix.xpa
Class XpaTrafficController
java.lang.Object
jmri.jmrix.xpa.XpaTrafficController
- All Implemented Interfaces:
Runnable,XpaInterface
Converts Stream-based I/O to/from Xpa messages. The "XpaInterface" side
sends/receives message objects. The connection to an XpaPortController is via
a pair of *Streams, which then carry sequences of characters for
transmission. Note that this processing is handled in an independent thread.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classCaptive class to handle transmission. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ArrayList<XpaListener>(package private) DataInputStream(package private) XpaListener(package private) OutputStream(package private) final XpaTrafficController.XmtHandler(local class) object to implement the transmit thread(package private) final LinkedList<byte[]>(package private) Thread -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidMake connection to existing PortController object.voidBreak connection to existing XpaPortController object.(package private) voidprotected voidnotifyMessage(XpaMessage m, XpaListener notMe) Forward a XpaMessage to all registered XpaInterface listeners.protected voidvoidvoidrun()Handle incoming characters.voidsendXpaMessage(XpaMessage m, XpaListener reply) Forward a pre-formatted message to the actual interface.voidStart the Transmit thread.booleanstatus()Test operational status of interface.
-
Field Details
-
xmtList
-
xmtHandler
(local class) object to implement the transmit thread -
xmtThread
-
cmdListeners
-
lastSender
-
istream
-
ostream
-
-
Constructor Details
-
XpaTrafficController
public XpaTrafficController()Create a new XpaTrafficController instance.
-
-
Method Details
-
startTransmitThread
Start the Transmit thread. -
status
Description copied from interface:XpaInterfaceTest operational status of interface.- Specified by:
statusin interfaceXpaInterface- Returns:
- true if the interface implementation is operational.
-
addXpaListener
- Specified by:
addXpaListenerin interfaceXpaInterface
-
removeXpaListener
- Specified by:
removeXpaListenerin interfaceXpaInterface
-
notifyMessage
Forward a XpaMessage to all registered XpaInterface listeners.- Parameters:
m- the message to forwardnotMe- registered listener not to forward the message to
-
notifyReply
-
sendXpaMessage
Forward a pre-formatted message to the actual interface.- Specified by:
sendXpaMessagein interfaceXpaInterface- Parameters:
m- the message to forwardreply- the listener to receive the reply
-
connectPort
Make connection to existing PortController object.- Parameters:
p- controller for the port associated with this controller
-
disconnectPort
Break connection to existing XpaPortController object. Once broken, attempts to send via "message" member will fail.- Parameters:
p- controller for the port associated with this controller
-
run
Handle incoming characters. This is a permanent loop, looking for input messages in character form on the stream connected to the PortController viaconnectPort. Terminates with the input stream breaking out of the try block. -
handleOneIncomingReply
- Throws:
IOException
-