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:
  • Field Details

  • Constructor Details

    • DecoderFile

      public DecoderFile()
    • DecoderFile

      public DecoderFile(String mfg, String mfgID, String model, String lowVersionID, String highVersionID, String family, String filename, int numFns, int numOuts, org.jdom2.Element decoder)
      Create a mechanism to manipulate a decoder definition from up to 10 parameters.
      Parameters:
      mfg - manufacturer name
      mfgID - manufacturer's NMRA manufacturer number, typically a "CV8" value
      model - decoder model designation
      lowVersionID - decoder version low byte, where applicable
      highVersionID - decoder version high byte, where applicable
      family - decoder family name, where applicable
      filename - filename of decoder XML definition
      numFns - decoder's number of available functions
      numOuts - decoder's number of available function outputs
      decoder - Element containing decoder XML definition
    • DecoderFile

      public DecoderFile(String mfg, String mfgID, String model, String lowVersionID, String highVersionID, String family, String filename, int numFns, int numOuts, org.jdom2.Element decoder, String replacementModel, String replacementFamily)
      Create a mechanism to manipulate a decoder definition from up to 12 parameters.
      Parameters:
      mfg - manufacturer name
      mfgID - manufacturer's NMRA manufacturer number, typically a "CV8" value
      model - decoder model designation
      lowVersionID - decoder version low byte, where applicable
      highVersionID - decoder version high byte, where applicable
      family - decoder family name, where applicable
      filename - filename of decoder XML definition
      numFns - decoder's number of available functions
      numOuts - decoder's number of available function outputs
      decoder - Element containing decoder XML definition
      replacementModel - name of decoder file (which replaces this one?)
      replacementFamily - name of decoder family (which replaces this one?)
    • DecoderFile

      public DecoderFile(String mfg, String mfgID, String model, String lowVersionID, String highVersionID, String family, String filename, String developerID, String manufacturerID, String productID, int numFns, int numOuts, org.jdom2.Element decoder, String replacementModel, String replacementFamily)
      Create a mechanism to manipulate a decoder definition from up to 15 parameters.
      Parameters:
      mfg - manufacturer name
      mfgID - manufacturer's NMRA manufacturer number, typically a "CV8" value
      model - decoder model designation
      lowVersionID - decoder version low byte, where applicable
      highVersionID - decoder version high byte, where applicable
      family - decoder family name, where applicable
      filename - filename of decoder XML definition
      developerID - (typically LocoNet SV2) developerID number (8 bits)
      manufacturerID - manufacturerID number (8 bits)
      productID - product ID number (16 bits)
      numFns - decoder's number of available functions
      numOuts - decoder's number of available function outputs
      decoder - Element containing decoder XML definition
      replacementModel - name of decoder file (which replaces this one?)
      replacementFamily - name of decoder family (which replaces this one?)
    • DecoderFile

      public DecoderFile(String mfg, String mfgID, String model, String lowVersionID, String highVersionID, String family, String filename, String developerID, String manufacturerID, String productID, int numFns, int numOuts, org.jdom2.Element decoder, String replacementModel, String replacementFamily, String programmingModes)
      Create a mechanism to manipulate a decoder definition from up to 16 parameters.
      Parameters:
      mfg - manufacturer name
      mfgID - manufacturer's NMRA manufacturer number, typically a "CV8" value
      model - decoder model designation
      lowVersionID - decoder version low byte, where applicable
      highVersionID - decoder version high byte, where applicable
      family - decoder family name, where applicable
      filename - filename of decoder XML definition
      developerID - (typically LocoNet SV2) developerID number (8 bits)
      manufacturerID - manufacturerID number (8 bits)
      productID - product ID number (16 bits)
      numFns - decoder's number of available functions
      numOuts - decoder's number of available function outputs
      decoder - Element containing decoder XML definition
      replacementModel - name of decoder file (which replaces this one?)
      replacementFamily - name of decoder family (which replaces this one?)
      programmingModes - a comma-separated list of supported programming modes
  • Method Details

    • setOneVersion

      public void setOneVersion(int i)
    • setVersionRange

      public void setVersionRange(int low, int high)
    • setVersionRange

      public void setVersionRange(String lowVersionID, 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 i
    • getVersions

      public boolean[] getVersions()
      return array of versions
      Returns:
      array of boolean where each element is true if version matches
    • getVersionsAsString

    • getMfg

      public String getMfg()
    • getMfgID

      public String getMfgID()
    • getDeveloperID

      Get the (LocoNet SV2) "Developer ID" number.

      This value is assigned by the device manufacturer and is an 8-bit number.

      Returns:
      the developerID number
    • getManufacturerID

      Get the (LocoNet SV2/Uhlenbrock LNCV) "Manufacturer ID" number.

      This value typically matches the NMRA manufacturer ID number and is an 8-bit number.

      Returns:
      the manufacturer number
    • getModel

      public String getModel()
    • getFamily

      public String getFamily()
    • getReplacementModel

    • getReplacementFamily

    • getFileName

      public String getFileName()
    • getNumFunctions

      public int getNumFunctions()
    • getNumOutputs

      public int getNumOutputs()
    • getShowable

    • getModelComment

    • getFamilyComment

    • getProductID

      public String getProductID()
      Get the "Product ID" value.

      When applied to LocoNet devices programmed using the LocoNet SV2 or the Uhlenbrock 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 SV2 or LNCV programming may use the Product ID value for other purposes.

      Returns:
      the productID number
    • getModelElement

      public org.jdom2.Element getModelElement()
    • getSupportedProtocols

    • getProgrammingModes

      Get all specified programming modes a decoder xml supports. This does not include the programming attributes (like ops=false).
      Returns:
      a comma separated string of modes as specified in the decoder xml or empty string when none are specified
    • isProgrammingMode

      public boolean isProgrammingMode(String mode)
    • getMfgName

      public static String getMfgName(org.jdom2.Element decoderElement)
    • getProgrammingModes

      public static String getProgrammingModes(org.jdom2.Element decoderElement)
    • isProductIDok

      boolean isProductIDok(org.jdom2.Element e, String extraInclude, String extraExclude)
    • isIncluded

      public static boolean isIncluded(org.jdom2.Element e, String productID, String modelID, String familyID, String extraInclude, String extraExclude)
      Parameters:
      e - XML element with possible "include" and "exclude" attributes to be checked
      productID - the specific ID of the decoder being loaded, to check against include/exclude conditions
      modelID - the model ID of the decoder being loaded, to check against include/exclude conditions
      familyID - the family ID of the decoder being loaded, to check against include/exclude conditions
      extraInclude - additional "include" terms
      extraExclude - 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 decoder
      variableModel - resulting VariableTableModel
    • processVariablesElement

      public void processVariablesElement(org.jdom2.Element variablesElement, VariableTableModel variableModel, String extraInclude, String extraExclude)
    • loadResetModel

      public void loadResetModel(org.jdom2.Element decoderElement, ResetTableModel resetModel)
    • loadExtraMenuModel

      public void loadExtraMenuModel(org.jdom2.Element decoderElement, ArrayList<ExtraMenuTableModel> extraMenuModelList, JLabel progStatus, Programmer mProgrammer)
    • titleString

      public 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 String titleString(String model, String family)