Package jmri.jmrix.can.adapters.loopback
Class LoopbackTrafficController
- java.lang.Object
-
- jmri.jmrix.AbstractMRTrafficController
-
- jmri.jmrix.can.AbstractCanTrafficController
-
- jmri.jmrix.can.TrafficController
-
- jmri.jmrix.can.adapters.loopback.LoopbackTrafficController
-
- All Implemented Interfaces:
CanInterface
public class LoopbackTrafficController extends TrafficController
Traffic controller for loopback CAN simulation.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier
-
-
Field Summary
Fields Modifier and Type Field Description protected CanSystemConnectionMemo
adaptermemo
-
Fields inherited from class jmri.jmrix.can.TrafficController
_canid
-
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 LoopbackTrafficController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addTrailerToOutput(byte[] msg, int offset, AbstractMRMessage m)
Add trailer to the outgoing byte stream.CanReply
decodeFromHardware(AbstractMRReply m)
Make a CanReply from a system-specific reply.AbstractMRMessage
encodeForHardware(CanMessage m)
Encode a CanMessage for the hardware.protected boolean
endOfMessage(AbstractMRReply r)
Dummy; loopback doesn't parse serial messages.protected void
forwardMessage(AbstractMRListener client, AbstractMRMessage m)
Forward a CanMessage to all registered CanInterface listeners.protected void
forwardReply(AbstractMRListener client, AbstractMRReply r)
Forward a CanReply to all registered CanInterface listeners.boolean
isBootMode()
protected int
lengthOfByteStream(AbstractMRMessage m)
Determine how many bytes the entire message will take, including space for header and trailerprotected AbstractMRMessage
newMessage()
Get the correct concrete class for the hardware connection messageprotected AbstractMRReply
newReply()
void
sendCanMessage(CanMessage m, CanListener reply)
Forward a preformatted message to the actual interface.void
sendCanReply(CanReply r, CanListener reply)
Forward a preformatted reply to the actual interface.-
Methods inherited from class jmri.jmrix.can.TrafficController
getCanid, setCanId
-
Methods inherited from class jmri.jmrix.can.AbstractCanTrafficController
addCanConsoleListener, addCanListener, distributeOneReply, enterNormalMode, enterProgMode, forwardToPort, handleOneIncomingReply, pollMessage, pollReplyHandler, removeCanListener
-
Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addConsoleListener, addHeaderToOutput, addListener, canReceive, connectionWarn, connectPort, disconnectPort, distributeReply, enterProgModeDelayTime, getLastSender, getPortName, getSynchronizeRx, handleTimeout, hasTimeouts, loadChars, newRcvNotifier, 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
status
-
-
-
-
Field Detail
-
adaptermemo
protected CanSystemConnectionMemo adaptermemo
-
-
Constructor Detail
-
LoopbackTrafficController
public LoopbackTrafficController()
-
-
Method Detail
-
forwardMessage
protected void forwardMessage(AbstractMRListener client, AbstractMRMessage m)
Forward a CanMessage to all registered CanInterface listeners. Implement this to forward a specific message type to a protocol-specific listener interface. This puts the casting into the concrete class.- Specified by:
forwardMessage
in classAbstractMRTrafficController
- Parameters:
client
- abstract listener.m
- message to forward.
-
forwardReply
protected void forwardReply(AbstractMRListener client, AbstractMRReply r)
Forward a CanReply to all registered CanInterface listeners.- Specified by:
forwardReply
in classAbstractMRTrafficController
-
isBootMode
public boolean isBootMode()
-
sendCanMessage
public void sendCanMessage(CanMessage m, CanListener reply)
Forward a preformatted message to the actual interface. Send a message through the interface.- Parameters:
m
- Message to be sent.reply
- Listener to be notified of reply.
-
sendCanReply
public void sendCanReply(CanReply r, CanListener reply)
Forward a preformatted reply to the actual interface. Send a reply through the interface.- Parameters:
r
- Reply to be sent.reply
- Listener to be notified of reply.
-
addTrailerToOutput
protected void addTrailerToOutput(byte[] msg, int offset, AbstractMRMessage m)
Add trailer to the outgoing byte stream.- Overrides:
addTrailerToOutput
in classAbstractMRTrafficController
- Parameters:
msg
- The output byte streamoffset
- the first byte not yet usedm
- output message to extend
-
lengthOfByteStream
protected int lengthOfByteStream(AbstractMRMessage m)
Determine how many bytes the entire message will take, including space for header and trailer- Overrides:
lengthOfByteStream
in classAbstractMRTrafficController
- Parameters:
m
- The message to be sent- Returns:
- Number of bytes
-
newMessage
protected AbstractMRMessage newMessage()
Description copied from class:AbstractCanTrafficController
Get the correct concrete class for the hardware connection message- Specified by:
newMessage
in classAbstractCanTrafficController
- Returns:
- new blank message
-
decodeFromHardware
public CanReply decodeFromHardware(AbstractMRReply m)
Make a CanReply from a system-specific reply. loop back returns null.- Specified by:
decodeFromHardware
in classAbstractCanTrafficController
-
encodeForHardware
public AbstractMRMessage encodeForHardware(CanMessage m)
Encode a CanMessage for the hardware. loop back returns null.- Specified by:
encodeForHardware
in classAbstractCanTrafficController
-
newReply
protected AbstractMRReply newReply()
- Specified by:
newReply
in classAbstractMRTrafficController
-
endOfMessage
protected boolean endOfMessage(AbstractMRReply r)
Dummy; loopback doesn't parse serial messages.- Specified by:
endOfMessage
in classAbstractMRTrafficController
-
-