Package fr.soleil.tango.clientapi

Examples of fr.soleil.tango.clientapi.TangoAttribute


     * @param attr
     */
    protected void setAttribute(String attributeName, int[] attributeValue)
            throws SalsaDeviceException {
        try {
            new TangoAttribute(scanServerName + "/" + attributeName).write(attributeValue);
        }
        catch (DevFailed e) {
            String message = "Error setting attribute " + attributeName + " to " + attributeValue
                    + " : " + e.getMessage();
            if (e.errors != null && e.errors.length > 0) {
View Full Code Here


     * @param attr
     */
    protected void setAttribute(String attributeName, long[] attributeValue)
            throws SalsaDeviceException {
        try {
            new TangoAttribute(scanServerName + "/" + attributeName).write(attributeValue);
        }
        catch (DevFailed e) {
            String message = "Error setting attribute " + attributeName + " to " + attributeValue
                    + " : " + e.getMessage();
            if (e.errors != null && e.errors.length > 0) {
View Full Code Here

     * @param attr
     */
    protected void setAttribute(String attributeName, float[] attributeValue)
            throws SalsaDeviceException {
        try {
            new TangoAttribute(scanServerName + "/" + attributeName).write(attributeValue);
        }
        catch (DevFailed e) {
            String message = "Error setting attribute " + attributeName + " to " + attributeValue
                    + " : " + e.getMessage();
            if (e.errors != null && e.errors.length > 0) {
View Full Code Here

     * @param attr
     */
    protected void setAttribute(String attributeName, double[] attributeValue)
            throws SalsaDeviceException {
        try {
            new TangoAttribute(scanServerName + "/" + attributeName).write(attributeValue);
        }
        catch (DevFailed e) {
            String message = "Error setting attribute " + attributeName + " to " + attributeValue
                    + " : " + e.getMessage();
            if (e.errors != null && e.errors.length > 0) {
View Full Code Here

     * @param attr
     */
    protected void setAttribute(String attributeName, String[] attributeValue)
            throws SalsaDeviceException {
        try {
            new TangoAttribute(scanServerName + "/" + attributeName).write(attributeValue);
        }
        catch (DevFailed e) {
            String message = "Error setting attribute " + attributeName + " to " + attributeValue
                    + " : " + e.getMessage();
            if (e.errors != null && e.errors.length > 0) {
View Full Code Here

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

                    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

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

                        if (dbDatum != null) {
                            dataRecorderDeviceName = dbDatum.extractString();
                        }

                        if (dataRecorderDeviceName != null && !dataRecorderDeviceName.isEmpty()) {
                            TangoAttribute tangoAttribute = new TangoAttribute(
                                    dataRecorderDeviceName + "/targetDirectory");
                            String targetDirectory = tangoAttribute.extract(String.class);
                            tangoAttribute = new TangoAttribute(dataRecorderDeviceName
                                    + "/fileName");
                            String fileName = tangoAttribute.extract(String.class);
                            tangoAttribute = new TangoAttribute(dataRecorderDeviceName
                                    + "/nxEntryName");
                            nxEntryName = tangoAttribute.extract(String.class);
                            // nexusFileName = targetDirectory + File.separator + fileName + ".nxs";
                            // Data Recorder always on linux environnement
                            nexusFileName = targetDirectory + "/" + fileName + ".nxs";
                        }
                    }
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());
            // 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

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.