Package jmri.jmrix.dccpp
Class DCCppTrafficController
java.lang.Object
jmri.jmrix.AbstractMRTrafficController
jmri.jmrix.dccpp.DCCppTrafficController
- All Implemented Interfaces:
DCCppInterface
- Direct Known Subclasses:
DCCppPacketizer
public abstract class DCCppTrafficController
extends AbstractMRTrafficController
implements DCCppInterface
Abstract base class for implementations of DCCppInterface.
This provides just the basic interface, plus the "" static method for locating the local implementation.
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier -
Field Summary
FieldsModifier and TypeFieldDescriptionboolean(package private) LinkedBlockingQueue<DCCppListener>(package private) LinkedBlockingQueue<DCCppMessage>(package private) DCCppCommandStationReference to the command station in communication here.protected HashMap<DCCppListener,Integer> (package private) DCCppSystemConnectionMemoReference to the system connection memo.intFields 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
ConstructorsConstructorDescriptionDCCppTrafficController(DCCppCommandStation pCommandStation) Create a new DCCppTrafficController instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDCCppListener(int mask, DCCppListener l) Request notification of things happening on the DCC++.protected booleanprotected AbstractMRMessageSets the system to normal mode during programming while in IDLESTATE.protected AbstractMRMessageHas to be available, even though it doesn't do anything on DCC++.voidForward a preformatted DCCppMessage to a specific listener interface.voidforwardReply(AbstractMRListener client, AbstractMRReply m) Forward a preformatted DCCppMessage to the registered DCCppListeners.Get access to communicating command station object.Get access to the system connection memo associated with this traffic controller.protected voidprotected intDetermine how many bytes the entire message will take, including space for header and trailer.protected AbstractMRReplynewReply()protected AbstractMRMessageInvoked if it's appropriate to do low-priority polling of the command station, this should return the next message to send, or null if the TrafficController should just sleep.protected AbstractMRListenerprotected booleanCheck to see if the programmer associated with this interface is idle or not.voidremoveDCCppListener(int mask, DCCppListener l) Stop notification of things happening on the XNet.abstract voidsendDCCppMessage(DCCppMessage m, DCCppListener reply) Forward a preformatted DCCppMessage to the actual interface.voidvoidSet the system connection memo associated with this traffic controller.protected voidPermanent loop for the transmit thread.Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, addTrailerToOutput, canReceive, connectionWarn, connectPort, disconnectPort, distributeReply, enterProgModeDelayTime, forwardToPort, getLastSender, getPortName, getSynchronizeRx, handleOneIncomingReply, hasTimeouts, loadChars, newRcvNotifier, notifyMessage, notifyReply, portReadyToSend, 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
-
startUpDelay
-
anyReceived
-
mListenerMasks
-
highPriorityQueue
-
highPriorityListeners
-
mCommandStation
Reference to the command station in communication here. -
mMemo
Reference to the system connection memo.
-
-
Constructor Details
-
DCCppTrafficController
DCCppTrafficController(DCCppCommandStation pCommandStation) Create a new DCCppTrafficController instance. Must provide a DCCppCommandStation reference at creation time.- Parameters:
pCommandStation- reference to associated command station object, preserved for later.
-
-
Method Details
-
transmitLoop
Description copied from class:AbstractMRTrafficControllerPermanent loop for the transmit thread.- Overrides:
transmitLoopin classAbstractMRTrafficController
-
sendDCCppMessage
Forward a preformatted DCCppMessage to the actual interface.- Specified by:
sendDCCppMessagein interfaceDCCppInterface- Parameters:
m- Message to send; will be updated with CRCreply- listener to receive replies.
-
lengthOfByteStream
Description copied from class:AbstractMRTrafficControllerDetermine how many bytes the entire message will take, including space for header and trailer.- Overrides:
lengthOfByteStreamin classAbstractMRTrafficController- Parameters:
m- the message to be sent- Returns:
- number of bytes
-
forwardMessage
Forward a preformatted DCCppMessage to a specific listener interface.- Specified by:
forwardMessagein classAbstractMRTrafficController- Parameters:
m- Message to send;reply- abstract listener.
-
forwardReply
Forward a preformatted DCCppMessage to the registered DCCppListeners. NOTE: this drops the packet if the checksum is bad.- Specified by:
forwardReplyin classAbstractMRTrafficController- Parameters:
client- Client to send message tom- Message to send
-
sendHighPriorityDCCppMessage
-
pollMessage
Description copied from class:AbstractMRTrafficControllerInvoked if it's appropriate to do low-priority polling of the command station, this should return the next message to send, or null if the TrafficController should just sleep.- Specified by:
pollMessagein classAbstractMRTrafficController- Returns:
- Formatted poll message
-
pollReplyHandler
- Specified by:
pollReplyHandlerin classAbstractMRTrafficController
-
addDCCppListener
Description copied from interface:DCCppInterfaceRequest notification of things happening on the DCC++.The same listener can register multiple times with different masks. (Multiple registrations with a single mask value are equivalent to a single registration) Mask values are defined as class constants. Note that these are bit masks, and should be OR'd, not added, if multiple values are desired.
The event notification contains the received message as source, not this object, so that we can notify of an incoming message to multiple places and then move on.
- Specified by:
addDCCppListenerin interfaceDCCppInterface- Parameters:
mask- The OR of the key values of messages to be reported (to reduce traffic, provide for listeners interested in different things)l- Object to be notified of new messages as they arrive.
-
removeDCCppListener
Description copied from interface:DCCppInterfaceStop notification of things happening on the XNet. Note that mask and XNetListener must match a previous request exactly.- Specified by:
removeDCCppListenerin interfaceDCCppInterface- Parameters:
mask- The OR of the key values of messages to be reported (to reduce traffic, provide for listeners interested in different things)l- Object to be notified of removal.
-
enterProgMode
Has to be available, even though it doesn't do anything on DCC++.- Specified by:
enterProgModein classAbstractMRTrafficController- Returns:
- any message that needs to be returned to the Command Station to change modes. If no message is needed, returns null.
- See Also:
-
enterNormalMode
Description copied from class:AbstractMRTrafficControllerSets the system to normal mode during programming while in IDLESTATE. IfAbstractMRTrafficController.programmerIdle()returns true, enterNormalMode() is called after a timeout.- Specified by:
enterNormalModein classAbstractMRTrafficController- Returns:
- the value of getExitProgModeMsg();
- See Also:
-
programmerIdle
Check to see if the programmer associated with this interface is idle or not.- Overrides:
programmerIdlein classAbstractMRTrafficController- Returns:
- true if not busy programming
-
endOfMessage
- Specified by:
endOfMessagein classAbstractMRTrafficController
-
newReply
- Specified by:
newReplyin classAbstractMRTrafficController
-
handleTimeout
- Overrides:
handleTimeoutin classAbstractMRTrafficController
-
getCommandStation
Get access to communicating command station object.- Returns:
- associated Command Station object
-
getSystemConnectionMemo
Get access to the system connection memo associated with this traffic controller.- Returns:
- associated systemConnectionMemo object
-
setSystemConnectionMemo
Set the system connection memo associated with this traffic controller.- Parameters:
m- associated systemConnectionMemo object
-
getTurnoutReplyCache
- Returns:
- an DCCppTurnoutReplyCache object associated with this traffic controller
-