Package fr.soleil.tango.clientapi

Examples of fr.soleil.tango.clientapi.TangoAttribute


     * @throws SalsaDeviceException
     */
    public boolean isScanResultReady() throws SalsaDeviceException {
        boolean ready;
        try {
            TangoAttribute attribute = new TangoAttribute(scanServerName + "/data_01");
            // If there is no data_01 attribute, the next line will throw a DevFailed exception.
            double[] data01Array = (double[]) attribute.readArray(Double.TYPE);
            ready = data01Array != null && data01Array.length != 0;
        }
        catch (DevFailed e) {
            ready = false;
        }
View Full Code Here


    public void doScanFunction(String scanServerName, Behaviour behaviour, ISensor sensor,
            IActuator actuator) throws SalsaDeviceException {
        try {
            DeviceProxy scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);

            TangoAttribute afterRunActionType = new TangoAttribute(scanServerName
                    + "/afterRunActionType");
            afterRunActionType.write(behaviour.getType());
            // TODO remove syso
            // System.out.println("behaviour.getType()=" + behaviour.getType());

            if (sensor != null) {
                // We need the sensor position.
                String sensorName = sensor.getName();
                if (sensorName != null && !sensorName.trim().equals("")) {
                    String[] sensorsNamesArray = scanServerProxy.read_attribute("sensors")
                            .extractStringArray();
                    int sensorPosition;
                    for (sensorPosition = 0; sensorPosition < sensorsNamesArray.length; ++sensorPosition) {
                        if (sensorName.equals(sensorsNamesArray[sensorPosition])) {
                            break;
                        }
                    }
                    if (sensorPosition < sensorsNamesArray.length) {
                        TangoAttribute afterRunActionSensor = new TangoAttribute(scanServerName
                                + "/afterRunActionSensor");
                        afterRunActionSensor.write(sensorPosition);
                    }
                    else {
                        throw new SalsaDeviceException("Error : sensor " + sensor.getName()
                                + " is unknow on the scan server " + scanServerName + ".");
                    }
                }
            }

            if (actuator != null) {
                // We need the actuator position.
                String actuatorName = actuator.getName();
                if (actuatorName != null && !actuatorName.trim().equals("")) {
                    String[] actuatorsNamesArray = scanServerProxy.read_attribute("actuators")
                            .extractStringArray();
                    int actuatorPosition;
                    for (actuatorPosition = 0; actuatorPosition < actuatorsNamesArray.length; ++actuatorPosition) {
                        if (actuatorName.equals(actuatorsNamesArray[actuatorPosition])) {
                            break;
                        }
                    }
                    if (actuatorPosition < actuatorsNamesArray.length) {
                        TangoAttribute afterRunActionActuator = new TangoAttribute(scanServerName
                                + "/afterRunActionActuator");
                        afterRunActionActuator.write(actuatorPosition);
                    }
                    else {
                        throw new SalsaDeviceException("Error : actuator " + actuator.getName()
                                + " is unknow on the scan server " + scanServerName + ".");
                    }
View Full Code Here

     * @throws SalsaDeviceException
     */
    public void setDataRecorderPartialMode(String scanServerName, boolean mode)
            throws SalsaDeviceException {
        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

     * @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

                    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) {
View Full Code Here

        @Override
        public void run() {

            String value = null;
            try {
                TangoAttribute tangoAttribute = new TangoAttribute(attributeName);
                value = tangoAttribute.extract(String.class);

                if (value != null) {
                    synchronized (m_attributeStringValues) {
                        m_attributeStringValues.put(attributeName, value);
                    }
View Full Code Here

        @Override
        public void run() {

            Double value = Double.NaN;
            try {
                TangoAttribute tangoAttribute = new TangoAttribute(attributeName);

                if (!writeValue) {
                    value = tangoAttribute.extract(Double.class);

                    if (value != null) {
                        synchronized (m_attributeDoubleValues) {
                            m_attributeDoubleValues.put(attributeName, value);
                        }
                    }

                    else {
                        value = tangoAttribute.extractWritten(Double.class);
                        if (value != null) {
                            synchronized (m_attributeDoubleWriteValues) {
                                m_attributeDoubleWriteValues.put(attributeName, value);
                            }
                        }
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.