Package jmri.jmrix.qsi
Class QsiTrafficController
java.lang.Object
jmri.jmrix.qsi.QsiTrafficController
- All Implemented Interfaces:
Runnable,QsiInterface
Converts Stream-based I/O to/from QSI messages. The "QsiInterface" side
sends/receives message objects. The connection to a QsiPortController is via
a pair of *Streams, which then carry sequences of characters for
transmission. Note that this processing is handled in an independent thread.
Messages to and from the programmer are in a packet format. In both directions, every message starts with 'S' and ends with 'E'. These are handled automatically, and are not included in the QsiMessage and QsiReply content.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Vector<QsiListener>(package private) DataInputStream(package private) QsiListenerstatic final int(package private) OutputStreamstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidMake connection to existing PortController object.voidBreak connection to existing QsiPortController object.(package private) booleanendNormalReply(QsiReply msg) (package private) booleanint(package private) voidbooleanbooleanbooleanprotected voidnotifyMessage(QsiMessage m, QsiListener notMe) Forward a QsiMessage to all registered QsiInterface listeners.protected voidvoidvoidrun()Handle incoming characters.voidsendQsiMessage(QsiMessage m, QsiListener reply) Forward a preformatted message to the actual interface.voidsetQsiState(int s) booleanstatus()Test operational status of interface.
-
Field Details
-
cmdListeners
-
lastSender
-
NORMAL
- See Also:
-
SIIBOOTMODE
- See Also:
-
V4BOOTMODE
- See Also:
-
istream
-
ostream
-
-
Constructor Details
-
QsiTrafficController
public QsiTrafficController()Create a new QsiTrafficController instance.
-
-
Method Details
-
status
Description copied from interface:QsiInterfaceTest operational status of interface.- Specified by:
statusin interfaceQsiInterface- Returns:
- true is interface implementation is operational
-
addQsiListener
- Specified by:
addQsiListenerin interfaceQsiInterface
-
removeQsiListener
- Specified by:
removeQsiListenerin interfaceQsiInterface
-
notifyMessage
Forward a QsiMessage to all registered QsiInterface listeners.- Parameters:
m- message to forward.notMe- Listener to hear the returned status
-
getQsiState
-
setQsiState
-
isNormalMode
-
isSIIBootMode
-
isV4BootMode
-
notifyReply
-
sendQsiMessage
Forward a preformatted message to the actual interface.- Specified by:
sendQsiMessagein interfaceQsiInterface- Parameters:
m- Message to be sent.reply- Listener to be notified of reply.
-
connectPort
Make connection to existing PortController object.- Parameters:
p- the QSI port controller.
-
disconnectPort
Break connection to existing QsiPortController object. Once broken, attempts to send via "message" member will fail.- Parameters:
p- the QSI port 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
-
endReply
-
endNormalReply
-