Search in sources :

Example 1 with ListNumberProvider

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

the class ColumnFromListNumberGeneratorFunction method calculate.

@Override
public Object calculate(final List<Object> args) {
    VString name = (VString) args.get(0);
    ListNumberProvider data = (ListNumberProvider) args.get(1);
    if (name == null || data == null) {
        return null;
    }
    return VTableFactory.column(name.getValue(), data);
}
Also used : VString(org.diirt.vtype.VString) ListNumberProvider(org.diirt.vtype.table.ListNumberProvider)

Example 2 with ListNumberProvider

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

the class ArrayWithBoundariesFormulaFunction method calculate.

@Override
public Object calculate(final List<Object> args) {
    if (NullUtils.containsNull(args)) {
        return null;
    }
    VNumberArray array = (VNumberArray) args.get(0);
    if (array.getSizes().size() != args.size() - 1) {
        throw new IllegalArgumentException("Dimension of the array must match the number of ListNumberProvider");
    }
    List<ArrayDimensionDisplay> dimDisplay = new ArrayList<>();
    for (int i = 1; i < args.size(); i++) {
        ListNumberProvider numberGenerator = (ListNumberProvider) args.get(i);
        dimDisplay.add(ValueFactory.newDisplay(numberGenerator.createListNumber(array.getSizes().getInt(i - 1) + 1), ""));
    }
    return ValueFactory.newVNumberArray(array.getData(), array.getSizes(), dimDisplay, array, array, array);
}
Also used : VNumberArray(org.diirt.vtype.VNumberArray) ArrayDimensionDisplay(org.diirt.vtype.ArrayDimensionDisplay) ArrayList(java.util.ArrayList) ListNumberProvider(org.diirt.vtype.table.ListNumberProvider)

Aggregations

ListNumberProvider (org.diirt.vtype.table.ListNumberProvider)2 ArrayList (java.util.ArrayList)1 ArrayDimensionDisplay (org.diirt.vtype.ArrayDimensionDisplay)1 VNumberArray (org.diirt.vtype.VNumberArray)1 VString (org.diirt.vtype.VString)1