Package jmri.jmrix.mqtt
Class MqttConsistManager
- java.lang.Object
-
- jmri.implementation.AbstractConsistManager
-
- jmri.jmrix.mqtt.MqttConsistManager
-
- All Implemented Interfaces:
ConsistManager
public class MqttConsistManager extends AbstractConsistManager
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.ConsistManager
ConsistManager.EnableListener
-
-
Field Summary
Fields Modifier and Type Field Description protected MqttSystemConnectionMemo
adapterMemo
java.lang.String
sendTopicPrefix
-
Fields inherited from class jmri.implementation.AbstractConsistManager
consistTable
-
-
Constructor Summary
Constructors Constructor Description MqttConsistManager(MqttSystemConnectionMemo memo)
Constructor - call the constructor for the superclass, and initialize the consist reader thread, which retrieves consist information from the command station.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateConsist(LocoAddress address)
Consist is activated on the controller for the specified LocoAddress This is used by MqttThrottle to either publish an existing consist or clear an old one upon opening the new throttle.Consist
addConsist(LocoAddress address)
Add a new MQTT Consist with the given address to consistTable/consistList.boolean
csConsistNeedsSeperateAddress()
Does a CS consist require a separate consist address?void
deactivateConsist(LocoAddress address)
If a consist exists with the given address, the consist is deactivated on the controller, otherwise it does nothing.boolean
isCommandStationConsistPossible()
This implementation does support advanced consists, so return true.void
requestUpdateFromLayout()
Request an update from the layout, loading Consists from the command station.void
setSendTopic(java.lang.String sendTopicPrefix)
protected boolean
shouldRequestUpdateFromLayout()
Allow a request for consist updates from the layout.-
Methods inherited from class jmri.implementation.AbstractConsistManager
addConsistListListener, decodeErrorCode, delConsist, getConsist, getConsistList, notifyConsistListChanged, removeConsistListListener
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jmri.ConsistManager
canBeDisabled, isEnabled, registerEnableListener, unregisterEnableListener
-
-
-
-
Field Detail
-
adapterMemo
protected MqttSystemConnectionMemo adapterMemo
-
sendTopicPrefix
@Nonnull public java.lang.String sendTopicPrefix
-
-
Constructor Detail
-
MqttConsistManager
public MqttConsistManager(MqttSystemConnectionMemo memo)
Constructor - call the constructor for the superclass, and initialize the consist reader thread, which retrieves consist information from the command station.- Parameters:
memo
- the associated connection memo
-
-
Method Detail
-
setSendTopic
public void setSendTopic(@Nonnull java.lang.String sendTopicPrefix)
-
isCommandStationConsistPossible
public boolean isCommandStationConsistPossible()
This implementation does support advanced consists, so return true.- Returns:
- true if command station consists are supported; false otherwise
-
csConsistNeedsSeperateAddress
public boolean csConsistNeedsSeperateAddress()
Does a CS consist require a separate consist address? CS consist addresses are assigned by the user, so return true.- Returns:
- true is command station consist requires separate address; false otherwise
-
addConsist
public Consist addConsist(LocoAddress address)
Add a new MQTT Consist with the given address to consistTable/consistList.- Specified by:
addConsist
in classAbstractConsistManager
- Parameters:
address
- consist address- Returns:
- a consist at address; this will be the existing consist if a consist is already known to exist at address
-
requestUpdateFromLayout
public void requestUpdateFromLayout()
Description copied from interface:ConsistManager
Request an update from the layout, loading Consists from the command station.- Specified by:
requestUpdateFromLayout
in interfaceConsistManager
- Overrides:
requestUpdateFromLayout
in classAbstractConsistManager
-
shouldRequestUpdateFromLayout
protected boolean shouldRequestUpdateFromLayout()
Description copied from class:AbstractConsistManager
Allow a request for consist updates from the layout. If not overridden by a concrete subclass, this method always returns true.- Overrides:
shouldRequestUpdateFromLayout
in classAbstractConsistManager
- Returns:
- true if the request can be made, false if not
-
activateConsist
public void activateConsist(LocoAddress address)
Consist is activated on the controller for the specified LocoAddress This is used by MqttThrottle to either publish an existing consist or clear an old one upon opening the new throttle.- Parameters:
address
- Consist address to be activated
-
deactivateConsist
public void deactivateConsist(LocoAddress address)
If a consist exists with the given address, the consist is deactivated on the controller, otherwise it does nothing. This is used by a throttle in case it is controlling a consist.- Parameters:
address
- Consist address to be deactivated
-
-