Package jmri.jmrix.mrc
Class MrcTrafficController
- java.lang.Object
-
- jmri.jmrix.mrc.MrcTrafficController
-
- All Implemented Interfaces:
MrcInterface
- Direct Known Subclasses:
MrcPacketizer
public abstract class MrcTrafficController extends java.lang.Object implements MrcInterface
Converts Stream-based I/O to/from MRC messages. The "MrcInterface" side sends/receives message objects.The connection to a MrcPortController 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 handles the state transitions, based on the necessary state in each message.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) MrcSystemConnectionMemo
adaptermemo
(package private) int
cabAddress
protected int
receivedByteCount
protected int
receivedMsgCount
protected java.util.Vector<MrcTrafficListenerFilter>
trafficListeners
protected int
transmittedMsgCount
-
Fields inherited from interface jmri.jmrix.mrc.MrcInterface
ALL, CLOCK, POLL, POWER, PROGRAMMING, SENSORS, THROTTLEINFO, TURNOUTS
-
-
Constructor Summary
Constructors Constructor Description MrcTrafficController()
Create a new MrcTrafficController instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addTrafficListener(int mask, MrcTrafficListener l)
void
changeTrafficListener(int mask, MrcTrafficListener l)
MrcSystemConnectionMemo
getAdapterMemo()
int
getCabNumber()
int
getReceivedByteCount()
Monitor the number of bytes in MRC messaages received across the interface.int
getReceivedMsgCount()
Monitor the number of MRC messaages received across the interface.java.lang.String
getSystemPrefix()
int
getTransmittedMsgCount()
Monitor the number of MRC messages transmitted across the interface.java.lang.String
getUserName()
abstract boolean
isXmtBusy()
Is there a backlog of information for the outbound link?void
notifyRcv(java.util.Date timestamp, MrcMessage m)
void
notifyXmit(java.util.Date timestamp, MrcMessage m)
void
removeTrafficListener(int mask, MrcTrafficListener l)
void
resetStatistics()
Reset statistics (received message count, transmitted message count, received byte count).abstract void
sendMrcMessage(MrcMessage m)
void
setAdapterMemo(MrcSystemConnectionMemo memo)
void
setCabNumber(int x)
abstract boolean
status()
-
-
-
Field Detail
-
cabAddress
int cabAddress
-
trafficListeners
protected java.util.Vector<MrcTrafficListenerFilter> trafficListeners
-
receivedMsgCount
protected int receivedMsgCount
-
receivedByteCount
protected int receivedByteCount
-
transmittedMsgCount
protected int transmittedMsgCount
-
adaptermemo
MrcSystemConnectionMemo adaptermemo
-
-
Constructor Detail
-
MrcTrafficController
public MrcTrafficController()
Create a new MrcTrafficController instance. Simple implementation.
-
-
Method Detail
-
setCabNumber
public void setCabNumber(int x)
-
getCabNumber
public int getCabNumber()
-
status
public abstract boolean status()
- Specified by:
status
in interfaceMrcInterface
-
sendMrcMessage
public abstract void sendMrcMessage(MrcMessage m)
- Specified by:
sendMrcMessage
in interfaceMrcInterface
-
addTrafficListener
public void addTrafficListener(int mask, MrcTrafficListener l)
- Specified by:
addTrafficListener
in interfaceMrcInterface
-
removeTrafficListener
public void removeTrafficListener(int mask, MrcTrafficListener l)
- Specified by:
removeTrafficListener
in interfaceMrcInterface
-
changeTrafficListener
public void changeTrafficListener(int mask, MrcTrafficListener l)
- Specified by:
changeTrafficListener
in interfaceMrcInterface
-
notifyRcv
public void notifyRcv(java.util.Date timestamp, MrcMessage m)
-
notifyXmit
public void notifyXmit(java.util.Date timestamp, MrcMessage m)
-
isXmtBusy
public abstract boolean isXmtBusy()
Is there a backlog of information for the outbound link? This includes both in the program (e.g. the outbound queue) and in the command station interface (e.g. flow control from the port).- Returns:
- true if busy, false if nothing waiting to send
-
resetStatistics
public void resetStatistics()
Reset statistics (received message count, transmitted message count, received byte count).
-
getReceivedMsgCount
public int getReceivedMsgCount()
Monitor the number of MRC messaages received across the interface. This includes the messages this client has sent.- Returns:
- count of messages received
-
getReceivedByteCount
public int getReceivedByteCount()
Monitor the number of bytes in MRC messaages received across the interface. This includes the messages this client has sent.- Returns:
- count of bytes in received messages
-
getTransmittedMsgCount
public int getTransmittedMsgCount()
Monitor the number of MRC messages transmitted across the interface.- Returns:
- count of messages sent
-
getAdapterMemo
public MrcSystemConnectionMemo getAdapterMemo()
-
setAdapterMemo
public void setAdapterMemo(MrcSystemConnectionMemo memo)
-
getUserName
public java.lang.String getUserName()
-
getSystemPrefix
public java.lang.String getSystemPrefix()
-
-