jmri.jmrix.powerline
Class SerialTrafficController

java.lang.Object
  extended by jmri.jmrix.AbstractMRTrafficController
      extended by jmri.jmrix.powerline.SerialTrafficController
All Implemented Interfaces:
SerialInterface
Direct Known Subclasses:
SpecificTrafficController, SpecificTrafficController

public class SerialTrafficController
extends AbstractMRTrafficController
implements SerialInterface

Converts Stream-based I/O to/from messages. The "SerialInterface" side sends/receives message objects.

The connection to a SerialPortController 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 maintains a list of nodes, but doesn't currently do anything with it.

This implementation is complete and can be instantiated, but is not functional. It will be created e.g. when a default object is needed for configuring nodes, etc, during the initial configuration. A subclass must be instantiated to actually communicate with an adapter.

Author:
Bob Jacobsen Copyright (C) 2001, 2003, 2005, 2006, 2008

Nested Class Summary
 
Nested classes/interfaces inherited from class jmri.jmrix.AbstractMRTrafficController
AbstractMRTrafficController.RcvNotifier, AbstractMRTrafficController.XmtNotifier
 
Field Summary
protected  boolean logDebug
           
protected static SerialTrafficController self
           
 
Fields inherited from class jmri.jmrix.AbstractMRTrafficController
allowUnexpectedReply, cmdListeners, controller, flushReceiveChars, IDLESTATE, istream, mCurrentMode, mCurrentState, mLastSender, mWaitBeforePoll, NORMALMODE, NOTIFIEDSTATE, OKSENDMSGSTATE, ostream, PROGRAMINGMODE, replyInDispatch, WAITMSGREPLYSTATE, WAITREPLYINNORMMODESTATE, WAITREPLYINPROGMODESTATE, xmtRunnable
 
Constructor Summary
SerialTrafficController()
           
 
Method Summary
 void addSerialListener(SerialListener l)
           
static void checkInstance(SerialTrafficController tc)
           
 void deleteSerialNode(int nodeAddress)
          Public method to delete a Serial node by node address
protected  boolean endOfMessage(AbstractMRReply msg)
           This is a default, null implementation, which must be overridden in an adapter-specific subclass.
protected  AbstractMRMessage enterNormalMode()
           
protected  AbstractMRMessage enterProgMode()
           
protected  int enterProgModeDelayTime()
           
protected  void forwardMessage(AbstractMRListener client, AbstractMRMessage m)
          Forward a SerialMessage to all registered SerialInterface listeners.
protected  void forwardReply(AbstractMRListener client, AbstractMRReply r)
          Forward a reply to all registered SerialInterface listeners.
protected  void forwardToPort(AbstractMRMessage m, AbstractMRListener reply)
          Actually transmits the next message to the port
 SerialNode getNodeFromAddress(int addr)
          Public method to identify a SerialNode from its node address Note: 'addr' is the node address, numbered from 0.
 SerialSensorManager getSensorManager()
           
 SerialMessage getSerialMessage(int length)
          Get a message of a specific length for filling in.
 SerialNode getSerialNode(int index)
          Public method to return the Serial node with a given index Note: To cycle through all nodes, begin with index=0, and increment your index at each call.
 void initializeSerialNode(SerialNode node)
          Public method to set up for initialization of a Serial node
protected  void initNodes()
           
static SerialTrafficController instance()
          static function returning the SerialTrafficController instance to use.
 int maxX10DimStep()
          Provide the maximum number of dimming steps available.
protected  AbstractMRReply newReply()
           This is a default, null implementation, which must be overridden in an adapter-specific subclass.
protected  AbstractMRMessage pollMessage()
          Eventually, do initialization if needed
protected  AbstractMRListener pollReplyHandler()
           
 void registerSerialNode(SerialNode node)
          Public method to register a Serial node
 void removeSerialListener(SerialListener l)
           
 void sendSerialMessage(SerialMessage m, SerialListener reply)
          Forward a preformatted message to the actual interface.
 void sendX10Sequence(X10Sequence s, SerialListener l)
          Send a sequence of X10 messages to an adapter.
protected  void setInstance()
           
 void setSensorManager(SerialSensorManager m)
           
 
