Package fr.esrf.TangoApi

Examples of fr.esrf.TangoApi.DeviceProxy


     *
     * @param context context of the scan
     * @throws SalsaDeviceException
     */
    public void stopScan(IContext context) throws SalsaDeviceException {
        DeviceProxy scanServerProxy;
        String scanServerName = context.getScanServerName();
        try {
            scanServerProxy = scanServerManager.getScanServerProxy(scanServerName);
            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 resumeScan(IContext context) throws SalsaDeviceException {
        initConnexion(context);
        DeviceProxy scanServerProxy;
        String scanServerName = context.getScanServerName();
        try {
            scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
            scanServerProxy.command_inout("Resume");
        }
        catch (DevFailed e) {
            scanServerManager.invalidateScanServerProxy(scanServerName);
            throw new SalsaDeviceException("Error : cannot resume the scan : " + e.getMessage(), e);
        }
View Full Code Here

     *
     * @param context context of the scan
     * @throws SalsaDeviceException
     */
    public void pauseScan(IContext context) throws SalsaDeviceException {
        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 ScanState getScanState(String scanServerName) throws SalsaDeviceException {
        ScanState state = ScanState.STOPPED;

        try {
            DeviceProxy scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
            if (scanServerProxy != null) {
                DevState devstate = scanServerProxy.state();
                if (devstate.value() == DevState.ON.value()) {
                    state = ScanState.STOPPED;
                }
                else if (devstate.value() == DevState.MOVING.value()
                        || devstate.value() == DevState.RUNNING.value()) {
View Full Code Here

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

     * @param scanServerName
     * @throws SalsaDeviceException
     */
    public void clearHistoric(String scanServerName) throws SalsaDeviceException {
        try {
            DeviceProxy scanServerProxy = scanServerManager.getScanServerProxy(scanServerName);
            scanServerProxy.command_inout("ClearHistoric");
        }
        catch (DevFailed e) {
            scanServerManager.invalidateScanServerProxy(scanServerName);
            e.printStackTrace();
            throw new SalsaDeviceException("Error : cannot read the historic : " + e.getMessage(),
View Full Code Here

     * @param scanServerName
     * @throws SalsaDeviceException
     */
    public void clearHistoric(String scanServerName) throws SalsaDeviceException {
        try {
            DeviceProxy scanServerProxy = ScanServerManager.getScanServerProxy(scanServerName);
            scanServerProxy.command_inout("ClearHistoric");
        }
        catch (DevFailed e) {
            scanServerManager.invalidateScanServerProxy(scanServerName);
            e.printStackTrace();
            throw new SalsaDeviceException("Error : cannot read the historic : " + e.getMessage(),
View Full Code Here

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

            DeviceAttribute afterRunActionType = new DeviceAttribute("afterRunActionType");
            afterRunActionType.insert(behaviour.getType());
            scanServerProxy.write_attribute(afterRunActionType);

            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) {
                        DeviceAttribute afterRunActionSensor = new DeviceAttribute(
                                "afterRunActionSensor");
                        afterRunActionSensor.insert(sensorPosition);
                        scanServerProxy.write_attribute(afterRunActionSensor);
                    }
                    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) {
                        DeviceAttribute afterRunActionActuator = new DeviceAttribute(
                                "afterRunActionActuator");
                        afterRunActionActuator.insert(actuatorPosition);
                        scanServerProxy.write_attribute(afterRunActionActuator);
                    }
                    else {
                        throw new SalsaDeviceException("Error : actuator " + actuator.getName()
                                + " is unknow on the scan server " + scanServerName + ".");
                    }
                }
            }

            scanServerProxy.command_inout("ExecuteAction");

        }
        catch (DevFailed e) {
            scanServerManager.invalidateScanServerProxy(scanServerName);
            e.printStackTrace();
View Full Code Here

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

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

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

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

            // TODO remove syso
            // System.out.println("ExecuteAction()=" + behaviour.getType());
            scanServerProxy.command_inout("ExecuteAction");

        }
        catch (DevFailed e) {
            scanServerManager.invalidateScanServerProxy(scanServerName);
            e.printStackTrace();
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");

                    // ? Scan sequencing.
                    // scanServerProxy.write_attribute(new DeviceAttribute("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
                    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

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.