Search in sources :

Example 6 with Display

use of org.diirt.vtype.Display in project org.csstudio.display.builder by kasemir.

the class SpinnerRepresentation method updateLimits.

/**
 * Updates, if required, the limits and zones.
 *
 * @return {@code true} is something changed and and UI update is required.
 */
private boolean updateLimits() {
    boolean somethingChanged = false;
    // Model's values.
    double newMin = model_widget.propMinimum().getValue();
    double newMax = model_widget.propMaximum().getValue();
    // If invalid limits, fall back to 0..100 range.
    if (Double.isNaN(newMin) || Double.isNaN(newMax) || newMin > newMax) {
        newMin = 0.0;
        newMax = 100.0;
    }
    if (model_widget.propLimitsFromPV().getValue()) {
        // Try to get display range from PV.
        final Display display_info = ValueUtil.displayOf(model_widget.runtimePropValue().getValue());
        if (display_info != null) {
            double infoMin = display_info.getLowerCtrlLimit();
            double infoMax = display_info.getUpperCtrlLimit();
            if (!Double.isNaN(infoMin) && !Double.isNaN(infoMax) && infoMin < infoMax) {
                newMin = infoMin;
                newMax = infoMax;
            }
        }
    }
    if (Double.compare(value_min, newMin) != 0) {
        value_min = newMin;
        somethingChanged = true;
    }
    if (Double.compare(value_max, newMax) != 0) {
        value_max = newMax;
        somethingChanged = true;
    }
    return somethingChanged;
}
Also used : Display(org.diirt.vtype.Display)

Example 7 with Display

use of org.diirt.vtype.Display in project org.csstudio.display.builder by kasemir.

the class TankRepresentation method valueChanged.

private void valueChanged(final WidgetProperty<?> property, final Object old_value, final Object new_value) {
    final VType vtype = model_widget.runtimePropValue().getValue();
    final boolean limits_from_pv = model_widget.propLimitsFromPV().getValue();
    double min_val = model_widget.propMinimum().getValue();
    double max_val = model_widget.propMaximum().getValue();
    if (limits_from_pv) {
        // Try display range from PV
        final Display display_info = ValueUtil.displayOf(vtype);
        if (display_info != null) {
            min_val = display_info.getLowerDisplayLimit();
            max_val = display_info.getUpperDisplayLimit();
        }
    }
    tank.setRange(min_val, max_val);
    double value;
    if (toolkit.isEditMode())
        value = (min_val + max_val) / 2;
    else
        value = VTypeUtil.getValueNumber(vtype).doubleValue();
    tank.setValue(value);
}
Also used : VType(org.diirt.vtype.VType) Display(org.diirt.vtype.Display)

Example 8 with Display

use of org.diirt.vtype.Display in project org.csstudio.display.builder by kasemir.

the class BaseKnobRepresentation method updateLimits.

/**
 * Updates, if required, the limits and zones.
 *
 * @return {@code true} is something changed and and UI update is required.
 */
private boolean updateLimits() {
    boolean somethingChanged = false;
    // Model's values.
    double newMin = model_widget.propMinimum().getValue();
    double newMax = model_widget.propMaximum().getValue();
    // If invalid limits, fall back to 0..100 range.
    if (Double.isNaN(newMin) || Double.isNaN(newMax) || newMin > newMax) {
        newMin = 0.0;
        newMax = 100.0;
    }
    double newLoLo = model_widget.propLevelLoLo().getValue();
    double newLow = model_widget.propLevelLow().getValue();
    double newHigh = model_widget.propLevelHigh().getValue();
    double newHiHi = model_widget.propLevelHiHi().getValue();
    if (model_widget.propLimitsFromPV().getValue()) {
        // Try to get display range from PV.
        final Display display_info = ValueUtil.displayOf(model_widget.runtimePropValue().getValue());
        if (display_info != null) {
            double infoMin = display_info.getLowerCtrlLimit();
            double infoMax = display_info.getUpperCtrlLimit();
            if (!Double.isNaN(infoMin) && !Double.isNaN(infoMax) && infoMin < infoMax) {
                newMin = infoMin;
                newMax = infoMax;
            }
            newLoLo = display_info.getLowerAlarmLimit();
            newLow = display_info.getLowerWarningLimit();
            newHigh = display_info.getUpperWarningLimit();
            newHiHi = display_info.getUpperAlarmLimit();
        }
    }
    if (!model_widget.propShowLoLo().getValue()) {
        newLoLo = Double.NaN;
    }
    if (!model_widget.propShowLow().getValue()) {
        newLow = Double.NaN;
    }
    if (!model_widget.propShowHigh().getValue()) {
        newHigh = Double.NaN;
    }
    if (!model_widget.propShowHiHi().getValue()) {
        newHiHi = Double.NaN;
    }
    if (Double.compare(min, newMin) != 0) {
        min = newMin;
        somethingChanged = true;
    }
    if (Double.compare(max, newMax) != 0) {
        max = newMax;
        somethingChanged = true;
    }
    if (Double.compare(lolo, newLoLo) != 0) {
        lolo = newLoLo;
        somethingChanged = true;
    }
    if (Double.compare(low, newLow) != 0) {
        low = newLow;
        somethingChanged = true;
    }
    if (Double.compare(high, newHigh) != 0) {
        high = newHigh;
        somethingChanged = true;
    }
    if (Double.compare(hihi, newHiHi) != 0) {
        hihi = newHiHi;
        somethingChanged = true;
    }
    return somethingChanged;
}
Also used : Display(org.diirt.vtype.Display)

Example 9 with Display

use of org.diirt.vtype.Display in project org.csstudio.display.builder by kasemir.

