Package fr.soleil.salsa.entity.scan2D

Examples of fr.soleil.salsa.entity.scan2D.IScanResult2D


     * Returns the result of the current scan.
     * @return
     * @throws SalsaDeviceException
     */
    public IScanResult2D readScanResult() throws SalsaDeviceException {
        IScanResult2D scanResult;
        if(isScanResultReady()) {
           
            int column;
            int columnsNumber;
            int rowsNumber;
            int row;
            IScanPoint[][] scanPointsMatrix;
            try {
                // Type
                DeviceAttribute scanTypeAttribute = scanServerProxy.read_attribute("scanType");
                int scanType = scanTypeAttribute.extractLong();
                if(scanType != 2) {
                    return null;
                }
                scanResult = new ScanResult2DImpl();
                scanResult.setResultType(IScanResult.ResultType.RESULT_2D);
               
                // Name.
                DeviceAttribute runNameAttribute = scanServerProxy.read_attribute("runName");
                String runName = runNameAttribute.extractString();
                scanResult.setRunName(runName);
               
                // Building empty matrix.
                DeviceAttribute sensorsTimeStampsAttribute = scanServerProxy.read_attribute("sensorsTimeStamps");
                columnsNumber = sensorsTimeStampsAttribute.getDimX();
                rowsNumber = sensorsTimeStampsAttribute.getDimY();
                scanPointsMatrix = new IScanPoint[rowsNumber][columnsNumber];
                for(row = 0; row < rowsNumber; ++row) {
                    for(column = 0; column < columnsNumber; ++column) {
                        scanPointsMatrix[row][column] = new ScanPointImpl();
                    }
                }
               
                // Times.
                double[] timesArray = sensorsTimeStampsAttribute.extractDoubleArray();
                row = 0;
                column = 0;
                for(double time : timesArray) {
                    scanPointsMatrix[row][column].setTime(time);
                    ++column;
                    if(column >= columnsNumber) {
                        column = 0;
                        ++ row;
                    }
                }
               
                // Sensors
                String[] sensorsNamesArrayTmp = scanServerProxy.read_attribute("sensors").extractStringArray();
                // The sensorsNamesArrayTmp contains the data twice : once for reading and once for writing.
                String[] sensorsNamesArray = new String[sensorsNamesArrayTmp.length / 2];
                for(int sensorIndex = 0; sensorIndex < sensorsNamesArray.length; ++sensorIndex) {
                    sensorsNamesArray[sensorIndex] = sensorsNamesArrayTmp[sensorIndex];
                }
               
                String[] sensorsValueKeysArray = scanServerProxy.read_attribute("sensorsDataList").extractStringArray();
               
                ISensor sensor;
                String sensorValueKey;
                String sensorName;
                double[] sensorValuesArray;
                DeviceAttribute sensorValueAttribute;
                for(int sensorIndex = 0; sensorIndex < sensorsNamesArray.length && sensorIndex < sensorsValueKeysArray.length; ++sensorIndex) {
                    sensorName = sensorsNamesArray[sensorIndex];
                    sensor = new SensorImpl();
                    sensor.setName(sensorName);
                    sensor.setEnabled(true);
                    scanResult.getSensorsList().add(sensor);
                   
                    sensorValueKey = sensorsValueKeysArray[sensorIndex];
                    sensorValueAttribute = scanServerProxy.read_attribute(sensorValueKey);
                    sensorValuesArray = AttributeHelper.extractToDoubleArray(sensorValueAttribute);
                    sensor.setScanServerAttributeName(scanServerProxy.get_name() + "/" + sensorValueKey);
                   
                    row = 0;
                    column = 0;
                    for(double sensorValue : sensorValuesArray) {
                        scanPointsMatrix[row][column].getSensorsValuesMap().put(sensor, sensorValue);
                        ++column;
                        if(column >= columnsNumber) {
                            column = 0;
                            ++ row;
                        }
                    }
                }
   
                // Actuators dimension X
                String[] actuatorsXNamesArrayTmp = scanServerProxy.read_attribute("actuators").extractStringArray();
                // The actuatorsXNamesArrayTmp contains the data twice : once for reading and once for writing.
                String actuatorXName;
                String[] actuatorsXNamesArray = new String[actuatorsXNamesArrayTmp.length / 2];
                for(int actuatorXIndex = 0; actuatorXIndex < actuatorsXNamesArray.length; ++actuatorXIndex) {
                    actuatorsXNamesArray[actuatorXIndex] = actuatorsXNamesArrayTmp[actuatorXIndex];
                }
               
                String[] actuatorsXValueKeysArray = scanServerProxy.read_attribute("actuatorsDataList").extractStringArray();
                IActuator actuatorX;
                String actuatorXValueKey;
                double[] actuatorXValuesArray;
                DeviceAttribute actuatorXValueAttribute;
                for(int actuatorXIndex = 0;
                        actuatorXIndex < actuatorsXNamesArray.length && actuatorXIndex < actuatorsXValueKeysArray.length;
                        ++actuatorXIndex) {
                    actuatorXName = actuatorsXNamesArray[actuatorXIndex];
                    actuatorX = new ActuatorImpl();
                    actuatorX.setName(actuatorXName);
                    actuatorX.setEnabled(true);
                    scanResult.getActuatorsXList().add(actuatorX);
                   
                    actuatorXValueKey = actuatorsXValueKeysArray[actuatorXIndex];
                   
                    actuatorXValueAttribute = scanServerProxy.read_attribute(actuatorXValueKey);
                    actuatorXValuesArray = AttributeHelper.extractToDoubleArray(actuatorXValueAttribute);
                    actuatorX.setScanServerAttributeName(scanServerProxy.get_name() + "/" + actuatorXValueKey);

                    row = 0;
                    column = 0;
                    for(double actuatorXValue : actuatorXValuesArray) {
                        scanPointsMatrix[row][column].getActuatorsXValuesMap().put(actuatorX, actuatorXValue);
                        ++column;
                        if(column >= columnsNumber) {
                            column = 0;
                            ++ row;
                        }
                    }
                }
   
                // Actuators dimension Y
                String[] actuatorsYNamesArrayTmp = scanServerProxy.read_attribute("actuators2").extractStringArray();
                // The actuatorsYNamesArrayTmp contains the data twice : once for reading and once for writing.
                String actuatorYName;
                String[] actuatorsYNamesArray = new String[actuatorsYNamesArrayTmp.length / 2];
                for(int actuatorYIndex = 0; actuatorYIndex < actuatorsYNamesArray.length; ++actuatorYIndex) {
                    actuatorsYNamesArray[actuatorYIndex] = actuatorsYNamesArrayTmp[actuatorYIndex];
                }
               
                String[] actuatorsYValueKeysArray = scanServerProxy.read_attribute("actuators2DataList").extractStringArray();
                IActuator actuatorY;
                String actuatorYValueKey;
                double[] actuatorYValuesArray;
                DeviceAttribute actuatorYValueAttribute;
                for(int actuatorYIndex = 0;
                        actuatorYIndex < actuatorsYNamesArray.length && actuatorYIndex < actuatorsYValueKeysArray.length;
                        ++actuatorYIndex) {
                    actuatorYName = actuatorsYNamesArray[actuatorYIndex];
                    actuatorY = new ActuatorImpl();
                    actuatorY.setName(actuatorYName);
                    actuatorY.setEnabled(true);
                    scanResult.getActuatorsYList().add(actuatorY);
                   
                    actuatorYValueKey = actuatorsYValueKeysArray[actuatorYIndex];
                   
                    actuatorYValueAttribute = scanServerProxy.read_attribute(actuatorYValueKey);
                    actuatorYValuesArray = AttributeHelper.extractToDoubleArray(actuatorYValueAttribute);
                    actuatorY.setScanServerAttributeName(scanServerProxy.get_name() + "/" + actuatorYValueKey);

                    row = 0;
                    for(double actuatorYValue : actuatorYValuesArray) {
                        for(column = 0; column < columnsNumber; ++column) {
                            scanPointsMatrix[row][column].getActuatorsYValuesMap().put(actuatorY, actuatorYValue);
                        }
                        ++row;
                    }
                }
               
                scanResult.setScanPointsMatrix(scanPointsMatrix);
            } catch (DevFailed e) {
                e.printStackTrace();
                String errorMessage = "Error while reading the scan result.";
                if(e.getMessage() != null) {
                    errorMessage += " " + e.getMessage();
View Full Code Here


                || scanResult.getActuatorsXList().size() == 0
                || !(scanResult instanceof IScanResult2D)) {
            return null;
        }

        IScanResult2D scanResult2D = (IScanResult2D) scanResult;

        if (scanResult2D.getActuatorsYList() == null
                || scanResult2D.getActuatorsYList().size() == 0) {
            return null;
        }

        IScanPoint[][] scanPointsMatrix = scanResult2D.getScanPointsMatrix();
        int rowsNumber = scanPointsMatrix.length;
        if (rowsNumber == 0) {
            return null;
        }
        int columnsNumber = scanPointsMatrix[0].length;
View Full Code Here

     * @param zComponentName
     * @return
     */
    public Object getZComponent(String zComponentName) {

        IScanResult2D scanResult2D = (IScanResult2D) getScanResult();
        List<ISensor> sensorsList = scanResult2D.getSensorsList();
        List<IActuator> actuatorsList = scanResult2D.getActuatorsYList();

        for (ISensor sensor : sensorsList) {
            if (sensor.getName().equals(zComponentName)) {
                return sensor;
            }
View Full Code Here

                || scanResult.getActuatorsXList().size() == 0
                || !(scanResult instanceof IScanResult2D)) {
            return null;
        }

        IScanResult2D scanResult2D = (IScanResult2D) scanResult;

        if (scanResult2D.getActuatorsYList() == null
                || scanResult2D.getActuatorsYList().size() == 0) {
            return null;
        }

        IScanPoint[][] scanPointsMatrix = scanResult2D.getScanPointsMatrix();
        int rowsNumber = scanPointsMatrix.length;
        if (rowsNumber == 0) {
            return null;
        }
        int columnsNumber = scanPointsMatrix[0].length;
View Full Code Here

     * @param zComponentName
     * @return
     */
    public Object getZComponent(String zComponentName) {

        IScanResult2D scanResult2D = (IScanResult2D) getScanResult();
        List<ISensor> sensorsList = scanResult2D.getSensorsList();
        List<IActuator> actuatorsList = scanResult2D.getActuatorsYList();

        for (ISensor sensor : sensorsList) {
            if (sensor.getName().equalsIgnoreCase(zComponentName)) {
                return sensor;
            }
View Full Code Here

                || scanResult.getActuatorsXList().size() == 0
                || !(scanResult instanceof IScanResult2D)) {
            return null;
        }

        IScanResult2D scanResult2D = (IScanResult2D) scanResult;

        if (scanResult2D.getActuatorsYList() == null
                || scanResult2D.getActuatorsYList().size() == 0) {
            return null;
        }

        IScanPoint[][] scanPointsMatrix = scanResult2D.getScanPointsMatrix();
        int rowsNumber = scanPointsMatrix.length;
        if (rowsNumber == 0) {
            return null;
        }
        int columnsNumber = scanPointsMatrix[0].length;
View Full Code Here

     * @param zComponentName
     * @return
     */
    public Object getZComponent(String zComponentName) {

        IScanResult2D scanResult2D = (IScanResult2D) getScanResult();
        List<ISensor> sensorsList = scanResult2D.getSensorsList();
        List<IActuator> actuatorsList = scanResult2D.getActuatorsYList();

        for (ISensor sensor : sensorsList) {
            if (sensor.getName().equalsIgnoreCase(zComponentName)) {
                return sensor;
            }
View Full Code Here

     *
     * @return
     * @throws SalsaDeviceException
     */
    public IScanResult2D readScanResult() throws SalsaDeviceException {
        IScanResult2D scanResult;
        if (isScanResultReady()) {

            int column;
            int columnsNumber;
            int rowsNumber;
            int row;
            IScanPoint[][] scanPointsMatrix;
            try {
                // Type
                TangoAttribute scanTypeAttribute = new TangoAttribute(scanServerName + "/scanType");
                int scanType = scanTypeAttribute.read(Integer.class);
                if (scanType != 2) {
                    return null;
                }
                scanResult = new ScanResult2DImpl();
                scanResult.setScanServer(scanServerName);
                scanResult.setResultType(IScanResult.ResultType.RESULT_2D);

                // Name.
                TangoAttribute runNameAttribute = new TangoAttribute(scanServerName + "/runName");
                String runName = runNameAttribute.read(String.class);
                scanResult.setRunName(runName);

                // Building empty matrix.
                TangoAttribute sensorsTimeStampsAttribute = new TangoAttribute(scanServerName
                        + "/sensorsTimeStamps");
                columnsNumber = sensorsTimeStampsAttribute.getDeviceAttribute().getDimX();
                rowsNumber = sensorsTimeStampsAttribute.getDeviceAttribute().getDimY();
                scanPointsMatrix = new IScanPoint[rowsNumber][columnsNumber];
                for (row = 0; row < rowsNumber; ++row) {
                    for (column = 0; column < columnsNumber; ++column) {
                        scanPointsMatrix[row][column] = new ScanPointImpl();
                    }
                }

                // Times.
                double[] timesArray = (double[]) sensorsTimeStampsAttribute.readArray(Double.TYPE);
                row = 0;
                column = 0;
                for (double time : timesArray) {
                    if ((row < rowsNumber) && (column < columnsNumber)) {
                        scanPointsMatrix[row][column].setTime(time);
                    }
                    ++column;
                    if (column >= columnsNumber) {
                        column = 0;
                        ++row;
                    }
                }

                // Sensors
                String[] sensorsNamesArrayTmp = new TangoAttribute(scanServerName + "/sensors")
                        .readSpecOrImage(String.class);
                // The sensorsNamesArrayTmp contains the data twice : once for reading and once for
                // writing.
                String[] sensorsNamesArray = new String[sensorsNamesArrayTmp.length / 2];
                for (int sensorIndex = 0; sensorIndex < sensorsNamesArray.length; ++sensorIndex) {
                    sensorsNamesArray[sensorIndex] = sensorsNamesArrayTmp[sensorIndex];
                }

                String[] sensorsValueKeysArray = new TangoAttribute(scanServerName
                        + "/sensorsDataList").readSpecOrImage(String.class);

                ISensor sensor;
                String sensorValueKey;
                String sensorName;
                double[] sensorValuesArray;
                TangoAttribute sensorValueAttribute;
                for (int sensorIndex = 0; sensorIndex < sensorsNamesArray.length
                        && sensorIndex < sensorsValueKeysArray.length; ++sensorIndex) {
                    sensorName = sensorsNamesArray[sensorIndex];
                    sensor = new SensorImpl();
                    sensor.setName(sensorName);
                    sensor.setEnabled(true);
                    scanResult.getSensorsList().add(sensor);

                    sensorValueKey = sensorsValueKeysArray[sensorIndex];
                    sensorValueAttribute = new TangoAttribute(scanServerName + "/" + sensorValueKey);
                    sensorValuesArray = (double[]) sensorValueAttribute.readArray(Double.TYPE);
                    sensor.setScanServerAttributeName(scanServerName + "/" + sensorValueKey);

                    row = 0;
                    column = 0;
                    for (double sensorValue : sensorValuesArray) {
                        if ((row < rowsNumber) && (column < columnsNumber)) {
                            scanPointsMatrix[row][column].getSensorsValuesMap().put(sensor,
                                    sensorValue);
                        }
                        ++column;
                        if (column >= columnsNumber) {
                            column = 0;
                            ++row;
                        }
                    }
                }

                // Actuators dimension X
                String[] actuatorsXNamesArrayTmp = new TangoAttribute(scanServerName + "/actuators")
                        .readSpecOrImage(String.class);
                // The actuatorsXNamesArrayTmp contains the data twice : once for reading and once
                // for writing.
                String actuatorXName;
                String[] actuatorsXNamesArray = new String[actuatorsXNamesArrayTmp.length / 2];
                for (int actuatorXIndex = 0; actuatorXIndex < actuatorsXNamesArray.length; ++actuatorXIndex) {
                    actuatorsXNamesArray[actuatorXIndex] = actuatorsXNamesArrayTmp[actuatorXIndex];
                }

                String[] actuatorsXValueKeysArray = new TangoAttribute(scanServerName
                        + "/actuatorsDataList").readSpecOrImage(String.class);
                IActuator actuatorX;
                String actuatorXValueKey;
                double[] actuatorXValuesArray;
                TangoAttribute actuatorXValueAttribute;
                for (int actuatorXIndex = 0; actuatorXIndex < actuatorsXNamesArray.length
                        && actuatorXIndex < actuatorsXValueKeysArray.length; ++actuatorXIndex) {
                    actuatorXName = actuatorsXNamesArray[actuatorXIndex];
                    actuatorX = new ActuatorImpl();
                    actuatorX.setName(actuatorXName);
                    actuatorX.setEnabled(true);
                    scanResult.getActuatorsXList().add(actuatorX);

                    actuatorXValueKey = actuatorsXValueKeysArray[actuatorXIndex];

                    actuatorXValueAttribute = new TangoAttribute(scanServerName + "/"
                            + actuatorXValueKey);
                    actuatorXValuesArray = (double[]) actuatorXValueAttribute
                            .readArray(Double.TYPE);
                    actuatorX.setScanServerAttributeName(scanServerName + "/" + actuatorXValueKey);

                    row = 0;
                    column = 0;
                    for (double actuatorXValue : actuatorXValuesArray) {
                        if ((row < rowsNumber) && (column < columnsNumber)) {
                            scanPointsMatrix[row][column].getActuatorsXValuesMap().put(actuatorX,
                                    actuatorXValue);
                        }
                        ++column;
                        if (column >= columnsNumber) {
                            column = 0;
                            ++row;
                        }
                    }
                }

                // Actuators dimension Y
                String[] actuatorsYNamesArrayTmp = new TangoAttribute(scanServerName
                        + "/actuators2").readSpecOrImage(String.class);
                // The actuatorsYNamesArrayTmp contains the data twice : once for reading and once
                // for writing.
                String actuatorYName;
                String[] actuatorsYNamesArray = new String[actuatorsYNamesArrayTmp.length / 2];
                for (int actuatorYIndex = 0; actuatorYIndex < actuatorsYNamesArray.length; ++actuatorYIndex) {
                    actuatorsYNamesArray[actuatorYIndex] = actuatorsYNamesArrayTmp[actuatorYIndex];
                }

                String[] actuatorsYValueKeysArray = new TangoAttribute(scanServerName
                        + "/actuators2DataList").readSpecOrImage(String.class);
                IActuator actuatorY;
                String actuatorYValueKey;
                double[] actuatorYValuesArray;
                TangoAttribute actuatorYValueAttribute;
                for (int actuatorYIndex = 0; actuatorYIndex < actuatorsYNamesArray.length
                        && actuatorYIndex < actuatorsYValueKeysArray.length; ++actuatorYIndex) {
                    actuatorYName = actuatorsYNamesArray[actuatorYIndex];
                    actuatorY = new ActuatorImpl();
                    actuatorY.setName(actuatorYName);
                    actuatorY.setEnabled(true);
                    scanResult.getActuatorsYList().add(actuatorY);

                    actuatorYValueKey = actuatorsYValueKeysArray[actuatorYIndex];

                    actuatorYValueAttribute = new TangoAttribute(scanServerName + "/"
                            + actuatorYValueKey);
                    actuatorYValuesArray = (double[]) actuatorYValueAttribute
                            .readArray(Double.TYPE);
                    actuatorY.setScanServerAttributeName(scanServerName + "/" + actuatorYValueKey);

                    row = 0;
                    for (double actuatorYValue : actuatorYValuesArray) {
                        for (column = 0; column < columnsNumber; ++column) {
                            if (row < rowsNumber) {
                                scanPointsMatrix[row][column].getActuatorsYValuesMap().put(
                                        actuatorY, actuatorYValue);
                            }
                        }
                        ++row;
                    }
                }

                scanResult.setScanPointsMatrix(scanPointsMatrix);
            }
            catch (DevFailed e) {
                e.printStackTrace();
                String errorMessage = "Error while reading the scan result.";
                if (e.getMessage() != null) {
View Full Code Here

                || scanResult.getActuatorsXList().size() == 0
                || !(scanResult instanceof IScanResult2D)) {
            return null;
        }

        IScanResult2D scanResult2D = (IScanResult2D) scanResult;

        if (scanResult2D.getActuatorsYList() == null
                || scanResult2D.getActuatorsYList().size() == 0) {
            return null;
        }

        IScanPoint[][] scanPointsMatrix = scanResult2D.getScanPointsMatrix();
        int rowsNumber = scanPointsMatrix.length;
        if (rowsNumber == 0) {
            return null;
        }
        int columnsNumber = scanPointsMatrix[0].length;
View Full Code Here

     * @param zComponentName
     * @return
     */
    public Object getZComponent(String zComponentName) {

        IScanResult2D scanResult2D = (IScanResult2D) getScanResult();
        List<ISensor> sensorsList = scanResult2D.getSensorsList();
        List<IActuator> actuatorsList = scanResult2D.getActuatorsYList();

        for (ISensor sensor : sensorsList) {
            if (sensor.getName().equalsIgnoreCase(zComponentName)) {
                return sensor;
            }
View Full Code Here

TOP

Related Classes of fr.soleil.salsa.entity.scan2D.IScanResult2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.