Methods inherited from class jmri.jmrix.AbstractMRTrafficController
addHeaderToOutput, addListener, addTrailerToOutput, canReceive, connectionWarn, connectPort, disconnectPort, finalize, getPortName, handleOneIncomingReply, handleTimeout, hasTimeouts, lengthOfByteStream, loadChars, newRcvNotifier, notifyMessage, notifyReply, portReadyToSend, portWarn, programmerIdle, readByteProtected, receiveLoop, removeListener, reportReceiveLoopException, resetTimeout, sendMessage, setAllowUnexpectedReply, status, waitForStartOfReply
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface jmri.jmrix.powerline.SerialInterface
status
 

Field Detail

logDebug

protected boolean logDebug

self

protected static SerialTrafficController self
Constructor Detail

SerialTrafficController

public SerialTrafficController()
Method Detail

initNodes

protected void initNodes()

sendX10Sequence

public void sendX10Sequence(X10Sequence s,
                            SerialListener l)
Send a sequence of X10 messages to an adapter.

Makes them into the local messages and then queues in order.

This is a default, null implementation, which must be overridden in an adapter-specific subclass.


maxX10DimStep

public int maxX10DimStep()
Provide the maximum number of dimming steps available.

Returns:
By default, dimming not available.

getSerialMessage

public SerialMessage getSerialMessage(int length)
Get a message of a specific length for filling in.

This is a default, null implementation, which must be overridden in an adapter-specific subclass.


registerSerialNode

public void registerSerialNode(SerialNode node)
Public method to register a Serial node


initializeSerialNode

public void initializeSerialNode(SerialNode node)
Public method to set up for initialization of a Serial node


getNodeFromAddress

public SerialNode getNodeFromAddress(int addr)
Public method to identify a SerialNode from its node address Note: 'addr' is the node address, numbered from 0. Returns 'null' if a SerialNode with the specified address was not found


deleteSerialNode

public void deleteSerialNode(int nodeAddress)
Public method to delete a Serial node by node address


getSerialNode

public SerialNode getSerialNode(int index)
Public method to return the Serial node with a given index Note: To cycle through all nodes, begin with index=0, and increment your index at each call. When index exceeds the number of defined nodes, this routine returns 'null'.


addSerialListener

public void addSerialListener(SerialListener l)
Specified by:
addSerialListener in interface SerialInterface

removeSerialListener

public void removeSerialListener(SerialListener l)
Specified by:
removeSerialListener in interface SerialInterface

enterProgModeDelayTime

protected int enterProgModeDelayTime()
Overrides:
enterProgModeDelayTime in class AbstractMRTrafficController

forwardMessage

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

Specified by:
forwardMessage in class AbstractMRTrafficController

forwardReply

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

Specified by:
forwardReply in class AbstractMRTrafficController

setSensorManager

public void setSensorManager(SerialSensorManager m)

getSensorManager

public SerialSensorManager getSensorManager()

pollMessage

protected AbstractMRMessage pollMessage()
Eventually, do initialization if needed

Specified by:
pollMessage in class AbstractMRTrafficController

pollReplyHandler

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

sendSerialMessage

public void sendSerialMessage(SerialMessage m,
                              SerialListener reply)
Forward a preformatted message to the actual interface.

Specified by:
sendSerialMessage in interface SerialInterface

forwardToPort

protected void forwardToPort(AbstractMRMessage m,
                             AbstractMRListener reply)
Description copied from class: AbstractMRTrafficController
Actually transmits the next message to the port

Overrides:
forwardToPort in class AbstractMRTrafficController

enterProgMode

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

enterNormalMode

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

instance

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

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

setInstance

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

checkInstance

public static void checkInstance(SerialTrafficController tc)

endOfMessage

protected boolean endOfMessage(AbstractMRReply msg)

This is a default, null implementation, which must be overridden in an adapter-specific subclass.

Specified by:
endOfMessage in class AbstractMRTrafficController

newReply

protected AbstractMRReply newReply()

This is a default, null implementation, which must be overridden in an adapter-specific subclass.

Specified by:
newReply in class AbstractMRTrafficController


Copyright © 1997 - 2008 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: SourceForge_Logo