Search in sources :

Example 21 with IPV

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;
}
Also used : EditPartListener(org.eclipse.gef.EditPartListener) AbstractBaseEditPart(org.csstudio.opibuilder.editparts.AbstractBaseEditPart) EditPart(org.eclipse.gef.EditPart) IPV(org.csstudio.simplepv.IPV)

Aggregations

IPV (org.csstudio.simplepv.IPV)21 VType (org.diirt.vtype.VType)9 Display (org.diirt.vtype.Display)4 VEnum (org.diirt.vtype.VEnum)3 StringProperty (org.csstudio.opibuilder.properties.StringProperty)2 ScriptData (org.csstudio.opibuilder.script.ScriptData)2 ActionsInput (org.csstudio.opibuilder.widgetActions.ActionsInput)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStream (java.io.InputStream)1 AbstractBaseEditPart (org.csstudio.opibuilder.editparts.AbstractBaseEditPart)1 AbstractLinkingContainerModel (org.csstudio.opibuilder.model.AbstractLinkingContainerModel)1 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)1 DisplayModel (org.csstudio.opibuilder.model.DisplayModel)1 AbstractWidgetProperty (org.csstudio.opibuilder.properties.AbstractWidgetProperty)1 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)1 PVValueProperty (org.csstudio.opibuilder.properties.PVValueProperty)1 WidgetPropertyChangeListener (org.csstudio.opibuilder.properties.WidgetPropertyChangeListener)1 PVTuple (org.csstudio.opibuilder.script.PVTuple)1