Class LnTrafficController
- java.lang.Object
- 
- jmri.jmrix.loconet.LnTrafficController
 
- 
- All Implemented Interfaces:
- LocoNetInterface
 - Direct Known Subclasses:
- LnPacketizer,- LnTrafficRouter
 
 public abstract class LnTrafficController extends java.lang.Object implements LocoNetInterface Abstract base class for implementations of LocoNetInterface.This provides just the basic interface and some statistics support. 
- 
- 
Field SummaryFields Modifier and Type Field Description protected java.util.Vector<LocoNetListener>listeners(package private) LocoNetSystemConnectionMemomemoReference to the system connection memo.protected intreceivedByteCountprotected intreceivedMsgCountprotected inttransmittedMsgCount- 
Fields inherited from interface jmri.jmrix.loconet.LocoNetInterfaceALL, POWER, PROGRAMMING, SENSORS, SLOTINFO, TURNOUTS
 
- 
 - 
Constructor SummaryConstructors Constructor Description LnTrafficController()Constructor without reference to a LocoNetSystemConnectionMemo.LnTrafficController(LocoNetSystemConnectionMemo memo)Constructor.
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddLocoNetListener(int mask, LocoNetListener l)Request notification of things happening on the LocoNet.voiddispose()Clean up any resources, particularly threads.intgetReceivedByteCount()Monitor the number of bytes in LocoNet messages received across the interface.intgetReceivedMsgCount()Monitor the number of LocoNet messages received across the interface.LocoNetSystemConnectionMemogetSystemConnectionMemo()Get the system connection memo associated with this connection.intgetTransmittedMsgCount()Monitor the number of LocoNet messages transmitted across the interface.abstract booleanisXmtBusy()Is there a backlog of information for the outbound link?voidnotify(LocoNetMessage m)Forward a LocoNetMessage to all registered listeners.voidremoveLocoNetListener(int mask, LocoNetListener l)voidresetStatistics()Reset statistics (received message count, transmitted message count, received byte count).abstract voidsendLocoNetMessage(LocoNetMessage m)Forward a preformatted LocoNetMessage to the actual interface.voidsetSystemConnectionMemo(LocoNetSystemConnectionMemo m)Set the system connection memo associated with this connection.abstract booleanstatus()Check whether an implementation is operational.
 
- 
- 
- 
Field Detail- 
memoLocoNetSystemConnectionMemo memo Reference to the system connection memo.
 - 
listenersprotected java.util.Vector<LocoNetListener> listeners 
 - 
receivedMsgCountprotected int receivedMsgCount 
 - 
receivedByteCountprotected int receivedByteCount 
 - 
transmittedMsgCountprotected int transmittedMsgCount 
 
- 
 - 
Constructor Detail- 
LnTrafficControllerpublic LnTrafficController() Constructor without reference to a LocoNetSystemConnectionMemo.
 - 
LnTrafficControllerpublic LnTrafficController(LocoNetSystemConnectionMemo memo) Constructor. Gets a reference to the LocoNetSystemConnectionMemo.- Parameters:
- memo- connection's memo
 
 
- 
 - 
Method Detail- 
setSystemConnectionMemopublic void setSystemConnectionMemo(LocoNetSystemConnectionMemo m) Set the system connection memo associated with this connection.- Specified by:
- setSystemConnectionMemoin interface- LocoNetInterface
- Parameters:
- m- associated systemConnectionMemo object
 
 - 
getSystemConnectionMemopublic LocoNetSystemConnectionMemo getSystemConnectionMemo() Get the system connection memo associated with this connection.- Specified by:
- getSystemConnectionMemoin interface- LocoNetInterface
- Returns:
- the associated systemConnectionMemo object
 
 - 
statuspublic abstract boolean status() Check whether an implementation is operational. Returns true if operational.- Specified by:
- statusin interface- LocoNetInterface
- Returns:
- true if implementation is operational.
 
 - 
sendLocoNetMessagepublic abstract void sendLocoNetMessage(LocoNetMessage m) Forward a preformatted LocoNetMessage to the actual interface.Implementations should update the transmit count statistic. - Specified by:
- sendLocoNetMessagein interface- LocoNetInterface
- Parameters:
- m- message to send; will be updated with CRC
 
 - 
addLocoNetListenerpublic void addLocoNetListener(int mask, @Nonnull LocoNetListener l) Description copied from interface:LocoNetInterfaceRequest 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:
- addLocoNetListenerin 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.
 
 - 
removeLocoNetListenerpublic void removeLocoNetListener(int mask, @Nonnull LocoNetListener l) - Specified by:
- removeLocoNetListenerin interface- LocoNetInterface
 
 - 
notifypublic void notify(LocoNetMessage m) Forward a LocoNetMessage to all registered listeners.Needs to have public access, as LnOverTcpPacketizerandIBLnPacketizerinvoke it, but don't inherit from it.- Parameters:
- m- message to forward. Listeners should not modify it!
 
 - 
isXmtBusypublic 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
 
 - 
resetStatisticspublic void resetStatistics() Reset statistics (received message count, transmitted message count, received byte count).
 - 
disposepublic void dispose() Clean up any resources, particularly threads.The object can't be used after this. 
 - 
getReceivedMsgCountpublic int getReceivedMsgCount() Monitor the number of LocoNet messages received across the interface. This includes the messages this client has sent.- Returns:
- the number of messages received
 
 - 
getReceivedByteCountpublic int getReceivedByteCount() Monitor the number of bytes in LocoNet messages received across the interface. This includes the bytes in messages this client has sent.- Returns:
- the number of bytes received
 
 - 
getTransmittedMsgCountpublic int getTransmittedMsgCount() Monitor the number of LocoNet messages transmitted across the interface.- Returns:
- the number of messages transmitted
 
 
- 
 
-