Package jmri.jmrix.marklin
Class MarklinTrafficController
java.lang.Object
jmri.jmrix.AbstractMRTrafficController
jmri.jmrix.marklin.MarklinTrafficController
- All Implemented Interfaces:
CommandStation,MarklinInterface
- Direct Known Subclasses:
MarklinSimTrafficController
public class MarklinTrafficController
extends AbstractMRTrafficController
implements MarklinInterface, CommandStation
Converts Stream-based I/O to/from Marklin CS2 messages. The
"MarklinInterface" side sends/receives message objects.
The connection to a MarklinPortController is via a pair of UDP 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. Based on work by Bob Jacobsen
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier -
Field Summary
FieldsFields 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 TypeMethodDescriptionvoidvoidAs we have to poll the system to get updates we put request into a queue and allow the abstract traffic controller to handle them when it is free.protected booleanOverride in the system specific code if necessaryvoiddispose()protected booleanprotected AbstractMRMessageMarklin doesn't support this function.protected AbstractMRMessageMarklin doesn't support this function.protected intGet the delay (wait time) after enabling the programming track.protected voidforwardMessage(AbstractMRListener client, AbstractMRMessage m) Forward a MarklinMessage to all registered MarklinInterface listeners.protected voidforwardReply(AbstractMRListener client, AbstractMRReply r) Forward a MarklinReply to all registered MarklinInterface listeners.booleanprotected AbstractMRReplynewReply()protected AbstractMRMessageCheck Tams MC for updates.protected AbstractMRListenervoidvoidRemoves a message that is used for polling from the queue.voidsendMarklinMessage(MarklinMessage m, MarklinListener reply) Forward a preformatted message to the actual interface.booleansendPacket(byte[] packet, int count) CommandStation implementation, not yet supported.voidvoidsetPollQueueDisabled(boolean poll) Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, addTrailerToOutput, connectionWarn, connectPort, disconnectPort, distributeReply, 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, warnOnTimeoutMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jmri.CommandStation
sendAccSignalDecoderPkt, sendAltAccSignalDecoderPktMethods inherited from interface jmri.jmrix.marklin.MarklinInterface
status
-
Field Details
-
adaptermemo
-
defaultUserName
-
-
Constructor Details
-
MarklinTrafficController
public MarklinTrafficController()Create a new MarklinTrafficController instance.
-
-
Method Details
-
setAdapterMemo
-
addMarklinListener
- Specified by:
addMarklinListenerin interfaceMarklinInterface
-
removeMarklinListener
- Specified by:
removeMarklinListenerin interfaceMarklinInterface
-
enterProgModeDelayTime
Description copied from class:AbstractMRTrafficControllerGet the delay (wait time) after enabling the programming track. Override in subclass to add a longer delay.- Overrides:
enterProgModeDelayTimein classAbstractMRTrafficController- Returns:
- 0 as default delay
-
sendPacket
CommandStation implementation, not yet supported. Send a specific packet to the rails.- Specified by:
sendPacketin interfaceCommandStation- Parameters:
packet- Byte array representing the packet, including the error-correction byte.count- Number of times to repeat the transmission.- Returns:
trueif the operation succeeds,falseotherwise.
-
forwardMessage
Forward a MarklinMessage to all registered MarklinInterface listeners.- Specified by:
forwardMessagein classAbstractMRTrafficController- Parameters:
client- abstract listener.m- message to forward.
-
forwardReply
Forward a MarklinReply to all registered MarklinInterface listeners.- Specified by:
forwardReplyin classAbstractMRTrafficController
-
sendMarklinMessage
Forward a preformatted message to the actual interface. Send a message through the interface.- Specified by:
sendMarklinMessagein interfaceMarklinInterface- Parameters:
m- Message to be sent.reply- Listener to be notified of reply.
-
enterProgMode
Marklin doesn't support this function.- Specified by:
enterProgModein classAbstractMRTrafficController- Returns:
- empty Marklin Message.
- See Also:
-
enterNormalMode
Marklin doesn't support this function.- Specified by:
enterNormalModein classAbstractMRTrafficController- Returns:
- empty Marklin Message.
- See Also:
-
newReply
- Specified by:
newReplyin classAbstractMRTrafficController
-
canReceive
Description copied from class:AbstractMRTrafficControllerOverride in the system specific code if necessary- Overrides:
canReceivein classAbstractMRTrafficController- Returns:
- true if it is okay to buffer receive characters into a reply message. When false, discard char received
-
endOfMessage
- Specified by:
endOfMessagein classAbstractMRTrafficController
-
getPollQueueDisabled
-
setPollQueueDisabled
-
addPollMessage
As we have to poll the system to get updates we put request into a queue and allow the abstract traffic controller to handle them when it is free.- Parameters:
mm- marklin message to add.ml- marklin listener.
-
removePollMessage
Removes a message that is used for polling from the queue.- Parameters:
mm- marklin message to remove.ml- marklin listener.
-
pollMessage
Check Tams MC for updates.- Specified by:
pollMessagein classAbstractMRTrafficController- Returns:
- Formatted poll message
-
pollReplyHandler
- Specified by:
pollReplyHandlerin classAbstractMRTrafficController
-
getUserName
- Specified by:
getUserNamein interfaceCommandStation
-
getSystemPrefix
- Specified by:
getSystemPrefixin interfaceCommandStation
-
dispose
-