Package jmri.jmrix.easydcc
Class EasyDccTrafficController
- java.lang.Object
-
- jmri.jmrix.AbstractMRTrafficController
-
- jmri.jmrix.easydcc.EasyDccTrafficController
-
- All Implemented Interfaces:
EasyDccInterface
- Direct Known Subclasses:
EasyDccSimulatorTrafficController
public class EasyDccTrafficController extends AbstractMRTrafficController implements EasyDccInterface
Converts Stream-based I/O to/from EasyDcc messages. The "EasyDccInterface" side sends/receives message objects.The connection to a EasyDccPortController 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.
Migrated for multiple connections, multi char connection prefix and Simulator.
-
-
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) EasyDccSystemConnectionMemomMemoReference to the system connection memo.-
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 Constructor Description EasyDccTrafficController(EasyDccSystemConnectionMemo adaptermemo)Create a new EasyDccTrafficController instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEasyDccListener(EasyDccListener l)protected booleanendOfMessage(AbstractMRReply msg)protected AbstractMRMessageenterNormalMode()Sets the system to normal mode during programming while in IDLESTATE.protected AbstractMRMessageenterProgMode()Set the system to programming mode.protected voidforwardMessage(AbstractMRListener client, AbstractMRMessage m)Forward an EasyDccMessage to all registered EasyDccInterface listeners.protected voidforwardReply(AbstractMRListener client, AbstractMRReply m)Forward an EasyDccReply to all registered EasyDccInterface listeners.EasyDccSystemConnectionMemogetSystemConnectionMemo()Get access to the system connection memo associated with this traffic controller.protected AbstractMRReplynewReply()protected AbstractMRMessagepollMessage()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 AbstractMRListenerpollReplyHandler()voidremoveEasyDccListener(EasyDccListener l)voidsendEasyDccMessage(EasyDccMessage m, EasyDccListener reply)Forward a preformatted message to the actual interface.voidsetSensorManager(SensorManager m)voidsetSystemConnectionMemo(EasyDccSystemConnectionMemo m)Set the system connection memo associated with this traffic controller.protected voidterminate()Don't send to-normal-mode message if in normal mode-
Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, addTrailerToOutput, canReceive, connectionWarn, connectPort, disconnectPort, distributeReply, enterProgModeDelayTime, 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, terminateThreads, transmitLoop, transmitWait, unexpectedReplyStateError, waitForStartOfReply, warnOnTimeout
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.jmrix.easydcc.EasyDccInterface
status
-
-
-
-
Field Detail
-
mMemo
EasyDccSystemConnectionMemo mMemo
Reference to the system connection memo.
-
-
Constructor Detail
-
EasyDccTrafficController
public EasyDccTrafficController(EasyDccSystemConnectionMemo adaptermemo)
Create a new EasyDccTrafficController instance.- Parameters:
adaptermemo- the associated SystemConnectionMemo
-
-
Method Detail
-
addEasyDccListener
public void addEasyDccListener(EasyDccListener l)
- Specified by:
addEasyDccListenerin interfaceEasyDccInterface
-
removeEasyDccListener
public void removeEasyDccListener(EasyDccListener l)
- Specified by:
removeEasyDccListenerin interfaceEasyDccInterface
-
forwardMessage
protected void forwardMessage(AbstractMRListener client, AbstractMRMessage m)
Forward an EasyDccMessage to all registered EasyDccInterface listeners.- Specified by:
forwardMessagein classAbstractMRTrafficController- Parameters:
client- abstract listener.m- message to forward.
-
forwardReply
protected void forwardReply(AbstractMRListener client, AbstractMRReply m)
Forward an EasyDccReply to all registered EasyDccInterface listeners.- Specified by:
forwardReplyin classAbstractMRTrafficController
-
setSensorManager
public void setSensorManager(SensorManager m)
-
pollMessage
protected AbstractMRMessage 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
protected AbstractMRListener pollReplyHandler()
- Specified by:
pollReplyHandlerin classAbstractMRTrafficController
-
sendEasyDccMessage
public void sendEasyDccMessage(EasyDccMessage m, EasyDccListener reply)
Forward a preformatted message to the actual interface.- Specified by:
sendEasyDccMessagein interfaceEasyDccInterface
-
enterProgMode
protected AbstractMRMessage enterProgMode()
Description copied from class:AbstractMRTrafficControllerSet the system to programming mode.- 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:
AbstractMRTrafficController.enterNormalMode()
-
enterNormalMode
protected AbstractMRMessage 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:
- 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()
-
getSystemConnectionMemo
public EasyDccSystemConnectionMemo getSystemConnectionMemo()
Get access to the system connection memo associated with this traffic controller.- Returns:
- associated systemConnectionMemo object
-
setSystemConnectionMemo
public void setSystemConnectionMemo(EasyDccSystemConnectionMemo m)
Set the system connection memo associated with this traffic controller.- Parameters:
m- associated systemConnectionMemo object
-
newReply
protected AbstractMRReply newReply()
- Specified by:
newReplyin classAbstractMRTrafficController
-
endOfMessage
protected boolean endOfMessage(AbstractMRReply msg)
- Specified by:
endOfMessagein classAbstractMRTrafficController
-
terminate
protected void terminate()
Don't send to-normal-mode message if in normal mode- Overrides:
terminatein classAbstractMRTrafficController
-
-