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