use of org.csstudio.opibuilder.script.Expression in project yamcs-studio by yamcs.
the class RulesProperty method writeToXML.
@Override
public void writeToXML(Element propElement) {
for (RuleData ruleData : ((RulesInput) getPropertyValue()).getRuleDataList()) {
Element ruleElement = new Element(XML_ELEMENT_RULE);
ruleElement.setAttribute(XML_ATTRIBUTE_NAME, ruleData.getName());
ruleElement.setAttribute(XML_ATTRIBUTE_PROPID, ruleData.getPropId());
ruleElement.setAttribute(XML_ATTRIBUTE_OUTPUTEXPRESSION, Boolean.toString(ruleData.isOutputExpValue()));
for (Expression exp : ruleData.getExpressionList()) {
Element expElement = new Element(XML_ELEMENT_EXPRESSION);
expElement.setAttribute(XML_ATTRIBUTE_BOOLEXP, exp.getBooleanExpression());
Element valueElement = new Element(XML_ELEMENT_VALUE);
if (ruleData.isOutputExpValue())
valueElement.setText(exp.getValue().toString());
else {
Object savedValue = ruleData.getProperty().getPropertyValue();
ruleData.getProperty().setPropertyValue_IgnoreOldValue(exp.getValue());
ruleData.getProperty().writeToXML(valueElement);
ruleData.getProperty().setPropertyValue_IgnoreOldValue(savedValue);
}
expElement.addContent(valueElement);
ruleElement.addContent(expElement);
}
for (PVTuple pv : ruleData.getPVList()) {
Element pvElement = new Element(XML_ELEMENT_PV);
pvElement.setText(pv.pvName);
pvElement.setAttribute(XML_ATTRIBUTE_TRIGGER, Boolean.toString(pv.trigger));
ruleElement.addContent(pvElement);
}
propElement.addContent(ruleElement);
}
}
Aggregations