jmri.jmrix.loconet
Class LnTrafficController

Show UML class diagram
java.lang.Object
  extended by jmri.jmrix.loconet.LnTrafficController
All Implemented Interfaces:
LocoNetInterface
Direct Known Subclasses:
LnPacketizer, LnTrafficRouter

public abstract class LnTrafficController
extends Object
implements LocoNetInterface

Abstract base class for implementations of LocoNetInterface.

This provides just the basic interface, plus the "" static method for locating the local implementation and some statistics support.


Field Summary
protected  Vector<LocoNetListener> listeners
           
(package private) static org.slf4j.Logger log
           
protected  int receivedByteCount
           
protected  int receivedMsgCount
           
protected static LnTrafficController self
           
protected  Vector<LnTrafficListenerFilter> trafficListeners
           
protected  int transmittedMsgCount
           
 
Fields inherited from interface jmri.jmrix.loconet.LocoNetInterface
ALL, POWER, PROGRAMMING, SENSORS, SLOTINFO, TURNOUTS
 
Constructor Summary
LnTrafficController()
           
 
Method Summary
 void addLocoNetListener(int mask, LocoNetListener l)
          Request notification of things happening on the LocoNet.
 void addTrafficListener(int mask, LnTrafficListener l)
           
 void changeTrafficListener(int mask, LnTrafficListener l)
           
 int getReceivedByteCount()
          Monitor the number of bytes in LocoNet messaages received across the interface.
 int getReceivedMsgCount()
          Monitor the number of LocoNet messaages received across the interface.
 int getTransmittedMsgCount()
          Monitor the number of LocoNet messaages transmitted across the interface.
static LnTrafficController instance()
          Deprecated. 2.13.4
abstract  boolean isXmtBusy()
          Is there a backlog of information for the outbound link?
 void notify(LocoNetMessage m)
          Forward a LocoNetMessage to all registered listeners.
 void notifyRcv(Date timestamp, LocoNetMessage m)
           
 void notifyXmit(Date timestamp, LocoNetMessage m)
           
 void removeLocoNetListener(int mask, LocoNetListener l)
           
 void removeTrafficListener(int mask, LnTrafficListener l)
           
 void resetStatistics()
          Reset statistics (received message count, transmitted message count, received byte count)
abstract  void sendLocoNetMessage(LocoNetMessage m)
          Forward a preformatted LocoNetMessage to the actual interface.
abstract  boolean status()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

self

protected static LnTrafficController self

listeners

protected Vector<LocoNetListener> listeners

trafficListeners

protected Vector<LnTrafficListenerFilter> trafficListeners

receivedMsgCount

protected int receivedMsgCount

receivedByteCount

protected int receivedByteCount

transmittedMsgCount

protected int transmittedMsgCount

log

static org.slf4j.Logger log
Constructor Detail

LnTrafficController

public LnTrafficController()
Method Detail

instance

@Deprecated
public static LnTrafficController instance()
Deprecated. 2.13.4

static function returning the LnTrafficController instance to use.

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

status

public abstract boolean status()
Specified by:
status in interface LocoNetInterface

sendLocoNetMessage

public abstract void sendLocoNetMessage(LocoNetMessage m)
Forward a preformatted LocoNetMessage to the actual interface.

Implementations should update the transmit count statistic.

Specified by:
sendLocoNetMessage in interface LocoNetInterface
Parameters:
m - Message to send; will be updated with CRC

addLocoNetListener

public void addLocoNetListener(int mask,
                               LocoNetListener l)
Description copied from interface: LocoNetInterface
Request notification of things happening on the LocoNet.

The same listener can register multiple times with different masks. (Multiple registrations with a single mask value are equivalent to a single registration) Mask values are defined as class constants. Note that these are bit masks, and should be OR'd, not added, if multiple values are desired.

The event notification contains the received message as source, not this object, so that we can notify of an incoming message to multiple places and then move on.

Specified by:
addLocoNetListener in interface LocoNetInterface
Parameters:
mask - The OR of the key values of messages to be reported (to reduce traffic, provide for listeners interested in different things)
l - Object to be notified of new messages as they arrive.

removeLocoNetListener

public void removeLocoNetListener(int mask,
                                  LocoNetListener l)
Specified by:
removeLocoNetListener in interface LocoNetInterface

addTrafficListener

public void addTrafficListener(int mask,
                               LnTrafficListener l)

removeTrafficListener

public void removeTrafficListener(int mask,
                                  LnTrafficListener l)

changeTrafficListener

public void changeTrafficListener(int mask,
                                  LnTrafficListener l)

notify

public void notify(LocoNetMessage m)
Forward a LocoNetMessage to all registered listeners.

this needs to have public access, as LnOverTcpPacketizer and IBLnPacketizer invoke it, but don't inherit from it

Parameters:
m - Message to forward. Listeners should not modify it!

notifyRcv

public void notifyRcv(Date timestamp,
                      LocoNetMessage m)

notifyXmit

public void notifyXmit(Date timestamp,
                       LocoNetMessage 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 LocoNet messaages received across the interface. This includes the messages this client has sent.


getReceivedByteCount

public int getReceivedByteCount()
Monitor the number of bytes in LocoNet messaages received across the interface. This includes the messages this client has sent.


getTransmittedMsgCount

public int getTransmittedMsgCount()
Monitor the number of LocoNet messaages transmitted across the interface.



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