Search in sources :

Example 1 with ArrayDimensionDisplay

use of org.diirt.vtype.ArrayDimensionDisplay 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)

Example 2 with ArrayDimensionDisplay

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

the class NdArrayFormulaFunction method calculate.

@Override
public Object calculate(final List<Object> args) {
    if (NullUtils.containsNull(args)) {
        return null;
    }
    VNumberArray data = (VNumberArray) args.get(0);
    ArrayDimensionDisplay[] displays = new ArrayDimensionDisplay[args.size() - 1];
    for (int i = 0; i < displays.length; i++) {
        displays[i] = (ArrayDimensionDisplay) args.get(i + 1);
    }
    return ValueFactory.ndArray(data, displays);
}
Also used : VNumberArray(org.diirt.vtype.VNumberArray) ArrayDimensionDisplay(org.diirt.vtype.ArrayDimensionDisplay)

Aggregations

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