Package fr.esrf.TangoApi

Examples of fr.esrf.TangoApi.DeviceAttribute


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


        Stage[] stages = Stage.values();
        for (Stage stage : stages) {
            String attributeName = getStageAttributeName(stage);
            if (attributeName != null) {
                String[] commandsTab = new String[0];
                DeviceAttribute da = new DeviceAttribute(attributeName);
                da.insert(commandsTab);
                scanServerProxy.write_attribute(da);
            }
        }

        if ((sao != null) && (sao.getHooks() != null)) {
            List<IHook> hooks = sao.getHooks();
            for (IHook h : hooks) {
                Stage stage = h.getStage();
                String attributeName = getStageAttributeName(stage);
                if (attributeName != null) {
                    List<String> commands = new ArrayList<String>();
                    if (h.getCommandsList() == null) {
                        continue;
                    }
                    for (IHookCommand c : h.getCommandsList()) {
                        if ((c.getCommand() != null) && (c.getCommand().trim().length() > 0) && c.isEnable()) {
                            commands.add(c.getCommand());
                        }
                    }
                    String[] commandsTab = new String[commands.size()];
                    commandsTab = commands.toArray(commandsTab);
                    DeviceAttribute da = new DeviceAttribute(attributeName);
                    da.insert(commandsTab);
                    writeAttributeLog(attributeName, Arrays.toString(commandsTab));
                    scanServerProxy.write_attribute(da);
                }
            }
        }
View Full Code Here

                        int errorStrategyType = esi.getStrategy().ordinal();

                        // Time out.
                        String catAttribute = cat + "TimeOut";
                        actionName = writeAttributeLog(catAttribute, String.valueOf(errorStrategyTimeOut));
                        scanServerProxy.write_attribute(new DeviceAttribute(catAttribute, errorStrategyTimeOut));
                        // Retry count.
                        catAttribute = cat + "RetryCount";
                        actionName = writeAttributeLog(catAttribute, String.valueOf(errorStrategyRetryCount));
                        scanServerProxy.write_attribute(new DeviceAttribute(catAttribute, errorStrategyRetryCount));
                        // Retry time out.
                        catAttribute = cat + "RetryTimeOut";
                        actionName = writeAttributeLog(catAttribute, String.valueOf(errorStrategyRetryTimeOut));
                        scanServerProxy.write_attribute(new DeviceAttribute(catAttribute, errorStrategyRetryTimeOut));
                        // Error strategy.
                        catAttribute = cat + "ErrorStrategy";
                        actionName = writeAttributeLog(catAttribute, String.valueOf(errorStrategyType));
                        scanServerProxy.write_attribute(new DeviceAttribute(catAttribute, errorStrategyType));
                    }
                    // Context validation error strategy.
                    int erreurStrategyValue = errorStrat.getContextValidationStrategy().ordinal();
                    actionName = writeAttributeLog(CurrentScanDataModel.CONTEXT_VALIDATION_STRATEGY,
                            String.valueOf(erreurStrategyValue));
