Package jmri.jmrix.lenz
Class XNetTrafficController
java.lang.Object
jmri.jmrix.AbstractMRTrafficController
jmri.jmrix.lenz.XNetTrafficController
- All Implemented Interfaces:
XNetInterface
- Direct Known Subclasses:
XNetPacketizer,XNetTrafficRouter
public abstract class XNetTrafficController
extends AbstractMRTrafficController
implements XNetInterface
Abstract base class for implementations of XNetInterface.
This provides just the basic interface.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final LinkedBlockingQueue<XNetListener>(package private) final LinkedBlockingQueue<XNetMessage>(package private) final LenzCommandStationReference to the command station in communication here.protected final HashMap<XNetListener,Integer> (package private) XNetSystemConnectionMemoReference to the system connection memo.(package private) static XNetTrafficControllerFields 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.lenz.XNetInterface
ALL, COMMINFO, CONSIST, CS_INFO, FEEDBACK, INTERFACE, PROGRAMMING, THROTTLE -
Constructor Summary
ConstructorsConstructorDescriptionXNetTrafficController(LenzCommandStation pCommandStation) Create a new XNetTrafficController. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddXNetListener(int mask, XNetListener l) Request notification of things happening on the XNet.voidMake connection to existing PortController object.protected booleanprotected AbstractMRMessageReturn the value of getExitProgModeMsg().protected AbstractMRMessageThis method has to be available, even though it doesn't do anything on Lenz.voidForward a preformatted XNetMessage to a specific listener interface.voidforwardReply(AbstractMRListener client, AbstractMRReply m) Forward a preformatted XNetMessage to the registered XNetListeners.Get access to communicating command station object.Return an XNetFeedbackMessageCache object associated with this traffic controller.Get access to the system connection memo associated with this traffic controller.protected void(package private) booleanprotected voidloadChars(AbstractMRReply msg, DataInputStream istream) Get characters from the input source, and file a message.protected AbstractMRReplynewReply()protected voidnotifyMessage(AbstractMRMessage m, AbstractMRListener notMe) Forward a Message to registered listeners.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.voidremoveXNetListener(int mask, XNetListener l) Stop notification of things happening on the XNet.voidvoidSet the system connection memo associated with this traffic controller.Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, addTrailerToOutput, canReceive, connectionWarn, disconnectPort, distributeReply, enterProgModeDelayTime, forwardToPort, getLastSender, getPortName, getSynchronizeRx, handleOneIncomingReply, hasTimeouts, lengthOfByteStream, newRcvNotifier, notifyReply, portReadyToSend, portWarn, portWarnTCP, readByteProtected, receiveLoop, recovery, removeListener, reportReceiveLoopException, resetTimeout, sendMessage, setAllowUnexpectedReply, setSynchronizeRx, status, terminate, terminateThreads, transmitLoop, 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.lenz.XNetInterface
sendXNetMessage, status
-
Field Details
-
mListenerMasks
-
self
-
highPriorityQueue
-
highPriorityListeners
-
mCommandStation
Reference to the command station in communication here. -
mMemo
Reference to the system connection memo.
-
-
Constructor Details
-
XNetTrafficController
XNetTrafficController(LenzCommandStation pCommandStation) Create a new XNetTrafficController. Must provide a LenzCommandStation reference at creation time.- Parameters:
pCommandStation- reference to associated command station object, preserved for later.
-
-
Method Details
-
connectPort
Make connection to existing PortController object.- Overrides:
connectPortin classAbstractMRTrafficController- Parameters:
p- the PortController
-
forwardMessage
Forward a preformatted XNetMessage to a specific listener interface.- Specified by:
forwardMessagein classAbstractMRTrafficController- Parameters:
m- Message to sendreply- abstract listener.
-
forwardReply
Forward a preformatted XNetMessage to the registered XNetListeners.NOTE: this drops the packet if the checksum is bad.
- Specified by:
forwardReplyin classAbstractMRTrafficController- Parameters:
client- is the client getting the messagem- Message to send
-
sendHighPriorityXNetMessage
-
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
-
addXNetListener
Description copied from interface:XNetInterfaceRequest notification of things happening on the XNet.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:
addXNetListenerin interfaceXNetInterface- 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.
-
removeXNetListener
Description copied from interface:XNetInterfaceStop notification of things happening on the XNet.Note that mask and XNetListener must match a previous request exactly.
- Specified by:
removeXNetListenerin interfaceXNetInterface- Parameters:
mask- listening mask.l- listener to remove notifications for.
-
enterProgMode
This method has to be available, even though it doesn't do anything on Lenz.- 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
Return the value of getExitProgModeMsg().- Specified by:
enterNormalModein 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:
-
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
-
loadChars
Get characters from the input source, and file a message.Returns only when the message is complete.
Only used in the Receive thread.
- Overrides:
loadCharsin classAbstractMRTrafficController- Parameters:
msg- message to fillistream- character source.- Throws:
IOException- when presented by the input source.
-
handleTimeout
- Overrides:
handleTimeoutin classAbstractMRTrafficController
-
notifyMessage
Description copied from class:AbstractMRTrafficControllerForward a Message to registered listeners.- Overrides:
notifyMessagein classAbstractMRTrafficController- Parameters:
m- Message to be forwarded intactnotMe- One (optional) listener to be skipped, usually because it's the originating object.
-
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
-
getFeedbackMessageCache
Return an XNetFeedbackMessageCache object associated with this traffic controller.- Returns:
- the feedback message cache. One is provided if null.
-
hasTimeSlot
boolean hasTimeSlot()- Returns:
- whether or not this connection currently has a timeslot from the Command station.
-