Class LnTrafficController
- All Implemented Interfaces:
LocoNetInterface
- Direct Known Subclasses:
LnPacketizer,LnTrafficRouter
This provides just the basic interface and some statistics support.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Vector<LocoNetListener>(package private) LocoNetSystemConnectionMemoReference to the system connection memo.protected intprotected intprotected intFields inherited from interface jmri.jmrix.loconet.LocoNetInterface
ALL, POWER, PROGRAMMING, SENSORS, SLOTINFO, TURNOUTS -
Constructor Summary
ConstructorsConstructorDescriptionConstructor without reference to a LocoNetSystemConnectionMemo.Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLocoNetListener(int mask, LocoNetListener l) Request notification of things happening on the LocoNet.voiddispose()Clean up any resources, particularly threads.intMonitor the number of bytes in LocoNet messages received across the interface.intMonitor the number of LocoNet messages received across the interface.Get the system connection memo associated with this connection.intMonitor the number of LocoNet messages transmitted across the interface.abstract booleanIs there a backlog of information for the outbound link?voidForward a LocoNetMessage to all registered listeners.voidremoveLocoNetListener(int mask, LocoNetListener l) voidReset statistics (received message count, transmitted message count, received byte count).abstract voidForward a preformatted LocoNetMessage to the actual interface.voidSet the system connection memo associated with this connection.abstract booleanstatus()Check whether an implementation is operational.
-
Field Details
-
memo
Reference to the system connection memo. -
listeners
-
receivedMsgCount
-
receivedByteCount
-
transmittedMsgCount
-
-
Constructor Details
-
LnTrafficController
public LnTrafficController()Constructor without reference to a LocoNetSystemConnectionMemo. -
LnTrafficController
Constructor. Gets a reference to the LocoNetSystemConnectionMemo.- Parameters:
memo- connection's memo
-
-
Method Details
-
setSystemConnectionMemo
Set the system connection memo associated with this connection.- Specified by:
setSystemConnectionMemoin interfaceLocoNetInterface- Parameters:
m- associated systemConnectionMemo object
-
getSystemConnectionMemo
Get the system connection memo associated with this connection.- Specified by:
getSystemConnectionMemoin interfaceLocoNetInterface- Returns:
- the associated systemConnectionMemo object
-
status
Check whether an implementation is operational. Returns true if operational.- Specified by:
statusin interfaceLocoNetInterface- Returns:
- true if implementation is operational.
-
sendLocoNetMessage
Forward a preformatted LocoNetMessage to the actual interface.Implementations should update the transmit count statistic.
- Specified by:
sendLocoNetMessagein interfaceLocoNetInterface- Parameters:
m- message to send; will be updated with CRC
-
addLocoNetListener
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 interfaceLocoNetInterface- 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
- Specified by:
removeLocoNetListenerin interfaceLocoNetInterface
-
notify
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!
-
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
Reset statistics (received message count, transmitted message count, received byte count). -
dispose
Clean up any resources, particularly threads.The object can't be used after this.
-
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
-
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
-
getTransmittedMsgCount
Monitor the number of LocoNet messages transmitted across the interface.- Returns:
- the number of messages transmitted
-