Package jmri.jmrix.loconet
Class LocoNetConsist
- java.lang.Object
-
- jmri.implementation.DccConsist
-
- jmri.jmrix.loconet.LocoNetConsist
-
- All Implemented Interfaces:
java.util.EventListener
,Consist
,SlotListener
,ProgListener
,ThrottleListener
public class LocoNetConsist extends DccConsist implements SlotListener, ThrottleListener
LocoNetConsist.java This is the Consist definition for a consist on a LocoNet system. It uses the LocoNet specific commands to build a consist.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jmri.ThrottleListener
ThrottleListener.DecisionType
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
IDLESTATE
(package private) static int
LEADREQUESTSTATE
(package private) static int
LINKSTAGEONESTATE
(package private) static int
LINKSTAGETHREESTATE
(package private) static int
LINKSTAGETWOSTATE
(package private) static int
UNLINKSTAGEONESTATE
-
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 LocoNetConsist(int address, LocoNetSystemConnectionMemo lm)
LocoNetConsist(DccLocoAddress address, LocoNetSystemConnectionMemo lm)
-
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 locomotive address?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
notifyChangedSlot(LocoNetSlot s)
void
notifyDecisionRequired(LocoAddress address, ThrottleListener.DecisionType question)
No steal or share decisions made locallyvoid
notifyFailedThrottleRequest(LocoAddress address, java.lang.String reason)
Get notification that an attempt to request a throttle has failed.void
notifyThrottleFound(DccThrottle t)
Get notification that a throttle has been found as requested.void
remove(DccLocoAddress locoAddress)
Remove a Locomotive from this Consist.protected void
removeFromAdvancedConsist(DccLocoAddress locoAddress)
Remove a Locomotive from an Advanced Consistvoid
removeFromCSConsist(DccLocoAddress locoAddress)
Remove a Locomotive from a LocoNet Universal Consist.void
restore(DccLocoAddress locoAddress, boolean directionNormal)
Restore a Locomotive to a Consist, but don't write to the command station.void
setConsistType(int type)
Set the Consist Type.int
sizeLimit()
Is there a size limit for this consist?-
Methods inherited from class jmri.implementation.DccConsist
addConsistListener, dispose, getConsistAddress, getConsistID, getConsistList, getConsistType, getPosition, getRosterId, loadDecoderFile, loadDecoderFromLoco, notifyConsistListeners, programmingOpReply, removeConsistListener, resetRosterEntryCVValue, restore, reverse, setConsistID, setPosition, setRosterEntryCVValue, setRosterId, updateRosterCV
-
-
-
-
Field Detail
-
IDLESTATE
static final int IDLESTATE
- See Also:
- Constant Field Values
-
LEADREQUESTSTATE
static final int LEADREQUESTSTATE
- See Also:
- Constant Field Values
-
LINKSTAGEONESTATE
static final int LINKSTAGEONESTATE
- See Also:
- Constant Field Values
-
LINKSTAGETWOSTATE
static final int LINKSTAGETWOSTATE
- See Also:
- Constant Field Values
-
LINKSTAGETHREESTATE
static final int LINKSTAGETHREESTATE
- See Also:
- Constant Field Values
-
UNLINKSTAGEONESTATE
static final int UNLINKSTAGEONESTATE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LocoNetConsist
public LocoNetConsist(int address, LocoNetSystemConnectionMemo lm)
-
LocoNetConsist
public LocoNetConsist(DccLocoAddress address, LocoNetSystemConnectionMemo lm)
-
-
Method Detail
-
setConsistType
public void setConsistType(int type)
Description copied from interface:Consist
Set the Consist Type.- Specified by:
setConsistType
in interfaceConsist
- Overrides:
setConsistType
in classDccConsist
- Parameters:
type
- the consist type
-
isAddressAllowed
public boolean isAddressAllowed(DccLocoAddress address)
Is this address allowed? On LocoNet systems, All addresses can be used in a Universal Consist and only 0 is not allowed in Advanced Consists. 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 (no limit) for both CS and Advanced Consists, 0 for any other consist type.
-
contains
public boolean contains(DccLocoAddress address)
Description copied from interface:Consist
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)
Description copied from interface: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
- the Locomotive address to add to the locomotivedirectionNormal
- if the locomotive is traveling the same direction as the consist, false otherwise
-
restore
public void restore(DccLocoAddress locoAddress, boolean directionNormal)
Restore a Locomotive to a 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, 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
-
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
- True if the locomotive is traveling the same direction as the consist, false otherwise
-
removeFromAdvancedConsist
protected void removeFromAdvancedConsist(DccLocoAddress locoAddress)
Remove a Locomotive from an Advanced Consist- Overrides:
removeFromAdvancedConsist
in classDccConsist
- Parameters:
locoAddress
- is the Locomotive address to add to the locomotive
-
removeFromCSConsist
public void removeFromCSConsist(DccLocoAddress locoAddress)
Remove a Locomotive from a LocoNet Universal Consist.- Parameters:
locoAddress
- is the Locomotive address to add to the locomotive.
-
notifyChangedSlot
public void notifyChangedSlot(LocoNetSlot s)
- Specified by:
notifyChangedSlot
in interfaceSlotListener
-
notifyThrottleFound
public void notifyThrottleFound(DccThrottle t)
Description copied from interface:ThrottleListener
Get notification that a throttle has been found as requested.- Specified by:
notifyThrottleFound
in interfaceThrottleListener
- Parameters:
t
- the throttle with the requested address
-
notifyFailedThrottleRequest
public void notifyFailedThrottleRequest(LocoAddress address, java.lang.String reason)
Description copied from interface:ThrottleListener
Get notification that an attempt to request a throttle has failed.- Specified by:
notifyFailedThrottleRequest
in interfaceThrottleListener
- Parameters:
address
- address of the failed requestreason
- failure cause
-
notifyDecisionRequired
public void notifyDecisionRequired(LocoAddress address, ThrottleListener.DecisionType question)
No steal or share decisions made locallyGet notification that a throttle request is in use by another device, and a "steal", "share", or "steal/share" decision may be required.
- Specified by:
notifyDecisionRequired
in interfaceThrottleListener
- Parameters:
address
- The LocoAddress that needs the decision.question
- The question being asked, steal / cancel, share / cancel, steal / share / cancel
-
-