jmri.jmrix.direct
Class TrafficController

java.lang.Object
  extended by jmri.jmrix.direct.TrafficController
All Implemented Interfaces:
CommandStation

public class TrafficController
extends Object
implements CommandStation

Converts Stream-based I/O to/from NMRA packets and controls sending to the direct interface.

This is much simpler than many other "TrafficHandler" classes, because

This actually bears more similarity to a pure implementation of the CommandStation interface, which is where the real guts of it is. In particular, note that transmission is not a threaded operation.

Author:
Bob Jacobsen Copyright (C) 2001

Field Summary
protected  DataInputStream istream
           
protected  OutputStream ostream
           
 
Constructor Summary
TrafficController()
           
 
Method Summary
 void connectPort(AbstractSerialPortController p)
          Make connection to existing PortController object.
 void disconnectPort(AbstractSerialPortController p)
          Break connection to existing PortController object.
static TrafficController instance()
          static function returning the instance to use.
 void sendPacket(byte[] packet, int repeats)
          Send a specific packet to the rails.
protected  void setInstance()
           
 boolean status()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

istream

protected DataInputStream istream

ostream

protected OutputStream ostream
Constructor Detail

TrafficController

public TrafficController()
Method Detail

instance

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

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

setInstance

protected void setInstance()

sendPacket

public void sendPacket(byte[] packet,
                       int repeats)
Send a specific packet to the rails.

Specified by:
sendPacket in interface CommandStation
Parameters:
packet - Byte array representing the packet, including the error-correction byte. Must not be null.
repeats - Number of times to repeat the transmission, but is ignored in the current implementation

status

public boolean status()

connectPort

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


disconnectPort

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



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