Search in sources :

Example 6 with ActionInfo

use of org.csstudio.display.builder.model.properties.ActionInfo in project org.csstudio.display.builder by kasemir.

the class WidgetRuntime method start.

/**
 * Start: Connect to PVs, start scripts
 *  @throws Exception on error
 */
public void start() throws Exception {
    // Update "value" property from primary PV, if defined
    final Optional<WidgetProperty<String>> name = widget.checkProperty(propPVName);
    final Optional<WidgetProperty<VType>> value = widget.checkProperty(runtimePropPVValue);
    if (name.isPresent() && value.isPresent())
        pv_name_binding.set(new PVNameToValueBinding(this, name.get(), value.get(), true));
    // Prepare action-related PVs
    final List<ActionInfo> actions = widget.propActions().getValue().getActions();
    if (actions.size() > 0) {
        final List<RuntimePV> action_pvs = new ArrayList<>();
        for (final ActionInfo action : actions) {
            if (action instanceof WritePVActionInfo) {
                final String pv_name = ((WritePVActionInfo) action).getPV();
                final String expanded = MacroHandler.replace(widget.getMacrosOrProperties(), pv_name);
                final RuntimePV pv = PVFactory.getPV(expanded);
                action_pvs.add(pv);
                addPV(pv, true);
            }
        }
        if (action_pvs.size() > 0)
            this.writable_pvs = action_pvs;
    }
    widget.propClass().addPropertyListener(update_widget_class);
    // Start scripts in pool because Jython setup is expensive
    RuntimeUtil.getExecutor().execute(this::startScripts);
}
Also used : WidgetProperty(org.csstudio.display.builder.model.WidgetProperty) RuntimePV(org.csstudio.display.builder.runtime.pv.RuntimePV) ArrayList(java.util.ArrayList) ActionInfo(org.csstudio.display.builder.model.properties.ActionInfo) WritePVActionInfo(org.csstudio.display.builder.model.properties.WritePVActionInfo) ExecuteScriptActionInfo(org.csstudio.display.builder.model.properties.ExecuteScriptActionInfo) WritePVActionInfo(org.csstudio.display.builder.model.properties.WritePVActionInfo)

Aggregations

ActionInfo (org.csstudio.display.builder.model.properties.ActionInfo)6 OpenDisplayActionInfo (org.csstudio.display.builder.model.properties.OpenDisplayActionInfo)4 ExecuteScriptActionInfo (org.csstudio.display.builder.model.properties.ExecuteScriptActionInfo)3 WritePVActionInfo (org.csstudio.display.builder.model.properties.WritePVActionInfo)3 ArrayList (java.util.ArrayList)2 Widget (org.csstudio.display.builder.model.Widget)2 ActionInfos (org.csstudio.display.builder.model.properties.ActionInfos)2 ScriptInfo (org.csstudio.display.builder.model.properties.ScriptInfo)2 HashMap (java.util.HashMap)1 Node (javafx.scene.Node)1 Scene (javafx.scene.Scene)1 Button (javafx.scene.control.Button)1 ButtonBase (javafx.scene.control.ButtonBase)1 MenuButton (javafx.scene.control.MenuButton)1 MenuItem (javafx.scene.control.MenuItem)1 Image (javafx.scene.image.Image)1 ImageView (javafx.scene.image.ImageView)1 DisplayModel (org.csstudio.display.builder.model.DisplayModel)1 WidgetProperty (org.csstudio.display.builder.model.WidgetProperty)1 MacroValueProvider (org.csstudio.display.builder.model.macros.MacroValueProvider)1