use of org.csstudio.simplepv.IPV in project yamcs-studio by yamcs.
the class PVUtil method createPV.
/**
* Create a PV and start it. PVListener can be added to the PV to monitor its value change, but please note that the
* listener is executed in non-UI thread. If the code need be executed in UI thread, please use
* {@link ScriptUtil#execInUI(Runnable, AbstractBaseEditPart)}. The monitor's maximum update rate is 50hz. If the PV
* updates faster than this rate, some updates will be discarded.
*
* @param name
* name of the PV.
* @param widget
* the reference widget. The PV will stop when the widget is deactivated, so it is not needed to stop the
* pv in script.
* @return the PV.
* @throws Exception
* the exception that might happen while creating the pv.
*/
public static final IPV createPV(String name, AbstractBaseEditPart widget) throws Exception {
final IPV pv = BOYPVFactory.createPV(name, false, 20);
pv.start();
widget.addEditPartListener(new EditPartListener.Stub() {
@Override
public void partDeactivated(EditPart arg0) {
pv.stop();
}
});
return pv;
}
Aggregations