use of org.diirt.util.array.ArrayDouble 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.util.array.ArrayDouble in project yamcs-studio by yamcs.
the class GaussianWaveform method nextValue.
@Override
VDoubleArray nextValue() {
if (lastTime == null)
lastTime = Instant.now();
if (initialRefernce == null) {
initialRefernce = lastTime;
}
double t = initialRefernce.until(lastTime, ChronoUnit.SECONDS);
double omega = 2 * Math.PI / periodInSeconds;
return newVDoubleArray(new ArrayDouble(generateNewValue(omega, t)), alarmNone(), newTime(lastTime), newDisplay(0.0, 0.0, 0.0, "x", Constants.DOUBLE_FORMAT, 1.0, 1.0, 1.0, 0.0, 1.0));
}
use of org.diirt.util.array.ArrayDouble in project org.csstudio.display.builder by kasemir.
the class FormatOptionHandlerTest method testNumberArrayParsing.
@Test
public void testNumberArrayParsing() throws Exception {
final ListNumber data = new ArrayDouble(1.0, 2.0, 3.0, 4.0);
final VType value = ValueFactory.newVNumberArray(data, ValueFactory.alarmNone(), ValueFactory.timeNow(), display);
Object parsed = FormatOptionHandler.parse(value, " [ 1, 2.5 , 3 ] ", FormatOption.DEFAULT);
assertThat(parsed, instanceOf(double[].class));
final double[] numbers = (double[]) parsed;
assertThat(numbers, equalTo(new double[] { 1.0, 2.5, 3.0 }));
}
use of org.diirt.util.array.ArrayDouble in project org.csstudio.display.builder by kasemir.
the class FormatOptionHandlerTest method testArray.
@Test
public void testArray() throws Exception {
final ListNumber data = new ArrayDouble(1.0, 2.0, 3.0, 4.0);
VType value = ValueFactory.newVNumberArray(data, ValueFactory.alarmNone(), ValueFactory.timeNow(), display);
System.out.println(value);
String text = FormatOptionHandler.format(value, FormatOption.DEFAULT, 0, true);
System.out.println(text);
assertThat(text, equalTo("[1, 2, 3, 4] V"));
text = FormatOptionHandler.format(value, FormatOption.DECIMAL, 2, true);
System.out.println(text);
assertThat(text, equalTo("[1.00, 2.00, 3.00, 4.00] V"));
}
use of org.diirt.util.array.ArrayDouble in project org.csstudio.display.builder by kasemir.
the class WaveformValueDataProvider method setValue.
/**
* Update the waveform value.
* @param value New value
* Fires event to listeners (plot)
*/
public void setValue(final VType value) {
final ListNumber new_numbers;
if (value instanceof VNumberArray)
new_numbers = ((VNumberArray) value).getData();
else
new_numbers = new ArrayDouble(VTypeHelper.toDouble(value));
lock.writeLock().lock();
try {
numbers = new_numbers;
} finally {
lock.writeLock().unlock();
}
}
Aggregations