Package jmri.jmrix.roco.z21
Class Z21TrafficController
java.lang.Object
jmri.jmrix.AbstractMRTrafficController
jmri.jmrix.roco.z21.Z21TrafficController
- All Implemented Interfaces:
Z21Interface
Abstract base for TrafficControllers in a Message/Reply protocol.
-
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, timeoutFlag, timeouts, WAITMSGREPLYSTATE, WAITREPLYINNORMMODESTATE, WAITREPLYINPROGMODESTATE, waitTimePoll, xmtException, xmtRunnable, xmtThread -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidMake connection to existing PortController object.voidBreak connection to existing PortController object.protected booleanprotected Z21MessageenterProgMode() and enterNormalMode() return any message that needs to be returned to the command station to change modes.protected Z21MessageenterProgMode() and enterNormalMode() return any message that needs to be returned to the command station to change modes.protected voidforwardMessage(AbstractMRListener client, AbstractMRMessage m) Implement this to forward a specific message type to a protocol-specific listener interface.protected voidforwardReply(AbstractMRListener client, AbstractMRReply m) Implement this to forward a specific Reply type to a protocol-specific listener interface.protected voidforwardToPort(AbstractMRMessage m, AbstractMRListener reply) Actually transmits the next message to the port.voidHandle each reply when complete.protected Z21ReplynewReply()protected Z21MessageInvoked 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 TC should just sleep.protected Z21Listenervoidvoidsendz21Message(Z21Message m, Z21Listener reply) Forward a preformatted message to the actual interface.booleanstatus()protected voidvoidTerminate the receive and transmit threads.Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, addTrailerToOutput, canReceive, connectionWarn, distributeReply, enterProgModeDelayTime, getLastSender, getPortName, getSynchronizeRx, handleTimeout, hasTimeouts, lengthOfByteStream, loadChars, newRcvNotifier, notifyMessage, notifyReply, portReadyToSend, portWarn, portWarnTCP, programmerIdle, readByteProtected, receiveLoop, recovery, removeListener, reportReceiveLoopException, resetTimeout, sendMessage, setAllowUnexpectedReply, setSynchronizeRx, transmitLoop, transmitWait, unexpectedReplyStateError, waitForStartOfReply, warnOnTimeout
-
Constructor Details
-
Z21TrafficController
public Z21TrafficController()
-
-
Method Details
-
forwardMessage
Implement this to forward a specific message type to a protocol-specific listener interface. This puts the casting into the concrete class.- Specified by:
forwardMessagein classAbstractMRTrafficController- Parameters:
client- abstract listener.m- message to forward.
-
forwardReply
Implement this to forward a specific Reply type to a protocol-specific listener interface. This puts the casting into the concrete class.- Specified by:
forwardReplyin classAbstractMRTrafficController
-
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 TC should just sleep.- Specified by:
pollMessagein classAbstractMRTrafficController- Returns:
- Formatted poll message
-
pollReplyHandler
- Specified by:
pollReplyHandlerin classAbstractMRTrafficController
-
enterProgMode
enterProgMode() and enterNormalMode() return any message that needs to be returned to the command station to change modes.- Specified by:
enterProgModein classAbstractMRTrafficController- Returns:
- if no message is needed, you may return null. If the programmerIdle() function returns true, enterNormalMode() is called after a timeout while in IDLESTATE during programming to return the system to normal mode.
- See Also:
-
enterNormalMode
enterProgMode() and enterNormalMode() return any message that needs to be returned to the command station to change modes.- Specified by:
enterNormalModein classAbstractMRTrafficController- Returns:
- if no message is needed, you may return null.
- See Also:
-
forwardToPort
Actually transmits the next message to the port.- Overrides:
forwardToPortin classAbstractMRTrafficController- Parameters:
m- the message to sendreply- the Listener sending the message, often provided as 'this'- See Also:
-
status
- Overrides:
statusin classAbstractMRTrafficController
-
connectPort
Make connection to existing PortController object.- Overrides:
connectPortin classAbstractMRTrafficController- Parameters:
p- the PortController
-
disconnectPort
Break connection to existing PortController object. Once broken, attempts to send via "message" member will fail.- Overrides:
disconnectPortin classAbstractMRTrafficController- Parameters:
p- the PortController
-
newReply
- Specified by:
newReplyin classAbstractMRTrafficController
-
endOfMessage
- Specified by:
endOfMessagein classAbstractMRTrafficController
-
handleOneIncomingReply
Handle each reply when complete.(This is public for testing purposes) Runs in the "Receive" thread.
- Overrides:
handleOneIncomingReplyin classAbstractMRTrafficController- Throws:
IOException- on error.
-
terminate
- Overrides:
terminatein classAbstractMRTrafficController
-
terminateThreads
Terminate the receive and transmit threads.This is intended to be used only by testing subclasses.
- Overrides:
terminateThreadsin classAbstractMRTrafficController
-
addz21Listener
- Specified by:
addz21Listenerin interfaceZ21Interface
-
removez21Listener
- Specified by:
removez21Listenerin interfaceZ21Interface
-
sendz21Message
Forward a preformatted message to the actual interface.- Specified by:
sendz21Messagein interfaceZ21Interface
-