Search in sources :

Example 1 with Display

use of org.diirt.vtype.Display in project yamcs-studio by yamcs.

the class PVComposite method createPVProperties.

private void createPVProperties(PVInfo pvInfo) {
    IPV pv = pvInfo.getPV();
    StringBuilder stateInfo = new StringBuilder();
    if (!pv.isStarted()) {
        stateInfo.append("Not started");
    } else if (pv.isConnected()) {
        stateInfo.append("Connected");
        if (pv.isPaused()) {
            stateInfo.append(" Paused");
        } else {
            stateInfo.append(" Running");
        }
    } else {
        stateInfo.append("Connecting");
    }
    createKeyValueTextPair("Name", pv.getName());
    createKeyValueTextPair("State", stateInfo.toString());
    createSeparator();
    if (pv.getValue() != null) {
        createKeyValueTextPair("Last Received Value", pv.getValue().toString());
        Display displayInfo = VTypeHelper.getDisplayInfo(pv.getValue());
        if (displayInfo != null) {
            createKeyValueTextPair("Units", displayInfo.getUnits());
            createKeyValueTextPair("Precision", "" + displayInfo.getFormat().getMaximumFractionDigits());
            createKeyValueTextPair("Display Low", "" + displayInfo.getLowerDisplayLimit());
            createKeyValueTextPair("Display High", "" + displayInfo.getUpperDisplayLimit());
            createKeyValueTextPair("Alarm Low", "" + displayInfo.getLowerAlarmLimit());
            createKeyValueTextPair("Warning Low", "" + displayInfo.getLowerWarningLimit());
            createKeyValueTextPair("Warning High", "" + displayInfo.getUpperWarningLimit());
            createKeyValueTextPair("Alarm High", "" + displayInfo.getUpperAlarmLimit());
        }
    }
}
Also used : IPV(org.csstudio.simplepv.IPV) Display(org.diirt.vtype.Display)

Example 2 with Display

use of org.diirt.vtype.Display in project yamcs-studio by yamcs.

the class VNumbersToVNumberArrayConverter method readValue.

@Override
public VNumberArray readValue() {
    final List<VNumber> values = new ArrayList<VNumber>();
    Display meta = displayNone();
    for (ReadFunction<? extends VNumber> function : arguments) {
        VNumber number = function.readValue();
        values.add(number);
        if (meta == null && number != null)
            meta = number;
    }
    ListDouble data = new ListDouble() {

        @Override
        public double getDouble(int index) {
            VNumber number = values.get(index);
            if (number == null || number.getValue() == null)
                return Double.NaN;
            else
                return number.getValue().doubleValue();
        }

        @Override
        public int size() {
            return values.size();
        }
    };
    return ValueFactory.newVDoubleArray(data, alarmNone(), timeNow(), displayNone());
}
Also used : ArrayList(java.util.ArrayList) VNumber(org.diirt.vtype.VNumber) ListDouble(org.diirt.util.array.ListDouble) Display(org.diirt.vtype.Display)

Example 3 with Display

use of org.diirt.vtype.Display in project yamcs-studio by yamcs.

the class ArrayOfNumberFormulaFunction method calculate.

@Override
public Object calculate(final List<Object> args) {
    ListDouble data = new ListDouble() {

        @Override
        public double getDouble(int index) {
            VNumber number = (VNumber) args.get(index);
            if (number == null || number.getValue() == null)
                return Double.NaN;
            else
                return number.getValue().doubleValue();
        }

        @Override
        public int size() {
            return args.size();
        }
    };
    VNumber firstNonNull = null;
    for (Object object : args) {
        if (object != null) {
            firstNonNull = (VNumber) object;
        }
    }
    Display display = displayNone();
    if (firstNonNull != null) {
        if (ValueUtil.displayHasValidDisplayLimits(firstNonNull)) {
            display = firstNonNull;
        } else {
            Statistics stats = StatisticsUtil.statisticsOf(data);
            display = newDisplay(stats.getRange().getMinimum(), stats.getRange().getMinimum(), stats.getRange().getMinimum(), "", NumberFormats.toStringFormat(), stats.getRange().getMaximum(), stats.getRange().getMaximum(), stats.getRange().getMaximum(), stats.getRange().getMinimum(), stats.getRange().getMaximum());
        }
    }
    return ValueFactory.newVNumberArray(data, highestSeverityOf(args, false), latestValidTimeOrNowOf(args), display);
}
Also used : ListDouble(org.diirt.util.array.ListDouble) VNumber(org.diirt.vtype.VNumber) Statistics(org.diirt.util.Statistics) ValueFactory.newDisplay(org.diirt.vtype.ValueFactory.newDisplay) Display(org.diirt.vtype.Display)

Example 4 with Display

use of org.diirt.vtype.Display in project yamcs-studio by yamcs.

the class ScrollbarEditPart method registerLoadLimitsListener.

/**
 */
private void registerLoadLimitsListener() {
    if (getExecutionMode() == ExecutionMode.RUN_MODE) {
        final ScrollBarModel model = getWidgetModel();
        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();
                            Display displayInfo = VTypeHelper.getDisplayInfo(value);
                            if (value != null && displayInfo != null) {
                                Display new_meta = displayInfo;
                                if (meta == null || !meta.equals(new_meta)) {
                                    meta = new_meta;
                                    model.setPropertyValue(ScrollBarModel.PROP_MAX, meta.getUpperDisplayLimit());
                                    model.setPropertyValue(ScrollBarModel.PROP_MIN, meta.getLowerDisplayLimit());
                                }
                            }
                        }
                    };
                pv.addListener(pvLoadLimitsListener);
            }
        }
    }
}
Also used : VType(org.diirt.vtype.VType) ScrollBarModel(org.csstudio.opibuilder.widgets.model.ScrollBarModel) IPV(org.csstudio.simplepv.IPV) Display(org.diirt.vtype.Display)

Example 5 with Display

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

the class ScrollBarRepresentation method limitsChanged.

private void limitsChanged(final WidgetProperty<?> property, final Object old_value, final Object new_value) {
    double min_val = model_widget.propMinimum().getValue();
    double max_val = model_widget.propMaximum().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) {
            min_val = display_info.getLowerDisplayLimit();
            max_val = display_info.getUpperDisplayLimit();
        }
    }
    // If invalid limits, fall back to 0..100 range
    if (min_val >= max_val) {
        min_val = 0.0;
        max_val = 100.0;
    }
    min = min_val;
    max = max_val;
    dirty_size.mark();
    toolkit.scheduleUpdate(this);
}
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