Search in sources :

Example 6 with ArrayDouble

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())));
    }
}
Also used : ArrayDouble(org.diirt.util.array.ArrayDouble) ArrayList(java.util.ArrayList) VNumber(org.diirt.vtype.VNumber) VString(org.diirt.vtype.VString)

Example 7 with ArrayDouble

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));
}
Also used : ArrayDouble(org.diirt.util.array.ArrayDouble)

Example 8 with ArrayDouble

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 }));
}
Also used : ListNumber(org.diirt.util.array.ListNumber) VType(org.diirt.vtype.VType) ArrayDouble(org.diirt.util.array.ArrayDouble) Test(org.junit.Test)

Example 9 with ArrayDouble

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"));
}
Also used : ListNumber(org.diirt.util.array.ListNumber) VType(org.diirt.vtype.VType) ArrayDouble(org.diirt.util.array.ArrayDouble) Test(org.junit.Test)

Example 10 with ArrayDouble

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();
    }
}
Also used : VNumberArray(org.diirt.vtype.VNumberArray) ListNumber(org.diirt.util.array.ListNumber) ArrayDouble(org.diirt.util.array.ArrayDouble)

Aggregations

ArrayDouble (org.diirt.util.array.ArrayDouble)10 ListNumber (org.diirt.util.array.ListNumber)6 ArrayList (java.util.ArrayList)3 List (java.util.List)3 VNumberArray (org.diirt.vtype.VNumberArray)3 ListDouble (org.diirt.util.array.ListDouble)2 VType (org.diirt.vtype.VType)2 Test (org.junit.Test)2 AbstractList (java.util.AbstractList)1 IntensityGraphModel (org.csstudio.opibuilder.widgets.model.IntensityGraphModel)1 AxisProperty (org.csstudio.opibuilder.widgets.model.IntensityGraphModel.AxisProperty)1 IntensityGraphFigure (org.csstudio.swt.widgets.figures.IntensityGraphFigure)1 IPixelInfoListener (org.csstudio.swt.widgets.figures.IntensityGraphFigure.IPixelInfoListener)1 IProfileDataChangeLisenter (org.csstudio.swt.widgets.figures.IntensityGraphFigure.IProfileDataChangeLisenter)1 PixelInfo (org.csstudio.swt.widgets.figures.IntensityGraphFigure.PixelInfo)1 ArrayInt (org.diirt.util.array.ArrayInt)1 VNumber (org.diirt.vtype.VNumber)1 VString (org.diirt.vtype.VString)1 ValueFactory.newVNumberArray (org.diirt.vtype.ValueFactory.newVNumberArray)1 Range (org.eclipse.nebula.visualization.xygraph.linearscale.Range)1