Package jmri.jmrix.can
Class AbstractCanTrafficController
- java.lang.Object
-
- jmri.jmrix.AbstractMRTrafficController
-
- jmri.jmrix.can.AbstractCanTrafficController
-
- All Implemented Interfaces:
CanInterface
- Direct Known Subclasses:
TrafficController
public abstract class AbstractCanTrafficController extends AbstractMRTrafficController implements CanInterface
Abstract base for TrafficControllers in a CANbus based Message/Reply protocol.AbstractMRTrafficController is extended to allow for the translation between CAN messages and the message format of the CAN adapter that connects to the layout.
-
-
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 Constructor Description AbstractCanTrafficController()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addCanConsoleListener(CanListener l)
Add a CanListener to start of the notification list.void
addCanListener(CanListener l)
abstract CanReply
decodeFromHardware(AbstractMRReply m)
void
distributeOneReply(CanReply msg, AbstractMRListener mLastSender)
abstract AbstractMRMessage
encodeForHardware(CanMessage m)
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
forwardToPort(AbstractMRMessage m, AbstractMRListener reply)
Actually transmits the next message to the port Overridden to include translation to the correct CAN hardware message format Actually transmit the next message to the port.void
handleOneIncomingReply()
Handle each reply when complete.protected abstract AbstractMRMessage
newMessage()
Get the correct concrete class for the hardware connection messageprotected 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()
Always nullvoid
removeCanListener(CanListener l)
-
Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, addTrailerToOutput, canReceive, connectionWarn, connectPort, disconnectPort, distributeReply, endOfMessage, enterProgModeDelayTime, forwardMessage, forwardReply, getLastSender, getPortName, getSynchronizeRx, handleTimeout, hasTimeouts, lengthOfByteStream, loadChars, newRcvNotifier, newReply, notifyMessage, notifyReply, portReadyToSend, portWarn, portWarnTCP, programmerIdle, readByteProtected, receiveLoop, recovery, removeListener, reportReceiveLoopException, resetTimeout, sendMessage, setAllowUnexpectedReply, setSynchronizeRx, status, terminate, 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.can.CanInterface
sendCanMessage, sendCanReply, status
-
-
-
-
Constructor Detail
-
AbstractCanTrafficController
public AbstractCanTrafficController()
-
-
Method Detail
-
addCanListener
public void addCanListener(CanListener l)
- Specified by:
addCanListener
in interfaceCanInterface
-
addCanConsoleListener
public void addCanConsoleListener(CanListener l)
Add a CanListener to start of the notification list. This is intended only for Consoles to receive the CanFrame 1st, not after another Listener has sent a response to that Frame.- Parameters:
l
- The CanListener to add.
-
removeCanListener
public void removeCanListener(CanListener l)
- Specified by:
removeCanListener
in interfaceCanInterface
-
forwardToPort
protected void forwardToPort(AbstractMRMessage m, AbstractMRListener reply)
Actually transmits the next message to the port Overridden to include translation to the correct CAN hardware message format Actually transmit the next message to the port.- Overrides:
forwardToPort
in classAbstractMRTrafficController
- Parameters:
m
- the message to sendreply
- the Listener sending the message, often provided as 'this'- See Also:
AbstractMRTrafficController.sendMessage(AbstractMRMessage, AbstractMRListener)
-
pollMessage
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. Always null- Specified by:
pollMessage
in classAbstractMRTrafficController
- Returns:
- Formatted poll message
-
pollReplyHandler
protected AbstractMRListener pollReplyHandler()
Always null- Specified by:
pollReplyHandler
in classAbstractMRTrafficController
-
enterProgMode
protected AbstractMRMessage enterProgMode()
Set the system to programming mode. Always null- 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
protected AbstractMRMessage enterNormalMode()
Sets the system to normal mode during programming while in IDLESTATE. IfAbstractMRTrafficController.programmerIdle()
returns true, enterNormalMode() is called after a timeout. Always null- 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()
-
newMessage
protected abstract AbstractMRMessage newMessage()
Get the correct concrete class for the hardware connection message- Returns:
- new blank message
-
decodeFromHardware
public abstract CanReply decodeFromHardware(AbstractMRReply m)
-
encodeForHardware
public abstract AbstractMRMessage encodeForHardware(CanMessage m)
-
handleOneIncomingReply
public void handleOneIncomingReply() throws java.io.IOException
Handle each reply when complete.Overridden to include translation form the CAN hardware format
- Overrides:
handleOneIncomingReply
in classAbstractMRTrafficController
- Throws:
java.io.IOException
- on error.
-
distributeOneReply
public void distributeOneReply(CanReply msg, AbstractMRListener mLastSender)
-
-