Package jmri.jmrix.mqtt
Class MqttThrottleManager
- java.lang.Object
-
- jmri.jmrix.AbstractThrottleManager
-
- jmri.jmrix.mqtt.MqttThrottleManager
-
- All Implemented Interfaces:
ThrottleManager
public class MqttThrottleManager extends AbstractThrottleManager
MQTT implementation of a ThrottleManager based on the AbstractThrottleManager.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jmri.jmrix.AbstractThrottleManager
AbstractThrottleManager.Addresses
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.String
rcvDirectionTopic
java.lang.String
rcvFunctionTopic
java.lang.String
rcvThrottleTopic
java.lang.String
sendDirectionTopic
java.lang.String
sendFunctionTopic
java.lang.String
sendThrottleTopic
protected java.util.HashMap<LocoAddress,MqttThrottle>
throttles
-
Fields inherited from class jmri.jmrix.AbstractThrottleManager
adapterMemo, userName
-
-
Constructor Summary
Constructors Constructor Description MqttThrottleManager(MqttSystemConnectionMemo memo)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addressTypeUnique()
There are no ambiguous addresses on this system.boolean
canBeLongAddress(int address)
Address 128 and above is a long addressboolean
canBeShortAddress(int address)
Address between 1 and 127 is a short addressvoid
dispatchThrottle(DccThrottle t, ThrottleListener l)
The throttle listener has finished with the specific Throttle and is is available for reuse/reallocation by somebody else.boolean
disposeThrottle(DccThrottle t, ThrottleListener l)
Not for general use, seereleaseThrottle
anddispatchThrottle
.boolean
hasDispatchFunction()
MQTT based systems DO use the Dispatch Functionprotected static boolean
isLongAddress(int num)
void
releaseThrottle(DccThrottle t, ThrottleListener l)
The specified Throttle Listener has finished using a given throttle and no longer requires access to it.void
requestThrottleSetup(LocoAddress address, boolean control)
Request a new throttle object be created for the address, and let the throttle listeners know about it.void
setRcvDirectionTopic(java.lang.String rcvDirectionTopic)
void
setRcvFunctionTopic(java.lang.String rcvFunctionTopic)
void
setRcvThrottleTopic(java.lang.String rcvThrottleTopic)
void
setSendDirectionTopic(java.lang.String sendDirectionTopic)
void
setSendFunctionTopic(java.lang.String sendFunctionTopic)
void
setSendThrottleTopic(java.lang.String sendThrottleTopic)
protected boolean
singleUse()
MQTT based systems can have multiple throttles for the same devicejava.util.EnumSet<SpeedStepMode>
supportedSpeedModes()
What speed modes are supported by this system?-
Methods inherited from class jmri.jmrix.AbstractThrottleManager
addressReleased, addressStillRequired, addressStillRequired, addressStillRequired, addressStillRequired, attachListener, cancelThrottleRequest, cancelThrottleRequest, cancelThrottleRequest, cancelThrottleRequest, dispose, enablePrefSilentShareOption, enablePrefSilentStealOption, failedThrottleRequest, forceDisposeThrottle, getAddress, getAddress, getAddressProtocolTypes, getAddressTypes, getAddressTypeString, getProtocolFromString, getThrottleInfo, getThrottleUsageCount, getThrottleUsageCount, getThrottleUsageCount, getThrottleUsageCount, getUserName, hideStealNotifications, makeHardwareDecision, notifyDecisionRequest, notifyThrottleKnown, removeListener, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottle, requestThrottleSetup, responseThrottleDecision, responseThrottleDecision, responseThrottleDecision, showSessionCancelDialogue, updateNumUsers
-
-
-
-
Field Detail
-
throttles
protected java.util.HashMap<LocoAddress,MqttThrottle> throttles
-
sendThrottleTopic
@Nonnull public java.lang.String sendThrottleTopic
-
rcvThrottleTopic
@Nonnull public java.lang.String rcvThrottleTopic
-
sendDirectionTopic
@Nonnull public java.lang.String sendDirectionTopic
-
rcvDirectionTopic
@Nonnull public java.lang.String rcvDirectionTopic
-
sendFunctionTopic
@Nonnull public java.lang.String sendFunctionTopic
-
rcvFunctionTopic
@Nonnull public java.lang.String rcvFunctionTopic
-
-
Constructor Detail
-
MqttThrottleManager
public MqttThrottleManager(MqttSystemConnectionMemo memo)
Constructor.- Parameters:
memo
- the memo for the connection this tm will use
-
-
Method Detail
-
setSendThrottleTopic
public void setSendThrottleTopic(@Nonnull java.lang.String sendThrottleTopic)
-
setRcvThrottleTopic
public void setRcvThrottleTopic(@Nonnull java.lang.String rcvThrottleTopic)
-
setSendDirectionTopic
public void setSendDirectionTopic(@Nonnull java.lang.String sendDirectionTopic)
-
setRcvDirectionTopic
public void setRcvDirectionTopic(@Nonnull java.lang.String rcvDirectionTopic)
-
setSendFunctionTopic
public void setSendFunctionTopic(@Nonnull java.lang.String sendFunctionTopic)
-
setRcvFunctionTopic
public void setRcvFunctionTopic(@Nonnull java.lang.String rcvFunctionTopic)
-
requestThrottleSetup
public void requestThrottleSetup(LocoAddress address, boolean control)
Request a new throttle object be created for the address, and let the throttle listeners know about it.- Specified by:
requestThrottleSetup
in classAbstractThrottleManager
- Parameters:
address
- addresscontrol
- false - read only.
-
hasDispatchFunction
public boolean hasDispatchFunction()
MQTT based systems DO use the Dispatch Function- Specified by:
hasDispatchFunction
in interfaceThrottleManager
- Overrides:
hasDispatchFunction
in classAbstractThrottleManager
- Returns:
- true if dispatch is possible; false otherwise
-
singleUse
protected boolean singleUse()
MQTT based systems can have multiple throttles for the same deviceDoes this DCC system allow a Throttle (e.g. an address) to be used by only one user at a time?
- Overrides:
singleUse
in classAbstractThrottleManager
- Returns:
- true or false
-
canBeLongAddress
public boolean canBeLongAddress(int address)
Address 128 and above is a long address- Parameters:
address
- address number to test- Returns:
- true if address can be long; false otherwise
-
canBeShortAddress
public boolean canBeShortAddress(int address)
Address between 1 and 127 is a short address- Parameters:
address
- address number to test- Returns:
- true if address can be short; false otherwise
-
addressTypeUnique
public boolean addressTypeUnique()
There are no ambiguous addresses on this system.- Returns:
- true if ambiguous addresses are not allowed; false otherwise
-
isLongAddress
protected static boolean isLongAddress(int num)
-
supportedSpeedModes
public java.util.EnumSet<SpeedStepMode> supportedSpeedModes()
What speed modes are supported by this system? value should be xor of possible modes specifed by the DccThrottle interface DCC++ supports 14,27,28 and 128 speed step modes- Specified by:
supportedSpeedModes
in interfaceThrottleManager
- Overrides:
supportedSpeedModes
in classAbstractThrottleManager
- Returns:
- an XOR of the possible modes specified in the throttle interface
-
disposeThrottle
public boolean disposeThrottle(DccThrottle t, ThrottleListener l)
Not for general use, seereleaseThrottle
anddispatchThrottle
.Dispose of object when finished it. This will free up hardware resource
Used for handling certain internal error conditions, where the object still exists but hardware is not associated with it.
After this, further usage of this Throttle object will result in a JmriException.
- Specified by:
disposeThrottle
in interfaceThrottleManager
- Overrides:
disposeThrottle
in classAbstractThrottleManager
- Parameters:
t
- Throttle being releasedl
- Throttle Listener releasing the throttle- Returns:
- true if the throttle has been disposed of.
-
dispatchThrottle
public void dispatchThrottle(DccThrottle t, ThrottleListener l)
The throttle listener has finished with the specific Throttle and is is available for reuse/reallocation by somebody else. If possible, tell the layout that this locomotive has been dispatched to another user. Not all layouts will implement this, in which case it is synomous with release();Normally, dispatch ends with a call to dispose.
- Specified by:
dispatchThrottle
in interfaceThrottleManager
- Overrides:
dispatchThrottle
in classAbstractThrottleManager
- Parameters:
t
- Throttle being releasedl
- Throttle Listener releasing the throttle
-
releaseThrottle
public void releaseThrottle(DccThrottle t, ThrottleListener l)
The specified Throttle Listener has finished using a given throttle and no longer requires access to it.After releasing the throttle, the manager will perform further checks to see if it is in use by any other listeners or if there are any PropertyChangeListeners attached. If there are no other uses of the throttle then it is disposed of.
Normally, release ends with a call to dispose.
- Specified by:
releaseThrottle
in interfaceThrottleManager
- Overrides:
releaseThrottle
in classAbstractThrottleManager
- Parameters:
t
- Throttle being releasedl
- Throttle Listener releasing the throttle
-
-