Package jmri.jmrix.dccpp.serial
Class SerialDCCppPacketizer
java.lang.Object
jmri.jmrix.AbstractMRTrafficController
jmri.jmrix.dccpp.DCCppTrafficController
jmri.jmrix.dccpp.DCCppPacketizer
jmri.jmrix.dccpp.serial.SerialDCCppPacketizer
- All Implemented Interfaces:
DCCppInterface
- Direct Known Subclasses:
DCCppEthernetPacketizer
This is an extension of the DCCppPacketizer to handle the device specific
requirements of the DCC++.
In particular, SerialDCCppPacketizer adds functions to add and remove the "<" and ">" bytes that appear around any message read in. Note that the bracket-adding could be pushed up to DCCppPacketizer, as it is a protocol thing, not an interface implementation thing. We'll come back to that later. What is however interface specific is the background refresh of functions. DCC++ sends the DCC commands exactly once. A background thread will repeat the last seen function commands to compensate for any momentary power loss or to recover from power off / power on events. It only makes sense to do this on the actual serial interface as it will be transparent for the network clients.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) final classNested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier -
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean(package private) final DelayQueue<DCCppMessage>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 TypeMethodDescriptionvoidClear the background refresh queue.intCheck how many entries are in the background refresh queuebooleanCheck if the background function refresh thread is active or notprotected intDetermine how many bytes the entire message will take, including space for header and trailervoidsendDCCppMessage(DCCppMessage m, DCCppListener reply) Forward a preformatted DCCppMessage to the actual interface.booleansetActiveRefresh(boolean activeState) Enable or disable the background refresh threadMethods 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, 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, terminateThreads, 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
-
resendFunctions
-
activeBackgroundRefresh
boolean activeBackgroundRefresh
-
-
Constructor Details
-
SerialDCCppPacketizer
-
-
Method Details
-
lengthOfByteStream
Determine how many bytes the entire message will take, including space for header and trailer- Overrides:
lengthOfByteStreamin classDCCppTrafficController- Parameters:
m- The message to be sent- Returns:
- Number of bytes
-
sendDCCppMessage
Description copied from class:DCCppPacketizerForward a preformatted DCCppMessage to the actual interface. The message is converted to a byte array and queue for transmission- Specified by:
sendDCCppMessagein interfaceDCCppInterface- Overrides:
sendDCCppMessagein classDCCppPacketizer- Parameters:
m- Message to sendreply- Listener to notify when the reply to the message is received
-
clearRefreshQueue
Clear the background refresh queue. The state is still kept in JMRI. -
getQueueLength
Check how many entries are in the background refresh queue- Returns:
- number of queued function groups
-
setActiveRefresh
Enable or disable the background refresh thread- Parameters:
activeState-trueto keep refreshing the functions,falseto disable this functionality.- Returns:
- the previous active state of the background refresh thread
-
isActiveRefresh
Check if the background function refresh thread is active or not- Returns:
- the background refresh status,
truefor active,falseif disabled.
-