Package jmri.implementation
Class DccConsist
- java.lang.Object
- 
- jmri.implementation.DccConsist
 
- 
- All Implemented Interfaces:
- java.util.EventListener,- Consist,- ProgListener
 - Direct Known Subclasses:
- EasyDccConsist,- LocoNetConsist,- MqttConsist,- 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 SummaryFields Modifier and Type Field Description protected DccLocoAddressconsistAddressprotected java.util.HashMap<DccLocoAddress,java.lang.Boolean>consistDirprotected java.lang.StringconsistIDprotected java.util.ArrayList<DccLocoAddress>consistListprotected java.util.HashMap<DccLocoAddress,java.lang.Integer>consistPositionprotected java.util.HashMap<DccLocoAddress,java.lang.String>consistRosterprotected intconsistType- 
Fields inherited from interface jmri.ConsistADVANCED_CONSIST, CS_CONSIST, POSITION_LEAD, POSITION_TRAIL
 - 
Fields inherited from interface jmri.ProgListenerCommError, ConfirmFailed, FailedTimeout, NoAck, NoLocoDetected, NotImplemented, OK, ProgrammerBusy, ProgrammingShort, SequenceError, UnknownError, UserAborted
 
- 
 - 
Constructor SummaryConstructors Constructor Description DccConsist(int address)DccConsist(DccLocoAddress address)DccConsist(DccLocoAddress address, AddressedProgrammerManager apm)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(DccLocoAddress address, boolean directionNormal)Add a Locomotive to an Advanced ConsistvoidaddConsistListener(ConsistListener listener)Add a Listener for consist events.protected voidaddToAdvancedConsist(DccLocoAddress address, boolean directionNormal)Add a Locomotive to an Advanced Consist.booleancontains(DccLocoAddress address)Does the consist contain the specified locomotive address?voiddispose()A method for cleaning up the consistDccLocoAddressgetConsistAddress()Get the Consist Addressjava.lang.StringgetConsistID()Get the text ID associated with the consist.java.util.ArrayList<DccLocoAddress>getConsistList()Get a list of the locomotives in the consist.intgetConsistType()Get the Consist Type.booleangetLocoDirection(DccLocoAddress address)Get the relative direction setting for a specific locomotive in the consist.intgetPosition(DccLocoAddress address)Get the position of a locomotive within the consist.java.lang.StringgetRosterId(DccLocoAddress address)Get the rosterId of a locomotive within the consistbooleanisAddressAllowed(DccLocoAddress address)Is this address allowed?protected voidloadDecoderFile(DecoderFile df, RosterEntry re, VariableTableModel variableModel)protected voidloadDecoderFromLoco(RosterEntry r, VariableTableModel varTable)protected voidnotifyConsistListeners(DccLocoAddress locoAddress, int errorCode)Notify all listener objects of a status change.voidprogrammingOpReply(int value, int status)Receive a callback at the end of a programming operation.voidremove(DccLocoAddress address)Remove a Locomotive from this Consist.voidremoveConsistListener(ConsistListener listener)Remove a Listener for consist eventsprotected voidremoveFromAdvancedConsist(DccLocoAddress address)Remove a Locomotive from an Advanced Consistprotected voidresetRosterEntryCVValue(DccLocoAddress address)Set the value in the roster entry's value for for CV19 to 0voidrestore()Restore the consist to the command station.voidrestore(DccLocoAddress address, boolean directionNormal)Restore a Locomotive to an Advanced Consist, but don't write to the command station.voidreverse()Reverse the order of locomotives in the consist and flip the direction bits of each locomotive.voidsetConsistID(java.lang.String id)Set the text ID associated with the consist.voidsetConsistType(int consist_type)Set the Consist Type.voidsetPosition(DccLocoAddress address, int position)Set the position of a locomotive within the consist.protected voidsetRosterEntryCVValue(DccLocoAddress address)Update the value in the roster entry for CV19 for the specified addressvoidsetRosterId(DccLocoAddress address, java.lang.String rosterId)Set the roster entry of a locomotive within the consist.intsizeLimit()Is there a size limit for this consist?protected voidupdateRosterCV(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- 
consistListprotected java.util.ArrayList<DccLocoAddress> consistList 
 - 
consistDirprotected java.util.HashMap<DccLocoAddress,java.lang.Boolean> consistDir 
 - 
consistPositionprotected java.util.HashMap<DccLocoAddress,java.lang.Integer> consistPosition 
 - 
consistRosterprotected java.util.HashMap<DccLocoAddress,java.lang.String> consistRoster 
 - 
consistTypeprotected int consistType 
 - 
consistAddressprotected DccLocoAddress consistAddress 
 - 
consistIDprotected java.lang.String consistID 
 
- 
 - 
Constructor Detail- 
DccConsistpublic DccConsist(int address) 
 - 
DccConsistpublic DccConsist(DccLocoAddress address) 
 - 
DccConsistpublic DccConsist(DccLocoAddress address, AddressedProgrammerManager apm) 
 
- 
 - 
Method Detail- 
disposepublic void dispose() Description copied from interface:ConsistA method for cleaning up the consist
 - 
setConsistTypepublic void setConsistType(int consist_type) Description copied from interface:ConsistSet the Consist Type.- Specified by:
- setConsistTypein interface- Consist
- Parameters:
- consist_type- the consist type
 
 - 
getConsistTypepublic int getConsistType() Description copied from interface:ConsistGet the Consist Type.- Specified by:
- getConsistTypein interface- Consist
- Returns:
- the consist type
 
 - 
getConsistAddresspublic DccLocoAddress getConsistAddress() Description copied from interface:ConsistGet the Consist Address- Specified by:
- getConsistAddressin interface- Consist
- Returns:
- the consist address
 
 - 
isAddressAllowedpublic boolean isAddressAllowed(DccLocoAddress address) 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:
- isAddressAllowedin interface- Consist
- Parameters:
- address- the address
- Returns:
- true if allowed; false otherwise
 
 - 
sizeLimitpublic int sizeLimit() Is there a size limit for this consist? For Decoder Assisted Consists, returns -1 (no limit) return 0 for any other consist type.
 - 
getConsistListpublic java.util.ArrayList<DccLocoAddress> getConsistList() Description copied from interface:ConsistGet a list of the locomotives in the consist.- Specified by:
- getConsistListin interface- Consist
- Returns:
- the list of addresses
 
 - 
containspublic boolean contains(DccLocoAddress address) Description copied from interface:ConsistDoes the consist contain the specified locomotive address?
 - 
getLocoDirectionpublic boolean getLocoDirection(DccLocoAddress address) Description copied from interface:ConsistGet the relative direction setting for a specific locomotive in the consist.- Specified by:
- getLocoDirectionin interface- Consist
- Parameters:
- address- the address to check
- Returns:
- true if locomotive is in consist in its normal direction of travel; false otherwise
 
 - 
addpublic void add(DccLocoAddress address, boolean directionNormal) Add a Locomotive to an Advanced Consist
 - 
restorepublic void restore(DccLocoAddress address, 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.
 - 
removepublic void remove(DccLocoAddress address) Remove a Locomotive from this Consist.
 - 
addToAdvancedConsistprotected void addToAdvancedConsist(DccLocoAddress address, boolean directionNormal) Add a Locomotive to an Advanced Consist.- Parameters:
- address- is the Locomotive address to add to the locomotive
- directionNormal- is True if the locomotive is traveling the same direction as the consist, or false otherwise.
 
 - 
removeFromAdvancedConsistprotected void removeFromAdvancedConsist(DccLocoAddress address) Remove a Locomotive from an Advanced Consist- Parameters:
- address- is the Locomotive address to remove from the consist
 
 - 
setPositionpublic void setPosition(DccLocoAddress address, int position) Set the position of a locomotive within the consist.- Specified by:
- setPositionin interface- Consist
- Parameters:
- address- is the Locomotive address
- position- is a constant representing the position within the consist.
 
 - 
getPositionpublic int getPosition(DccLocoAddress address) Get the position of a locomotive within the consist.- Specified by:
- getPositionin interface- Consist
- 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
 
 - 
setRosterIdpublic void setRosterId(DccLocoAddress address, java.lang.String rosterId) Set the roster entry of a locomotive within the consist.- Specified by:
- setRosterIdin interface- Consist
- Parameters:
- address- is the Locomotive address
- rosterId- is the roster Identifier of the associated roster entry.
 
 - 
getRosterIdpublic java.lang.String getRosterId(DccLocoAddress address) Get the rosterId of a locomotive within the consist- Specified by:
- getRosterIdin interface- Consist
- 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.
 
 - 
setRosterEntryCVValueprotected 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.
 
 - 
resetRosterEntryCVValueprotected 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.
 
 - 
updateRosterCVprotected 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.
 
 - 
loadDecoderFromLocoprotected void loadDecoderFromLoco(RosterEntry r, VariableTableModel varTable) 
 - 
loadDecoderFileprotected void loadDecoderFile(DecoderFile df, RosterEntry re, VariableTableModel variableModel) 
 - 
addConsistListenerpublic void addConsistListener(ConsistListener listener) Add a Listener for consist events.- Specified by:
- addConsistListenerin interface- Consist
- Parameters:
- listener- is a consistListener object
 
 - 
removeConsistListenerpublic void removeConsistListener(ConsistListener listener) Remove a Listener for consist events- Specified by:
- removeConsistListenerin interface- Consist
- Parameters:
- listener- is a consistListener object
 
 - 
setConsistIDpublic void setConsistID(java.lang.String id) Set the text ID associated with the consist.- Specified by:
- setConsistIDin interface- Consist
- Parameters:
- id- is a string identifier for the consist.
 
 - 
getConsistIDpublic java.lang.String getConsistID() Get the text ID associated with the consist.- Specified by:
- getConsistIDin interface- Consist
- Returns:
- String identifier for the consist. Default value is the string Identifier for the consist address.
 
 - 
reversepublic void reverse() Reverse the order of locomotives in the consist and flip the direction bits of each locomotive.
 - 
restorepublic void restore() Restore the consist to the command station.
 - 
notifyConsistListenersprotected void notifyConsistListeners(DccLocoAddress locoAddress, int errorCode) Notify all listener objects of a status change.- Parameters:
- locoAddress- is the address of any specific locomotive the status refers to.
- errorCode- is the status code to send to the consistListener objects
 
 - 
programmingOpReplypublic void programmingOpReply(int value, int status) Description copied from interface:ProgListenerReceive a callback at the end of a programming operation.- Specified by:
- programmingOpReplyin interface- ProgListener
- Parameters:
- value- Value from a read operation, or value written on a write
- status- Denotes the completion code. Note that this is a bitwise combination of the various status coded defined in this interface.
 
 
- 
 
-