use of org.csstudio.opibuilder.script.PVTuple in project yamcs-studio by yamcs.
the class RulesProperty method getPropertyValue.
@Override
public Object getPropertyValue() {
if (executionMode == ExecutionMode.RUN_MODE && widgetModel != null) {
RulesInput value = (RulesInput) super.getPropertyValue();
for (RuleData rd : value.getRuleDataList()) {
for (Object pv : rd.getPVList().toArray()) {
PVTuple pvTuple = (PVTuple) pv;
String newPV = OPIBuilderMacroUtil.replaceMacros(widgetModel, pvTuple.pvName);
if (!newPV.equals(pvTuple.pvName)) {
int i = rd.getPVList().indexOf(pv);
rd.getPVList().remove(pv);
rd.getPVList().add(i, new PVTuple(newPV, pvTuple.trigger));
}
}
}
return value;
} else
return super.getPropertyValue();
}
use of org.csstudio.opibuilder.script.PVTuple in project yamcs-studio by yamcs.
the class RulesProperty method readValueFromXML.
@Override
public RulesInput readValueFromXML(Element propElement) throws Exception {
RulesInput result = new RulesInput();
for (Object oe : propElement.getChildren(XML_ELEMENT_RULE)) {
Element se = (Element) oe;
RuleData ruleData = new RuleData(widgetModel);
ruleData.setName(se.getAttributeValue(XML_ATTRIBUTE_NAME));
ruleData.setPropId(se.getAttributeValue(XML_ATTRIBUTE_PROPID));
ruleData.setOutputExpValue(Boolean.parseBoolean(se.getAttributeValue(XML_ATTRIBUTE_OUTPUTEXPRESSION)));
for (Object eo : se.getChildren(XML_ELEMENT_EXPRESSION)) {
Element ee = (Element) eo;
String booleanExpression = ee.getAttributeValue(XML_ATTRIBUTE_BOOLEXP);
Object value = "null";
Element valueElement = ee.getChild(XML_ELEMENT_VALUE);
if (ruleData.isOutputExpValue())
value = valueElement.getText();
else {
value = ruleData.getProperty().readValueFromXML(valueElement);
}
Expression exp = new Expression(booleanExpression, value);
ruleData.addExpression(exp);
}
for (Object pvo : se.getChildren(XML_ELEMENT_PV)) {
Element pve = (Element) pvo;
boolean trig = true;
if (pve.getAttribute(XML_ATTRIBUTE_TRIGGER) != null)
trig = Boolean.parseBoolean(pve.getAttributeValue(XML_ATTRIBUTE_TRIGGER));
ruleData.addPV(new PVTuple(pve.getText(), trig));
}
result.getRuleDataList().add(ruleData);
}
return result;
}
use of org.csstudio.opibuilder.script.PVTuple in project yamcs-studio by yamcs.
the class ScriptProperty method readValueFromXML.
@Override
public ScriptsInput readValueFromXML(Element propElement) {
ScriptsInput result = new ScriptsInput();
for (Object oe : propElement.getChildren(XML_ELEMENT_PATH)) {
Element se = (Element) oe;
ScriptData sd = new ScriptData();
if (se.getAttributeValue(XML_ATTRIBUTE_PATHSTRING).equals(EMBEDDEDJS)) {
sd.setEmbedded(true);
sd.setScriptType(ScriptType.JAVASCRIPT);
sd.setScriptText(se.getChildText(XML_ELEMENT_SCRIPT_TEXT));
sd.setScriptName(se.getChildText(XML_ELEMENT_SCRIPT_NAME));
} else if (se.getAttributeValue(XML_ATTRIBUTE_PATHSTRING).equals(EMBEDDEDPY)) {
sd.setEmbedded(true);
sd.setScriptType(ScriptType.PYTHON);
sd.setScriptText(se.getChildText(XML_ELEMENT_SCRIPT_TEXT));
sd.setScriptName(se.getChildText(XML_ELEMENT_SCRIPT_NAME));
} else
sd = new ScriptData(new Path(se.getAttributeValue(XML_ATTRIBUTE_PATHSTRING)));
if (se.getAttributeValue(XML_ATTRIBUTE_CHECKCONNECT) != null)
sd.setCheckConnectivity(Boolean.parseBoolean(se.getAttributeValue(XML_ATTRIBUTE_CHECKCONNECT)));
if (se.getAttributeValue(XML_ATTRIBUTE_SKIP_FIRST_EXECUTION) != null)
sd.setSkipPVsFirstConnection(Boolean.parseBoolean(se.getAttributeValue(XML_ATTRIBUTE_SKIP_FIRST_EXECUTION)));
if (se.getAttributeValue(XML_ATTRIBUTE_STOP_EXECUTE_ON_ERROR) != null)
sd.setStopExecuteOnError(Boolean.parseBoolean(se.getAttributeValue(XML_ATTRIBUTE_STOP_EXECUTE_ON_ERROR)));
for (Object o : se.getChildren(XML_ELEMENT_PV)) {
Element pve = (Element) o;
boolean trig = true;
if (pve.getAttribute(XML_ATTRIBUTE_TRIGGER) != null)
trig = Boolean.parseBoolean(pve.getAttributeValue(XML_ATTRIBUTE_TRIGGER));
sd.addPV(new PVTuple(pve.getText(), trig));
}
result.getScriptList().add(sd);
}
return result;
}
use of org.csstudio.opibuilder.script.PVTuple in project yamcs-studio by yamcs.
the class PVTupleTableEditor method refreshToolbarOnSelection.
/**
* Refreshes the enabled-state of the actions.
*/
private void refreshToolbarOnSelection() {
IStructuredSelection selection = (IStructuredSelection) pvTupleListTableViewer.getSelection();
int num_tuple = 0;
for (Object obj : selection.toArray()) {
if (obj instanceof PVTuple)
num_tuple++;
}
if (num_tuple == 0) {
removeAction.setEnabled(false);
moveUpAction.setEnabled(false);
moveDownAction.setEnabled(false);
checkTriggerAction.setEnabled(false);
uncheckTriggerAction.setEnabled(false);
} else if (num_tuple == 1) {
removeAction.setEnabled(true);
moveUpAction.setEnabled(true);
moveDownAction.setEnabled(true);
checkTriggerAction.setEnabled(true);
uncheckTriggerAction.setEnabled(true);
} else {
removeAction.setEnabled(true);
moveUpAction.setEnabled(false);
moveDownAction.setEnabled(false);
checkTriggerAction.setEnabled(true);
uncheckTriggerAction.setEnabled(true);
}
}
use of org.csstudio.opibuilder.script.PVTuple in project yamcs-studio by yamcs.
the class RuleDataEditDialog method okPressed.
@Override
protected void okPressed() {
boolean hasTrigger = false;
for (PVTuple pvTuple : ruleData.getPVList()) {
hasTrigger |= pvTuple.trigger;
}
if (!hasTrigger) {
MessageDialog.openWarning(getShell(), "Warning", NLS.bind("At least one trigger PV must be selected for the rule:\n{0}", ruleData.getName()));
return;
}
super.okPressed();
}
Aggregations