Search in sources :

Example 1 with VDoubleArray

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

the class Sine2DWaveform method nextValue.

@Override
VDoubleArray nextValue() {
    if (initialReference == null) {
        initialReference = lastTime;
    }
    double t = initialReference.until(lastTime, ChronoUnit.SECONDS);
    double omega = 2 * Math.PI / periodInSeconds;
    double k = 2 * Math.PI / wavelengthInSamples;
    double min = -1.0;
    double max = 1.0;
    double range = 0.0;
    return (VDoubleArray) ValueFactory.newVNumberArray(generateNewValue(omega, t, k), new ArrayInt(ySamples, xSamples), ValueUtil.defaultArrayDisplay(new ArrayInt(ySamples, xSamples)), alarmNone(), newTime(lastTime), newDisplay(min, min + range * 0.1, min + range * 0.2, "", Constants.DOUBLE_FORMAT, min + range * 0.8, min + range * 0.9, max, min, max));
}
Also used : VDoubleArray(org.diirt.vtype.VDoubleArray) ArrayInt(org.diirt.util.array.ArrayInt)

Example 2 with VDoubleArray

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

the class PVUtil method getStringArray.

/**
 * Get string array from pv.
 *
 * @param pv
 *            The PV.
 * @return String array. For string array, it's the actual strings. For numeric arrays, the numbers are formatted as
 *         strings. For enum array, the labels are returned. For scalar PVs, an array with a single string is
 *         returned.
 */
public static final String[] getStringArray(IPV pv) {
    final VType value = checkPVValue(pv);
    if (value instanceof VStringArray) {
        final List<String> list = ((VStringArray) value).getData();
        return list.toArray(new String[list.size()]);
    } else if (value instanceof VDoubleArray) {
        final ListNumber list = ((VNumberArray) value).getData();
        final String[] text = new String[list.size()];
        for (int i = 0; i < text.length; ++i) text[i] = Double.toString(list.getDouble(i));
        return text;
    } else if (value instanceof VNumberArray) {
        final ListNumber list = ((VNumberArray) value).getData();
        final String[] text = new String[list.size()];
        for (int i = 0; i < text.length; ++i) text[i] = Long.toString(list.getLong(i));
        return text;
    } else if (value instanceof VEnumArray) {
        final List<String> labels = ((VEnumArray) value).getLabels();
        final ListInt list = ((VEnumArray) value).getIndexes();
        final String[] text = new String[list.size()];
        for (int i = 0; i < text.length; ++i) {
            final int index = list.getInt(i);
            if (index >= 0 && index <= labels.size())
                text[i] = labels.get(index);
            else
                text[i] = "<" + index + ">";
        }
        return text;
    }
    return new String[] { getString(pv) };
}
Also used : VDoubleArray(org.diirt.vtype.VDoubleArray) VNumberArray(org.diirt.vtype.VNumberArray) VEnumArray(org.diirt.vtype.VEnumArray) ListNumber(org.diirt.util.array.ListNumber) ListInt(org.diirt.util.array.ListInt) VType(org.diirt.vtype.VType) List(java.util.List) VStringArray(org.diirt.vtype.VStringArray)

Example 3 with VDoubleArray

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

the class Square2DWaveform method nextValue.

@Override
VDoubleArray nextValue() {
    if (initialReference == null) {
        initialReference = lastTime;
    }
    double t = initialReference.until(lastTime, ChronoUnit.SECONDS);
    double omega = 2 * Math.PI / periodInSeconds;
    double k = 2 * Math.PI / wavelengthInSamples;
    double min = -1.0;
    double max = 1.0;
    double range = 0.0;
    return (VDoubleArray) ValueFactory.newVNumberArray(generateNewValue(omega, t, k), new ArrayInt(ySamples, xSamples), ValueUtil.defaultArrayDisplay(new ArrayInt(ySamples, xSamples)), alarmNone(), newTime(lastTime), newDisplay(min, min + range * 0.1, min + range * 0.2, "", Constants.DOUBLE_FORMAT, min + range * 0.8, min + range * 0.9, max, min, max));
}
Also used : VDoubleArray(org.diirt.vtype.VDoubleArray) ArrayInt(org.diirt.util.array.ArrayInt)

Aggregations

VDoubleArray (org.diirt.vtype.VDoubleArray)3 ArrayInt (org.diirt.util.array.ArrayInt)2 List (java.util.List)1 ListInt (org.diirt.util.array.ListInt)1 ListNumber (org.diirt.util.array.ListNumber)1 VEnumArray (org.diirt.vtype.VEnumArray)1 VNumberArray (org.diirt.vtype.VNumberArray)1 VStringArray (org.diirt.vtype.VStringArray)1 VType (org.diirt.vtype.VType)1