jmri.jmrix.xpa
Class XpaTrafficController

java.lang.Object
  extended by jmri.jmrix.xpa.XpaTrafficController
All Implemented Interfaces:
Runnable, XpaInterface

public final class XpaTrafficController
extends Object
implements XpaInterface, Runnable

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

Author:
Paul Bender Copyright (C) 2004

Field Summary
protected  Vector<XpaListener> cmdListeners
           
protected static XpaTrafficController self
           
 
Constructor Summary
XpaTrafficController()
           
 
Method Summary
 void addXpaListener(XpaListener l)
           
 void connectPort(XpaPortController p)
          Make connection to existing PortController object.
 void disconnectPort(XpaPortController p)
          Break connection to existing XpaPortController object.
static XpaTrafficController instance()
          static function returning the XpaTrafficController instance to use.
protected  void notifyMessage(XpaMessage m, XpaListener notMe)
          Forward a XpaMessage to all registered XpaInterface listeners.
protected  void notifyReply(XpaMessage r)
           
 void removeXpaListener(XpaListener l)
           
 void run()
          Handle incoming characters.
 void sendXpaMessage(XpaMessage m, XpaListener reply)
          Forward a preformatted message to the actual interface.
 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<XpaListener> cmdListeners

self

protected static volatile XpaTrafficController self
Constructor Detail

XpaTrafficController

public XpaTrafficController()
Method Detail

status

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

Specified by:
status in interface XpaInterface
Returns:
true if the interface implementation is operational.

addXpaListener

public void addXpaListener(XpaListener l)
Specified by:
addXpaListener in interface XpaInterface

removeXpaListener

public void removeXpaListener(XpaListener l)
Specified by:
removeXpaListener in interface XpaInterface

notifyMessage

protected void notifyMessage(XpaMessage m,
                             XpaListener notMe)
Forward a XpaMessage to all registered XpaInterface listeners.


notifyReply

protected void notifyReply(XpaMessage r)

sendXpaMessage

public void sendXpaMessage(XpaMessage m,
                           XpaListener reply)
Forward a preformatted message to the actual interface.

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

connectPort

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


disconnectPort

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


instance

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

Returns:
The registered XpaTrafficController 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


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