Package fr.esrf.TangoApi

Examples of fr.esrf.TangoApi.DeviceProxy


        if (config.getDimensionX().getActuatorsList().size() == 0) {
            throw new SalsaDeviceException("Cannot start scan : no actuators were defined.");
        }

        int timeOut;
        DeviceProxy scanServerProxy = TangoDeviceHelper.getDeviceProxy(scanServerName, false);
        if (scanServerProxy != null) {
            try {
                // Reads the initial value of the time out.
                timeOut = scanServerProxy.get_timeout_millis();
                initScanCommon(config, scanServerName);
                try {

                    // Actuators X
                    setDimensionAttribute(scanServerName, 1, config.getDimensionX(), config.isOnTheFly());

                    // Hardware continuous scan : yes !
                    setAttribute("hwContinuous", true, false);

                    // Get the only one range
                    int nbOfPoint = 1;

                    IDimensionHCS dimension = config.getDimensionX();
                    if (dimension != null) {
                        List<IRangeHCS> rangeList = dimension.getRangesXList();
                        if ((rangeList != null) && !rangeList.isEmpty()) {
                            IRangeHCS range = rangeList.get(0);
                            nbOfPoint = range.getStepsNumber();
                        }
                    }

                    setAttribute("hwContinuousNbPt", nbOfPoint, false);

                    // End of specific configuration.

                    startScan();
                    // System.out.println("startScan=" + config);
                } finally {
                    // Sets the time out back to the initial value.
                    scanServerProxy.set_timeout_millis(timeOut);
                }
            } catch (DevFailed e) {
                // e.printStackTrace();
                throw new SalsaDeviceException(actionName + " Failed " + DevFailedUtils.toString(e), e);
            } catch (Exception ex) {
View Full Code Here


    public void startScan(IConfigK config, String scanServerName) throws SalsaDeviceException {
        if (config.getDimensionX().getActuatorsList().size() == 0) {
            throw new SalsaDeviceException("Cannot start scan : no actuators were defined.");
        }
        int timeOut;
        DeviceProxy scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
        if (scanServerProxy != null) {
            try {
                // Reads the initial value of the time out.
                timeOut = scanServerProxy.get_timeout_millis();
                try {
                    // Time out
                    scanServerProxy.set_timeout_millis(5000);

                    // Clean
                    command("Clean");

                    // Partial mode for recording,clean set mode to false
                    setAttribute("dataRecorderPartialMode", isDataRecorderPartialMode());

                    // Run name.
                    String runName = config.getName();
                    IDirectory directory = config.getDirectory();
                    while (directory != null) {
                        runName = directory.getName() + "." + runName;
                        directory = directory.getDirectory();
                    }
                    setAttribute("runName", runName);

                    // Scan number.
                    setAttribute("scanNumber", config.getScanNumber());

                    // Timebases.
                    List<ITimebase> timebasesList = config.getTimebaseList();
                    List<String> timebasesNameList = new ArrayList<String>(timebasesList.size());
                    for (ITimebase timebase : timebasesList) {
                        if (timebase.isEnabled()) {
                            timebasesNameList.add(timebase.getName());
                        }
                    }
                    String[] timebasesNameArray = timebasesNameList
                            .toArray(new String[timebasesNameList.size()]);
                    setAttribute("timebases", timebasesNameArray);

                    // Sensors
                    List<ISensor> sensorsList = config.getSensorsList();
                    List<String> sensorsNameList = new ArrayList<String>(sensorsList.size());
                    for (ISensor sensor : sensorsList) {
                        if (sensor.isEnabled()) {
                            sensorsNameList.add(sensor.getName());
                        }
                    }
                    String[] sensorsNameArray = sensorsNameList.toArray(new String[sensorsNameList
                            .size()]);
                    setAttribute("sensors", sensorsNameArray);

                    // Actuators
                    List<IActuator> actuatorsList;
                    List<String> actuatorsNamesList;
                    String[] actuatorsNamesArray;
                    IDimensionK dimension = config.getDimensionX();
                    actuatorsList = dimension.getActuatorsList();
                    actuatorsNamesList = new ArrayList<String>(actuatorsList.size());
                    for (IActuator actuator : actuatorsList) {
                        if (actuator.isEnabled()) {
                            actuatorsNamesList.add(actuator.getName());
                        }
                    }
                    actuatorsNamesArray = actuatorsNamesList.toArray(new String[actuatorsNamesList
                            .size()]);
                    // System.out.println("actuators=" + Arrays.toString(actuatorsNamesArray));
                    setAttribute("actuators", actuatorsNamesArray);

                    // Dimension
                    // A scan K has a single dimension, a single range, a single trajectory.

                    ITrajectoryK trajectoryK = config.getDimensionX().getRangeX().getTrajectory();
                    double[] trajectoriesPositionsArray = TrajectoryCalculator
                            .calculateKTrajectoriesPosition(trajectoryK);
                    // System.out.println("K Trajectory="
                    // + Arrays.toString(trajectoriesPositionsArray));
                    // System.out.println("K Trajectory size=" + trajectoriesPositionsArray.length);
                    double[] integrationsTimesArray = TrajectoryCalculator
                            .calculateIntegrationTimesK(trajectoryK);
                    // System.out.println("K integration size=" + integrationsTimesArray.length);
                    // System.out.println("K integration=" +
                    // Arrays.toString(integrationsTimesArray));

                    int pointNumber = trajectoriesPositionsArray.length;
                    setAttribute("pointNumber", pointNumber);

                    DeviceAttribute trajectoriesAttribute = new DeviceAttribute("trajectories");
                    trajectoriesAttribute.insert(trajectoriesPositionsArray,
                            trajectoriesPositionsArray.length, 1);
                    scanServerProxy.write_attribute(trajectoriesAttribute);
                    setAttribute("integrationTimes", integrationsTimesArray);

                    // Actuator delay.
                    double actuatorsDelay = config.getActuatorsDelay();
                    setAttribute("actuatorsDelay", actuatorsDelay);

                    // Zig zag.
                    boolean zigzag = config.isZigzag();
                    setAttribute("zigzag", zigzag);

                    // Enable actuator speed.
                    // boolean enableScanSpeed = config.isEnableScanSpeed();
                    // setAttribute("enableScanSpeed", enableScanSpeed);
                    // // TODO remove after fixing 22428
                    setAttribute("enableScanSpeed", false);

                    // Post scan behaviour.
                    IPostScanBehaviour postScanBehaviour = config.getScanAddOn()
                            .getPostScanBehaviour();
                    Behaviour behaviour = postScanBehaviour.getBehaviour();
                    if (behaviour == null) {
                        behaviour = Behaviour.NOOP;
                    }
                    int behaviourType = behaviour.getType();
                    setAttribute("afterRunActionType", behaviourType);
                    if (behaviour.getArgumentCount() >= 1) {
                        int behaviourSensorIndex = postScanBehaviour.getSensor();
                        setAttribute("afterRunActionSensor", behaviourSensorIndex);
                    }
                    else if (behaviour.getArgumentCount() >= 2) {
                        int behaviourActuatorIndex = postScanBehaviour.getActuator();
                        setAttribute("afterRunActionActuator", behaviourActuatorIndex);
                    }

                    // Error strategies.
                    if (config.getScanAddOn() != null
                            && config.getScanAddOn().getErrorStrategy() != null) {

                        IErrorStrategy errorStrat = config.getScanAddOn().getErrorStrategy();
                        IErrorStrategyItem[] categoriesESI = new IErrorStrategyItem[] {
                                errorStrat.getActuatorsErrorStrategy(),
                                errorStrat.getSensorsErrorStrategy(),
                                errorStrat.getTimebasesErrorStrategy(),
                                errorStrat.getHooksErrorStrategy() };
                        String[] categoriesStr = new String[] { "actuators", "sensors",
                                "timebases", "hooks" };

                        for (int i = 0; i < categoriesStr.length; i++) {
                            String cat = categoriesStr[i];
                            IErrorStrategyItem esi = categoriesESI[i];

                            double errorStrategyTimeOut = esi.getTimeOut();
                            int errorStrategyRetryCount = esi.getRetryCount();
                            double errorStrategyRetryTimeOut = esi.getTimeBetweenRetries();
                            int errorStrategyType = esi.getStrategy().ordinal();

                            // Time out.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat + "TimeOut",
                                    errorStrategyTimeOut));
                            // Retry count.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat + "RetryCount",
                                    errorStrategyRetryCount));
                            // Retry time out.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat
                                    + "RetryTimeOut", errorStrategyRetryTimeOut));
                            // Error strategy.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat
                                    + "ErrorStrategy", errorStrategyType));
                        }
                        // Context validation error strategy.
                        scanServerProxy.write_attribute(new DeviceAttribute(
                                "contextValidationErrorStrategy", errorStrat
                                        .getContextValidationStrategy().ordinal()));

                        String value = errorStrat.getContextValidationDevice();
                        if (value != null && value.isEmpty()) {
                            scanServerProxy.write_attribute(new DeviceAttribute(
                                    "contextValidation", value));
                        }
                    }

                    /* Hooks */
                    SetHooks(config.getScanAddOn(), scanServerProxy);

                    // Hardware continuous scan : no.
                    setAttribute("hwContinuous", false);

                    // On the fly mode (software continuous mode).
                    boolean onTheFly = config.isOnTheFly();
                    setAttribute("onTheFly", onTheFly);

                    // Fin configuration du scan.

                    // D�marrage du scan.
                    command("Start");
                }
                finally {
                    // Sets the time out back to the initial value.
                    scanServerProxy.set_timeout_millis(timeOut);
                }
            }
            catch (DevFailed e) {
                e.printStackTrace();
                String message = e.getMessage();
View Full Code Here

    public void startScan(IConfigHCS config, String scanServerName) throws SalsaDeviceException {
        if (config.getDimensionX().getActuatorsList().size() == 0) {
            throw new SalsaDeviceException("Cannot start scan : no actuators were defined.");
        }
        int timeOut;
        DeviceProxy scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
        if (scanServerProxy != null) {
            try {
                // Reads the initial value of the time out.
                timeOut = scanServerProxy.get_timeout_millis();
                try {
                    // Time out
                    scanServerProxy.set_timeout_millis(5000);

                    // Clean
                    command("Clean");

                    // ? Scan sequencing.
                    // scanServerProxy.write_attribute(new DeviceAttribute("scanSequencing", (short)
                    // 1));

                    // Hardware continuous scan : yes !
                    setAttribute("hwContinuous", true);
                    setAttribute("hwContinuousNbPt", config.getNumberOfPoints());

                    // Partial mode for recording, must be manage by an external client
                    // setAttribute("dataRecorderPartialMode", false);

                    // Run name.
                    String runName = config.getName();
                    IDirectory directory = config.getDirectory();
                    while (directory != null) {
                        runName = directory.getName() + "." + runName;
                        directory = directory.getDirectory();
                    }
                    setAttribute("runName", runName);

                    // Scan number.
                    setAttribute("scanNumber", config.getScanNumber());

                    // Timebases
                    List<ITimebase> timebasesList = config.getTimebaseList();
                    List<String> timebasesNameList = new ArrayList<String>(timebasesList.size());
                    for (ITimebase timebase : timebasesList) {
                        if (timebase.isEnabled()) {
                            timebasesNameList.add(timebase.getName());
                        }
                    }
                    String[] timebasesNameArray = timebasesNameList
                            .toArray(new String[timebasesNameList.size()]);
                    setAttribute("timebases", timebasesNameArray);

                    // Sensors
                    List<ISensor> sensorsList = config.getSensorsList();
                    List<String> sensorsNameList = new ArrayList<String>(sensorsList.size());
                    for (ISensor sensor : sensorsList) {
                        if (sensor.isEnabled()) {
                            sensorsNameList.add(sensor.getName());
                        }
                    }
                    String[] sensorsNameArray = sensorsNameList.toArray(new String[sensorsNameList
                            .size()]);
                    setAttribute("sensors", sensorsNameArray);

                    // Actuators
                    List<IActuator> actuatorsList;
                    List<String> actuatorsNamesList;
                    String[] actuatorsNamesArray;
                    IDimensionHCS dimension = config.getDimensionX();
                    actuatorsList = dimension.getActuatorsList();
                    actuatorsNamesList = new ArrayList<String>(actuatorsList.size());
                    for (IActuator actuator : actuatorsList) {
                        if (actuator.isEnabled()) {
                            actuatorsNamesList.add(actuator.getName());
                        }
                    }
                    actuatorsNamesArray = actuatorsNamesList.toArray(new String[actuatorsNamesList
                            .size()]);
                    setAttribute("actuators", actuatorsNamesArray);

                    // Dimensions
                    // Tango exchanges trajectories as double arrays that contains the positions, in
                    // order,
                    // actuator after actuator, range after range, of the trajectories of all the
                    // actuators.
                    // There is one such array per dimension.
                    double[] allActuatorsPositionsArray;
                    double initialValue;
                    // Contains the positions in order, range after range, of the trajectories of an
                    // actuator.
                    List<Double> actuatorPositionsList;
                    // Contains the positions in order, actuator after actuator, range after range,
                    // of
                    // the trajectories of all the actuators.
                    List<Double> allActuatorsPositionsList;
                    // The list of speeds.
                    List<Double> speedList = new ArrayList<Double>();
                    double[] speedArray;
                    // The actuators used for this dimension
                    List<IActuator> dimensionActuatorsList;
                    // Dimension.
                    // Initial computations.
                    dimensionActuatorsList = dimension.getActuatorsList();
                    // The positions, sorted as Tango expect them.
                    allActuatorsPositionsList = new ArrayList<Double>();
                    // The number of enabled actuators.
                    int enabledActuatorsNumber = 0;
                    // The positions must be sorted by actuator, so we loop over the actuators.
                    for (IActuator actuator : dimensionActuatorsList) {
                        if (actuator.isEnabled()) {
                            initialValue = ActuatorConnector.getData(actuator);
                            actuatorPositionsList = new ArrayList<Double>();
                            // For each actuators, the positions must be sorted by range.
                            for (ITrajectory trajectory : findActuatorTrajectories(dimension,
                                    actuator)) {
                                actuatorPositionsList.addAll(TrajectoryCalculator
                                        .calculateLinearTrajectoriesPosition(
                                                (ITrajectoryHCS) trajectory, initialValue, config));
                                // The speeds must be sorted in the same order, so we read them
                                // here.
                                speedList.add(trajectory.getSpeed());
                            }
                            allActuatorsPositionsList.addAll(actuatorPositionsList);
                            ++enabledActuatorsNumber;
                        }
                    }

                    // Integration Time.
                    double[] integrationsTimesArray = new double[] { config.getIntegrationTime(),
                            config.getIntegrationTime() };
                    // System.out.println("length=" + integrationsTimesArray.length);
                    setAttribute("integrationTimes", integrationsTimesArray);

                    // setAttribute("pointNumber", 0);
                    /*  if(enabledActuatorsNumber != 0) {
                          //setAttribute("pointNumber", allActuatorsPositionsList.size()/enabledActuatorsNumber);
                      }*/
                    /*for(IRangeHCS range : dimension.getRangesXList()) {
                        totalStepsNumber += range.getStepsNumber() + 1;
                    }
                    setAttribute("pointNumber", totalStepsNumber);
                    */

                    int totalStepsNumber = 0;
                    List<IRangeHCS> rangesList = config.getDimensionX().getRangesXList();
                    if (rangesList.size() > 0) {
                        totalStepsNumber += rangesList.get(0).getStepsNumber();
                        totalStepsNumber += rangesList.size() - 1;
                    }

                    // Trajectories.
                    // Builds the array from the list.
                    allActuatorsPositionsArray = toDoubleArray(allActuatorsPositionsList);
                    // Sends the array to Tango.
                    DeviceAttribute trajectoriesAttribute = new DeviceAttribute("trajectories");
                    // System.out.println("length=" + allActuatorsPositionsArray.length);
                    // System.out.println("config.getNumberOfPoints()=" +
                    // config.getNumberOfPoints());
                    // System.out.println("enabledActuatorsNumber=" + enabledActuatorsNumber);

                    if (enabledActuatorsNumber != 0) {
                        trajectoriesAttribute.insert(allActuatorsPositionsArray,
                                totalStepsNumber + 1, enabledActuatorsNumber);
                    }
                    else {
                        trajectoriesAttribute.insert(new double[] {}, 0, 1);
                    }
                    scanServerProxy.write_attribute(trajectoriesAttribute);

                    // Speed.
                    speedArray = toDoubleArray(speedList);
                    setAttribute("scanSpeed", speedArray);

                    // Actuator delay.
                    double actuatorsDelay = config.getActuatorsDelay();
                    setAttribute("actuatorsDelay", actuatorsDelay);

                    // Zig zag.
                    boolean zigzag = config.isZigzag();
                    setAttribute("zigzag", zigzag);

                    // Enable actuator speed.
                    boolean enableScanSpeed = config.isEnableScanSpeed();
                    setAttribute("enableScanSpeed", enableScanSpeed);

                    // Post scan behaviour.
                    IPostScanBehaviour postScanBehaviour = config.getScanAddOn()
                            .getPostScanBehaviour();
                    Behaviour behaviour = postScanBehaviour.getBehaviour();
                    if (behaviour == null) {
                        behaviour = Behaviour.NOOP;
                    }
                    int behaviourType = behaviour.getType();
                    setAttribute("afterRunActionType", behaviourType);
                    if (behaviour.getArgumentCount() >= 1) {
                        int behaviourSensorIndex = postScanBehaviour.getSensor();
                        setAttribute("afterRunActionSensor", behaviourSensorIndex);
                    }
                    else if (behaviour.getArgumentCount() >= 2) {
                        int behaviourActuatorIndex = postScanBehaviour.getActuator();
                        setAttribute("afterRunActionActuator", behaviourActuatorIndex);
                    }

                    // Error strategies.
                    if (config.getScanAddOn() != null
                            && config.getScanAddOn().getErrorStrategy() != null) {

                        IErrorStrategy errorStrat = config.getScanAddOn().getErrorStrategy();
                        IErrorStrategyItem[] categoriesESI = new IErrorStrategyItem[] {
                                errorStrat.getActuatorsErrorStrategy(),
                                errorStrat.getSensorsErrorStrategy(),
                                errorStrat.getTimebasesErrorStrategy(),
                                errorStrat.getHooksErrorStrategy() };
                        String[] categoriesStr = new String[] { "actuators", "sensors",
                                "timebases", "hooks" };

                        for (int i = 0; i < categoriesStr.length; i++) {
                            String cat = categoriesStr[i];
                            IErrorStrategyItem esi = categoriesESI[i];

                            double errorStrategyTimeOut = esi.getTimeOut();
                            int errorStrategyRetryCount = esi.getRetryCount();
                            double errorStrategyRetryTimeOut = esi.getTimeBetweenRetries();
                            int errorStrategyType = esi.getStrategy().ordinal();

                            // Time out.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat + "TimeOut",
                                    errorStrategyTimeOut));
                            // Retry count.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat + "RetryCount",
                                    errorStrategyRetryCount));
                            // Retry time out.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat
                                    + "RetryTimeOut", errorStrategyRetryTimeOut));
                            // Error strategy.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat
                                    + "ErrorStrategy", errorStrategyType));
                        }
                        // Context validation error strategy.
                        scanServerProxy.write_attribute(new DeviceAttribute(
                                "contextValidationErrorStrategy", errorStrat
                                        .getContextValidationStrategy().ordinal()));

                        scanServerProxy.write_attribute(new DeviceAttribute("contextValidation",
                                errorStrat.getContextValidationDevice()));
                    }

                    /* Hooks */
                    SetHooks(config.getScanAddOn(), scanServerProxy);

                    // On the fly mode (software continuous mode).
                    boolean onTheFly = config.isOnTheFly();
                    setAttribute("onTheFly", onTheFly);

                    // Fin configuration du scan.

                    // D�marrage du scan.
                    command("Start");
                }
                finally {
                    // Sets the time out back to the initial value.
                    scanServerProxy.set_timeout_millis(timeOut);
                }
            }
            catch (DevFailed e) {
                e.printStackTrace();
                String message = e.getMessage();
View Full Code Here

    public void startScan(IConfigK config, String scanServerName) throws SalsaDeviceException {
        if (config.getDimensionX().getActuatorsList().size() == 0) {
            throw new SalsaDeviceException("Cannot start scan : no actuators were defined.");
        }
        int timeOut;
        DeviceProxy scanServerProxy = getScanServerProxy();
        if (scanServerProxy != null) {
            try {
                // Reads the initial value of the time out.
                timeOut = scanServerProxy.get_timeout_millis();
                try {
                    // Time out
                    scanServerProxy.set_timeout_millis(5000);

                    // Clean
                    command("Clean");

                    // ? Scan sequencing.
                    // scanServerProxy.write_attribute(new DeviceAttribute("scanSequencing", (short)
                    // 1));

                    // Partial mode for recording.
                    setAttribute("dataRecorderPartialMode", false);

                    // Run name.
                    String runName = config.getName();
                    IDirectory directory = config.getDirectory();
                    while (directory != null) {
                        runName = directory.getName() + "." + runName;
                        directory = directory.getDirectory();
                    }
                    setAttribute("runName", runName);

                    // Scan number.
                    setAttribute("scanNumber", config.getScanNumber());

                    // Timebases.
                    List<ITimebase> timebasesList = config.getTimebaseList();
                    List<String> timebasesNameList = new ArrayList<String>(timebasesList.size());
                    for (ITimebase timebase : timebasesList) {
                        if (timebase.isEnabled()) {
                            timebasesNameList.add(timebase.getName());
                        }
                    }
                    String[] timebasesNameArray = timebasesNameList
                            .toArray(new String[timebasesNameList.size()]);
                    setAttribute("timebases", timebasesNameArray);

                    // Sensors
                    List<ISensor> sensorsList = config.getSensorsList();
                    List<String> sensorsNameList = new ArrayList<String>(sensorsList.size());
                    for (ISensor sensor : sensorsList) {
                        if (sensor.isEnabled()) {
                            sensorsNameList.add(sensor.getName());
                        }
                    }
                    String[] sensorsNameArray = sensorsNameList.toArray(new String[sensorsNameList
                            .size()]);
                    setAttribute("sensors", sensorsNameArray);

                    // Actuators
                    List<IActuator> actuatorsList;
                    List<String> actuatorsNamesList;
                    String[] actuatorsNamesArray;
                    IDimensionK dimension = config.getDimensionX();
                    actuatorsList = dimension.getActuatorsList();
                    actuatorsNamesList = new ArrayList<String>(actuatorsList.size());
                    for (IActuator actuator : actuatorsList) {
                        if (actuator.isEnabled()) {
                            actuatorsNamesList.add(actuator.getName());
                        }
                    }
                    actuatorsNamesArray = actuatorsNamesList.toArray(new String[actuatorsNamesList
                            .size()]);
                    setAttribute("actuators", actuatorsNamesArray);

                    // Dimension
                    // A scan K has a single dimension, a single range, a single trajectory.

                    ITrajectoryK trajectoryK = config.getDimensionX().getRangeX().getTrajectory();
                    double[] trajectoriesPositionsArray = TrajectoryCalculator
                            .calculateKTrajectoriesPosition(trajectoryK);
                    double[] integrationsTimesArray = TrajectoryCalculator
                            .calculateIntegrationTimesK(trajectoryK);
                    int pointNumber = trajectoriesPositionsArray.length;
                    setAttribute("pointNumber", pointNumber);
                    DeviceAttribute trajectoriesAttribute = new DeviceAttribute("trajectories");
                    trajectoriesAttribute.insert(trajectoriesPositionsArray, pointNumber, 1);
                    scanServerProxy.write_attribute(trajectoriesAttribute);
                    setAttribute("integrationTimes", integrationsTimesArray);

                    // Actuator delay.
                    double actuatorsDelay = config.getActuatorsDelay();
                    setAttribute("actuatorsDelay", actuatorsDelay);

                    // Zig zag.
                    boolean zigzag = config.isZigzag();
                    setAttribute("zigzag", zigzag);

                    // Enable actuator speed.
                    boolean enableScanSpeed = config.isEnableScanSpeed();
                    setAttribute("enableScanSpeed", enableScanSpeed);

                    // Post scan behaviour.
                    IPostScanBehaviour postScanBehaviour = config.getScanAddOn()
                            .getPostScanBehaviour();
                    Behaviour behaviour = postScanBehaviour.getBehaviour();
                    if (behaviour == null) {
                        behaviour = Behaviour.NOOP;
                    }
                    int behaviourType = behaviour.getType();
                    setAttribute("afterRunActionType", behaviourType);
                    if (behaviour.getArgumentCount() >= 1) {
                        int behaviourSensorIndex = postScanBehaviour.getSensor();
                        setAttribute("afterRunActionSensor", behaviourSensorIndex);
                    }
                    else if (behaviour.getArgumentCount() >= 2) {
                        int behaviourActuatorIndex = postScanBehaviour.getActuator();
                        setAttribute("afterRunActionActuator", behaviourActuatorIndex);
                    }

                    // Error strategies.
                    if (config.getScanAddOn() != null
                            && config.getScanAddOn().getErrorStrategy() != null) {

                        IErrorStrategy errorStrat = config.getScanAddOn().getErrorStrategy();
                        IErrorStrategyItem[] categoriesESI = new IErrorStrategyItem[] {
                                errorStrat.getActuatorsErrorStrategy(),
                                errorStrat.getSensorsErrorStrategy(),
                                errorStrat.getTimebasesErrorStrategy(),
                                errorStrat.getHooksErrorStrategy() };
                        String[] categoriesStr = new String[] { "actuators", "sensors",
                                "timebases", "hooks" };

                        for (int i = 0; i < categoriesStr.length; i++) {
                            String cat = categoriesStr[i];
                            IErrorStrategyItem esi = categoriesESI[i];

                            double errorStrategyTimeOut = esi.getTimeOut();
                            int errorStrategyRetryCount = esi.getRetryCount();
                            double errorStrategyRetryTimeOut = esi.getTimeBetweenRetries();
                            int errorStrategyType = esi.getStrategy().ordinal();

                            // Time out.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat + "TimeOut",
                                    errorStrategyTimeOut));
                            // Retry count.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat + "RetryCount",
                                    errorStrategyRetryCount));
                            // Retry time out.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat
                                    + "RetryTimeOut", errorStrategyRetryTimeOut));
                            // Error strategy.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat
                                    + "ErrorStrategy", errorStrategyType));
                        }
                        // Context validation error strategy.
                        scanServerProxy.write_attribute(new DeviceAttribute(
                                "contextValidationErrorStrategy", errorStrat
                                        .getContextValidationStrategy().ordinal()));

                        scanServerProxy.write_attribute(new DeviceAttribute("contextValidation",
                                errorStrat.getContextValidationDevice()));
                    }

                    /* Hooks */
                    SetHooks(config.getScanAddOn(), scanServerProxy);

                    // Hardware continuous scan : no.
                    setAttribute("hwContinuous", false);

                    // On the fly mode (software continuous mode).
                    boolean onTheFly = config.isOnTheFly();
                    setAttribute("onTheFly", onTheFly);

                    // Fin configuration du scan.

                    // D�marrage du scan.
                    command("Start");
                }
                finally {
                    // Sets the time out back to the initial value.
                    scanServerProxy.set_timeout_millis(timeOut);
                }
            }
            catch (DevFailed e) {
                e.printStackTrace();
                String message = e.getMessage();
View Full Code Here

    public void startScan(IConfigHCS config, String scanServerName) throws SalsaDeviceException {
        if (config.getDimensionX().getActuatorsList().size() == 0) {
            throw new SalsaDeviceException("Cannot start scan : no actuators were defined.");
        }
        int timeOut;
        DeviceProxy scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
        if (scanServerProxy != null) {
            try {
                // Reads the initial value of the time out.
                timeOut = scanServerProxy.get_timeout_millis();
                try {
                    // Time out
                    scanServerProxy.set_timeout_millis(5000);

                    // Clean
                    command("Clean");

                    // Partial mode for recording,clean set mode to false
                    setAttribute("dataRecorderPartialMode", isDataRecorderPartialMode());

                    // Hardware continuous scan : yes !
                    setAttribute("hwContinuous", true);

                    // Get the only one range
                    int nbOfPoint = 1;
                    double timeIntegration = 1;

                    IDimensionHCS dimension = config.getDimensionX();
                    if (dimension != null) {
                        List<IRangeHCS> rangeList = dimension.getRangesXList();
                        if (rangeList != null && !rangeList.isEmpty()) {
                            IRangeHCS range = rangeList.get(0);
                            nbOfPoint = range.getStepsNumber();
                            timeIntegration = range.getIntegrationTime();
                        }
                    }

                    setAttribute("hwContinuousNbPt", nbOfPoint);

                    // Partial mode for recording, must be manage by an external client
                    // setAttribute("dataRecorderPartialMode", false);

                    // Run name.
                    String runName = config.getName();
                    IDirectory directory = config.getDirectory();
                    while (directory != null) {
                        runName = directory.getName() + "." + runName;
                        directory = directory.getDirectory();
                    }
                    setAttribute("runName", runName);

                    // Scan number.
                    setAttribute("scanNumber", config.getScanNumber());

                    // Timebases
                    List<ITimebase> timebasesList = config.getTimebaseList();
                    List<String> timebasesNameList = new ArrayList<String>(timebasesList.size());
                    for (ITimebase timebase : timebasesList) {
                        if (timebase.isEnabled()) {
                            timebasesNameList.add(timebase.getName());
                        }
                    }
                    String[] timebasesNameArray = timebasesNameList
                            .toArray(new String[timebasesNameList.size()]);
                    setAttribute("timebases", timebasesNameArray);

                    // Sensors
                    List<ISensor> sensorsList = config.getSensorsList();
                    List<String> sensorsNameList = new ArrayList<String>(sensorsList.size());
                    for (ISensor sensor : sensorsList) {
                        if (sensor.isEnabled()) {
                            sensorsNameList.add(sensor.getName());
                        }
                    }
                    String[] sensorsNameArray = sensorsNameList.toArray(new String[sensorsNameList
                            .size()]);
                    setAttribute("sensors", sensorsNameArray);

                    // Actuators
                    List<IActuator> actuatorsList;
                    List<String> actuatorsNamesList;
                    String[] actuatorsNamesArray;
                    actuatorsList = dimension.getActuatorsList();
                    actuatorsNamesList = new ArrayList<String>(actuatorsList.size());
                    for (IActuator actuator : actuatorsList) {
                        if (actuator.isEnabled()) {
                            actuatorsNamesList.add(actuator.getName());
                        }
                    }
                    actuatorsNamesArray = actuatorsNamesList.toArray(new String[actuatorsNamesList
                            .size()]);
                    setAttribute("actuators", actuatorsNamesArray);

                    // Dimensions
                    // Tango exchanges trajectories as double arrays that contains the positions, in
                    // order,
                    // actuator after actuator, range after range, of the trajectories of all the
                    // actuators.
                    // There is one such array per dimension.
                    double[] allActuatorsPositionsArray;
                    double initialValue;
                    // Contains the positions in order, range after range, of the trajectories of an
                    // actuator.
                    List<Double> actuatorPositionsList;
                    // Contains the positions in order, actuator after actuator, range after range,
                    // of
                    // the trajectories of all the actuators.
                    List<Double> allActuatorsPositionsList;
                    // The list of speeds.
                    List<Double> speedList = new ArrayList<Double>();
                    double[] speedArray;
                    // The actuators used for this dimension
                    List<IActuator> dimensionActuatorsList = dimension.getActuatorsList();
                    // The positions, sorted as Tango expect them.
                    allActuatorsPositionsList = new ArrayList<Double>();
                    // The number of enabled actuators.
                    int enabledActuatorsNumber = 0;
                    // The positions must be sorted by actuator, so we loop over the actuators.
                    for (int index = 0; index < dimensionActuatorsList.size(); index++) {
                        IActuator actuator = dimensionActuatorsList.get(index);
                        if (actuator.isEnabled()) {
                            initialValue = ActuatorConnector.getData(actuator);
                            actuatorPositionsList = new ArrayList<Double>();
                            // For each actuators, the positions must be sorted by range.
                            for (ITrajectory trajectory : findActuatorTrajectories(dimension, index)) {
                                actuatorPositionsList.addAll(TrajectoryCalculator
                                        .calculateLinearTrajectoriesPosition(
                                                (ITrajectoryHCS) trajectory, initialValue, config));
                                // The speeds must be sorted in the same order, so we read them
                                // here.
                                speedList.add(trajectory.getSpeed());
                            }
                            allActuatorsPositionsList.addAll(actuatorPositionsList);
                            ++enabledActuatorsNumber;
                        }
                    }

                    // Integration Time.
                    double[] integrationsTimesArray = new double[] { timeIntegration,
                            timeIntegration };
                    // System.out.println("length=" + integrationsTimesArray.length);
                    setAttribute("integrationTimes", integrationsTimesArray);

                    int totalStepsNumber = 0;
                    List<IRangeHCS> rangesList = config.getDimensionX().getRangesXList();
                    if (rangesList.size() > 0) {
                        totalStepsNumber += rangesList.get(0).getStepsNumber();
                        totalStepsNumber += rangesList.size() - 1;
                    }

                    // Trajectories.
                    // Builds the array from the list.
                    allActuatorsPositionsArray = toDoubleArray(allActuatorsPositionsList);
                    // System.out.println("allActuatorsPositionsArray="
                    // + Arrays.toString(allActuatorsPositionsArray));
                    // Sends the array to Tango.
                    // Bug 19784 not use TangoAttribute API because of transmorph error
                    DeviceAttribute trajectoriesAttribute = new DeviceAttribute("trajectories");
                    if (enabledActuatorsNumber != 0) {
                        trajectoriesAttribute.insert(allActuatorsPositionsArray,
                                allActuatorsPositionsArray.length, enabledActuatorsNumber);
                    }
                    else {
                        trajectoriesAttribute.insert(new double[] {}, 0, 1);
                    }
                    scanServerProxy.write_attribute(trajectoriesAttribute);

                    // Speed.
                    speedArray = toDoubleArray(speedList);
                    setAttribute("scanSpeed", speedArray);

                    // Actuator delay.
                    double actuatorsDelay = config.getActuatorsDelay();
                    setAttribute("actuatorsDelay", actuatorsDelay);

                    // Zig zag.
                    boolean zigzag = config.isZigzag();
                    setAttribute("zigzag", zigzag);

                    // Enable actuator speed.
                    boolean enableScanSpeed = config.isEnableScanSpeed();
                    setAttribute("enableScanSpeed", enableScanSpeed);

                    // Post scan behaviour.
                    IPostScanBehaviour postScanBehaviour = config.getScanAddOn()
                            .getPostScanBehaviour();
                    Behaviour behaviour = postScanBehaviour.getBehaviour();
                    if (behaviour == null) {
                        behaviour = Behaviour.NOOP;
                    }
                    int behaviourType = behaviour.getType();
                    setAttribute("afterRunActionType", behaviourType);
                    if (behaviour.getArgumentCount() >= 1) {
                        int behaviourSensorIndex = postScanBehaviour.getSensor();
                        setAttribute("afterRunActionSensor", behaviourSensorIndex);
                    }
                    else if (behaviour.getArgumentCount() >= 2) {
                        int behaviourActuatorIndex = postScanBehaviour.getActuator();
                        setAttribute("afterRunActionActuator", behaviourActuatorIndex);
                    }

                    // Error strategies.
                    if (config.getScanAddOn() != null
                            && config.getScanAddOn().getErrorStrategy() != null) {

                        IErrorStrategy errorStrat = config.getScanAddOn().getErrorStrategy();
                        IErrorStrategyItem[] categoriesESI = new IErrorStrategyItem[] {
                                errorStrat.getActuatorsErrorStrategy(),
                                errorStrat.getSensorsErrorStrategy(),
                                errorStrat.getTimebasesErrorStrategy(),
                                errorStrat.getHooksErrorStrategy() };
                        String[] categoriesStr = new String[] { "actuators", "sensors",
                                "timebases", "hooks" };

                        for (int i = 0; i < categoriesStr.length; i++) {
                            String cat = categoriesStr[i];
                            IErrorStrategyItem esi = categoriesESI[i];

                            double errorStrategyTimeOut = esi.getTimeOut();
                            int errorStrategyRetryCount = esi.getRetryCount();
                            double errorStrategyRetryTimeOut = esi.getTimeBetweenRetries();
                            int errorStrategyType = esi.getStrategy().ordinal();

                            // Time out.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat + "TimeOut",
                                    errorStrategyTimeOut));
                            // Retry count.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat + "RetryCount",
                                    errorStrategyRetryCount));
                            // Retry time out.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat
                                    + "RetryTimeOut", errorStrategyRetryTimeOut));
                            // Error strategy.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat
                                    + "ErrorStrategy", errorStrategyType));
                        }
                        // Context validation error strategy.
                        scanServerProxy.write_attribute(new DeviceAttribute(
                                "contextValidationErrorStrategy", errorStrat
                                        .getContextValidationStrategy().ordinal()));

                        String value = errorStrat.getContextValidationDevice();
                        if (value != null && value.isEmpty()) {
                            scanServerProxy.write_attribute(new DeviceAttribute(
                                    "contextValidation", value));
                        }
                    }

                    /* Hooks */
                    SetHooks(config.getScanAddOn(), scanServerProxy);

                    // On the fly mode (software continuous mode).
                    boolean onTheFly = config.isOnTheFly();
                    setAttribute("onTheFly", onTheFly);

                    // Fin configuration du scan.

                    // D�marrage du scan.
                    command("Start");
                }
                finally {
                    // Sets the time out back to the initial value.
                    scanServerProxy.set_timeout_millis(timeOut);
                }
            }
            catch (DevFailed e) {
                e.printStackTrace();
                String message = e.getMessage();
View Full Code Here

        if (config.getDimensionX().getActuatorsList().size() == 0) {
            throw new SalsaDeviceException(
                    "Cannot start scan : no actuators were defined for dimension X.");
        }
        int timeOut;
        DeviceProxy scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
        if (scanServerProxy != null) {
            try {
                // Reads the initial value of the time out.
                timeOut = scanServerProxy.get_timeout_millis();
                try {
                    // Time out
                    scanServerProxy.set_timeout_millis(5000);

                    // Clean
                    command("Clean");

                    // ? Scan sequencing.
                    // setAttribute("scanSequencing", (short) 1));

                    // Partial mode for recording, must be manage by an external client
                    // setAttribute("dataRecorderPartialMode", false);

                    // Run name.
                    String runName = config.getName();
                    IDirectory directory = config.getDirectory();
                    while (directory != null) {
                        runName = directory.getName() + "." + runName;
                        directory = directory.getDirectory();
                    }
                    setAttribute("runName", runName);

                    // Scan number.
                    setAttribute("scanNumber", config.getScanNumber());

                    // Timebases
                    List<ITimebase> timebasesList = config.getTimebaseList();
                    List<String> timebasesNameList = new ArrayList<String>(timebasesList.size());
                    for (ITimebase timebase : timebasesList) {
                        if (timebase.isEnabled()) {
                            timebasesNameList.add(timebase.getName());
                        }
                    }
                    String[] timebasesNameArray = timebasesNameList
                            .toArray(new String[timebasesNameList.size()]);
                    setAttribute("timebases", timebasesNameArray);

                    // Sensors
                    List<ISensor> sensorsList = config.getSensorsList();
                    List<String> sensorsNameList = new ArrayList<String>(sensorsList.size());
                    for (ISensor sensor : sensorsList) {
                        if (sensor.isEnabled()) {
                            sensorsNameList.add(sensor.getName());
                        }
                    }
                    String[] sensorsNameArray = sensorsNameList.toArray(new String[sensorsNameList
                            .size()]);

                    setAttribute("sensors", sensorsNameArray);

                    // Actuators X
                    List<IActuator> actuatorsXList;
                    List<String> actuatorsNamesXList;
                    String[] actuatorsNamesXArray;
                    IDimension2DX dimensionX = config.getDimensionX();
                    actuatorsXList = dimensionX.getActuatorsList();
                    actuatorsNamesXList = new ArrayList<String>(actuatorsXList.size());
                    for (IActuator actuator : actuatorsXList) {
                        if (actuator.isEnabled()) {
                            actuatorsNamesXList.add(actuator.getName());
                        }
                    }
                    actuatorsNamesXArray = actuatorsNamesXList
                            .toArray(new String[actuatorsNamesXList.size()]);
                    setAttribute("actuators", actuatorsNamesXArray);

                    // Actuators y
                    List<IActuator> actuatorsYList;
                    List<String> actuatorsNamesYList;
                    String[] actuatorsNamesYArray;
                    IDimension2DY dimensionY = config.getDimensionY();
                    actuatorsYList = dimensionY.getActuatorsList();
                    actuatorsNamesYList = new ArrayList<String>(actuatorsYList.size());
                    for (IActuator actuator : actuatorsYList) {
                        if (actuator.isEnabled()) {
                            actuatorsNamesYList.add(actuator.getName());
                        }
                    }
                    actuatorsNamesYArray = actuatorsNamesYList
                            .toArray(new String[actuatorsNamesYList.size()]);
                    setAttribute("actuators2", actuatorsNamesYArray);

                    // Dimensions X
                    // Tango exchanges trajectories as double arrays that contains the positions, in
                    // order,
                    // actuator after actuator, range after range, of the trajectories of all the
                    // actuators.
                    // There is one such array per dimension.
                    double[] allActuatorsPositionsXArray;
                    double initialValueX;

                    // Contains the positions in order, range after range, of the trajectories of an
                    // actuator.
                    List<Double> actuatorPositionsXList;
                    // Contains the positions in order, actuator after actuator, range after range,
                    // of
                    // the trajectories of all the actuators.
                    List<Double> allActuatorsPositionsXList;
                    // The list of integrations times.
                    List<Double> integrationsTimesXList;
                    double[] integrationsTimesXArray;
                    int integrationTimeIndexX;
                    // The list of speeds.
                    List<Double> speedXList = new ArrayList<Double>();
                    double[] speedXArray;
                    // The number of points, which is the total steps numbers + 1 per range.
                    int totalStepsNumberX;
                    // The actuators used for this dimension
                    List<IActuator> dimensionActuatorsXList;
                    // Tango API
                    dimensionActuatorsXList = dimensionX.getActuatorsList();
                    // The positions, sorted as Tango expect them.
                    allActuatorsPositionsXList = new ArrayList<Double>();
                    // The number of enabled actuators.
                    int enabledActuatorsXNumber = 0;
                    // The positions must be sorted by actuator, so we loop over the actuators.
                    for (IActuator actuator : dimensionActuatorsXList) {
                        if (actuator.isEnabled()) {
                            initialValueX = ActuatorConnector.getData(actuator);
                            actuatorPositionsXList = new ArrayList<Double>();
                            // For each actuators, the positions must be sorted by range.
                            for (ITrajectory2DX trajectory : findActuatorTrajectories(dimensionX,
                                    actuator)) {
                                actuatorPositionsXList.addAll(TrajectoryCalculator
                                        .calculateLinearTrajectoriesPosition(trajectory,
                                                initialValueX));
                                // The speeds must be sorted in the same order, so we read them
                                // here.
                                speedXList.add(trajectory.getSpeed());
                            }
                            allActuatorsPositionsXList.addAll(actuatorPositionsXList);
                            ++enabledActuatorsXNumber;
                        }
                    }

                    // Integration Time and steps number.
                    integrationsTimesXList = new ArrayList<Double>(dimensionX.getRangesList()
                            .size());
                    int stepsNumberX;
                    totalStepsNumberX = 0;
                    for (IRange2DX range : dimensionX.getRangesList()) {
                        stepsNumberX = range.getStepsNumber();
                        for (integrationTimeIndexX = 0; integrationTimeIndexX < stepsNumberX + 1; ++integrationTimeIndexX) {
                            integrationsTimesXList.add(range.getIntegrationTime());
                        }
                        totalStepsNumberX += stepsNumberX + 1;
                    }
                    integrationsTimesXArray = toDoubleArray(integrationsTimesXList);
                    setAttribute("integrationTimes", integrationsTimesXArray);
                    setAttribute("pointNumber", totalStepsNumberX);

                    // Trajectories
                    // Builds the array from the list.
                    allActuatorsPositionsXArray = toDoubleArray(allActuatorsPositionsXList);
                    // Sends the array to Tango.
                    DeviceAttribute trajectoriesXAttribute = new DeviceAttribute("trajectories");
                    if (enabledActuatorsXNumber != 0) {
                        trajectoriesXAttribute.insert(allActuatorsPositionsXArray,
                                totalStepsNumberX, enabledActuatorsXNumber);
                    }
                    else {
                        trajectoriesXAttribute.insert(new double[] {}, 0, 1);
                    }
                    scanServerProxy.write_attribute(trajectoriesXAttribute);

                    // Speed.
                    speedXArray = toDoubleArray(speedXList);
                    setAttribute("scanSpeed", speedXArray);

                    // Dimensions Y
                    // Tango exchanges trajectories as double arrays that contains the positions, in
                    // order,
                    // actuator after actuator, range after range, of the trajectories of all the
                    // actuators.
                    // There is one such array per dimension.
                    double[] allActuatorsPositionsYArray;
                    double initialValueY;

                    // Contains the positions in order, range after range, of the trajectories of an
                    // actuator.
                    List<Double> actuatorPositionsYList;
                    // Contains the positions in order, actuator after actuator, range after range,
                    // of
                    // the trajectories of all the actuators.
                    List<Double> allActuatorsPositionsYList;
                    // The number of points, which is the total steps numbers + 1 per range.
                    int totalStepsNumberY;
                    // The actuators used for this dimension
                    List<IActuator> dimensionActuatorsYList;
                    // Dimension
                    dimensionActuatorsYList = dimensionY.getActuatorsList();
                    // The positions, sorted as Tango expect them.
                    allActuatorsPositionsYList = new ArrayList<Double>();
                    // The number of enabled actuators.
                    int enabledActuatorsYNumber = 0;
                    // The positions must be sorted by actuator, so we loop over the actuators.
                    for (IActuator actuator : dimensionActuatorsYList) {
                        if (actuator.isEnabled()) {
                            initialValueY = ActuatorConnector.getData(actuator);
                            actuatorPositionsYList = new ArrayList<Double>();
                            // For each actuators, the positions must be sorted by range.
                            for (ITrajectory2DY trajectory : findActuatorTrajectories(dimensionY,
                                    actuator)) {
                                actuatorPositionsYList.addAll(TrajectoryCalculator
                                        .calculateLinearTrajectoriesPosition(trajectory,
                                                initialValueY));
                            }
                            allActuatorsPositionsYList.addAll(actuatorPositionsYList);
                            ++enabledActuatorsYNumber;
                        }
                    }

                    // The number of points
                    totalStepsNumberY = 0;
                    for (IRange2DY range : dimensionY.getRangesList()) {
                        totalStepsNumberY += range.getStepsNumber() + 1;
                    }
                    setAttribute("pointNumber2", totalStepsNumberY);

                    // Builds the array from the list.
                    allActuatorsPositionsYArray = toDoubleArray(allActuatorsPositionsYList);
                    DeviceAttribute trajectoriesYAttribute = new DeviceAttribute("trajectories2");
                    if (enabledActuatorsYNumber > 0) {
                        // Sends the array to Tango.
                        trajectoriesYAttribute.insert(allActuatorsPositionsYArray,
                                totalStepsNumberY, enabledActuatorsYNumber);
                    }
                    else {
                        trajectoriesYAttribute.insert(new double[] {}, 0, 1);
                    }
                    scanServerProxy.write_attribute(trajectoriesYAttribute);

                    // Actuator delay.
                    double actuatorsDelay = config.getActuatorsDelay();
                    setAttribute("actuatorsDelay", actuatorsDelay);

                    // Zig zag.
                    boolean zigzag = config.isZigzag();
                    setAttribute("zigzag", zigzag);

                    // Enable actuator speed.
                    boolean enableScanSpeed = config.isEnableScanSpeed();
                    setAttribute("enableScanSpeed", enableScanSpeed);

                    // Post scan behaviour.
                    IPostScanBehaviour postScanBehaviour = config.getScanAddOn()
                            .getPostScanBehaviour();
                    Behaviour behaviour = postScanBehaviour.getBehaviour();
                    if (behaviour == null) {
                        behaviour = Behaviour.NOOP;
                    }
                    int behaviourType = behaviour.getType();
                    setAttribute("afterRunActionType", behaviourType);
                    if (behaviour.getArgumentCount() >= 1) {
                        int behaviourSensorIndex = postScanBehaviour.getSensor();
                        setAttribute("afterRunActionSensor", behaviourSensorIndex);
                    }
                    else if (behaviour.getArgumentCount() >= 2) {
                        int behaviourActuatorIndex = postScanBehaviour.getActuator();
                        setAttribute("afterRunActionActuator", behaviourActuatorIndex);
                    }

                    // Error strategies.
                    if (config.getScanAddOn() != null
                            && config.getScanAddOn().getErrorStrategy() != null) {

                        IErrorStrategy errorStrat = config.getScanAddOn().getErrorStrategy();
                        IErrorStrategyItem[] categoriesESI = new IErrorStrategyItem[] {
                                errorStrat.getActuatorsErrorStrategy(),
                                errorStrat.getSensorsErrorStrategy(),
                                errorStrat.getTimebasesErrorStrategy(),
                                errorStrat.getHooksErrorStrategy() };
                        String[] categoriesStr = new String[] { "actuators", "sensors",
                                "timebases", "hooks" };

                        for (int i = 0; i < categoriesStr.length; i++) {
                            String cat = categoriesStr[i];
                            IErrorStrategyItem esi = categoriesESI[i];

                            double errorStrategyTimeOut = esi.getTimeOut();
                            int errorStrategyRetryCount = esi.getRetryCount();
                            double errorStrategyRetryTimeOut = esi.getTimeBetweenRetries();
                            int errorStrategyType = esi.getStrategy().ordinal();

                            // Time out.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat + "TimeOut",
                                    errorStrategyTimeOut));
                            // Retry count.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat + "RetryCount",
                                    errorStrategyRetryCount));
                            // Retry time out.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat
                                    + "RetryTimeOut", errorStrategyRetryTimeOut));
                            // Error strategy.
                            scanServerProxy.write_attribute(new DeviceAttribute(cat
                                    + "ErrorStrategy", errorStrategyType));
                        }
                        // Context validation error strategy.
                        scanServerProxy.write_attribute(new DeviceAttribute(
                                "contextValidationErrorStrategy", errorStrat
                                        .getContextValidationStrategy().ordinal()));

                        scanServerProxy.write_attribute(new DeviceAttribute("contextValidation",
                                errorStrat.getContextValidationDevice()));
                    }

                    /* Hooks */
                    SetHooks(config.getScanAddOn(), scanServerProxy);

                    // Hardware continuous scan : no.
                    setAttribute("hwContinuous", false);

                    // On the fly mode (software continuous mode).
                    boolean onTheFly = config.isOnTheFly();
                    setAttribute("onTheFly", onTheFly);

                    // Fin configuration du scan.

                    // D�marrage du scan.
                    command("Start");
                }
                finally {
                    // Sets the time out back to the initial value.
                    scanServerProxy.set_timeout_millis(timeOut);
                }
            }
            catch (DevFailed e) {
                e.printStackTrace();
                String message = e.getMessage();
View Full Code Here

     */
    public IScanStatus getScanStatus(String scanServerName) throws SalsaDeviceException {
        try {

            ScanStatusImpl result = new ScanStatusImpl();
            DeviceProxy scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
            // System.out.println("scanServerProxy=" + scanServerProxy);
            if (scanServerProxy == null) {
                // scanServerManager.invalidateScanServerProxy(scanServerName);
                /*Exception e = new Exception("Error : cannot read scan status informations on "
                        + scanServerName);
View Full Code Here

     * @param context context of the scan
     * @throws SalsaDeviceException
     */
    public void stopScan(IContext context) throws SalsaDeviceException {
        initConnexion(context);
        DeviceProxy scanServerProxy;
        String scanServerName = context.getScanServerName();
        try {
            scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
            if (scanServerProxy != null) {
                scanServerProxy.command_inout("Abort");
            }
        }
        catch (DevFailed e) {
            scanServerManager.invalidateScanServerProxy(scanServerName);
            throw new SalsaDeviceException("Error : cannot stop the scan : " + e.getMessage(), e);
View Full Code Here

     * @param context context of the scan
     * @throws SalsaDeviceException
     */
    public void pauseScan(IContext context) throws SalsaDeviceException {
        initConnexion(context);
        DeviceProxy scanServerProxy;
        String scanServerName = context.getScanServerName();

        try {
            scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
            scanServerProxy.command_inout("Pause");
        }
        catch (DevFailed e) {
            scanServerManager.invalidateScanServerProxy(scanServerName);
            throw new SalsaDeviceException("Error : cannot pause the scan : " + e.getMessage(), e);
        }
View Full Code Here

     */
    public IScanStatus getScanStatus(String scanServerName) throws SalsaDeviceException {
        try {

            ScanStatusImpl result = new ScanStatusImpl();
            DeviceProxy scanServerProxy = scanServerManager.getScanServerProxy(scanServerName);
            // System.out.println("scanServerProxy=" + scanServerProxy);
            if (scanServerProxy == null) {
                // scanServerManager.invalidateScanServerProxy(scanServerName);
                /*Exception e = new Exception("Error : cannot read scan status informations on "
                        + scanServerName);
View Full Code Here

TOP

Related Classes of fr.esrf.TangoApi.DeviceProxy

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.