View Full Code Here

                setAttribute(pointNumberName, totalStepsNumber, false);

                // Trajectories.
                // Sends the array to Tango.
                String trajectoriesName = "trajectories" + indexStr;
                DeviceAttribute trajectoriesAttribute = new DeviceAttribute(trajectoriesName);
                if (enabledActuatorsNumber != 0) {
                    trajectoriesAttribute.insert(allActuatorsPositionsArray, totalStepsNumber, enabledActuatorsNumber);
                } else {
                    trajectoriesAttribute.insert(new double[] {}, 0, 1);
                }

                // Attribute only manage in X dimension
                if (dimensionIndex == 1) {
                    actionName = writeAttributeLog("integrationTimes", Arrays.toString(integrationsTimesArray));
View Full Code Here

        if (scanServerProxy != null) {
            if (isScanResultReady()) {
                try {
                    // Type
                    actionName = "read_attribute(\"" + CurrentScanDataModel.SCAN_TYPE + "\")";
                    DeviceAttribute scanTypeAttribute = scanServerProxy.read_attribute(CurrentScanDataModel.SCAN_TYPE);
                    int scanType = scanTypeAttribute.extractLong();
                    LOGGER.trace("{}.{}={}", scanServerName, actionName, String.valueOf(scanType));
                    // 0 -> time scan
                    // 1 -> scan 1d
                    // 2 -> scan 2d
                    switch (scanType) {
View Full Code Here

        Stage[] stages = Stage.values();
        for (Stage stage : stages) {
            String attributeName = getStageAttributeName(stage);
            if (attributeName != null) {
                String[] commandsTab = new String[0];
                DeviceAttribute da = new DeviceAttribute(attributeName);
                da.insert(commandsTab);
                scanServerProxy.write_attribute(da);
            }
        }

        if ((sao != null) && (sao.getHooks() != null)) {
            List<IHook> hooks = sao.getHooks();
            for (IHook h : hooks) {
                Stage stage = h.getStage();
                String attributeName = getStageAttributeName(stage);
                if (attributeName != null) {
                    List<String> commands = new ArrayList<String>();
                    if (h.getCommandsList() == null) {
                        continue;
                    }
                    for (IHookCommand c : h.getCommandsList()) {
                        if ((c.getCommand() != null) && (c.getCommand().trim().length() > 0) && c.isEnable()) {
                            commands.add(c.getCommand());
                        }
                    }
                    String[] commandsTab = new String[commands.size()];
                    commandsTab = commands.toArray(commandsTab);
                    DeviceAttribute da = new DeviceAttribute(attributeName);
                    da.insert(commandsTab);
                    scanServerProxy.write_attribute(da);
                }
            }
        }
    }
View Full Code Here

                        int errorStrategyType = esi.getStrategy().ordinal();

                        // Time out.
                        String catAttribute = cat + "TimeOut";
                        actionName = writeAttributeLog(catAttribute, String.valueOf(errorStrategyTimeOut));
                        scanServerProxy.write_attribute(new DeviceAttribute(catAttribute, errorStrategyTimeOut));
                        // Retry count.
                        catAttribute = cat + "RetryCount";
                        actionName = writeAttributeLog(catAttribute, String.valueOf(errorStrategyRetryCount));
                        scanServerProxy.write_attribute(new DeviceAttribute(catAttribute, errorStrategyRetryCount));
                        // Retry time out.
                        catAttribute = cat + "RetryTimeOut";
                        actionName = writeAttributeLog(catAttribute, String.valueOf(errorStrategyRetryTimeOut));
                        scanServerProxy.write_attribute(new DeviceAttribute(catAttribute, errorStrategyRetryTimeOut));
                        // Error strategy.
                        catAttribute = cat + "ErrorStrategy";
                        actionName = writeAttributeLog(catAttribute, String.valueOf(errorStrategyType));
                        scanServerProxy.write_attribute(new DeviceAttribute(catAttribute, errorStrategyType));
                    }
                    // Context validation error strategy.
                    int erreurStrategyValue = errorStrat.getContextValidationStrategy().ordinal();
                    actionName = writeAttributeLog(CurrentScanDataModel.CONTEXT_VALIDATION_STRATEGY,
                            String.valueOf(erreurStrategyValue));
View Full Code Here

                // System.out.println("pointNumber=" + totalStepsNumber);

                // Trajectories.
                // Sends the array to Tango.
                String trajectoriesName = "trajectories" + indexStr;
                DeviceAttribute trajectoriesAttribute = new DeviceAttribute(trajectoriesName);
                if (enabledActuatorsNumber != 0) {
                    trajectoriesAttribute.insert(allActuatorsPositionsArray, totalStepsNumber, enabledActuatorsNumber);
                } else {
                    trajectoriesAttribute.insert(new double[] {}, 0, 1);
                }

                // Attribute only manage in X dimension
                if (dimensionIndex == 1) {
                    actionName = "write_attribute(\"integrationTimes\"," + Arrays.toString(integrationsTimesArray)
View Full Code Here

        if (scanServerProxy != null) {
            if (isScanResultReady()) {
                try {
                    // Type
                    actionName = "read_attribute(\"" + CurrentScanDataModel.SCAN_TYPE + "\")";
                    DeviceAttribute scanTypeAttribute = scanServerProxy.read_attribute(CurrentScanDataModel.SCAN_TYPE);
                    int scanType = scanTypeAttribute.extractLong();
                    // 0 -> time scan
                    // 1 -> scan 1d
                    // 2 -> scan 2d
                    switch (scanType) {
                        case 0:
View Full Code Here

        // If a scan result is ready, there is a data_01 attribute.
        DeviceProxy scanServerProxy;
        boolean ready;
        scanServerProxy = getScanServerProxy(scanServerName);
        try {
            DeviceAttribute data01Attribute = scanServerProxy.read_attribute("data_01");
            // If there is no data_01 attribute, the next line will throw a DevFailed exception.
            double[] data01Array = AttributeHelper.extractToDoubleArray(data01Attribute);
            ready = data01Array != null && data01Array.length != 0;
        }
        catch (DevFailed e) {
View Full Code Here

TOP

Related Classes of fr.esrf.TangoApi.DeviceAttribute

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.