Search in sources :

Example 1 with VNumber

use of org.diirt.vtype.VNumber 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 2 with VNumber

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

the class AbstractVNumberVNumberArrayToVNumberArrayFormulaFunction method calculate.

@Override
public final Object calculate(List<Object> args) {
    if (NullUtils.containsNull(args)) {
        return null;
    }
    VNumber arg1 = (VNumber) args.get(0);
    VNumberArray arg2 = (VNumberArray) args.get(1);
    return newVNumberArray(calculate(arg1.getValue().doubleValue(), arg2.getData()), highestSeverityOf(args, false), latestValidTimeOrNowOf(args), displayNone());
}
Also used : ValueFactory.newVNumberArray(org.diirt.vtype.ValueFactory.newVNumberArray) VNumberArray(org.diirt.vtype.VNumberArray) VNumber(org.diirt.vtype.VNumber)

Example 3 with VNumber

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

the class AbstractVNumberVNumberToVBooleanFormulaFunction method calculate.

@Override
public final Object calculate(List<Object> args) {
    if (NullUtils.containsNull(args)) {
        return null;
    }
    VNumber arg1 = (VNumber) args.get(0);
    VNumber arg2 = (VNumber) args.get(1);
    return ValueFactory.newVBoolean(calculate(arg1.getValue().doubleValue(), arg2.getValue().doubleValue()), highestSeverityOf(args, false), latestValidTimeOrNowOf(args));
}
Also used : VNumber(org.diirt.vtype.VNumber)

Example 4 with VNumber

use of org.diirt.vtype.VNumber 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 5 with VNumber

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

the class DimDisplayFormulaFunction method calculate.

@Override
public Object calculate(final List<Object> args) {
    VNumber size = (VNumber) args.get(0);
    VBoolean invert = (VBoolean) args.get(1);
    if (size == null || invert == null) {
        return null;
    }
    return ValueFactory.newDisplay(size.getValue().intValue(), VTableFactory.step(0, 1), invert.getValue());
}
Also used : VNumber(org.diirt.vtype.VNumber) VBoolean(org.diirt.vtype.VBoolean)

Aggregations

VNumber (org.diirt.vtype.VNumber)16 VNumberArray (org.diirt.vtype.VNumberArray)6 ArrayList (java.util.ArrayList)3 ValueFactory.newVNumberArray (org.diirt.vtype.ValueFactory.newVNumberArray)3 ListDouble (org.diirt.util.array.ListDouble)2 Display (org.diirt.vtype.Display)2 VStringArray (org.diirt.vtype.VStringArray)2 Instant (java.time.Instant)1 DesiredRateExpression (org.diirt.datasource.expression.DesiredRateExpression)1 Statistics (org.diirt.util.Statistics)1 ArrayDouble (org.diirt.util.array.ArrayDouble)1 VBoolean (org.diirt.vtype.VBoolean)1 VString (org.diirt.vtype.VString)1 ValueFactory.newDisplay (org.diirt.vtype.ValueFactory.newDisplay)1 ValueFactory.newVNumber (org.diirt.vtype.ValueFactory.newVNumber)1