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));
}
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) };
}
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));
}
Aggregations