Search in sources :

Example 21 with Attribute

use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.

the class VariableTableModel method setIndxRow.

/**
     * Load one row in the IndexedVariableTableModel, by reading in the Element
     * containing its definition.
     * <p>
     * Invoked from DecoderFile
     *
     * @param row       number of row to fill
     * @param e         Element of type "variable"
     * @param productID product ID of decoder, passed in so that subparts of the
     *                  variable can use it for selection
     */
public int setIndxRow(int row, Element e, String productID, String modelID, String familyID) {
    // get the values for the VariableValue ctor
    // Note the name variable is actually the label attribute
    String name = LocaleSelector.getAttribute(e, "label");
    if (log.isDebugEnabled()) {
        log.debug("Starting to setIndexedRow \"" + name + "\" row " + row);
    }
    String cvName = e.getAttributeValue("CVname");
    String item = (e.getAttribute("item") != null ? e.getAttribute("item").getValue() : null);
    String comment = LocaleSelector.getAttribute(e, "comment");
    int piVal = Integer.valueOf(e.getAttribute("PI").getValue()).intValue();
    int siVal = (e.getAttribute("SI") != null ? Integer.valueOf(e.getAttribute("SI").getValue()).intValue() : -1);
    String cv = e.getAttribute("CV").getValue();
    String mask = null;
    if (e.getAttribute("mask") != null) {
        mask = e.getAttribute("mask").getValue();
    } else {
        mask = "VVVVVVVV";
    }
    boolean readOnly = e.getAttribute("readOnly") != null ? e.getAttribute("readOnly").getValue().equals("yes") : false;
    boolean infoOnly = e.getAttribute("infoOnly") != null ? e.getAttribute("infoOnly").getValue().equals("yes") : false;
    boolean writeOnly = e.getAttribute("writeOnly") != null ? e.getAttribute("writeOnly").getValue().equals("yes") : false;
    boolean opsOnly = e.getAttribute("opsOnly") != null ? e.getAttribute("opsOnly").getValue().equals("yes") : false;
    JButton br = new JButton("Read");
    _readButtons.addElement(br);
    JButton bw = new JButton("Write");
    _writeButtons.addElement(bw);
    setButtonsReadWrite(readOnly, infoOnly, writeOnly, bw, br, row);
    if (_indxCvModel == null) {
        log.error("IndexedCvModel reference is null; can not add variables");
        return -1;
    }
    // add the information to the indexed CV model
    int _newRow = _indxCvModel.addIndxCV(cvName, _piCv, piVal, _siCv, siVal, cv, readOnly, infoOnly, writeOnly);
    if (_newRow != row) {
        row = _newRow;
        if (log.isDebugEnabled()) {
            log.debug("new row is " + _newRow + ", row was " + row);
        }
    }
    // Find and process the specific content types
    VariableValue iv;
    iv = createIndexedVariableFromElement(e, name, comment, cvName, readOnly, infoOnly, writeOnly, opsOnly, cv, mask, item, productID, modelID, familyID);
    if (iv == null) {
        // trouble reporting
        reportBogus();
        return -1;
    }
    processModifierElements(e, iv);
    setToolTip(e, iv);
    // record new variable, update state, hook up listeners
    rowVector.addElement(iv);
    iv.setState(VariableValue.FROMFILE);
    iv.addPropertyChangeListener(this);
    // set to default value if specified (CV load may later override this)
    Attribute a;
    if ((a = e.getAttribute("default")) != null) {
        String val = a.getValue();
        if (log.isDebugEnabled()) {
            log.debug("Found default value: " + val + " for " + name);
        }
        iv.setIntValue(Integer.valueOf(val).intValue());
        if (_indxCvModel.getCvByRow(row).getInfoOnly()) {
            _indxCvModel.getCvByRow(row).setState(VariableValue.READ);
        } else {
            // correct for transition to "edited"
            _indxCvModel.getCvByRow(row).setState(VariableValue.FROMFILE);
        }
    } else {
        _indxCvModel.getCvByRow(row).setState(VariableValue.UNKNOWN);
    }
    return row;
}
Also used : Attribute(org.jdom2.Attribute) JButton(javax.swing.JButton)

Example 22 with Attribute

