use of org.csstudio.display.builder.runtime.pv.RuntimePV in project org.csstudio.display.builder by kasemir.
the class ArrayPVDispatcherTest method testStringArray.
/**
* Test double-typed array PV
*/
@Test
public void testStringArray() throws Exception {
final RuntimePV array_pv = PVFactory.getPV("loc://an_array(\"One\", \"Two\", \"Three\")");
final AtomicReference<List<RuntimePV>> element_pvs = new AtomicReference<>();
final CountDownLatch got_element_pvs = new CountDownLatch(1);
// Listener to the ArrayPVDispatcher
final Listener dispatch_listener = new Listener() {
@Override
public void arrayChanged(final List<RuntimePV> pvs) {
element_pvs.set(pvs);
got_element_pvs.countDown();
}
};
final ArrayPVDispatcher dispatcher = new ArrayPVDispatcher(array_pv, "elementA247FE_", dispatch_listener);
// Await initial set of per-element PVs
got_element_pvs.await();
assertThat(VTypeUtil.getValueString(element_pvs.get().get(0).read(), false), equalTo("One"));
assertThat(VTypeUtil.getValueString(element_pvs.get().get(1).read(), false), equalTo("Two"));
assertThat(VTypeUtil.getValueString(element_pvs.get().get(2).read(), false), equalTo("Three"));
// Change array -> Observe update of per-element PV
System.out.println("Updating array");
array_pv.write(new String[] { "Uno", "Due", "Another", "Vier" });
dump(element_pvs.get());
assertThat(VTypeUtil.getValueString(element_pvs.get().get(0).read(), false), equalTo("Uno"));
assertThat(VTypeUtil.getValueString(element_pvs.get().get(3).read(), false), equalTo("Vier"));
// Change per-element PV -> Observe update of array
System.out.println("Updating per-element PV for element [2]");
element_pvs.get().get(2).write("Hello");
final List<String> array_value = ((VStringArray) array_pv.read()).getData();
System.out.println("Array: " + array_value);
assertThat(array_value.get(2), equalTo("Hello"));
// Close dispatcher
dispatcher.close();
// Close the array PV
PVFactory.releasePV(array_pv);
}
use of org.csstudio.display.builder.runtime.pv.RuntimePV in project org.csstudio.display.builder by kasemir.
the class PVNameToValueBinding method disconnect.
private void disconnect() {
final RuntimePV pv = pv_ref.getAndSet(null);
if (pv == null)
return;
pv.removeListener(listener);
PVFactory.releasePV(pv);
runtime.removePV(pv);
}
use of org.csstudio.display.builder.runtime.pv.RuntimePV in project org.csstudio.display.builder by kasemir.
the class TableWidgetRuntime method start.
@Override
public void start() throws Exception {
super.start();
// Connect selection info PV
final String selection_pv_name = widget.propSelectionPV().getValue();
if (!selection_pv_name.isEmpty()) {
logger.log(Level.FINER, "Connecting {0} to {1}", new Object[] { widget, selection_pv_name });
try {
final RuntimePV pv = PVFactory.getPV(selection_pv_name);
addPV(pv);
widget.runtimePropSelection().addPropertyListener(selection_listener);
selection_pv = pv;
} catch (Exception ex) {
logger.log(Level.WARNING, "Error connecting PV " + selection_pv_name, ex);
}
}
}
use of org.csstudio.display.builder.runtime.pv.RuntimePV in project org.csstudio.display.builder by kasemir.
the class TableWidgetRuntime method stop.
@Override
public void stop() {
// Disconnect selection info PV
final RuntimePV pv = selection_pv;
selection_pv = null;
if (pv != null) {
widget.runtimePropSelection().removePropertyListener(selection_listener);
removePV(pv);
PVFactory.releasePV(pv);
}
super.stop();
}
use of org.csstudio.display.builder.runtime.pv.RuntimePV in project org.csstudio.display.builder by kasemir.
the class DataBrowserWidgetRuntime method start.
@Override
public void start() throws Exception {
super.start();
String pv_name = widget.propSelectionValuePVName().getValue();
if (!pv_name.isEmpty())
pv_name = MacroHandler.replace(widget.getEffectiveMacros(), pv_name);
if (!pv_name.isEmpty()) {
final RuntimePV pv = PVFactory.getPV(pv_name);
addPV(pv);
selection_pv = pv;
db_model_listener = new ModelSampleSelectionListener();
widget.getDataBrowserModel().addListener(db_model_listener);
}
}
Aggregations