Package jmri.jmrix.lenz
Class XNetConsist
- java.lang.Object
-
- jmri.implementation.DccConsist
-
- jmri.jmrix.lenz.XNetConsist
-
- All Implemented Interfaces:
java.util.EventListener
,Consist
,AbstractMRListener
,XNetListener
,ProgListener
public class XNetConsist extends DccConsist implements XNetListener
XNetConsist.java This is the Consist definition for a consist on an XPresNet system. it uses the XpressNet specific commands to build a consist.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) XNetSystemConnectionMemo
systemMemo
protected XNetTrafficController
tc
-
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 XNetConsist(int address, XNetTrafficController controller, XNetSystemConnectionMemo systemMemo)
Initialize a consist for the specific address.XNetConsist(DccLocoAddress address, XNetTrafficController controller, XNetSystemConnectionMemo systemMemo)
Initialize a consist for the specific address.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(DccLocoAddress locoAddress, boolean directionNormal)
Add a Locomotive to a Consist.protected void
addToAdvancedConsist(DccLocoAddress locoAddress, boolean directionNormal)
Add a Locomotive to an Advanced Consist.boolean
contains(DccLocoAddress address)
Does the consist contain the specified address?void
dispose()
Clean Up local storage, and remove the XNetListener.boolean
getLocoDirection(DccLocoAddress address)
Get the relative direction setting for a specific locomotive in the consist.boolean
isAddressAllowed(DccLocoAddress address)
Is this address allowed?void
message(XNetMessage l)
Member function that will be invoked by an XNetInterface implementation to forward an XNet message sent to the layout.void
message(XNetReply l)
Listeners for messages from the command station.void
notifyTimeout(XNetMessage msg)
Member function invoked by an XNetInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.void
remove(DccLocoAddress locoAddress)
Remove a Locomotive from this Consist.protected void
removeFromAdvancedConsist(DccLocoAddress locoAddress)
Remove a Locomotive from an Advanced Consist.void
removeFromCSConsist(DccLocoAddress locoAddress)
Remove a Locomotive from a Lenz Double Header.locoAddressvoid
restore(DccLocoAddress locoAddress, boolean directionNormal)
Restore a Locomotive to an Advanced Consist, but don't write to the command station.void
setConsistType(int consistType)
Set the Consist Type.int
sizeLimit()
Is there a size limit for this consist?-
Methods inherited from class jmri.implementation.DccConsist
addConsistListener, getConsistAddress, getConsistID, getConsistList, getConsistType, getPosition, getRosterId, loadDecoderFile, loadDecoderFromLoco, notifyConsistListeners, programmingOpReply, removeConsistListener, resetRosterEntryCVValue, restore, reverse, setConsistID, setPosition, setRosterEntryCVValue, setRosterId, updateRosterCV
-
-
-
-
Field Detail
-
tc
protected XNetTrafficController tc
-
systemMemo
final XNetSystemConnectionMemo systemMemo
-
-
Constructor Detail
-
XNetConsist
public XNetConsist(int address, XNetTrafficController controller, XNetSystemConnectionMemo systemMemo)
Initialize a consist for the specific address. Default consist type is an advanced consist.- Parameters:
address
- loco address.controller
- system connection traffic controller.systemMemo
- system connection.
-
XNetConsist
public XNetConsist(DccLocoAddress address, XNetTrafficController controller, XNetSystemConnectionMemo systemMemo)
Initialize a consist for the specific address. Default consist type is an advanced consist.- Parameters:
address
- loco address.controller
- system connection traffic controller.systemMemo
- system connection.
-
-
Method Detail
-
dispose
public void dispose()
Clean Up local storage, and remove the XNetListener.- Specified by:
dispose
in interfaceConsist
- Overrides:
dispose
in classDccConsist
-
setConsistType
public void setConsistType(int consistType)
Set the Consist Type.- Specified by:
setConsistType
in interfaceConsist
- Overrides:
setConsistType
in classDccConsist
- Parameters:
consistType
- An integer, should be either jmri.Consist.ADVANCED_CONSIST or jmri.Consist.CS_CONSIST.
-
isAddressAllowed
public boolean isAddressAllowed(DccLocoAddress address)
Is this address allowed?On Lenz systems, All addresses but 0 can be used in a consist (Either and Advanced Consist or a Double Header). 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
-DccLocoAddress
object to check.- 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:
- 2 For Lenz double headers. -1 (no limit) For Decoder Assisted Consists. 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
-DccLocoAddress
object 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.- Specified by:
getLocoDirection
in interfaceConsist
- Overrides:
getLocoDirection
in classDccConsist
- Parameters:
address
-DccLocoAddress
object to check- Returns:
- true means forward, false means backwards.
-
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
- 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 an Advanced 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
- the Locomotive address to add to the locomotivedirectionNormal
- 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
- the Locomotive address to add to the Consist
-
addToAdvancedConsist
protected void addToAdvancedConsist(DccLocoAddress locoAddress, boolean directionNormal)
Add a Locomotive to an Advanced Consist.- Overrides:
addToAdvancedConsist
in classDccConsist
- Parameters:
locoAddress
- the Locomotive address to add to the locomotivedirectionNormal
- is True if the locomotive is traveling the same direction as the consist, or false otherwise.
-
removeFromAdvancedConsist
protected void removeFromAdvancedConsist(DccLocoAddress locoAddress)
Remove a Locomotive from an Advanced Consist.- Overrides:
removeFromAdvancedConsist
in classDccConsist
- Parameters:
locoAddress
- the Locomotive address to add to the locomotive
-
removeFromCSConsist
public void removeFromCSConsist(DccLocoAddress locoAddress)
Remove a Locomotive from a Lenz Double Header.locoAddress- Parameters:
locoAddress
- is the Locomotive address, unused here.
-
message
public void message(XNetReply l)
Listeners for messages from the command station.- Specified by:
message
in interfaceXNetListener
- Parameters:
l
- The received XNet message. Note that this same object may be presented to multiple users. It should not be modified here.
-
message
public void message(XNetMessage l)
Description copied from interface:XNetListener
Member function that will be invoked by an XNetInterface implementation to forward an XNet message sent to the layout. Normally, this function will do nothing.- Specified by:
message
in interfaceXNetListener
- Parameters:
l
- The received XNet message. Note that this same object may be presented to multiple users. It should not be modified here.
-
notifyTimeout
public void notifyTimeout(XNetMessage msg)
Description copied from interface:XNetListener
Member function invoked by an XNetInterface implementation to notify a sender that an outgoing message timed out and was dropped from the queue.- Specified by:
notifyTimeout
in interfaceXNetListener
- Parameters:
msg
- message which has timed out.
-
-