Search in sources :

Example 11 with VString

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

the class ConcatStringsFunction method calculate.

@Override
public Object calculate(List<Object> args) {
    // Handle nulls
    if (NullUtils.containsNull(args)) {
        return null;
    }
    // Concatenate strings
    StringBuilder sb = new StringBuilder();
    for (Object object : args) {
        VString str = (VString) object;
        sb.append(str.getValue());
    }
    // Return new value
    return ValueFactory.newVString(sb.toString(), highestSeverityOf(args, false), latestValidTimeOrNowOf(args));
}
Also used : VString(org.diirt.vtype.VString)

Example 12 with VString

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

the class ColumnFromVNumberArrayFunction method calculate.

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

Example 13 with VString

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

the class ColumnOfVTableFunction method calculate.

@Override
public Object calculate(final List<Object> args) {
    VTable table = (VTable) args.get(0);
    VString columnName = (VString) args.get(1);
    if (columnName == null || table == null) {
        return null;
    }
    int index = -1;
    for (int i = 0; i < table.getColumnCount(); i++) {
        if (Objects.equals(columnName.getValue(), table.getColumnName(i))) {
            index = i;
        }
    }
    if (index == -1) {
        throw new RuntimeException("Table does not contain column '" + columnName.getValue() + "'");
    }
    Class<?> type = table.getColumnType(index);
    if (String.class.isAssignableFrom(type)) {
        @SuppressWarnings("unchecked") List<String> data = (List<String>) table.getColumnData(index);
        return ValueFactory.newVStringArray(data, ValueFactory.alarmNone(), ValueFactory.timeNow());
    }
    if (Double.TYPE.isAssignableFrom(type)) {
        ListDouble data = (ListDouble) table.getColumnData(index);
        return ValueFactory.newVDoubleArray(data, ValueFactory.alarmNone(), ValueFactory.timeNow(), ValueFactory.displayNone());
    }
    if (Integer.TYPE.isAssignableFrom(type)) {
        ListInt data = (ListInt) table.getColumnData(index);
        return ValueFactory.newVIntArray(data, ValueFactory.alarmNone(), ValueFactory.timeNow(), ValueFactory.displayNone());
    }
    throw new RuntimeException("Unsupported type " + type.getSimpleName());
}
Also used : ListInt(org.diirt.util.array.ListInt) VString(org.diirt.vtype.VString) VTable(org.diirt.vtype.VTable) List(java.util.List) ListDouble(org.diirt.util.array.ListDouble) VString(org.diirt.vtype.VString)

Example 14 with VString

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

the class TableRangeFilterFunction method calculate.

@Override
public Object calculate(final List<Object> args) {
    VTable table = (VTable) args.get(0);
    VString columnName = (VString) args.get(1);
    VType min = (VType) args.get(2);
    VType max = (VType) args.get(3);
    if (columnName == null || columnName.getValue() == null || table == null || min == null || max == null) {
        return null;
    }
    VTable result = VTableFactory.tableRangeFilter(table, columnName.getValue(), min, max);
    return result;
}
Also used : VType(org.diirt.vtype.VType) VString(org.diirt.vtype.VString) VTable(org.diirt.vtype.VTable)

Example 15 with VString

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

the class TableStringMatchFilterFunction method calculate.

@Override
public Object calculate(final List<Object> args) {
    VTable table = (VTable) args.get(0);
    VString columnName = (VString) args.get(1);
    VString substring = (VString) args.get(2);
    if (columnName == null || columnName.getValue() == null || table == null || substring == null) {
        return null;
    }
    VTable result = VTableFactory.tableStringMatchFilter(table, columnName.getValue(), substring.getValue());
    return result;
}
Also used : VString(org.diirt.vtype.VString) VTable(org.diirt.vtype.VTable)

Aggregations

VString (org.diirt.vtype.VString)20 VTable (org.diirt.vtype.VTable)9 VNumberArray (org.diirt.vtype.VNumberArray)5 ListInt (org.diirt.util.array.ListInt)4 ListNumber (org.diirt.util.array.ListNumber)4 VNumber (org.diirt.vtype.VNumber)4 VStringArray (org.diirt.vtype.VStringArray)4 VType (org.diirt.vtype.VType)4 VEnum (org.diirt.vtype.VEnum)3 VEnumArray (org.diirt.vtype.VEnumArray)3 ArrayList (java.util.ArrayList)2 Background (javafx.scene.layout.Background)2 BackgroundFill (javafx.scene.layout.BackgroundFill)2 ArrayInt (org.diirt.util.array.ArrayInt)2 VBoolean (org.diirt.vtype.VBoolean)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Rotate (javafx.scene.transform.Rotate)1 Translate (javafx.scene.transform.Translate)1