use of org.diirt.vtype.VString in project yamcs-studio by yamcs.
the class ColumnFromVStringArrayFunction method calculate.
@Override
public Object calculate(final List<Object> args) {
VString name = (VString) args.get(0);
VStringArray data = (VStringArray) args.get(1);
if (name == null || data == null) {
return null;
}
return VTableFactory.column(name.getValue(), data);
}
use of org.diirt.vtype.VString in project yamcs-studio by yamcs.
the class TableRangeArrayFilterFunction method calculate.
@Override
public Object calculate(final List<Object> args) {
if (NullUtils.containsNull(args)) {
return null;
}
VTable table = (VTable) args.get(0);
VString columnName = (VString) args.get(1);
VNumberArray range = (VNumberArray) args.get(2);
if (range.getData().size() != 2) {
throw new IllegalArgumentException("Range array must be of 2 elements");
}
VTable result = VTableFactory.tableRangeFilter(table, columnName.getValue(), ValueFactory.newVDouble(range.getData().getDouble(0)), ValueFactory.newVDouble(range.getData().getDouble(1)));
return result;
}
use of org.diirt.vtype.VString in project yamcs-studio by yamcs.
the class TableValueFilterFunction method calculate.
@Override
public Object calculate(final List<Object> args) {
VTable table = (VTable) args.get(0);
VString columnName = (VString) args.get(1);
VType value = (VType) args.get(2);
if (columnName == null || columnName.getValue() == null || table == null || value == null) {
return null;
}
VTable result = VTableFactory.tableValueFilter(table, columnName.getValue(), value);
return result;
}
use of org.diirt.vtype.VString in project org.csstudio.display.builder by kasemir.
the class ArrayPVDispatcher method updateArrayFromElements.
/**
* Update the array PV with the current value of all element PVs
*/
private void updateArrayFromElements() throws Exception {
final List<RuntimePV> pvs = element_pvs.get();
final int N = pvs.size();
if (N == 1) {
// Is 'array' really a scalar?
final VType array = array_pv.read();
if (array instanceof VNumber || array instanceof VString) {
array_pv.write(pvs.get(0).read());
return;
}
}
if (is_string) {
final String[] value = new String[N];
for (int i = 0; i < N; ++i) value[i] = VTypeUtil.getValueString(pvs.get(i).read(), false);
array_pv.write(value);
} else {
final double[] value = new double[N];
for (int i = 0; i < N; ++i) value[i] = VTypeUtil.getValueNumber(pvs.get(i).read()).doubleValue();
array_pv.write(value);
}
}
use of org.diirt.vtype.VString in project yamcs-studio by yamcs.
the class VStringOfFunction method readValue.
@Override
public VString readValue() {
VType value = argument.readValue();
if (forward != null) {
forward.writeValue(value);
}
if (value == null) {
return null;
}
String string = format.format(value);
Alarm alarm = ValueUtil.alarmOf(value);
if (alarm == null) {
alarm = ValueFactory.alarmNone();
}
Time time = ValueUtil.timeOf(value);
if (time == null) {
time = ValueFactory.timeNow();
}
return ValueFactory.newVString(string, alarm, time);
}
Aggregations