Package fr.soleil.salsa.exception

Examples of fr.soleil.salsa.exception.SalsaDeviceException


        try {
            attribute = proxy.read_attribute(attributeName);
        }
        catch (DevFailed e) {
            e.printStackTrace();
            SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                    "Error while trying to access the TangORB attribute value for the device "
                            + proxy.get_name() + "/" + attributeName + ".", e);
            throw salsaDeviceException;
        }
        return attribute;
View Full Code Here


                proxy.write_attribute(attribute);
            }
        }
        catch (DevFailed e) {
            e.printStackTrace();
            SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                    "Error while trying to access the TangORB attribute value for the device "
                            + device.getName() + ".", e);
            throw salsaDeviceException;
        }
    }
View Full Code Here

     */
    private static AttributeInfo getAttributeInfo(IDevice device) throws SalsaDeviceException {
        String name = device.getName();
        int separatorPos = name.lastIndexOf("/");
        if (separatorPos < 0) {
            throw new SalsaDeviceException("Error : invalid device name " + name + " : no \"/\".",
                    false);
        }
        String attributeName = name.substring(separatorPos + 1);
        DeviceProxy proxy = getDeviceProxy(device);
        if (proxy == null) {
View Full Code Here

        try {
            info = proxy.get_attribute_info(attributeName);
        }
        catch (DevFailed e) {
            e.printStackTrace();
            SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                    "Error while trying to read the TangORB attribute info for the device "
                            + proxy.get_name() + "/" + attributeName + ".", e);
            throw salsaDeviceException;
        }
        return info;
View Full Code Here

            case AttrDataFormat._IMAGE:
                dimensionType = DimensionType.IMAGE;
                break;
            default:
                // Normally impossible.
                throw new SalsaDeviceException("Unknown data format for the device "
                        + device.getName() + ".");
        }
        return dimensionType;
    }
