use of org.yamcs.studio.data.vtype.VNumber in project yamcs-studio by yamcs.
the class ArrayOfNumberFormulaFunction method calculate.
@Override
public Object calculate(List<Object> args) {
ListDouble data = new ListDouble() {
@Override
public double getDouble(int index) {
var 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 (var object : args) {
if (object != null) {
firstNonNull = (VNumber) object;
}
}
var display = displayNone();
if (firstNonNull != null) {
if (ValueUtil.displayHasValidDisplayLimits(firstNonNull)) {
display = firstNonNull;
} else {
var 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);
}
Aggregations