Package jmri.jmrix.dccpp.dccppovertcp
Class DCCppOverTcpPacketizer
java.lang.Object
jmri.jmrix.AbstractMRTrafficController
jmri.jmrix.dccpp.DCCppTrafficController
jmri.jmrix.dccpp.DCCppPacketizer
jmri.jmrix.dccpp.dccppovertcp.DCCppOverTcpPacketizer
- All Implemented Interfaces:
DCCppInterface
Converts Stream-based I/O to/from DCC++ messages. The "DCCppInterface" side
sends/receives DCCppMessage objects. The connection to a
DCCppPortnetworkController is via a pair of *Streams, which then carry
sequences of characters for transmission.
Messages come to this via the main GUI thread, and are forwarded back to listeners in that same thread. Reception and transmission are handled in dedicated threads by RcvHandler and XmtHandler objects. Those are internal classes defined here. The thread priorities are:
- RcvHandler - at highest available priority
- XmtHandler - down one, which is assumed to be above the GUI
- (everything else)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) classCaptive class to handle incoming characters.(package private) classCaptive class to handle transmission.Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BufferedReader(package private) static final String(package private) static final String(package private) static final String(package private) static final Stringprotected RunnableRcvHandler (a local class) object to implement the receive thread(package private) static final String(package private) static final String(package private) booleanprotected final RunnableXmtHandler (a local class) object to implement the transmit threadprotected LinkedList<DCCppMessage>Synchronized list used as a transmit queue.Fields inherited from class jmri.jmrix.dccpp.DCCppTrafficController
anyReceived, mListenerMasks, startUpDelayFields inherited from class jmri.jmrix.AbstractMRTrafficController
allowUnexpectedReply, AUTORETRYSTATE, cmdListeners, connectionError, controller, flushReceiveChars, IDLESTATE, istream, listenerQueue, maxRcvExceptionCount, mCurrentMode, mCurrentState, mLastSender, msgQueue, mWaitBeforePoll, NORMALMODE, NOTIFIEDSTATE, OKSENDMSGSTATE, ostream, POLLSTATE, PROGRAMINGMODE, rcvException, rcvThread, replyInDispatch, threadStopRequest, timeoutFlag, timeouts, WAITMSGREPLYSTATE, WAITREPLYINNORMMODESTATE, WAITREPLYINPROGMODESTATE, waitTimePoll, xmtException, xmtRunnable, xmtThreadFields inherited from interface jmri.jmrix.dccpp.DCCppInterface
ALL, COMMINFO, CONSIST, CS_INFO, FEEDBACK, INTERFACE, PROGRAMMING, THROTTLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidMake connection to existing DCCppNetworkPortController object.voidBreak connection to existing DCCppNetworkPortController object.booleanvoidsendDCCppMessage(DCCppMessage m, DCCppListener reply) Forward a preformatted DCCppMessage to the actual interface.voidInvoked at startup to start the threads needed here.voidTerminate the receive and transmit threads.Methods inherited from class jmri.jmrix.dccpp.DCCppPacketizer
addHeaderToOutput, addTrailerToOutput, loadChars, portReadyToSendMethods inherited from class jmri.jmrix.dccpp.DCCppTrafficController
addDCCppListener, endOfMessage, enterNormalMode, enterProgMode, forwardMessage, forwardReply, getCommandStation, getSystemConnectionMemo, getTurnoutReplyCache, handleTimeout, lengthOfByteStream, newReply, pollMessage, pollReplyHandler, programmerIdle, removeDCCppListener, sendHighPriorityDCCppMessage, setSystemConnectionMemo, transmitLoopMethods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addListener, canReceive, connectionWarn, connectPort, disconnectPort, distributeReply, enterProgModeDelayTime, forwardToPort, getLastSender, getPortName, getSynchronizeRx, handleOneIncomingReply, hasTimeouts, newRcvNotifier, notifyMessage, notifyReply, portWarn, portWarnTCP, readByteProtected, receiveLoop, recovery, removeListener, reportReceiveLoopException, resetTimeout, sendMessage, setAllowUnexpectedReply, setSynchronizeRx, status, terminate, transmitWait, unexpectedReplyStateError, waitForStartOfReply, warnOnTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.jmrix.dccpp.DCCppInterface
status
-
Field Details
-
OLD_RECEIVE_PREFIX
- See Also:
-
OLD_SEND_PREFIX
- See Also:
-
RECEIVE_PREFIX
- See Also:
-
SEND_PREFIX
- See Also:
-
OLD_SERVER_VERSION_STRING
- See Also:
-
NEW_SERVER_VERSION_STRING
- See Also:
-
useOldPrefix
boolean useOldPrefix -
istreamReader
-
xmtHandler
XmtHandler (a local class) object to implement the transmit thread -
rcvHandler
RcvHandler (a local class) object to implement the receive thread -
xmtList
Synchronized list used as a transmit queue. -
networkController
-
-
Constructor Details
-
DCCppOverTcpPacketizer
-
-
Method Details
-
isXmtBusy
-
connectPort
Make connection to existing DCCppNetworkPortController object.- Parameters:
p- Port networkController for connected. Save this for a later disconnect call
-
disconnectPort
Break connection to existing DCCppNetworkPortController object. Once broken, attempts to send via "message" member will fail.- Parameters:
p- previously connected port
-
sendDCCppMessage
Forward a preformatted DCCppMessage to the actual interface. Checksum is computed and overwritten here, then the message is converted to a byte array and queue for transmission- Specified by:
sendDCCppMessagein interfaceDCCppInterface- Overrides:
sendDCCppMessagein classDCCppPacketizer- Parameters:
m- Message to send; will be updated with CRCreply- Listener to notify when the reply to the message is received
-
startThreads
Invoked at startup to start the threads needed here. -
terminateThreads
Terminate the receive and transmit threads.This is intended to be used only by testing subclasses.
- Overrides:
terminateThreadsin classAbstractMRTrafficController
-