Search in sources :

Example 1 with PVTuple

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();
}
Also used : RuleData(org.csstudio.opibuilder.script.RuleData) RulesInput(org.csstudio.opibuilder.script.RulesInput) PVTuple(org.csstudio.opibuilder.script.PVTuple)

Example 2 with PVTuple

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;
}
Also used : RuleData(org.csstudio.opibuilder.script.RuleData) RulesInput(org.csstudio.opibuilder.script.RulesInput) Expression(org.csstudio.opibuilder.script.Expression) Element(org.jdom.Element) PVTuple(org.csstudio.opibuilder.script.PVTuple)

Example 3 with PVTuple

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;
}
Also used : Path(org.eclipse.core.runtime.Path) Element(org.jdom.Element) ScriptsInput(org.csstudio.opibuilder.script.ScriptsInput) ScriptData(org.csstudio.opibuilder.script.ScriptData) PVTuple(org.csstudio.opibuilder.script.PVTuple)

Example 4 with PVTuple

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);
    }
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PVTuple(org.csstudio.opibuilder.script.PVTuple)

Example 5 with PVTuple

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();
}
Also used : PVTuple(org.csstudio.opibuilder.script.PVTuple)

Aggregations

PVTuple (org.csstudio.opibuilder.script.PVTuple)13 ScriptData (org.csstudio.opibuilder.script.ScriptData)6 RuleData (org.csstudio.opibuilder.script.RuleData)5 ScriptsInput (org.csstudio.opibuilder.script.ScriptsInput)5 RulesInput (org.csstudio.opibuilder.script.RulesInput)4 Element (org.jdom.Element)4 Expression (org.csstudio.opibuilder.script.Expression)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 AbstractWidgetProperty (org.csstudio.opibuilder.properties.AbstractWidgetProperty)1 WidgetPropertyChangeListener (org.csstudio.opibuilder.properties.WidgetPropertyChangeListener)1 IPV (org.csstudio.simplepv.IPV)1 Path (org.eclipse.core.runtime.Path)1 Point (org.eclipse.draw2d.geometry.Point)1 Action (org.eclipse.jface.action.Action)1 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1