use of org.diirt.vtype.VNumber in project yamcs-studio by yamcs.
the class ElementAtStringFormulaFunction method calculate.
@Override
public Object calculate(List<Object> args) {
if (NullUtils.containsNull(args)) {
return null;
}
VStringArray stringArray = (VStringArray) args.get(0);
VNumber index = (VNumber) args.get(1);
int i = index.getValue().intValue();
return newVString(stringArray.getData().get(i), stringArray, stringArray);
}
use of org.diirt.vtype.VNumber in project yamcs-studio by yamcs.
the class RescaleArrayFormulaFunction method calculate.
@Override
public Object calculate(final List<Object> args) {
if (NullUtils.containsNull(args)) {
return null;
}
VNumberArray arg1 = (VNumberArray) args.get(0);
VNumber arg2 = (VNumber) args.get(1);
VNumber arg3 = (VNumber) args.get(2);
return newVNumberArray(ListMath.rescale(arg1.getData(), arg2.getValue().doubleValue(), arg3.getValue().doubleValue()), highestSeverityOf(args, false), latestValidTimeOrNowOf(args), displayNone());
}
use of org.diirt.vtype.VNumber in project yamcs-studio by yamcs.
the class EnumFromVNumberFunction method calculate.
@Override
public Object calculate(List<Object> args) {
if (NullUtils.containsNull(args)) {
return null;
}
VNumber value = (VNumber) args.get(0);
VNumberArray intervals = (VNumberArray) args.get(1);
VStringArray labels = (VStringArray) args.get(2);
int index = 0;
while (index < intervals.getData().size() && value.getValue().doubleValue() >= intervals.getData().getDouble(index)) {
index++;
}
return newVEnum(index, labels.getData(), value, latestValidTimeOrNowOf(args));
}
use of org.diirt.vtype.VNumber in project yamcs-studio by yamcs.
the class VTableFactory method valueNumberTable.
private static VTable valueNumberTable(List<String> names, List<? extends VType> values) {
double[] data = new double[values.size()];
List<String> severity = new ArrayList<>();
List<String> status = new ArrayList<>();
for (int i = 0; i < values.size(); i++) {
VNumber vNumber = (VNumber) values.get(i);
data[i] = vNumber.getValue().doubleValue();
severity.add(vNumber.getAlarmSeverity().name());
status.add(vNumber.getAlarmName());
}
if (names == null) {
return newVTable(column("Value", newVDoubleArray(new ArrayDouble(data), alarmNone(), timeNow(), displayNone())), column("Severity", newVStringArray(severity, alarmNone(), timeNow())), column("Status", newVStringArray(status, alarmNone(), timeNow())));
} else {
return newVTable(column("Name", newVStringArray(names, alarmNone(), timeNow())), column("Value", newVDoubleArray(new ArrayDouble(data), alarmNone(), timeNow(), displayNone())), column("Severity", newVStringArray(severity, alarmNone(), timeNow())), column("Status", newVStringArray(status, alarmNone(), timeNow())));
}
}
use of org.diirt.vtype.VNumber in project yamcs-studio by yamcs.
the class AbstractVIntNumberVIntNumberToVIntNumberFormulaFunction method calculate.
@Override
public final Object calculate(List<Object> args) {
if (NullUtils.containsNull(args)) {
return null;
}
Number arg1 = ((VNumber) args.get(0)).getValue();
Number arg2 = ((VNumber) args.get(1)).getValue();
if (arg1 instanceof Float || arg2 instanceof Float || arg1 instanceof Double || arg2 instanceof Double) {
throw new IllegalArgumentException("Operator '" + getName() + "' only works with integers");
}
return newVInt(calculate(arg1.intValue(), arg2.intValue()), highestSeverityOf(args, false), latestValidTimeOrNowOf(args), displayNone());
}
Aggregations