Examples of IScanResult1D


Examples of fr.soleil.salsa.entity.scan1d.IScanResult1D

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

            int pointIndex;
            try {
                // Type
                DeviceAttribute scanTypeAttribute = scanServerProxy.read_attribute("scanType");
                int scanType = scanTypeAttribute.extractLong();
                if (scanType != 1 && scanType != 0) {
                    return null;
                }

                scanResult = new ScanResult1DImpl();
                scanResult.setResultType(IScanResult.ResultType.RESULT_1D);

                // Name.
                DeviceAttribute runNameAttribute = scanServerProxy.read_attribute("runName");
                String runName = runNameAttribute.extractString();
                scanResult.setRunName(runName);

                // Time
                double[] timesArray = scanServerProxy.read_attribute("sensorsTimeStamps")
                        .extractDoubleArray();
                List<IScanPoint> scanPointsList = new ArrayList<IScanPoint>(timesArray.length);
                IScanPoint scanPoint;
                for (double time : timesArray) {
                    scanPoint = new ScanPointImpl();
                    scanPoint.setTime(time);
                    scanPointsList.add(scanPoint);
                }

                // 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);

                    pointIndex = 0;
                    for (double sensorValue : sensorValuesArray) {
                        // The reading can occur during the scan. Because of this, more values can
                        // have been added since
                        // scanPointsList was initialized. Hence the test scanPointsList.size() >
                        // pointIndex.
                        if (scanPointsList.size() > pointIndex) {
                            scanPoint = scanPointsList.get(pointIndex);
                            scanPoint.getSensorsValuesMap().put(sensor, sensorValue);
                        }
                        ++pointIndex;
                    }
                }

                // 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);

                    pointIndex = 0;
                    for (double actuatorXValue : actuatorXValuesArray) {
                        // The reading can occur during the scan. Because of this, more values can
                        // have been added since
                        // scanPointsList was initialized. Hence the test scanPointsList.size() >
                        // pointIndex.
                        if (scanPointsList.size() > pointIndex) {
                            scanPoint = scanPointsList.get(pointIndex);
                            scanPoint.getActuatorsXValuesMap().put(actuatorX, actuatorXValue);
                        }
                        ++pointIndex;
                    }
                }

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

Examples of fr.soleil.salsa.entity.scan1d.IScanResult1D

     *
     * @return
     * @throws SalsaDeviceException
     */
    public IScanResult1D readScanResult() throws SalsaDeviceException {
        IScanResult1D scanResult = null;
        DeviceProxy scanServerProxy = getScanServerProxy();
        if (scanServerProxy != null) {
            if (isScanResultReady()) {

                int pointIndex;
                try {
                    // Type
                    DeviceAttribute scanTypeAttribute = scanServerProxy.read_attribute("scanType");
                    int scanType = scanTypeAttribute.extractLong();
                    if (scanType != 1 && scanType != 0) {
                        return null;
                    }

                    scanResult = new ScanResult1DImpl();
                    scanResult.setScanServer(scanServerName);

                    scanResult.setResultType(IScanResult.ResultType.RESULT_1D);

                    // Name.
                    DeviceAttribute runNameAttribute = scanServerProxy.read_attribute("runName");
                    String runName = runNameAttribute.extractString();
                    scanResult.setRunName(runName);

                    // Time
                    double[] timesArray = scanServerProxy.read_attribute("sensorsTimeStamps")
                            .extractDoubleArray();
                    List<IScanPoint> scanPointsList = new ArrayList<IScanPoint>(timesArray.length);
                    IScanPoint scanPoint;
                    for (double time : timesArray) {
                        scanPoint = new ScanPointImpl();
                        scanPoint.setTime(time);
                        scanPointsList.add(scanPoint);
                    }

                    // 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;
                    TangoAttribute attribute;
                    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];
                        attribute = new TangoAttribute(scanServerName + "/" + sensorValueKey);
                        sensorValuesArray = (double[]) attribute.readArray(Double.TYPE);
                        sensor.setScanServerAttributeName(scanServerProxy.get_name() + "/"
                                + sensorValueKey);

                        pointIndex = 0;
                        for (double sensorValue : sensorValuesArray) {
                            // The reading can occur during the scan. Because of this, more values
                            // can
                            // have been added since
                            // scanPointsList was initialized. Hence the test scanPointsList.size()
                            // >
                            // pointIndex.
                            if (scanPointsList.size() > pointIndex) {
                                scanPoint = scanPointsList.get(pointIndex);
                                scanPoint.getSensorsValuesMap().put(sensor, sensorValue);
                            }
                            ++pointIndex;
                        }
                    }

                    // 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;
                    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];

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

                        pointIndex = 0;
                        for (double actuatorXValue : actuatorXValuesArray) {
                            // The reading can occur during the scan. Because of this, more values
                            // can have been added since scanPointsList was initialized. Hence the
                            // test scanPointsList.size() > pointIndex.
                            if (scanPointsList.size() > pointIndex) {
                                scanPoint = scanPointsList.get(pointIndex);
                                scanPoint.getActuatorsXValuesMap().put(actuatorX, actuatorXValue);
                            }
                            ++pointIndex;
                        }
                    }

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