View Full Code Here

        // Tango connection objects.
        // Splits the device name into the corresponding deviceName and attributeName.
        String name = device.getName();
        int separatorPos = name.lastIndexOf("/");
        if (separatorPos < 0) {
            throw new SalsaDeviceException("Error : invalid device name " + name + " : no \"/\".",
                    false);
        }
        String deviceName = name.substring(0, separatorPos);
        String attributeName = name.substring(separatorPos + 1);

        DeviceProxy proxy = getDeviceProxy(deviceName);
        DeviceAttribute attribute = getDeviceAttribute(proxy, attributeName);
        AttributeInfo info = getAttributeInfo(proxy, attributeName);
        // Report.

        // Readable / writable.
        boolean readable;
        boolean writeable;
        switch (info.writable.value()) {
            case AttrWriteType._READ:
                readable = true;
                writeable = false;
                break;
            case AttrWriteType._READ_WITH_WRITE:
            case AttrWriteType._READ_WRITE:
                readable = true;
                writeable = true;
                break;
            case AttrWriteType._WRITE:
                readable = false;
                writeable = true;
                break;
            default:
                // Normally impossible.
                throw new SalsaDeviceException("Unknown write type for the device " + name + ".");
        }
        report.setReadable(readable);
        report.setWriteable(writeable);

        // Data and data format.
        try {
            TangoAttribute tangoAttribute = new TangoAttribute(name);

            double[] rawData;
            switch (info.data_format.value()) {
                case AttrDataFormat._SCALAR:
                    report.setDimensionType(DimensionType.SCALAR);
                    rawData = AttributeHelper.extractToDoubleArray(attribute);
                    if (readable) {
                        report.setReadScalarData(rawData[0]);
                    }
                    else {
                        report.setReadScalarData(null);
                    }
                    if (writeable) {
                        Double dataWritten = tangoAttribute.readWritten(Double.class);
                        report.setWriteScalarData(dataWritten);
                    }
                    else {
                        report.setWriteScalarData(null);
                    }
                    report.setReadSpectrumData(null);
                    report.setWriteSpectrumData(null);
                    report.setReadImageData(null);
                    report.setWriteImageData(null);
                    break;
                case AttrDataFormat._SPECTRUM:
                    report.setDimensionType(DimensionType.SPECTRUM);
                    rawData = AttributeHelper.extractToDoubleArray(attribute);
                    int spectrumLength = attribute.getDimX();
                    Double[] readSpectrumData = null;
                    Double[] writeSpectrumData = null;

                    if (readable) {
                        readSpectrumData = new Double[spectrumLength];
                        writeSpectrumData = null;
                        for (int index = 0; index < spectrumLength; ++index) {
                            readSpectrumData[index] = rawData[index];
                        }
                    }

                    if (writeable) {
                        writeSpectrumData = new Double[spectrumLength];
                        for (int index = 0; index < spectrumLength; ++index) {
                            writeSpectrumData = tangoAttribute.readSpecOrImage(Double.class);

                        }

                    }
                    report.setReadScalarData(null);
                    report.setWriteScalarData(null);
                    report.setReadSpectrumData(readSpectrumData);
                    report.setWriteSpectrumData(writeSpectrumData);
                    report.setReadImageData(null);
                    report.setWriteImageData(null);
                    break;
                case AttrDataFormat._IMAGE:
                    report.setDimensionType(DimensionType.IMAGE);
                    rawData = AttributeHelper.extractToDoubleArray(attribute);
                    int xDim = attribute.getDimX();
                    int yDim = attribute.getDimY();
                    Double[][] readImageData;
                    Double[][] writeImageData;
                    Double[] writtenImage = tangoAttribute.readSpecOrImage(Double.class);
                    int yOffset;
                    if (readable) {
                        readImageData = new Double[yDim][xDim];
                        if (writeable) {
                            writeImageData = new Double[yDim][xDim];

                            for (int yPos = 0; yPos < yDim; ++yPos) {
                                yOffset = yPos * xDim;

                                for (int xPos = 0; xPos < xDim; ++xPos) {
                                    readImageData[yPos][xPos] = rawData[xPos + yOffset];
                                    writeImageData[yPos][xPos] = writtenImage[xPos + yOffset];

                                }
                            }
                        }
                        else {
                            writeImageData = null;
                            for (int yPos = 0; yPos < yDim; ++yPos) {
                                yOffset = yPos * xDim;
                                for (int xPos = 0; xPos < xDim; ++xPos) {
                                    readImageData[yPos][xPos] = rawData[xPos + yOffset];
                                }
                            }
                        }
                    }
                    else {
                        readImageData = null;
                        if (writeable) {
                            writeImageData = new Double[yDim][xDim];
                            for (int yPos = 0; yPos < yDim; ++yPos) {
                                yOffset = yPos * xDim;
                                for (int xPos = 0; xPos < xDim; ++xPos) {
                                    writeImageData[yPos][xPos] = writtenImage[xPos + yOffset];
                                }
                            }
                        }
                        else {
                            writeImageData = null;
                        }
                    }
                    report.setReadScalarData(null);
                    report.setWriteScalarData(null);
                    report.setReadSpectrumData(null);
                    report.setWriteSpectrumData(null);
                    report.setReadImageData(readImageData);
                    report.setWriteImageData(writeImageData);
                    break;
                default:
                    // Normally impossible.
                    throw new SalsaDeviceException("Unknown data format for the device " + name
                            + ".");
            }
        }
        catch (DevFailed e) {
            e.printStackTrace();
            SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                    "Error while trying to read the TangORB attribute data for the device "
                            + device.getName() + ".", e);
            throw salsaDeviceException;
        }

        String quality;
        try {
            quality = QualityUtilities.getNameForQuality(attribute.getQuality());
        }
        catch (DevFailed e) {
            SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                    "Error while trying to read the quality of the TangORB attribute value for the device "
                            + device.getName() + ".", e);
            throw salsaDeviceException;
        }
        report.setQuality(quality);

        String state;
        try {
            state = StateUtilities.getNameForState(proxy.state());
        }
        catch (DevFailed e) {
            SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                    "Error while trying to read the state of the TangORB attribute value for the device "
                            + device.getName() + ".", e);
            throw salsaDeviceException;
        }
        report.setState(state);
View Full Code Here

        try {
            proxy = new DeviceProxy(deviceName);
        }
        catch(DevFailed e) {
            e.printStackTrace();
            SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                    "Error while creating a TangORB device for the timebase " + timebase.getName() + ".", e);
            throw salsaDeviceException;
        }
        return proxy;
    }
View Full Code Here

                    errorMessage += " " + e.getMessage();
                }
                if (e.errors != null && e.errors.length > 0) {
                    errorMessage += " : " + e.errors[0].desc;
                }
                throw new SalsaDeviceException(errorMessage, e);
            }
        }
        else {
            scanResult = null;
        }
View Full Code Here

            }
            catch (DevFailed e) {
                if (actionName == null) {
                    actionName = "";
                }
                throw new SalsaDeviceException(
                        actionName + " Failed " + DevFailedUtils.toString(e), e);
            }
        }
    }
View Full Code Here

            }
            catch (DevFailed e) {
                if (actionName == null) {
                    actionName = "";
                }
                throw new SalsaDeviceException(
                        actionName + " Failed " + DevFailedUtils.toString(e), e);
            }
            catch (SalsaTrajectoryException e) {
                e.printStackTrace();
                throw new SalsaDeviceException(e.getMessage(), e);
            }
        }
    }
View Full Code Here

TOP

Related Classes of fr.soleil.salsa.exception.SalsaDeviceException

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.