Package jmri.jmrit.decoderdefn
Class DecoderFile
- java.lang.Object
-
- jmri.jmrit.XmlFile
-
- jmri.jmrit.decoderdefn.DecoderFile
-
public class DecoderFile extends XmlFile
Represents and manipulates a decoder definition, both as a file and in memory. The internal storage is a JDOM tree.This object is created by DecoderIndexFile to represent the decoder identification info _before_ the actual decoder file is read.
- See Also:
DecoderIndexFile
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DecoderFile.Showable
-
Nested classes/interfaces inherited from class jmri.jmrit.XmlFile
XmlFile.Validate
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String
_developerID
(package private) org.jdom2.Element
_element
(package private) java.lang.String
_family
(package private) java.lang.String
_filename
(package private) java.lang.String
_manufacturerID
(package private) java.lang.String
_mfg
(package private) java.lang.String
_mfgID
(package private) java.lang.String
_model
(package private) int
_numFns
(package private) int
_numOuts
(package private) java.lang.String
_productID
(package private) java.lang.String
_replacementFamily
(package private) java.lang.String
_replacementModel
static java.lang.String
fileLocation
(package private) int
nextCvStoreIndex
(package private) java.util.ArrayList<LocoAddress.Protocol>
protocols
(package private) boolean[]
versions
-
Fields inherited from class jmri.jmrit.XmlFile
dtdLocation, xsltLocation
-
-
Constructor Summary
Constructors Constructor Description DecoderFile()
DecoderFile(java.lang.String mfg, java.lang.String mfgID, java.lang.String model, java.lang.String lowVersionID, java.lang.String highVersionID, java.lang.String family, java.lang.String filename, int numFns, int numOuts, org.jdom2.Element decoder)
Create a mechanism to manipulate a decoder definition.DecoderFile(java.lang.String mfg, java.lang.String mfgID, java.lang.String model, java.lang.String lowVersionID, java.lang.String highVersionID, java.lang.String family, java.lang.String filename, int numFns, int numOuts, org.jdom2.Element decoder, java.lang.String replacementModel, java.lang.String replacementFamily)
Create a mechanism to manipulate a decoder definition.DecoderFile(java.lang.String mfg, java.lang.String mfgID, java.lang.String model, java.lang.String lowVersionID, java.lang.String highVersionID, java.lang.String family, java.lang.String filename, java.lang.String developerID, java.lang.String manufacturerID, java.lang.String productID, int numFns, int numOuts, org.jdom2.Element decoder, java.lang.String replacementModel, java.lang.String replacementFamily)
Create a mechanism to manipulate a decoder definition.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getDeveloperID()
Get the SV2 "Developer ID" number.java.lang.String
getFamily()
java.lang.String
getFamilyComment()
java.lang.String
getFileName()
java.lang.String
getManufacturerID()
Get the SV2 "Manufacturer ID" number.java.lang.String
getMfg()
java.lang.String
getMfgID()
static java.lang.String
getMfgName(org.jdom2.Element decoderElement)
java.lang.String
getModel()
java.lang.String
getModelComment()
org.jdom2.Element
getModelElement()
int
getNumFunctions()
int
getNumOutputs()
java.lang.String
getProductID()
Get the "Product ID" value.java.lang.String
getReplacementFamily()
java.lang.String
getReplacementModel()
DecoderFile.Showable
getShowable()
LocoAddress.Protocol[]
getSupportedProtocols()
boolean[]
getVersions()
return array of versionsjava.lang.String
getVersionsAsString()
static boolean
isIncluded(org.jdom2.Element e, java.lang.String productID, java.lang.String modelID, java.lang.String familyID, java.lang.String extraInclude, java.lang.String extraExclude)
(package private) boolean
isProductIDok(org.jdom2.Element e, java.lang.String extraInclude, java.lang.String extraExclude)
boolean
isVersion(int i)
Test for correct decoder version numbervoid
loadExtraMenuModel(org.jdom2.Element decoderElement, java.util.ArrayList<ExtraMenuTableModel> extraMenuModelList, javax.swing.JLabel progStatus, Programmer mProgrammer)
void
loadResetModel(org.jdom2.Element decoderElement, ResetTableModel resetModel)
void
loadVariableModel(org.jdom2.Element decoderElement, VariableTableModel variableModel)
Load a VariableTableModel for a given decoder Element, for the purposes of programming.void
processVariablesElement(org.jdom2.Element variablesElement, VariableTableModel variableModel, java.lang.String extraInclude, java.lang.String extraExclude)
void
setOneVersion(int i)
void
setVersionRange(int low, int high)
void
setVersionRange(java.lang.String lowVersionID, java.lang.String highVersionID)
java.lang.String
titleString()
Convert to a canonical text form for ComboBoxes, etc.static java.lang.String
titleString(java.lang.String model, java.lang.String family)
-
Methods inherited from class jmri.jmrit.XmlFile
addDefaultInfo, backupFileName, checkFile, createFileNameWithDate, dumpElement, findFile, getBuilder, getDefaultDtdLocation, getDefaultValidate, getDtdLocation, getProcessingInstructionHRef, getProcessingInstructionType, getRoot, getValidate, makeBackupFile, makeBackupFile, newDocument, newDocument, revertBackupFile, rootFromFile, rootFromInputStream, rootFromName, rootFromURL, setDefaultDtdLocation, setDefaultValidate, setDtdLocation, setValidate, userFileChooser, userFileChooser, writeXML, xmlDir
-
-
-
-
Field Detail
-
versions
boolean[] versions
-
_mfg
java.lang.String _mfg
-
_mfgID
java.lang.String _mfgID
-
_model
java.lang.String _model
-
_family
java.lang.String _family
-
_filename
java.lang.String _filename
-
_productID
java.lang.String _productID
-
_replacementModel
java.lang.String _replacementModel
-
_replacementFamily
java.lang.String _replacementFamily
-
_developerID
java.lang.String _developerID
-
_manufacturerID
java.lang.String _manufacturerID
-
_numFns
int _numFns
-
_numOuts
int _numOuts
-
_element
org.jdom2.Element _element
-
protocols
java.util.ArrayList<LocoAddress.Protocol> protocols
-
nextCvStoreIndex
int nextCvStoreIndex
-
fileLocation
public static java.lang.String fileLocation
-
-
Constructor Detail
-
DecoderFile
public DecoderFile()
-
DecoderFile
public DecoderFile(java.lang.String mfg, java.lang.String mfgID, java.lang.String model, java.lang.String lowVersionID, java.lang.String highVersionID, java.lang.String family, java.lang.String filename, int numFns, int numOuts, org.jdom2.Element decoder)
Create a mechanism to manipulate a decoder definition.- Parameters:
mfg
- manufacturer namemfgID
- manufacturer's NMRA manufacturer number, typically a "CV8" valuemodel
- decoder model designationlowVersionID
- decoder version low byte, where applicablehighVersionID
- decoder version high byte, where applicablefamily
- decoder family name, where applicablefilename
- filename of decoder XML definitionnumFns
- decoder's number of available functionsnumOuts
- decoder's number of available function outputsdecoder
- Element containing decoder XML definition
-
DecoderFile
public DecoderFile(java.lang.String mfg, java.lang.String mfgID, java.lang.String model, java.lang.String lowVersionID, java.lang.String highVersionID, java.lang.String family, java.lang.String filename, int numFns, int numOuts, org.jdom2.Element decoder, java.lang.String replacementModel, java.lang.String replacementFamily)
Create a mechanism to manipulate a decoder definition.- Parameters:
mfg
- manufacturer namemfgID
- manufacturer's NMRA manufacturer number, typically a "CV8" valuemodel
- decoder model designationlowVersionID
- decoder version low byte, where applicablehighVersionID
- decoder version high byte, where applicablefamily
- decoder family name, where applicablefilename
- filename of decoder XML definitionnumFns
- decoder's number of available functionsnumOuts
- decoder's number of available function outputsdecoder
- Element containing decoder XML definitionreplacementModel
- name of decoder file (which replaces this one?)replacementFamily
- name of decoder family (which replaces this one?)
-
DecoderFile
public DecoderFile(java.lang.String mfg, java.lang.String mfgID, java.lang.String model, java.lang.String lowVersionID, java.lang.String highVersionID, java.lang.String family, java.lang.String filename, java.lang.String developerID, java.lang.String manufacturerID, java.lang.String productID, int numFns, int numOuts, org.jdom2.Element decoder, java.lang.String replacementModel, java.lang.String replacementFamily)
Create a mechanism to manipulate a decoder definition.- Parameters:
mfg
- manufacturer namemfgID
- manufacturer's NMRA manufacturer number, typically a "CV8" valuemodel
- decoder model designationlowVersionID
- decoder version low byte, where applicablehighVersionID
- decoder version high byte, where applicablefamily
- decoder family name, where applicablefilename
- filename of decoder XML definitiondeveloperID
- SV2 developerID number (8 bits)manufacturerID
- SV2 manufacturerID number (8 bits)productID
- (typically) SV2 product ID number (16 bits)numFns
- decoder's number of available functionsnumOuts
- decoder's number of available function outputsdecoder
- Element containing decoder XML definitionreplacementModel
- name of decoder file (which replaces this one?)replacementFamily
- name of decoder family (which replaces this one?)
-
-
Method Detail
-
setOneVersion
public void setOneVersion(int i)
-
setVersionRange
public void setVersionRange(int low, int high)
-
setVersionRange
public void setVersionRange(java.lang.String lowVersionID, java.lang.String highVersionID)
-
isVersion
public boolean isVersion(int i)
Test for correct decoder version number- Parameters:
i
- the version to match- Returns:
- true if decoder version matches id
-
getVersions
public boolean[] getVersions()
return array of versions- Returns:
- array of boolean where each element is true if version matches; false otherwise
-
getVersionsAsString
@Nonnull public java.lang.String getVersionsAsString()
-
getMfg
public java.lang.String getMfg()
-
getMfgID
public java.lang.String getMfgID()
-
getDeveloperID
public java.lang.String getDeveloperID()
Get the SV2 "Developer ID" number. This value is assigned by the device manufacturer and is an 8-bit number.- Returns:
- the developerID number
-
getManufacturerID
public java.lang.String getManufacturerID()
Get the SV2 "Manufacturer ID" number. This value typically matches the NMRA manufacturer ID number and is an 8-bit number.- Returns:
- the manufacturer number
-
getModel
public java.lang.String getModel()
-
getFamily
public java.lang.String getFamily()
-
getReplacementModel
public java.lang.String getReplacementModel()
-
getReplacementFamily
public java.lang.String getReplacementFamily()
-
getFileName
public java.lang.String getFileName()
-
getNumFunctions
public int getNumFunctions()
-
getNumOutputs
public int getNumOutputs()
-
getShowable
public DecoderFile.Showable getShowable()
-
getModelComment
public java.lang.String getModelComment()
-
getFamilyComment
public java.lang.String getFamilyComment()
-
getProductID
public java.lang.String getProductID()
Get the "Product ID" value. When applied to LocoNet devices programmed using the SV2 or the LNCV protocol, this is a 16-bit value, and is used in identifying the decoder definition file that matches an SV2 or LNCV device. Decoders which do not support LocoNet SV2 or LNCV programming may use the Product ID value for other purposes.- Returns:
- the productID number
-
getModelElement
public org.jdom2.Element getModelElement()
-
getMfgName
public static java.lang.String getMfgName(org.jdom2.Element decoderElement)
-
getSupportedProtocols
public LocoAddress.Protocol[] getSupportedProtocols()
-
isProductIDok
boolean isProductIDok(org.jdom2.Element e, java.lang.String extraInclude, java.lang.String extraExclude)
-
isIncluded
public static boolean isIncluded(org.jdom2.Element e, java.lang.String productID, java.lang.String modelID, java.lang.String familyID, java.lang.String extraInclude, java.lang.String extraExclude)
- Parameters:
e
- XML element with possible "include" and "exclude" attributes to be checkedproductID
- the specific ID of the decoder being loaded, to check against include/exclude conditionsmodelID
- the model ID of the decoder being loaded, to check against include/exclude conditionsfamilyID
- the family ID of the decoder being loaded, to check against include/exclude conditionsextraInclude
- additional "include" termsextraExclude
- additional "exclude" terms- Returns:
- true if element is included; false otherwise
-
loadVariableModel
public void loadVariableModel(org.jdom2.Element decoderElement, VariableTableModel variableModel)
Load a VariableTableModel for a given decoder Element, for the purposes of programming.- Parameters:
decoderElement
- element which corresponds to the decodervariableModel
- resulting VariableTableModel
-
processVariablesElement
public void processVariablesElement(org.jdom2.Element variablesElement, VariableTableModel variableModel, java.lang.String extraInclude, java.lang.String extraExclude)
-
loadResetModel
public void loadResetModel(org.jdom2.Element decoderElement, ResetTableModel resetModel)
-
loadExtraMenuModel
public void loadExtraMenuModel(org.jdom2.Element decoderElement, java.util.ArrayList<ExtraMenuTableModel> extraMenuModelList, javax.swing.JLabel progStatus, Programmer mProgrammer)
-
titleString
public java.lang.String titleString()
Convert to a canonical text form for ComboBoxes, etc.Must be able to distinguish identical models in different families.
- Returns:
- the title string for the decoder
-
titleString
public static java.lang.String titleString(java.lang.String model, java.lang.String family)
-
-