use of org.csstudio.display.builder.model.properties.WritePVActionInfo in project org.csstudio.display.builder by kasemir.
the class JFXActionsDialogDemo method start.
@Override
public void start(final Stage stage) {
final Widget widget = new Widget("demo");
final Macros macros = new Macros();
macros.add("S", "Test");
macros.add("N", "17");
final ActionInfos actions = new ActionInfos(Arrays.asList(new OpenDisplayActionInfo("Related Display", "../opi/some_file.opi", macros, Target.TAB), new WritePVActionInfo("Reset", "Test:CS:Reset", "1"), new ExecuteScriptActionInfo("Script", new ScriptInfo(ScriptInfo.EMBEDDED_PYTHON, "print 'hi'", false, Collections.emptyList()))));
final ActionsDialog dialog = new ActionsDialog(widget, actions);
final Optional<ActionInfos> result = dialog.showAndWait();
if (result.isPresent()) {
if (result.get().isExecutedAsOne())
System.out.println("Execute all commands as one:");
for (ActionInfo info : result.get().getActions()) {
if (info instanceof ExecuteScriptActionInfo) {
final ExecuteScriptActionInfo action = (ExecuteScriptActionInfo) info;
System.out.println("Execute " + action.getDescription() + ", " + action.getInfo() + ": " + action.getInfo().getText());
} else
System.out.println(info);
}
} else
System.out.println("Cancelled");
}
use of org.csstudio.display.builder.model.properties.WritePVActionInfo 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);
}
Aggregations