Search in sources :

Example 11 with PVTuple

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);
    }
}
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 12 with PVTuple

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

Example 13 with PVTuple

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