Class 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
    • Constructor Detail

      • 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,
                           Element decoder)
        Create a mechanism to manipulate a decoder definition.
        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​(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,
                           Element decoder,
                           java.lang.String replacementModel,
                           java.lang.String replacementFamily)
        Create a mechanism to manipulate a decoder definition.
        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​(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,
                           Element decoder,
                           java.lang.String replacementModel,
                           java.lang.String replacementFamily)
        Create a mechanism to manipulate a decoder definition.
        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 - 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 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?)
    • Method Detail

      • 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
      • 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()
      • 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
      • isProductIDok

        boolean isProductIDok​(Element e,
                              java.lang.String extraInclude,
                              java.lang.String extraExclude)
      • isIncluded

        public static boolean isIncluded​(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 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​(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
      • 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)