Package fr.soleil.tango.clientapi

Examples of fr.soleil.tango.clientapi.TangoAttribute


     */
    public void setDataRecorderPartialMode(String scanServerName, boolean mode)
            throws SalsaDeviceException {
        dataRecorderPartialMode = mode;
        try {
            TangoAttribute tangoAttribute = new TangoAttribute(scanServerName
                    + "/dataRecorderPartialMode");
            tangoAttribute.insert(mode);
            tangoAttribute.write();
        }
        catch (DevFailed e) {
            // scanServerManager.invalidateScanServerProxy(scanServerName);
            throw new SalsaDeviceException("Error : cannot write " + scanServerName
                    + "/dataRecorderPartialMode to " + mode + e.getMessage(), e);
View Full Code Here


            return Double.NaN;
        }
        // BUG 19414
        // return AttributeManager.readDoubleAttribute(device.getName());
        try {
            TangoAttribute tangoAttribute = new TangoAttribute(device.getName());
            return tangoAttribute.extract(Double.class);
        }
        catch (Exception e) {
            // e.printStackTrace();
            SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                    "Error while trying to read the TangORB attribute value for the device "
View Full Code Here

        }

        // BUG 19414
        // return AttributeManager.readDoubleWrittenAttribute(device.getName());
        try {
            TangoAttribute tangoAttribute = new TangoAttribute(device.getName());
            return tangoAttribute.extractWritten(Double.class);
        }
        catch (Exception e) {
            // e.printStackTrace();
            SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                    "Error while trying to read the TangORB attribute value for the device "
View Full Code Here

     * @param device
     * @return
     * @throws SalsaDeviceException
     */
    public static void setData(IDevice device, Double data) throws SalsaDeviceException {
        TangoAttribute attribute = getTangoAttribute(device);
        if (attribute != null) {
            try {
                attribute.write(data);
            }
            catch (DevFailed e) {
                e.printStackTrace();
                SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                        "Error while trying to write the TangORB attribute value for the device "
View Full Code Here

     * @param device
     * @return
     * @throws SalsaDeviceException
     */
    public static void setData(IDevice device, Double[] dataArray) throws SalsaDeviceException {
        TangoAttribute attribute = getTangoAttribute(device);
        if (attribute != null) {
            int length = dataArray.length;
            double[] doubleArray = new double[length];
            for (int index = 0; index < length; ++index) {
                doubleArray[index] = dataArray[index].doubleValue();
            }
            try {
                attribute.writeSpectrum(doubleArray);
            }
            catch (DevFailed e) {
                e.printStackTrace();
                SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                        "Error while trying to write the TangORB attribute value for the device "
View Full Code Here

     * @param device
     * @return
     * @throws SalsaDeviceException
     */
    public static void setData(IDevice device, Double[][] dataMatrix) throws SalsaDeviceException {
        TangoAttribute attribute = getTangoAttribute(device);
        if (attribute != null) {
            int dimY = dataMatrix.length;
            if (dimY != 0) {
                int dimX = dataMatrix[0].length;
                int length = dimY * dimX;
                double[] doubleArray = new double[length];
                for (int yIndex = 0; yIndex < dimY; ++yIndex) {
                    for (int xIndex = 0; xIndex < dimX; ++xIndex) {
                        doubleArray[yIndex * dimX + xIndex] = dataMatrix[yIndex][xIndex];
                    }
                }
                try {
                    attribute.writeImage(dimX, dimY, doubleArray);
                }
                catch (DevFailed e) {
                    e.printStackTrace();
                    SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                            "Error while trying to write the TangORB attribute value for the device "
View Full Code Here

     * @param device
     * @throws SalsaDeviceException
     */
    public static String getQuality(IDevice device) throws SalsaDeviceException {
        String quality;
        TangoAttribute attribute = getTangoAttribute(device);
        if (attribute != null) {
            try {
                quality = QualityUtilities.getNameForQuality(attribute.getDeviceAttribute()
                        .getQuality());
            }
            catch (DevFailed e) {
                SalsaDeviceException salsaDeviceException = new SalsaDeviceException(
                        "Error while trying to read the quality of the TangORB attribute value for the device "
View Full Code Here

     * @return The desired {@link TangoAttribute}, or <code>null</code> if device was
     *         <code>null</code> or if its name was <code>null</code> or empty
     * @throws SalsaDeviceException If a problem occurred while accessing the attribute
     */
    private static TangoAttribute getTangoAttribute(IDevice device) throws SalsaDeviceException {
        TangoAttribute result = null;
        if (device != null) {
            result = getTangoAttribute(device.getName());
        }
        return result;
    }
View Full Code Here

     *         <code>null</code> or empty
     * @throws SalsaDeviceException If a problem occurred while accessing the attribute
     */
    private static TangoAttribute getTangoAttribute(String completeName)
            throws SalsaDeviceException {
        TangoAttribute result = null;
        if (completeName != null && !completeName.trim().isEmpty()) {
            try {
                result = new TangoAttribute(completeName);
            }
            catch (DevFailed e) {
                e.printStackTrace();
                throw generateSalsaAccessDeviceException(e, completeName);
            }
View Full Code Here

        }
        String deviceName = name.substring(0, separatorPos);
        String attributeName = name.substring(separatorPos + 1);

        DeviceProxy proxy = getDeviceProxy(deviceName);
        TangoAttribute attribute = getTangoAttribute(proxy.get_name() + "/" + 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);
            String format = null;
            try {
                AttributeProxy attributeProxy = tangoAttribute.getAttributeProxy();
                if (attributeProxy != null) {
                    AttributeInfo attributeInfo = attributeProxy.get_info();
                    if (attributeInfo != null) {
                        format = attributeInfo.format;
                    }
                }
            }
            catch (Exception e) {
                // Ignore exception: it is not a problem if format is not recovered
                format = null;
            }
            report.setFormat(format);

            double[] rawData;
            switch (info.data_format.value()) {
                case AttrDataFormat._SCALAR:
                    report.setDimensionType(DimensionType.SCALAR);
                    if (readable) {
                        report.setReadScalarData(tangoAttribute.read(Double.class));
                    }
                    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 = (double[]) tangoAttribute.readArray(Double.TYPE);
                    int spectrumLength = attribute.getDeviceAttribute().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 = (double[]) tangoAttribute.readArray(Double.TYPE);
                    int xDim = attribute.getDeviceAttribute().getDimX();
                    int yDim = attribute.getDeviceAttribute().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];
View Full Code Here

TOP

Related Classes of fr.soleil.tango.clientapi.TangoAttribute

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.