jmri.jmrix.easydcc
Class EasyDccTrafficController

java.lang.Object
  extended by jmri.jmrix.AbstractMRTrafficController
      extended by jmri.jmrix.easydcc.EasyDccTrafficController
All Implemented Interfaces:
EasyDccInterface

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 transistions, based on the necessary state in each message.

Author:
Bob Jacobsen Copyright (C) 2001

Nested Class Summary
 
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier
 
Field Summary
protected static EasyDccTrafficController 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
EasyDccTrafficController()
           
 
Method Summary
 void addEasyDccListener(EasyDccListener l)
           
protected  boolean endOfMessage(AbstractMRReply msg)
           
protected  AbstractMRMessage enterNormalMode()
           
protected  AbstractMRMessage enterProgMode()
           
protected  void forwardMessage(AbstractMRListener client, AbstractMRMessage m)
          Forward a EasyDccMessage to all registered EasyDccInterface listeners.
protected  void forwardReply(AbstractMRListener client, AbstractMRReply m)
          Forward a EasyDccReply to all registered EasyDccInterface listeners.
static EasyDccTrafficController instance()
          static function returning the EasyDccTrafficController instance to use.
protected  AbstractMRReply newReply()
           
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 TC should just sleep.
protected  AbstractMRListener pollReplyHandler()
           
 void removeEasyDccListener(EasyDccListener l)
           
 void sendEasyDccMessage(EasyDccMessage m, EasyDccListener reply)
          Forward a preformatted message to the actual interface.
protected  void setInstance()
           
 void setSensorManager(SensorManager m)
           
 
Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addHeaderToOutput, addListener, addTrailerToOutput, canReceive, connectionWarn, connectPort, disconnectPort, enterProgModeDelayTime, finalize, forwardToPort, getLastSender, getPortName, getSelfLock, handleOneIncomingReply, handleTimeout, hasTimeouts, lengthOfByteStream, 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.easydcc.EasyDccInterface
status
 

Field Detail

self

protected static volatile EasyDccTrafficController self
Constructor Detail

EasyDccTrafficController

public EasyDccTrafficController()
Method Detail

addEasyDccListener

public void addEasyDccListener(EasyDccListener l)
Specified by:
addEasyDccListener in interface EasyDccInterface

removeEasyDccListener

public void removeEasyDccListener(EasyDccListener l)
Specified by:
removeEasyDccListener in interface EasyDccInterface

forwardMessage

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

Specified by:
forwardMessage in class AbstractMRTrafficController

forwardReply

protected void forwardReply(AbstractMRListener client,
                            AbstractMRReply m)
Forward a EasyDccReply to all registered EasyDccInterface listeners.

Specified by:
forwardReply in class AbstractMRTrafficController

setSensorManager

public void setSensorManager(SensorManager m)

pollMessage

protected AbstractMRMessage pollMessage()
Description copied from class: AbstractMRTrafficController
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 TC should just sleep.

Specified by:
pollMessage in class AbstractMRTrafficController

pollReplyHandler

protected AbstractMRListener pollReplyHandler()
Specified by:
pollReplyHandler in class AbstractMRTrafficController

sendEasyDccMessage

public void sendEasyDccMessage(EasyDccMessage m,
                               EasyDccListener reply)
Forward a preformatted message to the actual interface.

Specified by:
sendEasyDccMessage in interface EasyDccInterface

enterProgMode

protected AbstractMRMessage enterProgMode()
Specified by:
enterProgMode in class AbstractMRTrafficController

enterNormalMode

protected AbstractMRMessage enterNormalMode()
Specified by:
enterNormalMode in class AbstractMRTrafficController

instance

public static EasyDccTrafficController instance()
static function returning the EasyDccTrafficController instance to use.

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

setInstance

protected void setInstance()
Specified by:
setInstance in class AbstractMRTrafficController

newReply

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

endOfMessage

protected boolean endOfMessage(AbstractMRReply msg)
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