Package jmri.jmrix.jmriclient
Class JMRIClientTrafficController
java.lang.Object
jmri.jmrix.AbstractMRTrafficController
jmri.jmrix.jmriclient.JMRIClientTrafficController
- All Implemented Interfaces:
JMRIClientInterface
public class JMRIClientTrafficController extends AbstractMRTrafficController implements JMRIClientInterface
Converts Stream-based I/O to/from JMRIClient messages. The
"JMRIClientInterface" side sends/receives message objects.
The connection to a JMRIClientPortController is via a pair of *Streams, which then carry sequences of characters for transmission. Note that this processing is handled in an independent thread.
This handles the state transitions, based on the necessary state in each message.
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier
-
Field Summary
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, WAITMSGREPLYSTATE, WAITREPLYINNORMMODESTATE, WAITREPLYINPROGMODESTATE, waitTimePoll, xmtException, xmtRunnable, xmtThread
-
Constructor Summary
Constructors Constructor Description JMRIClientTrafficController()
Create a new JMRIClientTrafficController instance. -
Method Summary
Modifier and Type Method Description void
addJMRIClientListener(JMRIClientListener l)
protected boolean
endOfMessage(AbstractMRReply msg)
protected AbstractMRMessage
enterNormalMode()
Sets the system to normal mode during programming while in IDLESTATE.protected AbstractMRMessage
enterProgMode()
Set the system to programming mode.protected void
forwardMessage(AbstractMRListener client, AbstractMRMessage m)
Forward a JMRIClientMessage to all registered JMRIClientInterface listeners.protected void
forwardReply(AbstractMRListener client, AbstractMRReply m)
Forward a JMRIClientReply to all registered JMRIClientInterface listeners.protected AbstractMRReply
newReply()
protected AbstractMRMessage
pollMessage()
Invoked 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 AbstractMRListener
pollReplyHandler()
void
removeJMRIClientListener(JMRIClientListener l)
void
sendJMRIClientMessage(JMRIClientMessage m, JMRIClientListener reply)
Forward a preformatted message to the actual interface.Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addHeaderToOutput, addListener, addTrailerToOutput, canReceive, connectionWarn, connectPort, disconnectPort, distributeReply, enterProgModeDelayTime, finalize, forwardToPort, getLastSender, getPortName, getSynchronizeRx, handleOneIncomingReply, handleTimeout, hasTimeouts, lengthOfByteStream, loadChars, newRcvNotifier, notifyMessage, notifyReply, portReadyToSend, portWarn, portWarnTCP, programmerIdle, readByteProtected, receiveLoop, recovery, removeListener, reportReceiveLoopException, resetTimeout, sendMessage, setAllowUnexpectedReply, setSynchronizeRx, status, terminate, terminateThreads, transmitLoop, transmitWait, unexpectedReplyStateError, waitForStartOfReply
-
Constructor Details
-
JMRIClientTrafficController
public JMRIClientTrafficController()Create a new JMRIClientTrafficController instance.
-
-
Method Details
-
addJMRIClientListener
- Specified by:
addJMRIClientListener
in interfaceJMRIClientInterface
-
removeJMRIClientListener
- Specified by:
removeJMRIClientListener
in interfaceJMRIClientInterface
-
forwardMessage
Forward a JMRIClientMessage to all registered JMRIClientInterface listeners.- Specified by:
forwardMessage
in classAbstractMRTrafficController
- Parameters:
client
- abstract listener.m
- message to forward.
-
forwardReply
Forward a JMRIClientReply to all registered JMRIClientInterface listeners.- Specified by:
forwardReply
in classAbstractMRTrafficController
-
pollMessage
Description copied from class:AbstractMRTrafficController
Invoked 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:
pollMessage
in classAbstractMRTrafficController
- Returns:
- Formatted poll message
-
pollReplyHandler
- Specified by:
pollReplyHandler
in classAbstractMRTrafficController
-
sendJMRIClientMessage
Forward a preformatted message to the actual interface.- Specified by:
sendJMRIClientMessage
in interfaceJMRIClientInterface
-
enterProgMode
Description copied from class:AbstractMRTrafficController
Set the system to programming mode.- Specified by:
enterProgMode
in 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:
AbstractMRTrafficController.enterNormalMode()
-
enterNormalMode
Description copied from class:AbstractMRTrafficController
Sets the system to normal mode during programming while in IDLESTATE. IfAbstractMRTrafficController.programmerIdle()
returns true, enterNormalMode() is called after a timeout.- Specified by:
enterNormalMode
in 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:
AbstractMRTrafficController.enterProgMode()
-
newReply
- Specified by:
newReply
in classAbstractMRTrafficController
-
endOfMessage
- Specified by:
endOfMessage
in classAbstractMRTrafficController
-