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);
}
}
}
}
Aggregations