Class LocoNetThrottledTransmitter
- All Implemented Interfaces:
LocoNetInterface
A LocoNetThrottledTransmitter object sits in front of a LocoNetInterface (e.g. TrafficHandler) and meters out specific LocoNet messages.
The internal Memo class is used to hold the pending message and the time it's to be sent. Time computations are in units of milliseconds, as that's all the accuracy that's needed here.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) class -
Field Summary
FieldsModifier and TypeFieldDescription(package private) LocoNetInterface(package private) boolean(package private) long(package private) LocoNetSystemConnectionMemoReference to the system connection memo.(package private) long(package private) boolean(package private) DelayQueue<LocoNetThrottledTransmitter.Memo>(package private) booleanstatic final StringConstant for the name of the Service Thread.(package private) LocoNetThrottledTransmitter.ServiceThreadFields inherited from interface jmri.jmrix.loconet.LocoNetInterface
ALL, POWER, PROGRAMMING, SENSORS, SLOTINFO, TURNOUTS -
Constructor Summary
ConstructorsConstructorDescriptionLocoNetThrottledTransmitter(LocoNetInterface controller, boolean mTurnoutExtraSpace) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLocoNetListener(int mask, LocoNetListener listener) Request notification of things happening on the LocoNet.(package private) longvoiddispose()Request that server thread cease operation, no more messages can be sent.Get the system connection memo associated with this traffic controller.(package private) static longnowMSec()voidremoveLocoNetListener(int mask, LocoNetListener listener) voidAccept a message to be sent after suitable delay.voidSet the system connection memo associated with this traffic controller.booleanstatus()Check whether an implementation is operational.
-
Field Details
-
memo
Reference to the system connection memo. -
mTurnoutExtraSpace
boolean mTurnoutExtraSpace -
disposed
-
running
-
controller
-
minInterval
long minInterval -
lastSendTimeMSec
long lastSendTimeMSec -
queue
-
SERVICE_THREAD_NAME
Constant for the name of the Service Thread. Requires the connection UserName prepending.- See Also:
-
theServiceThread
-
-
Constructor Details
-
LocoNetThrottledTransmitter
public LocoNetThrottledTransmitter(@Nonnull LocoNetInterface controller, boolean mTurnoutExtraSpace)
-
-
Method Details
-
setSystemConnectionMemo
Set the system connection memo associated with this traffic controller.- Specified by:
setSystemConnectionMemoin interfaceLocoNetInterface- Parameters:
m- associated systemConnectionMemo object
-
getSystemConnectionMemo
Get the system connection memo associated with this traffic controller.- Specified by:
getSystemConnectionMemoin interfaceLocoNetInterface- Returns:
- the associated systemConnectionMemo object
-
dispose
Request that server thread cease operation, no more messages can be sent. Note that this returns before the thread is known to be done if it still has work pending. If you need to be sure it's done, check and wait on !running. -
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)listener- Object to be notified of new messages as they arrive.
-
removeLocoNetListener
- Specified by:
removeLocoNetListenerin interfaceLocoNetInterface
-
status
Description copied from interface:LocoNetInterfaceCheck whether an implementation is operational. Returns true if operational.- Specified by:
statusin interfaceLocoNetInterface- Returns:
- true if implementation is operational.
-
sendLocoNetMessage
Accept a message to be sent after suitable delay.- Specified by:
sendLocoNetMessagein interfaceLocoNetInterface
-
calcSendTimeMSec
long calcSendTimeMSec() -
nowMSec
-