Package jmri.jmrix.direct
Class TrafficController
- java.lang.Object
-
- jmri.jmrix.direct.TrafficController
-
- All Implemented Interfaces:
CommandStation
public class TrafficController extends java.lang.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
- It's not handling mode information, or even any information back from the device; it's just sending.
- It can work with the direct packets.
-
-
Constructor Summary
Constructors Constructor Description TrafficController(DirectSystemConnectionMemo memo)
Create a new Direct TrafficController instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
connectPort(AbstractSerialPortController p)
Make connection to existing PortController object.void
disconnectPort(AbstractSerialPortController p)
Break connection to existing PortController object.java.lang.String
getSystemPrefix()
java.lang.String
getUserName()
boolean
sendPacket(byte[] packet, int repeats)
Send a specific packet to the rails.boolean
status()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.CommandStation
sendAccSignalDecoderPkt, sendAltAccSignalDecoderPkt
-
-
-
-
Constructor Detail
-
TrafficController
public TrafficController(DirectSystemConnectionMemo memo)
Create a new Direct TrafficController instance.- Parameters:
memo
- system connection.
-
-
Method Detail
-
sendPacket
public boolean sendPacket(byte[] packet, int repeats)
Send a specific packet to the rails.- Specified by:
sendPacket
in interfaceCommandStation
- 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- Returns:
true
if the operation succeeds,false
otherwise.
-
status
public boolean status()
-
connectPort
public void connectPort(AbstractSerialPortController p)
Make connection to existing PortController object.- Parameters:
p
- the controller to connect to
-
disconnectPort
public void disconnectPort(AbstractSerialPortController p)
Break connection to existing PortController object. Once broken, attempts to send via "message" member will fail.- Parameters:
p
- the controller to disconnect from
-
getUserName
public java.lang.String getUserName()
- Specified by:
getUserName
in interfaceCommandStation
-
getSystemPrefix
public java.lang.String getSystemPrefix()
- Specified by:
getSystemPrefix
in interfaceCommandStation
-
-