use of org.csstudio.opibuilder.script.PVTuple 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);
}
}
use of org.csstudio.opibuilder.script.PVTuple in project yamcs-studio by yamcs.
the class ScriptProperty method writeToXML.
@Override
public void writeToXML(Element propElement) {
for (ScriptData scriptData : ((ScriptsInput) getPropertyValue()).getScriptList()) {
Element pathElement = new Element(XML_ELEMENT_PATH);
String pathString = null;
if (scriptData.isEmbedded()) {
if (scriptData.getScriptType() == ScriptType.JAVASCRIPT)
pathString = EMBEDDEDJS;
else if (scriptData.getScriptType() == ScriptType.PYTHON)
pathString = EMBEDDEDPY;
Element scriptNameElement = new Element(XML_ELEMENT_SCRIPT_NAME);
scriptNameElement.setText(scriptData.getScriptName());
pathElement.addContent(scriptNameElement);
Element scriptTextElement = new Element(XML_ELEMENT_SCRIPT_TEXT);
scriptTextElement.setContent(new CDATA(scriptData.getScriptText()));
pathElement.addContent(scriptTextElement);
} else
pathString = scriptData.getPath().toPortableString();
pathElement.setAttribute(XML_ATTRIBUTE_PATHSTRING, pathString);
pathElement.setAttribute(XML_ATTRIBUTE_CHECKCONNECT, Boolean.toString(scriptData.isCheckConnectivity()));
pathElement.setAttribute(XML_ATTRIBUTE_SKIP_FIRST_EXECUTION, Boolean.toString(scriptData.isSkipPVsFirstConnection()));
pathElement.setAttribute(XML_ATTRIBUTE_STOP_EXECUTE_ON_ERROR, Boolean.toString(scriptData.isStopExecuteOnError()));
for (PVTuple pv : scriptData.getPVList()) {
Element pvElement = new Element(XML_ELEMENT_PV);
pvElement.setText(pv.pvName);
pvElement.setAttribute(XML_ATTRIBUTE_TRIGGER, Boolean.toString(pv.trigger));
pathElement.addContent(pvElement);
}
propElement.addContent(pathElement);
}
}
use of org.csstudio.opibuilder.script.PVTuple in project yamcs-studio by yamcs.
the class ScriptProperty method getPropertyValue.
@Override
public Object getPropertyValue() {
if (executionMode == ExecutionMode.RUN_MODE && widgetModel != null) {
ScriptsInput value = (ScriptsInput) super.getPropertyValue();
for (ScriptData sd : value.getScriptList()) {
for (Object pv : sd.getPVList().toArray()) {
PVTuple pvTuple = (PVTuple) pv;
String newPV = OPIBuilderMacroUtil.replaceMacros(widgetModel, pvTuple.pvName);
if (!newPV.equals(pvTuple.pvName)) {
int i = sd.getPVList().indexOf(pv);
sd.getPVList().remove(pv);
sd.getPVList().add(i, new PVTuple(newPV, pvTuple.trigger));
}
}
}
return value;
} else
return super.getPropertyValue();
}
Aggregations