Examples of fr.soleil.salsa.entity.scan1d.IScanResult1D

     *
     * @return
     * @throws SalsaDeviceException
     */
    public IScanResult1D readScanResult() throws SalsaDeviceException {
        IScanResult1D scanResult = null;
        DeviceProxy scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
        if (scanServerProxy != null) {
            if (isScanResultReady()) {

                int pointIndex;
                try {
                    // Type
                    DeviceAttribute scanTypeAttribute = scanServerProxy.read_attribute("scanType");
                    int scanType = scanTypeAttribute.extractLong();
                    if (scanType != 1 && scanType != 0) {
                        return null;
                    }

                    scanResult = new ScanResult1DImpl();
                    scanResult.setScanServer(scanServerName);

                    scanResult.setResultType(IScanResult.ResultType.RESULT_1D);

                    // Name.
                    DeviceAttribute runNameAttribute = scanServerProxy.read_attribute("runName");
                    String runName = runNameAttribute.extractString();
                    scanResult.setRunName(runName);

                    // Time
                    double[] timesArray = scanServerProxy.read_attribute("sensorsTimeStamps")
                            .extractDoubleArray();
                    List<IScanPoint> scanPointsList = new ArrayList<IScanPoint>(timesArray.length);
                    IScanPoint scanPoint;
                    for (double time : timesArray) {
                        scanPoint = new ScanPointImpl();
                        scanPoint.setTime(time);
                        scanPointsList.add(scanPoint);
                    }

                    // 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;
                    TangoAttribute attribute;
                    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];
                        attribute = new TangoAttribute(scanServerName + "/" + sensorValueKey);
                        sensorValuesArray = (double[]) attribute.readArray(Double.TYPE);
                        sensor.setScanServerAttributeName(scanServerProxy.get_name() + "/"
                                + sensorValueKey);

                        pointIndex = 0;
                        for (double sensorValue : sensorValuesArray) {
                            // The reading can occur during the scan. Because of this, more values
                            // can
                            // have been added since
                            // scanPointsList was initialized. Hence the test scanPointsList.size()
                            // >
                            // pointIndex.
                            if (scanPointsList.size() > pointIndex) {
                                scanPoint = scanPointsList.get(pointIndex);
                                scanPoint.getSensorsValuesMap().put(sensor, sensorValue);
                            }
                            ++pointIndex;
                        }
                    }

                    // 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;
                    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];

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

                        pointIndex = 0;
                        for (double actuatorXValue : actuatorXValuesArray) {
                            // The reading can occur during the scan. Because of this, more values
                            // can have been added since scanPointsList was initialized. Hence the
                            // test scanPointsList.size() > pointIndex.
                            if (scanPointsList.size() > pointIndex) {
                                scanPoint = scanPointsList.get(pointIndex);
                                scanPoint.getActuatorsXValuesMap().put(actuatorX, actuatorXValue);
                            }
                            ++pointIndex;
                        }
                    }

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

