Package jmri.jmrix.lenz
Class XNetTrafficRouter
- java.lang.Object
-
- jmri.jmrix.AbstractMRTrafficController
-
- jmri.jmrix.lenz.XNetTrafficController
-
- jmri.jmrix.lenz.XNetTrafficRouter
-
- All Implemented Interfaces:
java.util.EventListener
,AbstractMRListener
,XNetInterface
,XNetListener
public class XNetTrafficRouter extends XNetTrafficController implements XNetListener
Implements an XNetInterface by doing a scatter-gather to another, simpler implementation.This is intended for remote operation, where only one copy of each message should go to/from another node. By putting a LnTrafficRouter implementation at the remote node, all of the routing of messages to multiple consumers can be done without traffic over the connection.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier
-
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
connected
(package private) XNetListener
lastSender
Store the last sender-
Fields inherited from class jmri.jmrix.lenz.XNetTrafficController
highPriorityListeners, highPriorityQueue, mCommandStation, mListenerMasks, mMemo, self
-
Fields 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, xmtThread
-
Fields inherited from interface jmri.jmrix.lenz.XNetInterface
ALL, COMMINFO, CONSIST, CS_INFO, FEEDBACK, INTERFACE, PROGRAMMING, THROTTLE
-
-
Constructor Summary
Constructors Constructor Description XNetTrafficRouter(LenzCommandStation pCommandStation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
connect(XNetInterface i)
Make connection to existing XNetInterface object for upstream communication.void
disconnectPort(XNetInterface i)
Break connection to upstream LocoNetInterface object.void
message(XNetMessage l)
Listen for the messages to the LI100/LI101.void
message(XNetReply m)
Receive an XNet message from upstream and forward it to all the local clients.protected void
notify(XNetReply m)
Forward an XNetMessage to all registered listeners.void
notifyTimeout(XNetMessage msg)
Member function invoked by an XNetInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.void
sendXNetMessage(XNetMessage m, XNetListener replyTo)
Forward a preformatted XNetMessage to the actual interface.boolean
status()
Check whether an implementation is operational.-
Methods inherited from class jmri.jmrix.lenz.XNetTrafficController
addXNetListener, connectPort, endOfMessage, enterNormalMode, enterProgMode, forwardMessage, forwardReply, getCommandStation, getFeedbackMessageCache, getSystemConnectionMemo, handleTimeout, hasTimeSlot, loadChars, newReply, notifyMessage, pollMessage, pollReplyHandler, programmerIdle, removeXNetListener, sendHighPriorityXNetMessage, setSystemConnectionMemo
-
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, terminate, terminateThreads, transmitLoop, transmitWait, unexpectedReplyStateError, waitForStartOfReply, warnOnTimeout
-
-
-
-
Field Detail
-
connected
boolean connected
-
lastSender
XNetListener lastSender
Store the last sender
-
-
Constructor Detail
-
XNetTrafficRouter
public XNetTrafficRouter(LenzCommandStation pCommandStation)
-
-
Method Detail
-
status
public boolean status()
Description copied from interface:XNetInterface
Check whether an implementation is operational.- Specified by:
status
in interfaceXNetInterface
- Overrides:
status
in classAbstractMRTrafficController
- Returns:
- true if OK, else false.
-
sendXNetMessage
public void sendXNetMessage(XNetMessage m, XNetListener replyTo)
Forward a preformatted XNetMessage to the actual interface.- Specified by:
sendXNetMessage
in interfaceXNetInterface
- Parameters:
m
- Message to send; will be updated with CRCreplyTo
- sending listener to NOT notify.
-
message
public void message(XNetReply m)
Receive an XNet message from upstream and forward it to all the local clients.- Specified by:
message
in interfaceXNetListener
- Parameters:
m
- The received XNet message. Note that this same object may be presented to multiple users. It should not be modified here.
-
message
public void message(XNetMessage l)
Listen for the messages to the LI100/LI101.- Specified by:
message
in interfaceXNetListener
- Parameters:
l
- The received XNet message. Note that this same object may be presented to multiple users. It should not be modified here.
-
notifyTimeout
public void notifyTimeout(XNetMessage msg)
Description copied from interface:XNetListener
Member function invoked by an XNetInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.- Specified by:
notifyTimeout
in interfaceXNetListener
- Parameters:
msg
- message which has timed out.
-
connect
public void connect(XNetInterface i)
Make connection to existing XNetInterface object for upstream communication.- Parameters:
i
- Interface to be connected
-
disconnectPort
public void disconnectPort(XNetInterface i)
Break connection to upstream LocoNetInterface object. Once broken, attempts to send via "message" member will fail.- Parameters:
i
- previously connected interface
-
-