use of org.csstudio.vtype.pv.PV in project org.csstudio.display.builder by kasemir.
the class RulesJythonScriptTest method testJythonScript.
@Test
public void testJythonScript() throws Exception {
final DisplayModel display = ModelLoader.resolveAndLoadModel("../org.csstudio.display.builder.runtime.test/examples/dummy.opi", "rules_test.opi");
final Widget widget = display.getChildren().parallelStream().filter(w -> w.getName().equals("Rectangle")).findFirst().get();
System.out.println(widget);
String pv_name = "loc://test2";
PVPool.addPVFactory(new LocalPVFactory());
final PV pv = PVPool.getPV(pv_name);
pv.write(1);
// Set widget variable in script
// final ScriptSupport scripting = new ScriptSupport();
// final Script script = scripting.compile("../org.csstudio.display.builder.runtime.test/examples/updateText.py");
/*
for (int run=0; run<10; ++run)
{
widget.setPropertyValue("text", "Initial");
String text = widget.getPropertyValue("text");
assertThat(text, equalTo("Initial"));
script.submit(widget).get();
assertThat(widget.getPropertyValue("text"), equalTo("Hello"));
widget.setPropertyValue("text", "Initial");
assertThat(widget.getPropertyValue("text"), equalTo("Initial"));
script.submit(widget).get();
assertThat(widget.getPropertyValue("text"), equalTo("Hello"));
}
scripting.close();
*/
}
use of org.csstudio.vtype.pv.PV in project org.csstudio.display.builder by kasemir.
the class RuntimeDemoSWT method run.
@Override
public void run() {
final Display display = new Display();
toolkit = new SWTRepresentation(display);
RuntimeUtil.hookRepresentationListener(toolkit);
// Load model in background
RuntimeUtil.getExecutor().execute(() -> loadModel(display));
while (!display.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
toolkit.shutdown();
display.dispose();
int refs = 0;
for (final RefCountMap.ReferencedEntry<PV> ref : PVPool.getPVReferences()) {
refs += ref.getReferences();
logger.log(Level.SEVERE, "PV {0} left with {1} references", new Object[] { ref.getEntry().getName(), ref.getReferences() });
}
if (refs == 0)
logger.log(Level.FINE, "All PV references were released, good job, get a cookie!");
// JCA Context remains running, so need to exit() to really quit
System.exit(0);
}
Aggregations