use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.

the class VariableTableModel method setDefaultValue.

/**
     * If there's a "default" attribute, set that value to start
     *
     * @return true if the value was set
     */
protected boolean setDefaultValue(Element e, VariableValue v) {
    Attribute a;
    if ((a = e.getAttribute("default")) != null) {
        String val = a.getValue();
        v.setIntValue(Integer.valueOf(val).intValue());
        return true;
    }
    return false;
}
Also used : Attribute(org.jdom2.Attribute)

Example 23 with Attribute

use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.

the class VariableTableModel method processIndexedVal.

protected VariableValue processIndexedVal(Element child, String name, String comment, String cvName, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, String cv, String mask, String item) throws NumberFormatException {
    VariableValue iv;
    int minVal = 0;
    int maxVal = 255;
    Attribute a;
    if ((a = child.getAttribute("min")) != null) {
        minVal = Integer.valueOf(a.getValue()).intValue();
    }
    if ((a = child.getAttribute("max")) != null) {
        maxVal = Integer.valueOf(a.getValue()).intValue();
    }
    iv = new IndexedVariableValue(name, comment, cvName, readOnly, infoOnly, writeOnly, opsOnly, cv, mask, minVal, maxVal, _indxCvModel.allIndxCvMap(), _status, item);
    return iv;
}
Also used : Attribute(org.jdom2.Attribute)

Example 24 with Attribute

use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.

the class PositionFile method getReceiverMax.

/**
     * Get the nth receiver max time.
     *
     * @return 0 if not present
     */
public int getReceiverMax(int n) {
    List<Element> kids = root.getChildren("receiver");
    for (int i = 0; i < kids.size(); i++) {
        Element e = kids.get(i);
        Attribute a = e.getAttribute("number");
        if (a == null) {
            continue;
        }
        int num = -1;
        try {
            num = a.getIntValue();
        } catch (org.jdom2.DataConversionException ex1) {
            log.error("in getReceiverMax", ex1);
        }
        if (num != n) {
            continue;
        }
        a = e.getAttribute("maxtime");
        if (a == null) {
            // default value
            return 99999;
        }
        try {
            return a.getIntValue();
        } catch (org.jdom2.DataConversionException ex2) {
            return 99999;
        }
    }
    return 99999;
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

Example 25 with Attribute

use of org.openmuc.jasn1.compiler.pkix1explicit88.Attribute in project JMRI by JMRI.

the class PositionFile method getReceiverPosition.

/**
     * Get the nth receiver position in the file.
     *
     * @return null if not present
     */
public Point3d getReceiverPosition(int n) {
    List<Element> kids = root.getChildren("receiver");
    for (int i = 0; i < kids.size(); i++) {
        Element e = kids.get(i);
        Attribute a = e.getAttribute("number");
        if (a == null) {
            continue;
        }
        int num = -1;
        try {
            num = a.getIntValue();
        } catch (org.jdom2.DataConversionException ex) {
            log.error("in getReceiverPosition", ex);
        }
        if (num == n) {
            return positionFromElement(e.getChild("position"));
        }
    }
    return null;
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element)

Aggregations

Attribute (org.jdom2.Attribute)148 Element (org.jdom2.Element)104 Document (org.jdom2.Document)18 ArrayList (java.util.ArrayList)17 DataConversionException (org.jdom2.DataConversionException)16 Editor (jmri.jmrit.display.Editor)15 Test (org.junit.Test)15 IOException (java.io.IOException)14 NamedIcon (jmri.jmrit.catalog.NamedIcon)13 Attribute (org.bouncycastle.asn1.x509.Attribute)11 HashMap (java.util.HashMap)10 List (java.util.List)9 HashSet (java.util.HashSet)7 Map (java.util.Map)7 LayoutEditor (jmri.jmrit.display.layoutEditor.LayoutEditor)7 Attribute (ucar.nc2.Attribute)7 Asn1Integer (com.android.hotspot2.asn1.Asn1Integer)5 Asn1Object (com.android.hotspot2.asn1.Asn1Object)5 Asn1Oid (com.android.hotspot2.asn1.Asn1Oid)5 OidMappings (com.android.hotspot2.asn1.OidMappings)5