use of org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.
the class WarrantPreferences method loadSpeedMap.
// Avoid firePropertyChange until SignalSpeedMap is completely loaded
private boolean loadSpeedMap(Element child) {
if (child == null) {
return false;
}
Element rampParms = child.getChild(STEP_INCREMENTS);
if (rampParms == null) {
return false;
}
Attribute a;
if ((a = rampParms.getAttribute(TIME_INCREMENT)) != null) {
try {
this._msIncrTime = a.getIntValue();
} catch (DataConversionException ex) {
this._msIncrTime = 500;
log.error("Unable to read ramp time increment. Setting to default value (500ms).", ex);
}
}
if ((a = rampParms.getAttribute(RAMP_INCREMENT)) != null) {
try {
this._throttleIncr = a.getFloatValue();
} catch (DataConversionException ex) {
this._throttleIncr = 0.03f;
log.error("Unable to read ramp throttle increment. Setting to default value (0.03).", ex);
}
}
if ((a = rampParms.getAttribute(THROTTLE_SCALE)) != null) {
try {
_throttleScale = a.getFloatValue();
} catch (DataConversionException ex) {
_throttleScale = .90f;
log.error("Unable to read throttle scale. Setting to default value (0.90f).", ex);
}
}
rampParms = child.getChild(SPEED_NAME_PREFS);
if (rampParms == null) {
return false;
}
if ((a = rampParms.getAttribute("percentNormal")) != null) {
if (a.getValue().equals("yes")) {
_interpretation = 1;
} else {
_interpretation = 2;
}
}
if ((a = rampParms.getAttribute(INTERPRETATION)) != null) {
try {
_interpretation = a.getIntValue();
} catch (DataConversionException ex) {
_interpretation = 1;
log.error("Unable to read interpetation of Speed Map. Setting to default value % normal.", ex);
}
}
HashMap<String, Float> map = new LinkedHashMap<>();
List<Element> list = rampParms.getChildren();
for (int i = 0; i < list.size(); i++) {
String name = list.get(i).getName();
Float speed = 0f;
try {
speed = Float.valueOf(list.get(i).getText());
} catch (NumberFormatException nfe) {
log.error("Speed names has invalid content for {} = ", name, list.get(i).getText());
}
log.debug("Add {}, {} to AspectSpeed Table", name, speed);
map.put(name, speed);
}
// no firePropertyChange
this.setSpeedNames(map);
rampParms = child.getChild(APPEARANCE_PREFS);
if (rampParms == null) {
return false;
}
LinkedHashMap<String, String> heads = new LinkedHashMap<>();
list = rampParms.getChildren();
for (int i = 0; i < list.size(); i++) {
String name = Bundle.getMessage(list.get(i).getName());
String speed = list.get(i).getText();
heads.put(name, speed);
}
// no firePropertyChange
this.setAppearances(heads);
// Now set SignalSpeedMap members.
SignalSpeedMap speedMap = jmri.InstanceManager.getDefault(SignalSpeedMap.class);
speedMap.setRampParams(_msIncrTime, _msIncrTime);
speedMap.setDefaultThrottleFactor(_throttleScale);
speedMap.setLayoutScale(_scale);
speedMap.setAspects(new HashMap<>(this._speedNames), _interpretation);
speedMap.setAppearances(new HashMap<>(this._headAppearances));
return true;
}
use of org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.
the class TrainSwitchListText method load.
public static void load(Element e) {
Element emts = e.getChild(Xml.SWITCH_LIST_TEXT_STRINGS);
if (emts == null) {
return;
}
Attribute a;
if (emts.getChild(Xml.SWICH_LIST_FOR) != null) {
if ((a = emts.getChild(Xml.SWICH_LIST_FOR).getAttribute(Xml.TEXT)) != null) {
setStringSwitchListFor(a.getValue());
}
}
if (emts.getChild(Xml.SCHEDULED_WORK_TRAIN) != null) {
if ((a = emts.getChild(Xml.SCHEDULED_WORK_TRAIN).getAttribute(Xml.TEXT)) != null) {
setStringScheduledWork(a.getValue());
}
}
if (emts.getChild(Xml.DEPARTS_AT) != null) {
if ((a = emts.getChild(Xml.DEPARTS_AT).getAttribute(Xml.TEXT)) != null) {
setStringDepartsAt(a.getValue());
}
}
if (emts.getChild(Xml.DEPARTS_EXPECTED_ARRIVAL) != null) {
if ((a = emts.getChild(Xml.DEPARTS_EXPECTED_ARRIVAL).getAttribute(Xml.TEXT)) != null) {
setStringDepartsAtExpectedArrival(a.getValue());
}
}
if (emts.getChild(Xml.DEPARTED_EXPECTED) != null) {
if ((a = emts.getChild(Xml.DEPARTED_EXPECTED).getAttribute(Xml.TEXT)) != null) {
setStringDepartedExpected(a.getValue());
}
}
if (emts.getChild(Xml.VISIT_NUMBER) != null) {
if ((a = emts.getChild(Xml.VISIT_NUMBER).getAttribute(Xml.TEXT)) != null) {
setStringVisitNumber(a.getValue());
}
}
if (emts.getChild(Xml.VISIT_NUMBER_DEPARTED) != null) {
if ((a = emts.getChild(Xml.VISIT_NUMBER_DEPARTED).getAttribute(Xml.TEXT)) != null) {
setStringVisitNumberDeparted(a.getValue());
}
}
if (emts.getChild(Xml.VISIT_NUMBER_TERMINATES) != null) {
if ((a = emts.getChild(Xml.VISIT_NUMBER_TERMINATES).getAttribute(Xml.TEXT)) != null) {
setStringVisitNumberTerminates(a.getValue());
}
}
if (emts.getChild(Xml.VISIT_NUMBER_TERMINATES_DEPARTED) != null) {
if ((a = emts.getChild(Xml.VISIT_NUMBER_TERMINATES_DEPARTED).getAttribute(Xml.TEXT)) != null) {
setStringVisitNumberTerminatesDeparted(a.getValue());
}
}
if (emts.getChild(Xml.VISIT_NUMBER_DONE) != null) {
if ((a = emts.getChild(Xml.VISIT_NUMBER_DONE).getAttribute(Xml.TEXT)) != null) {
setStringVisitNumberDone(a.getValue());
}
}
if (emts.getChild(Xml.TRAIN_DIRECTION_CHANGE) != null) {
if ((a = emts.getChild(Xml.TRAIN_DIRECTION_CHANGE).getAttribute(Xml.TEXT)) != null) {
setStringTrainDirectionChange(a.getValue());
}
}
if (emts.getChild(Xml.NO_CAR_PICK_UPS) != null) {
if ((a = emts.getChild(Xml.NO_CAR_PICK_UPS).getAttribute(Xml.TEXT)) != null) {
setStringNoCarPickUps(a.getValue());
}
}
if (emts.getChild(Xml.NO_CAR_SET_OUTS) != null) {
if ((a = emts.getChild(Xml.NO_CAR_SET_OUTS).getAttribute(Xml.TEXT)) != null) {
setStringNoCarDrops(a.getValue());
}
}
if (emts.getChild(Xml.TRAIN_DONE) != null) {
if ((a = emts.getChild(Xml.TRAIN_DONE).getAttribute(Xml.TEXT)) != null) {
setStringTrainDone(a.getValue());
}
}
if (emts.getChild(Xml.TRAIN_DEPARTS_CARS) != null) {
if ((a = emts.getChild(Xml.TRAIN_DEPARTS_CARS).getAttribute(Xml.TEXT)) != null) {
setStringTrainDepartsCars(a.getValue());
}
}
if (emts.getChild(Xml.TRAIN_DEPARTS_LOADS) != null) {
if ((a = emts.getChild(Xml.TRAIN_DEPARTS_LOADS).getAttribute(Xml.TEXT)) != null) {
setStringTrainDepartsLoads(a.getValue());
}
}
if (emts.getChild(Xml.SWITCH_LIST_TRACK) != null) {
if ((a = emts.getChild(Xml.SWITCH_LIST_TRACK).getAttribute(Xml.TEXT)) != null) {
setStringSwitchListByTrack(a.getValue());
}
}
if (emts.getChild(Xml.HOLD_CAR) != null) {
if ((a = emts.getChild(Xml.HOLD_CAR).getAttribute(Xml.TEXT)) != null) {
setStringHoldCar(a.getValue());
}
}
}
use of org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.
the class SymbolicProgFrame method processLocoFile.
void processLocoFile(Element loco) {
// load the name et al
locoRoadName.setText(loco.getAttributeValue("roadName"));
locoRoadNumber.setText(loco.getAttributeValue("roadNumber"));
locoMfg.setText(loco.getAttributeValue("mfg"));
locoModel.setText(loco.getAttributeValue("model"));
// load the variable definitions for the decoder
Element decoder = loco.getChild("decoder");
if (decoder != null) {
// get the file name
String mfg = decoder.getAttribute("mfg").getValue();
String model = decoder.getAttribute("model").getValue();
String filename = "xml" + File.separator + mfg + "_" + model + ".xml";
if (log.isDebugEnabled()) {
log.debug("will read decoder info from " + filename);
}
readAndParseConfigFile(new File(filename));
if (log.isDebugEnabled()) {
log.debug("finished processing decoder file for loco file");
}
} else {
log.error("No decoder element found in config file");
}
// get the CVs and load
Element values = loco.getChild("values");
if (values != null) {
// get the CV values and load
List<Element> varList = values.getChildren("CVvalue");
if (log.isDebugEnabled()) {
log.debug("Found " + varList.size() + " CVvalues");
}
for (int i = 0; i < varList.size(); i++) {
// locate the row
if (((varList.get(i))).getAttribute("name") == null) {
if (log.isDebugEnabled()) {
log.debug("unexpected null in name " + ((varList.get(i))) + " " + ((varList.get(i))).getAttributes());
}
break;
}
if (((varList.get(i))).getAttribute("value") == null) {
if (log.isDebugEnabled()) {
log.debug("unexpected null in value " + ((varList.get(i))) + " " + ((varList.get(i))).getAttributes());
}
break;
}
String name = ((varList.get(i))).getAttribute("name").getValue();
String value = ((varList.get(i))).getAttribute("value").getValue();
if (log.isDebugEnabled()) {
log.debug("CV: " + i + "th entry, CV number " + name + " has value: " + value);
}
CvValue cvObject = cvModel.allCvMap().get(name);
cvObject.setValue(Integer.valueOf(value).intValue());
cvObject.setState(CvValue.FROMFILE);
}
variableModel.configDone();
} else {
log.error("no values element found in config file; CVs not configured");
return;
}
// get the variable values and load
Element decoderDef = values.getChild("decoderDef");
if (decoderDef != null) {
List<Element> varList = decoderDef.getChildren("varValue");
if (log.isDebugEnabled()) {
log.debug("Found " + varList.size() + " varValues");
}
for (int i = 0; i < varList.size(); i++) {
// locate the row
Attribute itemAttr = null;
if ((itemAttr = varList.get(i).getAttribute("item")) == null) {
if (log.isDebugEnabled()) {
log.debug("unexpected null in item " + varList.get(i));
}
break;
}
if ((itemAttr = varList.get(i).getAttribute("name")) == null) {
if (log.isDebugEnabled()) {
log.debug("unexpected null in name " + varList.get(i));
}
break;
}
String item = itemAttr.getValue();
if (((varList.get(i))).getAttribute("value") == null) {
if (log.isDebugEnabled()) {
log.debug("unexpected null in value " + ((varList.get(i))));
}
break;
}
String value = ((varList.get(i))).getAttribute("value").getValue();
if (log.isDebugEnabled()) {
log.debug("Variable " + i + " is " + item + " value: " + value);
}
int row;
for (row = 0; row < variableModel.getRowCount(); row++) {
if (variableModel.getLabel(row).equals(item)) {
break;
}
}
if (log.isDebugEnabled()) {
log.debug("Variable " + item + " is row " + row);
}
if (!value.equals("")) {
// don't set if no value was stored
variableModel.setIntValue(row, Integer.valueOf(value).intValue());
}
variableModel.setState(row, VariableValue.FROMFILE);
}
variableModel.configDone();
} else {
log.error("no decoderDef element found in config file");
}
// the act of loading values marks as dirty, but we're actually in synch
variableModel.setFileDirty(false);
}
use of org.bouncycastle.asn1.x509.Attribute in project JMRI by JMRI.
the class VariableTableModel method processIEnumVal.
protected VariableValue processIEnumVal(Element child, String name, String comment, String cvName, boolean readOnly, boolean infoOnly, boolean writeOnly, boolean opsOnly, String cv, String mask, String item, String productID, String modelID, String familyID) throws NumberFormatException {
VariableValue iv;
List<Element> l = child.getChildren("ienumChoice");
IndexedEnumVariableValue v1 = new IndexedEnumVariableValue(name, comment, cvName, readOnly, infoOnly, writeOnly, opsOnly, cv, mask, _indxCvModel.allIndxCvMap(), _status, item);
iv = v1;
for (int x = 0; x < l.size(); x++) {
Element ex = l.get(x);
if (DecoderFile.isIncluded(ex, productID, modelID, familyID, "", "") == false) {
// add inherited include, inherited exclude
l.remove(x);
x--;
}
}
v1.nItems(l.size());
for (int k = 0; k < l.size(); k++) {
Element enumChElement = l.get(k);
// is a value specified?
Attribute valAttr = enumChElement.getAttribute("value");
if (valAttr == null) {
v1.addItem(LocaleSelector.getAttribute(enumChElement, "choice"));
} else {
v1.addItem(LocaleSelector.getAttribute(enumChElement, "choice"), Integer.parseInt(valAttr.getValue()));
}
}
v1.lastItem();
return iv;
}
use of org.bouncycastle.asn1.x509.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;
}
Aggregations