jmri.jmrix.can.adapters.loopback
Class LoopbackTrafficController

java.lang.Object
  extended by jmri.jmrix.AbstractMRTrafficController
      extended by jmri.jmrix.can.AbstractCanTrafficController
          extended by jmri.jmrix.can.TrafficController
              extended by jmri.jmrix.can.adapters.loopback.LoopbackTrafficController
All Implemented Interfaces:
CanInterface

public class LoopbackTrafficController
extends TrafficController

Traffic controller for loopback CAN simulation.

Author:
Bob Jacobsen Copyright (C) 2008

Nested Class Summary
 
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier
 
Field Summary
 
Fields inherited from class jmri.jmrix.can.TrafficController
_canid, self
 
Fields inherited from class jmri.jmrix.AbstractMRTrafficController
allowUnexpectedReply, AUTORETRYSTATE, cmdListeners, controller, flushReceiveChars, IDLESTATE, istream, mCurrentMode, mCurrentState, mLastSender, mWaitBeforePoll, NORMALMODE, NOTIFIEDSTATE, OKSENDMSGSTATE, ostream, POLLSTATE, PROGRAMINGMODE, rcvException, replyInDispatch, WAITMSGREPLYSTATE, WAITREPLYINNORMMODESTATE, WAITREPLYINPROGMODESTATE, waitTimePoll, xmtException, xmtRunnable
 
Constructor Summary
LoopbackTrafficController()
           
 
Method Summary
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)
           
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.
static TrafficController instance()
          static function returning the CanTrafficController instance to use.
 boolean isBootMode()
           
protected  int lengthOfByteStream(AbstractMRMessage m)
          Determine how much many bytes the entire message will take, including space for header and trailer
protected  AbstractMRMessage newMessage()
          Get the correct concrete class for the hardware connection message
protected  AbstractMRReply newReply()
           
 void sendCanMessage(CanMessage m, CanListener reply)
          Forward a preformatted message to the actual interface.
 
Methods inherited from class jmri.jmrix.can.TrafficController
getCanid, setInstance
 
Methods inherited from class jmri.jmrix.can.AbstractCanTrafficController
addCanListener, enterNormalMode, enterProgMode, forwardToPort, handleOneIncomingReply, pollMessage, pollReplyHandler, removeCanListener
 
Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addHeaderToOutput, addListener, canReceive, connectionWarn, connectPort, disconnectPort, enterProgModeDelayTime, finalize, getLastSender, getPortName, getSelfLock, handleTimeout, hasTimeouts, loadChars, newRcvNotifier, notifyMessage, notifyReply, portReadyToSend, portWarn, portWarnTCP, programmerIdle, readByteProtected, receiveLoop, removeListener, reportReceiveLoopException, resetTimeout, sendMessage, setAllowUnexpectedReply, status, terminate, transmitWait, waitForStartOfReply
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.jmrix.can.CanInterface
status
 

Constructor Detail

LoopbackTrafficController

public LoopbackTrafficController()
Method Detail

forwardMessage

protected void forwardMessage(AbstractMRListener client,
                              AbstractMRMessage m)
Forward a CanMessage to all registered CanInterface listeners.

Specified by:
forwardMessage in class AbstractMRTrafficController

forwardReply

protected void forwardReply(AbstractMRListener client,
                            AbstractMRReply r)
Forward a CanReply to all registered CanInterface listeners.

Specified by:
forwardReply in class AbstractMRTrafficController

isBootMode

public boolean isBootMode()

sendCanMessage

public void sendCanMessage(CanMessage m,
                           CanListener reply)
Forward a preformatted message to the actual interface.

Parameters:
m - Message 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 class AbstractMRTrafficController
Parameters:
msg - The output byte stream
offset - the first byte not yet used

lengthOfByteStream

protected int lengthOfByteStream(AbstractMRMessage m)
Determine how much many bytes the entire message will take, including space for header and trailer

Overrides:
lengthOfByteStream in class AbstractMRTrafficController
Parameters:
m - The message to be sent
Returns:
Number of bytes

instance

public static TrafficController instance()
static function returning the CanTrafficController instance to use.

Returns:
The registered SprogTrafficController instance for general use, if need be creating one.

newMessage

protected AbstractMRMessage newMessage()
Description copied from class: AbstractCanTrafficController
Get the correct concrete class for the hardware connection message

Specified by:
newMessage in class AbstractCanTrafficController

decodeFromHardware

public CanReply decodeFromHardware(AbstractMRReply m)
Make a CanReply from a system-specific reply

Specified by:
decodeFromHardware in class AbstractCanTrafficController

encodeForHardware

public AbstractMRMessage encodeForHardware(CanMessage m)
Encode a CanMessage for the hardware

Specified by:
encodeForHardware in class AbstractCanTrafficController

newReply

protected AbstractMRReply newReply()
Specified by:
newReply in class AbstractMRTrafficController

endOfMessage

protected boolean endOfMessage(AbstractMRReply r)
Specified by:
endOfMessage in class AbstractMRTrafficController


Copyright © 1997 - 2011 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads