Search in sources :

Example 1 with ArrayDouble

use of org.yamcs.studio.data.vtype.ArrayDouble in project yamcs-studio by yamcs.

the class ArrayRangeOfFormulaFunction method calculate.

@Override
public Object calculate(List<Object> args) {
    if (containsNull(args)) {
        return null;
    }
    var numberArray = (VNumberArray) args.get(0);
    var min = numberArray.getDimensionDisplay().get(0).getCellBoundaries().getDouble(0);
    var max = numberArray.getDimensionDisplay().get(0).getCellBoundaries().getDouble(numberArray.getSizes().getInt(0));
    return newVNumberArray(new ArrayDouble(min, max), highestSeverityOf(args, false), latestValidTimeOrNowOf(args), displayNone());
}
Also used : VNumberArray(org.yamcs.studio.data.vtype.VNumberArray) ValueFactory.newVNumberArray(org.yamcs.studio.data.vtype.ValueFactory.newVNumberArray) ArrayDouble(org.yamcs.studio.data.vtype.ArrayDouble)

Example 2 with ArrayDouble

use of org.yamcs.studio.data.vtype.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);
    var omega = 2 * Math.PI / periodInSeconds;
    return newVDoubleArray(new ArrayDouble(generateNewValue(omega, t)), alarmNone(), newTime(lastTime), newDisplay(0.0, 0.0, 0.0, "x", DOUBLE_FORMAT, 1.0, 1.0, 1.0, 0.0, 1.0));
}
Also used : ArrayDouble(org.yamcs.studio.data.vtype.ArrayDouble)

Example 3 with ArrayDouble

use of org.yamcs.studio.data.vtype.ArrayDouble in project yamcs-studio by yamcs.

the class IntensityGraphEditPart method doCreateFigure.

@Override
protected IFigure doCreateFigure() {
    var model = getWidgetModel();
    graph = new IntensityGraphFigure(getExecutionMode() == ExecutionMode.RUN_MODE);
    graph.setMin(model.getMinimum());
    graph.setMax(model.getMaximum());
    graph.setDataWidth(model.getDataWidth());
    graph.setDataHeight(model.getDataHeight());
    graph.setColorMap(model.getColorMap());
    graph.setShowRamp(model.isShowRamp());
    graph.setCropLeft(model.getCropLeft());
    graph.setCropRight(model.getCropRight());
    graph.setCropTop(model.getCropTOP());
    graph.setCropBottom(model.getCropBottom());
    graph.setInRGBMode(model.isRGBMode());
    graph.setColorDepth(model.getColorDepth());
    graph.setSingleLineProfiling(model.isSingleLineProfiling());
    graph.setROIColor(model.getROIColor().getSWTColor());
    // init X-Axis
    for (var axisProperty : AxisProperty.values()) {
        var propID = IntensityGraphModel.makeAxisPropID(IntensityGraphModel.X_AXIS_ID, axisProperty.propIDPre);
        setAxisProperty(graph.getXAxis(), axisProperty, model.getPropertyValue(propID));
    }
    // init Y-Axis
    for (var axisProperty : AxisProperty.values()) {
        var propID = IntensityGraphModel.makeAxisPropID(IntensityGraphModel.Y_AXIS_ID, axisProperty.propIDPre);
        setAxisProperty(graph.getYAxis(), axisProperty, model.getPropertyValue(propID));
    }
    if (getExecutionMode() == ExecutionMode.RUN_MODE) {
        // add profile data listener
        if (model.getHorizonProfileYPV().trim().length() > 0 || model.getVerticalProfileYPV().trim().length() > 0) {
            graph.addProfileDataListener((xProfileData, yProfileData, xAxisRange, yAxisRange) -> {
                // horizontal
                setPVValue(PROP_HORIZON_PROFILE_Y_PV_NAME, xProfileData);
                var horizonXData = new double[xProfileData.length];
                var d = (xAxisRange.getUpper() - xAxisRange.getLower()) / (xProfileData.length - 1);
                for (var i1 = 0; i1 < xProfileData.length; i1++) {
                    horizonXData[i1] = xAxisRange.getLower() + d * i1;
                }
                setPVValue(PROP_HORIZON_PROFILE_X_PV_NAME, horizonXData);
                // vertical
                setPVValue(PROP_VERTICAL_PROFILE_Y_PV_NAME, yProfileData);
                var verticalXData = new double[yProfileData.length];
                d = (yAxisRange.getUpper() - yAxisRange.getLower()) / (yProfileData.length - 1);
                for (var i2 = 0; i2 < yProfileData.length; i2++) {
                    verticalXData[i2] = yAxisRange.getUpper() - d * i2;
                }
                setPVValue(PROP_VERTICAL_PROFILE_X_PV_NAME, verticalXData);
            });
        }
        if (model.getPixelInfoPV().trim().length() > 0) {
            // Listen to pixel info, forward to PV
            graph.addPixelInfoListener((pixel_info, selected) -> {
                // TODO "Selected" column should be boolean, but there is no 'ArrayBoolean', and List<Boolean>
                // also fails
                List<Object> values = Arrays.<Object>asList(new ArrayDouble(pixel_info.xcoord), new ArrayDouble(pixel_info.ycoord), new ArrayDouble(pixel_info.value), new ArrayInt(selected ? 1 : 0));
                Object value = ValueFactory.newVTable(PXL_TABLE_TYPES, PXL_TABLE_COLUMNS, values);
                setPVValue(PROP_PIXEL_INFO_PV_NAME, value);
            });
        }
    }
    updatePropSheet();
    return graph;
}
Also used : IntensityGraphFigure(org.csstudio.swt.widgets.figures.IntensityGraphFigure) ArrayDouble(org.yamcs.studio.data.vtype.ArrayDouble) ArrayInt(org.yamcs.studio.data.vtype.ArrayInt)

Example 4 with ArrayDouble

use of org.yamcs.studio.data.vtype.ArrayDouble in project yamcs-studio by yamcs.

the class DftFormulaFunction method calculate.

@Override
public Object calculate(List<Object> args) {
    var array = (VNumberArray) args.get(0);
    if (array == null) {
        return null;
    }
    if (array.getSizes().size() != 1) {
        throw new IllegalArgumentException("Only 1D array supported for DFT");
    }
    // TODO: no need to allocate empty array
    var fft = ListMath.dft(array.getData(), new ArrayDouble(new double[array.getData().size()]));
    var real = fft.get(0);
    var imaginary = fft.get(1);
    ListNumber modulus = new ListDouble() {

        @Override
        public double getDouble(int index) {
            var x = real.getDouble(index);
            var y = imaginary.getDouble(index);
            if (x != 0 || y != 0) {
                return Math.sqrt(x * x + y * y);
            } else {
                return 0.0;
            }
        }

        @Override
        public int size() {
            return real.size();
        }
    };
    ListNumber phase = new ListDouble() {

        @Override
        public double getDouble(int index) {
            var x = real.getDouble(index);
            var y = imaginary.getDouble(index);
            return Math.atan2(y, x);
        }

        @Override
        public int size() {
            return real.size();
        }
    };
    return ValueFactory.newVTable(Arrays.<Class<?>>asList(double.class, double.class, double.class, double.class), Arrays.asList("x", "y", "mod", "phase"), Arrays.<Object>asList(real, imaginary, modulus, phase));
}
Also used : VNumberArray(org.yamcs.studio.data.vtype.VNumberArray) ListNumber(org.yamcs.studio.data.vtype.ListNumber) ArrayDouble(org.yamcs.studio.data.vtype.ArrayDouble) ListDouble(org.yamcs.studio.data.vtype.ListDouble)

Aggregations

ArrayDouble (org.yamcs.studio.data.vtype.ArrayDouble)4 VNumberArray (org.yamcs.studio.data.vtype.VNumberArray)2 IntensityGraphFigure (org.csstudio.swt.widgets.figures.IntensityGraphFigure)1 ArrayInt (org.yamcs.studio.data.vtype.ArrayInt)1 ListDouble (org.yamcs.studio.data.vtype.ListDouble)1 ListNumber (org.yamcs.studio.data.vtype.ListNumber)1 ValueFactory.newVNumberArray (org.yamcs.studio.data.vtype.ValueFactory.newVNumberArray)1