Package jmri.implementation
Class DccConsist
- java.lang.Object
-
- jmri.implementation.DccConsist
-
- All Implemented Interfaces:
java.util.EventListener
,Consist
,ProgListener
- Direct Known Subclasses:
EasyDccConsist
,LocoNetConsist
,NceConsist
,NmraConsist
,XNetConsist
public class DccConsist extends java.lang.Object implements Consist, ProgListener
This is the Default DCC consist. It utilizes the fact that IF a Command Station supports OpsMode Programming, you can write the consist information to CV19, so ANY Command Station that supports Ops Mode Programming can write this address to a Command Station that supports it.
-
-
Field Summary
Fields Modifier and Type Field Description protected DccLocoAddress
consistAddress
protected java.util.HashMap<DccLocoAddress,java.lang.Boolean>
consistDir
protected java.lang.String
consistID
protected java.util.ArrayList<DccLocoAddress>
consistList
protected java.util.HashMap<DccLocoAddress,java.lang.Integer>
consistPosition
protected java.util.HashMap<DccLocoAddress,java.lang.String>
consistRoster
protected int
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 DccConsist(int address)
DccConsist(DccLocoAddress address)
DccConsist(DccLocoAddress address, AddressedProgrammerManager apm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(DccLocoAddress LocoAddress, boolean directionNormal)
Add a Locomotive to a Consistvoid
addConsistListener(ConsistListener Listener)
Add a listener for consist eventsprotected void
addToAdvancedConsist(DccLocoAddress LocoAddress, boolean directionNormal)
boolean
contains(DccLocoAddress address)
Does the consist contain the specified locomotive address?void
dispose()
A method for cleaning up the consistDccLocoAddress
getConsistAddress()
Get the Consist Addressjava.lang.String
getConsistID()
Get the text ID associated with the consistjava.util.ArrayList<DccLocoAddress>
getConsistList()
Get a list of the locomotives in the consist.int
getConsistType()
Get the Consist Type.boolean
getLocoDirection(DccLocoAddress address)
Get the relative direction setting for a specific locomotive in the consist.int
getPosition(DccLocoAddress address)
Get the position of a locomotive within the consistjava.lang.String
getRosterId(DccLocoAddress address)
Get the rosterId of a locomotive within the consistboolean
isAddressAllowed(DccLocoAddress address)
Is the specific address allowed?protected void
loadDecoderFile(DecoderFile df, RosterEntry re, VariableTableModel variableModel)
protected void
loadDecoderFromLoco(RosterEntry r, VariableTableModel varTable)
protected void
notifyConsistListeners(DccLocoAddress LocoAddress, int ErrorCode)
void
programmingOpReply(int value, int status)
Receive a callback at the end of a programming operation.void
remove(DccLocoAddress LocoAddress)
Remove a Locomotive from this Consistvoid
removeConsistListener(ConsistListener Listener)
Remove a listener for consist eventsprotected void
removeFromAdvancedConsist(DccLocoAddress LocoAddress)
protected void
resetRosterEntryCVValue(DccLocoAddress address)
Set the value in the roster entry's value for for CV19 to 0void
restore()
restore the consist to the command station.void
restore(DccLocoAddress LocoAddress, boolean directionNormal)
Restore a Locomotive to a Consist, but don't write to the command station.void
reverse()
Reverse the order of the consist and the direction the locomotives are travelingvoid
setConsistID(java.lang.String ID)
Set the text ID associated with the consistvoid
setConsistType(int consist_type)
Set the Consist Type.void
setPosition(DccLocoAddress address, int position)
Set the position of a locomotive within the consistprotected void
setRosterEntryCVValue(DccLocoAddress address)
Update the value in the roster entry for CV19 for the specified addressvoid
setRosterId(DccLocoAddress address, java.lang.String rosterId)
Set the roster entry of a locomotive within the consistint
sizeLimit()
Is there a size limit for this type of consist?protected void
updateRosterCV(DccLocoAddress address, java.lang.Boolean direction, int value)
If allowed by the preferences, Update the CV19 value in the specified address's roster entry, if the roster entry is known.
-
-
-
Field Detail
-
consistList
protected java.util.ArrayList<DccLocoAddress> consistList
-
consistDir
protected java.util.HashMap<DccLocoAddress,java.lang.Boolean> consistDir
-
consistPosition
protected java.util.HashMap<DccLocoAddress,java.lang.Integer> consistPosition
-
consistRoster
protected java.util.HashMap<DccLocoAddress,java.lang.String> consistRoster
-
consistType
protected int consistType
-
consistAddress
protected DccLocoAddress consistAddress
-
consistID
protected java.lang.String consistID
-
-
Constructor Detail
-
DccConsist
public DccConsist(int address)
-
DccConsist
public DccConsist(DccLocoAddress address)
-
DccConsist
public DccConsist(DccLocoAddress address, AddressedProgrammerManager apm)
-
-
Method Detail
-
dispose
public void dispose()
Description copied from interface:Consist
A method for cleaning up the consist
-
setConsistType
public void setConsistType(int consist_type)
Description copied from interface:Consist
Set the Consist Type.- Specified by:
setConsistType
in interfaceConsist
- Parameters:
consist_type
- the consist type
-
getConsistType
public int getConsistType()
Description copied from interface:Consist
Get the Consist Type.- Specified by:
getConsistType
in interfaceConsist
- Returns:
- the consist type
-
getConsistAddress
public DccLocoAddress getConsistAddress()
Description copied from interface:Consist
Get the Consist Address- Specified by:
getConsistAddress
in interfaceConsist
- Returns:
- the consist address
-
isAddressAllowed
public boolean isAddressAllowed(DccLocoAddress address)
Description copied from interface:Consist
Is the specific address allowed? (needed for system specific restrictions)- Specified by:
isAddressAllowed
in interfaceConsist
- Parameters:
address
- the address- Returns:
- true if allowed; false otherwise
-
sizeLimit
public int sizeLimit()
Description copied from interface:Consist
Is there a size limit for this type of consist?
-
getConsistList
public java.util.ArrayList<DccLocoAddress> getConsistList()
Description copied from interface:Consist
Get a list of the locomotives in the consist.- Specified by:
getConsistList
in interfaceConsist
- Returns:
- the list of addresses
-
contains
public boolean contains(DccLocoAddress address)
Description copied from interface:Consist
Does the consist contain the specified locomotive address?
-
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
- 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)
Description copied from interface:Consist
Add a Locomotive to a Consist
-
restore
public void restore(DccLocoAddress LocoAddress, boolean directionNormal)
Description copied from interface:Consist
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.
-
remove
public void remove(DccLocoAddress LocoAddress)
Description copied from interface:Consist
Remove a Locomotive from this Consist
-
addToAdvancedConsist
protected void addToAdvancedConsist(DccLocoAddress LocoAddress, boolean directionNormal)
-
removeFromAdvancedConsist
protected void removeFromAdvancedConsist(DccLocoAddress LocoAddress)
-
setPosition
public void setPosition(DccLocoAddress address, int position)
Description copied from interface:Consist
Set the position of a locomotive within the consist- Specified by:
setPosition
in interfaceConsist
- Parameters:
address
- is the Locomotive addressposition
- is a constant representing the position within the consist.
-
getPosition
public int getPosition(DccLocoAddress address)
Description copied from interface:Consist
Get the position of a locomotive within the consist- Specified by:
getPosition
in interfaceConsist
- Parameters:
address
- is the Locomotive address of interest- Returns:
- integer equal to jmri.Consist.POSITION_LEAD for the designated lead locomotive. equal to jmri.Consist.POSITION_TRAIL for the designated trailing locomotive. between 1 and 254 for other locomotives in the consist
-
setRosterId
public void setRosterId(DccLocoAddress address, java.lang.String rosterId)
Set the roster entry of a locomotive within the consist- Specified by:
setRosterId
in interfaceConsist
- Parameters:
address
- is the Locomotive addressrosterId
- is the roster Identifer of the associated roster entry.
-
getRosterId
public java.lang.String getRosterId(DccLocoAddress address)
Get the rosterId of a locomotive within the consist- Specified by:
getRosterId
in interfaceConsist
- Parameters:
address
- is the Locomotive address of interest- Returns:
- string roster Identifier associated with the given address in the consist. Returns null if no roster entry is associated with this entry.
-
setRosterEntryCVValue
protected void setRosterEntryCVValue(DccLocoAddress address)
Update the value in the roster entry for CV19 for the specified address- Parameters:
address
- is the Locomotive address we are updating.
-
resetRosterEntryCVValue
protected void resetRosterEntryCVValue(DccLocoAddress address)
Set the value in the roster entry's value for for CV19 to 0- Parameters:
address
- is the Locomotive address we are updating.
-
updateRosterCV
protected void updateRosterCV(DccLocoAddress address, java.lang.Boolean direction, int value)
If allowed by the preferences, Update the CV19 value in the specified address's roster entry, if the roster entry is known.- Parameters:
address
- is the Locomotive address we are updating.direction
- the direction to set.value
- the numeric value of the consist address.
-
loadDecoderFromLoco
protected void loadDecoderFromLoco(RosterEntry r, VariableTableModel varTable)
-
loadDecoderFile
protected void loadDecoderFile(DecoderFile df, RosterEntry re, VariableTableModel variableModel)
-
addConsistListener
public void addConsistListener(ConsistListener Listener)
Description copied from interface:Consist
Add a listener for consist events- Specified by:
addConsistListener
in interfaceConsist
- Parameters:
Listener
- is a consistListener object
-
removeConsistListener
public void removeConsistListener(ConsistListener Listener)
Description copied from interface:Consist
Remove a listener for consist events- Specified by:
removeConsistListener
in interfaceConsist
- Parameters:
Listener
- is a consistListener object
-
setConsistID
public void setConsistID(java.lang.String ID)
Description copied from interface:Consist
Set the text ID associated with the consist- Specified by:
setConsistID
in interfaceConsist
- Parameters:
ID
- is a string identifier for the consist
-
getConsistID
public java.lang.String getConsistID()
Description copied from interface:Consist
Get the text ID associated with the consist- Specified by:
getConsistID
in interfaceConsist
- Returns:
- String identifier for the consist default value is the string Identifier for the consist address.
-
reverse
public void reverse()
Description copied from interface:Consist
Reverse the order of the consist and the direction the locomotives are traveling
-
restore
public void restore()
Description copied from interface:Consist
restore the consist to the command station.
-
notifyConsistListeners
protected void notifyConsistListeners(DccLocoAddress LocoAddress, int ErrorCode)
-
programmingOpReply
public void programmingOpReply(int value, int status)
Description copied from interface:ProgListener
Receive a callback at the end of a programming operation.- Specified by:
programmingOpReply
in interfaceProgListener
- Parameters:
value
- Value from a read operation, or value written on a writestatus
- Denotes the completion code. Note that this is a bitwise combination of the various status coded defined in this interface.
-
-