Package fr.esrf.TangoApi

Examples of fr.esrf.TangoApi.DeviceProxy


     * @param scanServerName
     * @return
     * @throws SalsaDeviceException
     */
    public ScanState getScanState(String scanServerName) throws SalsaDeviceException {
        DeviceProxy scanServerProxy;
        ScanState state;
        scanServerProxy = getScanServerProxy(scanServerName);
        try {
            DeviceAttribute stateAttribute = scanServerProxy.read_attribute("State");
            String stateString = AttributeHelper.extractToString(stateAttribute);
            if ("ON".equals(stateString)) {
                state = ScanState.STOPPED;
            }
            else if ("MOVING".equals(stateString)) {
View Full Code Here


     *
     * @param scanServerName
     * @return
     */
    public List<HistoricRecord> getHistoric(String scanServerName) throws SalsaDeviceException {
        DeviceProxy scanServerProxy;
        DeviceAttribute historicAttribute;
        String historicStringArray[];
        try {
            scanServerProxy = getScanServerProxy(scanServerName);
            historicAttribute = scanServerProxy.read_attribute("historic");
            historicStringArray = AttributeHelper.extractToStringArray(historicAttribute);
        }
        catch (DevFailed e) {
            invalidateScanServerProxy(scanServerName);
            e.printStackTrace();
View Full Code Here

     * @param scanServerName
     * @throws SalsaDeviceException
     */
    public void clearHistoric(String scanServerName) throws SalsaDeviceException {
        try {
            DeviceProxy scanServerProxy = getScanServerProxy(scanServerName);
            scanServerProxy.command_inout("ClearHistoric");
        }
        catch (DevFailed e) {
            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 = 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) {
            invalidateScanServerProxy(scanServerName);
            e.printStackTrace();
View Full Code Here

     * @return
     * @throws SalsaDeviceException
     */
    private synchronized DeviceProxy getScanServerProxy(String scanServerName)
            throws SalsaDeviceException {
        DeviceProxy scanServerProxy;
        if (scanServerName == null) {
            throw new SalsaDeviceException("Cannot connect to the scan server : name is null.");
        }
        else if (scanServerName.equals(serverNameCache)) {
            scanServerProxy = serverProxyCache;
        }
        else if (serverProxyCacheMap.containsKey(scanServerName)) {
            scanServerProxy = serverProxyCacheMap.get(scanServerName);
            serverProxyCache = scanServerProxy;
            serverNameCache = scanServerName;
        }
        else {
            try {
                scanServerProxy = new DeviceProxy(scanServerName);
                serverProxyCacheMap.put(scanServerName, scanServerProxy);
                serverProxyCache = scanServerProxy;
                serverNameCache = scanServerName;
            }
            catch (DevFailed e) {
View Full Code Here

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

            IScanStatus result = new ScanStatusImpl();
            DeviceProxy scanServerProxy = getScanServerProxy(scanServerName);
            DevState state = scanServerProxy.read_attribute("State").extractState();
            result.setState("" + state.value());

            result.setStatus(scanServerProxy.read_attribute("Status").extractString());
            result.setRunStartDate(scanServerProxy.read_attribute("runStartDate").extractString());
            result
                    .setScanStartDate(scanServerProxy.read_attribute("scanStartDate")
                            .extractString());
            result.setScanEndDate(scanServerProxy.read_attribute("scanEndDate").extractString());
            result.setRunEndDate(scanServerProxy.read_attribute("runEndDate").extractString());
            result.setScanDuration(scanServerProxy.read_attribute("scanDuration").extractString());
            result.setRunDuration(scanServerProxy.read_attribute("runDuration").extractString());
            result.setScanRemainingTime(scanServerProxy.read_attribute("scanRemainingTime")
                    .extractString());
            result.setRunRemainingTime(scanServerProxy.read_attribute("runRemainingTime")
                    .extractString());
            result.setScanElapsed(scanServerProxy.read_attribute("scanElapsed").extractString());
            result.setRunElapsed(scanServerProxy.read_attribute("runElapsed").extractString());
            result
                    .setRunCompletion(scanServerProxy.read_attribute("runCompletion")
                            .extractDouble());
            result.setScanCompletion(scanServerProxy.read_attribute("scanCompletion")
                    .extractDouble());
            result.setDeadTime(scanServerProxy.read_attribute("deadTime").extractDouble());
            result.setDeadTimePercentage(scanServerProxy.read_attribute("deadTimePercent")
                    .extractDouble());
            result.setDeadTimePerPoint(scanServerProxy.read_attribute("deadTimePerPoint")
                    .extractDouble());
            return result;
        }
        catch (DevFailed e) {
            invalidateScanServerProxy(scanServerName);
View Full Code Here

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

                    if ((dataRecorderDeviceName != null) && !dataRecorderDeviceName.isEmpty()) {
                        DeviceProxy dataRecorderProxy = TangoDeviceHelper.getDeviceProxy(dataRecorderDeviceName);
                        if (TangoCommandHelper.isCommandExist(dataRecorderDeviceName, "GetConfigList")) {
                            DeviceData deviceData = dataRecorderProxy.command_inout("GetConfigList");
                            if (deviceData != null) {
                                configList = deviceData.extractStringArray();
                            }
                        }
                    }
View Full Code Here

     * @return
     * @throws SalsaDeviceException
     */
    public IConfig.ScanType getScanType(String scanServerName) throws SalsaDeviceException {
        try {
            DeviceProxy scanServerProxy = getScanServerProxy(scanServerName);
            short scanType = AttributeHelper.extractToShort(scanServerProxy
                    .read_attribute("scanType"));
            switch (scanType) {
                case 0:
                    return IConfig.ScanType.SCAN_1D;
                case 1:
View Full Code Here

     * @throws SalsaDeviceException
     */
    public IScanResult readScanResult(String scanServerName) throws SalsaDeviceException {
        IScanResult scanResult;
        if (isScanResultReady(scanServerName)) {
            DeviceProxy scanServerProxy = getScanServerProxy(scanServerName);
            // Type
            IConfig.ScanType scanType = getScanType(scanServerName);
            switch (scanType) {
                case SCAN_1D:
                    try {
View Full Code Here

     *
     * @param context context of the scan
     * @throws SalsaDeviceException
     */
    public void stopScan(IContext context) throws SalsaDeviceException {
        DeviceProxy scanServerProxy;
        String scanServerName = context.getScanServerName();
        try {
            scanServerProxy = getScanServerProxy(scanServerName);
            scanServerProxy.command_inout("Abort");
        }
        catch (DevFailed e) {
            invalidateScanServerProxy(scanServerName);
            e.printStackTrace();
            throw new SalsaDeviceException("Error : cannot stop the scan : " + e.getMessage(), e);
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.