Class LocoNetThrottledTransmitter
- java.lang.Object
- 
- jmri.jmrix.loconet.LocoNetThrottledTransmitter
 
- 
- All Implemented Interfaces:
- LocoNetInterface
 
 public class LocoNetThrottledTransmitter extends java.lang.Object implements LocoNetInterface Delay LocoNet messages that need to be throttled.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 SummaryNested Classes Modifier and Type Class Description (package private) static classLocoNetThrottledTransmitter.Memo(package private) classLocoNetThrottledTransmitter.ServiceThread
 - 
Field SummaryFields Modifier and Type Field Description (package private) LocoNetInterfacecontroller(package private) booleandisposed(package private) longlastSendTimeMSec(package private) LocoNetSystemConnectionMemomemoReference to the system connection memo.(package private) longminInterval(package private) booleanmTurnoutExtraSpace(package private) java.util.concurrent.DelayQueue<LocoNetThrottledTransmitter.Memo>queue(package private) booleanrunningstatic java.lang.StringSERVICE_THREAD_NAMEConstant for the name of the Service Thread.(package private) LocoNetThrottledTransmitter.ServiceThreadtheServiceThread- 
Fields inherited from interface jmri.jmrix.loconet.LocoNetInterfaceALL, POWER, PROGRAMMING, SENSORS, SLOTINFO, TURNOUTS
 
- 
 - 
Constructor SummaryConstructors Constructor Description LocoNetThrottledTransmitter(LocoNetInterface controller, boolean mTurnoutExtraSpace)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLocoNetListener(int mask, LocoNetListener listener)Request notification of things happening on the LocoNet.(package private) longcalcSendTimeMSec()voiddispose()Request that server thread cease operation, no more messages can be sent.LocoNetSystemConnectionMemogetSystemConnectionMemo()Get the system connection memo associated with this traffic controller.(package private) static longnowMSec()voidremoveLocoNetListener(int mask, LocoNetListener listener)voidsendLocoNetMessage(LocoNetMessage msg)Accept a message to be sent after suitable delay.voidsetSystemConnectionMemo(LocoNetSystemConnectionMemo m)Set the system connection memo associated with this traffic controller.booleanstatus()Check whether an implementation is operational.
 
- 
- 
- 
Field Detail- 
memoLocoNetSystemConnectionMemo memo Reference to the system connection memo.
 - 
mTurnoutExtraSpaceboolean mTurnoutExtraSpace 
 - 
disposedvolatile boolean disposed 
 - 
runningvolatile boolean running 
 - 
controllerLocoNetInterface controller 
 - 
minIntervallong minInterval 
 - 
lastSendTimeMSeclong lastSendTimeMSec 
 - 
queuejava.util.concurrent.DelayQueue<LocoNetThrottledTransmitter.Memo> queue 
 - 
SERVICE_THREAD_NAMEpublic static final java.lang.String SERVICE_THREAD_NAME Constant for the name of the Service Thread. Requires the connection UserName prepending.- See Also:
- Constant Field Values
 
 - 
theServiceThreadLocoNetThrottledTransmitter.ServiceThread theServiceThread 
 
- 
 - 
Constructor Detail- 
LocoNetThrottledTransmitterpublic LocoNetThrottledTransmitter(@Nonnull LocoNetInterface controller, boolean mTurnoutExtraSpace) 
 
- 
 - 
Method Detail- 
setSystemConnectionMemopublic void setSystemConnectionMemo(LocoNetSystemConnectionMemo m) Set the system connection memo associated with this traffic controller.- Specified by:
- setSystemConnectionMemoin interface- LocoNetInterface
- Parameters:
- m- associated systemConnectionMemo object
 
 - 
getSystemConnectionMemopublic LocoNetSystemConnectionMemo getSystemConnectionMemo() Get the system connection memo associated with this traffic controller.- Specified by:
- getSystemConnectionMemoin interface- LocoNetInterface
- Returns:
- the associated systemConnectionMemo object
 
 - 
disposepublic void 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.
 - 
addLocoNetListenerpublic void addLocoNetListener(int mask, LocoNetListener listener) 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)
- listener- Object to be notified of new messages as they arrive.
 
 - 
removeLocoNetListenerpublic void removeLocoNetListener(int mask, LocoNetListener listener) - Specified by:
- removeLocoNetListenerin interface- LocoNetInterface
 
 - 
statuspublic boolean status() Description copied from interface:LocoNetInterfaceCheck whether an implementation is operational. Returns true if operational.- Specified by:
- statusin interface- LocoNetInterface
- Returns:
- true if implementation is operational.
 
 - 
sendLocoNetMessagepublic void sendLocoNetMessage(LocoNetMessage msg) Accept a message to be sent after suitable delay.- Specified by:
- sendLocoNetMessagein interface- LocoNetInterface
 
 - 
calcSendTimeMSeclong calcSendTimeMSec() 
 - 
nowMSecstatic long nowMSec() 
 
- 
 
-