jmri.jmrix.qsi
Class QsiTrafficController

Show UML class diagram
java.lang.Object
  extended by jmri.jmrix.qsi.QsiTrafficController
All Implemented Interfaces:
Runnable, QsiInterface

public class QsiTrafficController
extends Object
implements QsiInterface, Runnable

Converts Stream-based I/O to/from QSI messages. The "QsiInterface" side sends/receives message objects. The connection to a QsiPortController is via a pair of *Streams, which then carry sequences of characters for transmission. Note that this processing is handled in an independent thread.

Messages to and from the programmer are in a packet format. In both directions, every message starts with 'S' and ends with 'E'. These are handled automatically, and are not included in the QsiMessage and QsiReply content.


Field Summary
protected  Vector<QsiListener> cmdListeners
           
(package private)  DataInputStream istream
           
(package private)  QsiListener lastSender
           
(package private) static org.slf4j.Logger log
           
static int NORMAL
           
(package private)  OutputStream ostream
           
protected static QsiTrafficController self
           
static int SIIBOOTMODE
           
static int V4BOOTMODE
           
 
Constructor Summary
QsiTrafficController()
           
 
Method Summary
 void addQsiListener(QsiListener l)
           
 void connectPort(QsiPortController p)
          Make connection to existing PortController object.
 void disconnectPort(QsiPortController p)
          Break connection to existing QsiPortController object.
(package private)  boolean endNormalReply(QsiReply msg)
           
(package private)  boolean endReply(QsiReply msg)
           
 int getQsiState()
           
(package private)  void handleOneIncomingReply()
           
static QsiTrafficController instance()
          static function returning the QsiTrafficController instance to use.
 boolean isNormalMode()
           
 boolean isSIIBootMode()
           
 boolean isV4BootMode()
           
protected  void notifyMessage(QsiMessage m, QsiListener notMe)
          Forward a QsiMessage to all registered QsiInterface listeners.
protected  void notifyReply(QsiReply r)
           
 void removeQsiListener(QsiListener l)
           
 void run()
          Handle incoming characters.
 void sendQsiMessage(QsiMessage m, QsiListener reply)
          Forward a preformatted message to the actual interface.
 void setQsiState(int s)
           
 boolean status()
          Test operational status of interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cmdListeners

protected Vector<QsiListener> cmdListeners

lastSender

QsiListener lastSender

NORMAL

public static final int NORMAL
See Also:
Constant Field Values

SIIBOOTMODE

public static final int SIIBOOTMODE
See Also:
Constant Field Values

V4BOOTMODE

public static final int V4BOOTMODE
See Also:
Constant Field Values

self

protected static volatile QsiTrafficController self

istream

DataInputStream istream

ostream

OutputStream ostream

log

static org.slf4j.Logger log
Constructor Detail

QsiTrafficController

public QsiTrafficController()
Method Detail

status

public boolean status()
Description copied from interface: QsiInterface
Test operational status of interface.

Specified by:
status in interface QsiInterface
Returns:
true is interface implementation is operational.

addQsiListener

public void addQsiListener(QsiListener l)
Specified by:
addQsiListener in interface QsiInterface

removeQsiListener

public void removeQsiListener(QsiListener l)
Specified by:
removeQsiListener in interface QsiInterface

notifyMessage

protected void notifyMessage(QsiMessage m,
                             QsiListener notMe)
Forward a QsiMessage to all registered QsiInterface listeners.


getQsiState

public int getQsiState()

setQsiState

public void setQsiState(int s)

isNormalMode

public boolean isNormalMode()

isSIIBootMode

public boolean isSIIBootMode()

isV4BootMode

public boolean isV4BootMode()

notifyReply

protected void notifyReply(QsiReply r)

sendQsiMessage

public void sendQsiMessage(QsiMessage m,
                           QsiListener reply)
Forward a preformatted message to the actual interface.

Specified by:
sendQsiMessage in interface QsiInterface
Parameters:
m - Message to be sent.
reply - Listener to be notified of reply.

connectPort

public void connectPort(QsiPortController p)
Make connection to existing PortController object.


disconnectPort

public void disconnectPort(QsiPortController p)
Break connection to existing QsiPortController object. Once broken, attempts to send via "message" member will fail.


instance

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

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

run

public void run()
Handle incoming characters. This is a permanent loop, looking for input messages in character form on the stream connected to the PortController via connectPort. Terminates with the input stream breaking out of the try block.

Specified by:
run in interface Runnable

handleOneIncomingReply

void handleOneIncomingReply()
                      throws IOException
Throws:
IOException

endReply

boolean endReply(QsiReply msg)

endNormalReply

boolean endNormalReply(QsiReply msg)


Copyright © 1997-2013 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