the class ProgressBarRepresentation method valueChanged.

private void valueChanged(final WidgetProperty<?> property, final Object old_value, final Object new_value) {
    final VType vtype = model_widget.runtimePropValue().getValue();
    final boolean limits_from_pv = model_widget.propLimitsFromPV().getValue();
    double min_val = model_widget.propMinimum().getValue();
    double max_val = model_widget.propMaximum().getValue();
    if (limits_from_pv) {
        // Try display range from PV
        final Display display_info = ValueUtil.displayOf(vtype);
        if (display_info != null) {
            min_val = display_info.getLowerDisplayLimit();
            max_val = display_info.getUpperDisplayLimit();
        }
    }
    // Fall back to 0..100 range
    if (min_val >= max_val) {
        min_val = 0.0;
        max_val = 100.0;
    }
    // Determine percentage of value within the min..max range
    final double value = VTypeUtil.getValueNumber(vtype).doubleValue();
    final double percentage = (value - min_val) / (max_val - min_val);
    // Limit to 0.0 .. 1.0
    if (percentage < 0.0)
        this.percentage = 0.0;
    else if (percentage > 1.0)
        this.percentage = 1.0;
    else
        this.percentage = percentage;
    dirty_value.mark();
    toolkit.scheduleUpdate(this);
}
Also used : VType(org.diirt.vtype.VType) Display(org.diirt.vtype.Display)

Example 10 with Display

use of org.diirt.vtype.Display in project org.csstudio.display.builder by kasemir.

the class ScaledSliderRepresentation method limitsChanged.

private void limitsChanged(final WidgetProperty<?> property, final Object old_value, final Object new_value) {
    // Start with widget config
    double new_min = model_widget.propMinimum().getValue();
    double new_max = model_widget.propMaximum().getValue();
    double new_lolo = model_widget.propLevelLoLo().getValue();
    double new_low = model_widget.propLevelLo().getValue();
    double new_high = model_widget.propLevelHi().getValue();
    double new_hihi = model_widget.propLevelHiHi().getValue();
    if (model_widget.propLimitsFromPV().getValue()) {
        // Try to get display range from PV
        final Display display_info = ValueUtil.displayOf(model_widget.runtimePropValue().getValue());
        if (display_info != null) {
            new_min = display_info.getLowerCtrlLimit();
            new_max = display_info.getUpperCtrlLimit();
            new_lolo = display_info.getLowerAlarmLimit();
            new_low = display_info.getLowerWarningLimit();
            new_high = display_info.getUpperWarningLimit();
            new_hihi = display_info.getUpperAlarmLimit();
        }
    }
    if (!model_widget.propShowLoLo().getValue())
        new_lolo = Double.NaN;
    if (!model_widget.propShowLow().getValue())
        new_low = Double.NaN;
    if (!model_widget.propShowHigh().getValue())
        new_high = Double.NaN;
    if (!model_widget.propShowHiHi().getValue())
        new_hihi = Double.NaN;
    // If invalid limits, fall back to 0..100 range
    if (!(new_min < new_max)) {
        new_min = 0.0;
        new_max = 100.0;
    }
    boolean changes = false;
    if (Double.compare(min, new_min) != 0) {
        min = new_min;
        changes = true;
    }
    if (Double.compare(max, new_max) != 0) {
        max = new_max;
        changes = true;
    }
    final double pixel_span = model_widget.propHorizontal().getValue() ? model_widget.propWidth().getValue() : model_widget.propHeight().getValue();
    double tick_dist = model_widget.propMajorTickStepHint().getValue() / pixel_span * (max - min);
    tick_dist = selectNiceStep(tick_dist);
    if (Double.compare(tick_dist, tick_unit) != 0) {
        tick_unit = tick_dist;
        changes = true;
    }
    if (Double.compare(lolo, new_lolo) != 0) {
        lolo = new_lolo;
        changes = true;
    }
    if (Double.compare(low, new_low) != 0) {
        low = new_low;
        changes = true;
    }
    if (Double.compare(high, new_high) != 0) {
        high = new_high;
        changes = true;
    }
    if (Double.compare(hihi, new_hihi) != 0) {
        hihi = new_hihi;
        changes = true;
    }
    if (changes)
        layoutChanged(null, null, null);
}
Also used : Display(org.diirt.vtype.Display)

Aggregations

Display (org.diirt.vtype.Display)19 VType (org.diirt.vtype.VType)7 IPV (org.csstudio.simplepv.IPV)4 VNumber (org.diirt.vtype.VNumber)3 ArrayList (java.util.ArrayList)2 ListDouble (org.diirt.util.array.ListDouble)2 NumberFormat (java.text.NumberFormat)1 Instant (java.time.Instant)1 ArchiveVNumber (org.csstudio.archive.vtype.ArchiveVNumber)1 ArchiveVStatistics (org.csstudio.archive.vtype.ArchiveVStatistics)1 ArchiveVType (org.csstudio.archive.vtype.ArchiveVType)1 AbstractMarkedWidgetModel (org.csstudio.opibuilder.widgets.model.AbstractMarkedWidgetModel)1 ScrollBarModel (org.csstudio.opibuilder.widgets.model.ScrollBarModel)1 ThumbWheelModel (org.csstudio.opibuilder.widgets.model.ThumbWheelModel)1 Statistics (org.diirt.util.Statistics)1 ListNumber (org.diirt.util.array.ListNumber)1 VStatistics (org.diirt.vtype.VStatistics)1 VString (org.diirt.vtype.VString)1 ValueFactory.newDisplay (org.diirt.vtype.ValueFactory.newDisplay)1