Search in sources :

Example 1 with AbstractMarkedWidgetModel

use of org.csstudio.opibuilder.widgets.model.AbstractMarkedWidgetModel in project yamcs-studio by yamcs.

the class AbstractMarkedWidgetEditPart method registerLoadLimitsListener.

/**
 */
private void registerLoadLimitsListener() {
    if (getExecutionMode() == ExecutionMode.RUN_MODE) {
        final AbstractMarkedWidgetModel model = (AbstractMarkedWidgetModel) getModel();
        if (model.isLimitsFromPV()) {
            IPV pv = getPV(AbstractPVWidgetModel.PROP_PVNAME);
            if (pv != null) {
                if (pvLoadLimitsListener == null)
                    pvLoadLimitsListener = new IPVListener.Stub() {

                        @Override
                        public void valueChanged(IPV pv) {
                            VType value = pv.getValue();
                            if (value != null && VTypeHelper.getDisplayInfo(value) != null) {
                                Display new_meta = VTypeHelper.getDisplayInfo(value);
                                if (meta == null || !meta.equals(new_meta)) {
                                    meta = new_meta;
                                    Double upperLimit;
                                    Double lowerLimit;
                                    if (model.isControlWidget()) {
                                        // DRVH / DRVL
                                        upperLimit = meta.getUpperCtrlLimit();
                                        lowerLimit = meta.getLowerCtrlLimit();
                                    } else {
                                        // HOPR / LOPR
                                        upperLimit = meta.getUpperDisplayLimit();
                                        lowerLimit = meta.getLowerDisplayLimit();
                                    }
                                    if (!Double.isNaN(upperLimit)) {
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_MAX, upperLimit);
                                    }
                                    if (!Double.isNaN(lowerLimit)) {
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_MIN, lowerLimit);
                                    }
                                    if (Double.isNaN(meta.getUpperWarningLimit()))
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_HI, false);
                                    else {
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_HI, true);
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_HI_LEVEL, meta.getUpperWarningLimit());
                                    }
                                    if (Double.isNaN(meta.getUpperAlarmLimit()))
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_HIHI, false);
                                    else {
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_HIHI, true);
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_HIHI_LEVEL, meta.getUpperAlarmLimit());
                                    }
                                    if (Double.isNaN(meta.getLowerWarningLimit()))
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_LO, false);
                                    else {
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_LO, true);
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_LO_LEVEL, meta.getLowerWarningLimit());
                                    }
                                    if (Double.isNaN(meta.getLowerAlarmLimit()))
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_LOLO, false);
                                    else {
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_SHOW_LOLO, true);
                                        model.setPropertyValue(AbstractMarkedWidgetModel.PROP_LOLO_LEVEL, meta.getLowerAlarmLimit());
                                    }
                                }
                            }
                        }
                    };
                pv.addListener(pvLoadLimitsListener);
            }
        }
    }
}
Also used : VType(org.diirt.vtype.VType) AbstractMarkedWidgetModel(org.csstudio.opibuilder.widgets.model.AbstractMarkedWidgetModel) IPV(org.csstudio.simplepv.IPV) Display(org.diirt.vtype.Display)

Aggregations

AbstractMarkedWidgetModel (org.csstudio.opibuilder.widgets.model.AbstractMarkedWidgetModel)1 IPV (org.csstudio.simplepv.IPV)1 Display (org.diirt.vtype.Display)1 VType (org.diirt.vtype.VType)1