Examples of fr.soleil.salsa.entity.scan1d.IScanResult1D

     * Returns the result of the current scan.
     * @return
     * @throws SalsaDeviceException
     */
    public IScanResult1D readScanResult() throws SalsaDeviceException {
        IScanResult1D scanResult;
        if(isScanResultReady()) {
           
            int pointIndex;
            try {
                // Type
                DeviceAttribute scanTypeAttribute = scanServerProxy.read_attribute("scanType");
                int scanType = scanTypeAttribute.extractLong();
                if(scanType != 1 && scanType != 0) {
                    return null;
                }
               
                scanResult = new ScanResult1DImpl();
                scanResult.setResultType(IScanResult.ResultType.RESULT_1D);
               
                // Name.
                DeviceAttribute runNameAttribute = scanServerProxy.read_attribute("runName");
                String runName = runNameAttribute.extractString();
                scanResult.setRunName(runName);
               
                // Time
                double[] timesArray = scanServerProxy.read_attribute("sensorsTimeStamps").extractDoubleArray();
                List<IScanPoint> scanPointsList = new ArrayList<IScanPoint>(timesArray.length);
                IScanPoint scanPoint;
                for(double time : timesArray) {
                    scanPoint = new ScanPointImpl();
                    scanPoint.setTime(time);
                    scanPointsList.add(scanPoint);
                }
               
                // 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);
                   
                    pointIndex = 0;
                    for(double sensorValue : sensorValuesArray) {
                        // The reading can occur during the scan. Because of this, more values can have been added since
                        // scanPointsList was initialized. Hence the test scanPointsList.size() > pointIndex.
                        if(scanPointsList.size() > pointIndex) {
                            scanPoint = scanPointsList.get(pointIndex);
                            scanPoint.getSensorsValuesMap().put(sensor, sensorValue);
                        }
                        ++pointIndex;
                    }
                }
   
                // 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);
   
                    pointIndex = 0;
                    for(double actuatorXValue : actuatorXValuesArray) {
                        // The reading can occur during the scan. Because of this, more values can have been added since
                        // scanPointsList was initialized. Hence the test scanPointsList.size() > pointIndex.
                        if(scanPointsList.size() > pointIndex) {
                            scanPoint = scanPointsList.get(pointIndex);
                            scanPoint.getActuatorsXValuesMap().put(actuatorX, actuatorXValue);
                        }
                        ++pointIndex;
                    }
                }
               
                scanResult.setScanPointsList(scanPointsList);
            } catch (DevFailed e) {
                e.printStackTrace();
                String errorMessage = "Error while reading the scan result.";
                if(e.getMessage() != null) {
                    errorMessage += " " + e.getMessage();
View Full Code Here

Examples of fr.soleil.salsa.entity.scan1d.IScanResult1D

     *
     * @return
     * @throws SalsaDeviceException
     */
    public IScanResult1D readScanResult() throws SalsaDeviceException {
        IScanResult1D scanResult = null;
        DeviceProxy scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
        if (scanServerProxy != null) {
            if (isScanResultReady()) {

                try {
                    // Type
                    actionName = "read_attribute(\"scanType\")";
                    DeviceAttribute scanTypeAttribute = scanServerProxy.read_attribute("scanType");
                    int scanType = scanTypeAttribute.extractLong();
                    if (scanType != 1 && scanType != 0) {
                        return null;
                    }

                    scanResult = new ScanResult1DImpl();
                    scanResult.setScanServer(scanServerName);

                    scanResult.setResultType(IScanResult.ResultType.RESULT_1D);

                    // Name.
                    actionName = "read_attribute(\"runName\")";
                    DeviceAttribute runNameAttribute = scanServerProxy.read_attribute("runName");
                    String runName = runNameAttribute.extractString();
                    scanResult.setRunName(runName);

                    IScanPoint scanPoint;
                    List<IScanPoint> scanPointsList = new ArrayList<IScanPoint>();

                    // Time
View Full Code Here

Examples of fr.soleil.salsa.entity.scan1d.IScanResult1D

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

            int pointIndex;
            try {
                // Type
                DeviceAttribute scanTypeAttribute = scanServerProxy.read_attribute("scanType");
                int scanType = scanTypeAttribute.extractLong();
                if (scanType != 1 && scanType != 0) {
                    return null;
                }

                scanResult = new ScanResult1DImpl();
                scanResult.setResultType(IScanResult.ResultType.RESULT_1D);

                // Name.
                DeviceAttribute runNameAttribute = scanServerProxy.read_attribute("runName");
                String runName = runNameAttribute.extractString();
                scanResult.setRunName(runName);

                // Time
                double[] timesArray = scanServerProxy.read_attribute("sensorsTimeStamps")
                        .extractDoubleArray();
                List<IScanPoint> scanPointsList = new ArrayList<IScanPoint>(timesArray.length);
                IScanPoint scanPoint;
                for (double time : timesArray) {
                    scanPoint = new ScanPointImpl();
                    scanPoint.setTime(time);
                    scanPointsList.add(scanPoint);
                }

                // 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);

                    pointIndex = 0;
                    for (double sensorValue : sensorValuesArray) {
                        // The reading can occur during the scan. Because of this, more values can
                        // have been added since
                        // scanPointsList was initialized. Hence the test scanPointsList.size() >
                        // pointIndex.
                        if (scanPointsList.size() > pointIndex) {
                            scanPoint = scanPointsList.get(pointIndex);
                            scanPoint.getSensorsValuesMap().put(sensor, sensorValue);
                        }
                        ++pointIndex;
                    }
                }

                // 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);

                    pointIndex = 0;
                    for (double actuatorXValue : actuatorXValuesArray) {
                        // The reading can occur during the scan. Because of this, more values can
                        // have been added since
                        // scanPointsList was initialized. Hence the test scanPointsList.size() >
                        // pointIndex.
                        if (scanPointsList.size() > pointIndex) {
                            scanPoint = scanPointsList.get(pointIndex);
                            scanPoint.getActuatorsXValuesMap().put(actuatorX, actuatorXValue);
                        }
                        ++pointIndex;
                    }
                }

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

Examples of fr.soleil.salsa.entity.scan1d.IScanResult1D

     *
     * @return
     * @throws SalsaDeviceException
     */
    public IScanResult1D readScanResult() throws SalsaDeviceException {
        IScanResult1D scanResult = null;
        DeviceProxy scanServerProxy = TangoDeviceHelper.getDeviceProxy(scanServerName);
        if (scanServerProxy != null) {
            if (isScanResultReady()) {

                try {
                    // Type
                    actionName = "read_attribute(\"scanType\")";
                    DeviceAttribute scanTypeAttribute = scanServerProxy.read_attribute("scanType");
                    int scanType = scanTypeAttribute.extractLong();
                    if (scanType != 1 && scanType != 0) {
                        return null;
                    }

                    scanResult = new ScanResult1DImpl();
                    scanResult.setScanServer(scanServerName);

                    scanResult.setResultType(IScanResult.ResultType.RESULT_1D);

                    // Name.
                    actionName = "read_attribute(\"runName\")";
                    DeviceAttribute runNameAttribute = scanServerProxy.read_attribute("runName");
                    String runName = runNameAttribute.extractString();
                    scanResult.setRunName(runName);

                    IScanPoint scanPoint;
                    List<IScanPoint> scanPointsList = new ArrayList<IScanPoint>();

                    // Time
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.