Package jmri.jmrix.mqtt
Class MqttConsist
- java.lang.Object
-
- jmri.implementation.DccConsist
-
- jmri.jmrix.mqtt.MqttConsist
-
- All Implemented Interfaces:
java.util.EventListener
,Consist
,ProgListener
public class MqttConsist extends DccConsist
This is the Consist definition for a consist on an MQTT system.
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.String
sendTopicPrefix
-
Fields inherited from class jmri.implementation.DccConsist
consistAddress, consistDir, consistID, consistList, consistPosition, consistRoster, consistType
-
Fields inherited from interface jmri.Consist
ADVANCED_CONSIST, CS_CONSIST, POSITION_LEAD, POSITION_TRAIL
-
Fields inherited from interface jmri.ProgListener
CommError, ConfirmFailed, FailedTimeout, NoAck, NoLocoDetected, NotImplemented, OK, ProgrammerBusy, ProgrammingShort, SequenceError, UnknownError, UserAborted
-
-
Constructor Summary
Constructors Constructor Description MqttConsist(int address, MqttSystemConnectionMemo memo, java.lang.String sendTopicPrefix)
MqttConsist(DccLocoAddress address, MqttSystemConnectionMemo memo, java.lang.String sendTopicPrefix)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activate()
Activates the consist for use with a throttlevoid
add(DccLocoAddress locoAddress, boolean directionNormal)
Add a Locomotive to a Consist.boolean
contains(DccLocoAddress address)
Does the consist contain the specified address?void
deactivate()
Deactivates and removes the consist from a throttlevoid
dispose()
A method for cleaning up the consistboolean
getLocoDirection(DccLocoAddress address)
Get the relative direction setting for a specific locomotive in the consist.boolean
isAddressAllowed(DccLocoAddress address)
Is this address allowed?void
remove(DccLocoAddress locoAddress)
Remove a Locomotive from this Consist.void
restore(DccLocoAddress locoAddress, boolean directionNormal)
Restore a Locomotive to Consist, but don't write to the command station.void
setConsistType(int consist_type)
Set the Consist Type.int
sizeLimit()
Is there a size limit for this consist?-
Methods inherited from class jmri.implementation.DccConsist
addConsistListener, addToAdvancedConsist, getConsistAddress, getConsistID, getConsistList, getConsistType, getPosition, getRosterId, loadDecoderFile, loadDecoderFromLoco, notifyConsistListeners, programmingOpReply, removeConsistListener, removeFromAdvancedConsist, resetRosterEntryCVValue, restore, reverse, setConsistID, setPosition, setRosterEntryCVValue, setRosterId, updateRosterCV
-
-
-
-
Field Detail
-
sendTopicPrefix
@Nonnull public java.lang.String sendTopicPrefix
-
-
Constructor Detail
-
MqttConsist
public MqttConsist(int address, MqttSystemConnectionMemo memo, java.lang.String sendTopicPrefix)
-
MqttConsist
public MqttConsist(DccLocoAddress address, MqttSystemConnectionMemo memo, java.lang.String sendTopicPrefix)
-
-
Method Detail
-
dispose
public void dispose()
Description copied from interface:Consist
A method for cleaning up the consist- Specified by:
dispose
in interfaceConsist
- Overrides:
dispose
in classDccConsist
-
setConsistType
public void setConsistType(int consist_type)
Description copied from interface:Consist
Set the Consist Type.- Specified by:
setConsistType
in interfaceConsist
- Overrides:
setConsistType
in classDccConsist
- Parameters:
consist_type
- the consist type
-
isAddressAllowed
public boolean isAddressAllowed(DccLocoAddress address)
Is this address allowed? On MQTT systems, all addresses but 0 can be used in a consist. Is this address allowed? Since address 00 is an analog locomotive, we can't program CV19 to include it in a consist, but all other addresses are ok.- Specified by:
isAddressAllowed
in interfaceConsist
- Overrides:
isAddressAllowed
in classDccConsist
- Parameters:
address
- the address- Returns:
- true if allowed; false otherwise
-
sizeLimit
public int sizeLimit()
Is there a size limit for this consist?- Specified by:
sizeLimit
in interfaceConsist
- Overrides:
sizeLimit
in classDccConsist
- Returns:
- -1 for Controller Consists (no limit), 0 for any other consist type
-
contains
public boolean contains(DccLocoAddress address)
Does the consist contain the specified address? Does the consist contain the specified locomotive address?- Specified by:
contains
in interfaceConsist
- Overrides:
contains
in classDccConsist
- Parameters:
address
- the address to check- Returns:
- true if in consist; false otherwise
-
getLocoDirection
public boolean getLocoDirection(DccLocoAddress address)
Get the relative direction setting for a specific locomotive in the consist. Get the relative direction setting for a specific locomotive in the consist.- Specified by:
getLocoDirection
in interfaceConsist
- Overrides:
getLocoDirection
in classDccConsist
- Parameters:
address
- the address to check- Returns:
- true if locomotive is in consist in its normal direction of travel; false otherwise
-
add
public void add(DccLocoAddress locoAddress, boolean directionNormal)
Add a Locomotive to a Consist.- Specified by:
add
in interfaceConsist
- Overrides:
add
in classDccConsist
- Parameters:
locoAddress
- is the Locomotive address to add to the locomotivedirectionNormal
- is True if the locomotive is traveling the same direction as the consist, or false otherwise.
-
restore
public void restore(DccLocoAddress locoAddress, boolean directionNormal)
Restore a Locomotive to Consist, but don't write to the command station. This is used for restoring the consist from a file or adding a consist read from the command station.- Specified by:
restore
in interfaceConsist
- Overrides:
restore
in classDccConsist
- Parameters:
locoAddress
- is the Locomotive address to add to the locomotivedirectionNormal
- is True if the locomotive is traveling the same direction as the consist, or false otherwise.
-
remove
public void remove(DccLocoAddress locoAddress)
Remove a Locomotive from this Consist.- Specified by:
remove
in interfaceConsist
- Overrides:
remove
in classDccConsist
- Parameters:
locoAddress
- is the Locomotive address to add to the locomotive
-
activate
public void activate()
Activates the consist for use with a throttle
-
deactivate
public void deactivate()
Deactivates and removes the consist from a throttle
-
-