Examples of DevicePreferences


Examples of fr.soleil.salsa.preferences.DevicePreferences

            initPreferences();
        }
    }

    public void initPreferences() {
        DevicePreferences devicePreferences = SalsaAPI.getDevicePreferences();

        try {
            uiPreferences = UIPreferencesPersistence.loadSystemPreferences();
            if (uiPreferences != null && devicePreferences != null) {
                String scanServerName = devicePreferences.getScanServer();
                setScanServerName(scanServerName);
                dataFitterName = devicePreferences.getDataFitter();

                if (TangoAttributeHelper.isAttributeRunning(scanServerName, "data_01")) {

                    Map<String, PlotProperties> propertiesMap = uiPreferences
                            .getPlotPropertiesMap();
                    // Parse plot properties to set the axis
                    Set<String> plotKeySet = propertiesMap.keySet();
                    PlotProperties plotProp = null;
                    Vector<String> y2SensorDataVector = new Vector<String>();
                    Vector<String> y1SensorDataVector = new Vector<String>();
                    Vector<String> y2DataVector = new Vector<String>();
                    Vector<String> y1DataVector = new Vector<String>();
                    Vector<String> zDataVector = new Vector<String>();
                    Vector<String> noneDataVector = new Vector<String>();
                    String simpleActuatorName = null;
                    String y1dataFitterAttribute = null;
                    String y2dataFitterAttribute = null;
                    String attributeName = null;
                    String deviceName = null;
                    for (String dataViewId : plotKeySet) {
                        if (dataViewId.indexOf("/") > -1) {
                            attributeName = TangoDeviceHelper.getEntityName(dataViewId);
                            deviceName = TangoDeviceHelper.getDeviceName(dataViewId);
                        }
                        else {
                            attributeName = dataViewId;
                            deviceName = scanServerName;
                        }

                        plotProp = propertiesMap.get(dataViewId);
                        int axis = plotProp.getAxisChoice();
                        switch (axis) {
                            case IChartViewer.Y1:
                                CurrentScanDataModel.addAttributeAxisMap(attributeName, Axis.Y1);
                                break;
                            case IChartViewer.Y2:
                                CurrentScanDataModel.addAttributeAxisMap(attributeName, Axis.Y1);
                                break;
                            case IChartViewer.X:
                                CurrentScanDataModel.addAttributeAxisMap(attributeName, Axis.X);
                                break;
                            case 3:
                                CurrentScanDataModel.addAttributeAxisMap(attributeName, Axis.Z);
                                break;
                            case -1:
                                CurrentScanDataModel.addAttributeAxisMap(attributeName, Axis.NONE);
                                break;
                            default:
                                break;
                        }

                        if (TangoAttributeHelper.isAttributeRunning(deviceName, attributeName)) {
                            // System.out.println(dataViewId + " getAxis =>" + axis);
                            if (dataFitterName != null && !dataFitterName.isEmpty()
                                    && dataViewId.startsWith(dataFitterName)) {
                                switch (axis) {
                                    case IChartViewer.Y1:
                                        y1dataFitterAttribute = dataViewId;
                                        break;
                                    case IChartViewer.Y2:
                                        y2dataFitterAttribute = dataViewId;
                                        break;
                                    default:
                                        break;
                                }
                            }
                            else {
                                switch (axis) {
                                    case IChartViewer.X:
                                        simpleActuatorName = dataViewId;
                                        break;
                                    case IChartViewer.Y1:
                                        if (dataViewId.indexOf("/") > -1) {
                                            y1DataVector.add(dataViewId);
                                        }
                                        else {
                                            y1SensorDataVector.add(dataViewId);
                                        }
                                        break;
                                    case IChartViewer.Y2:
                                        if (dataViewId.indexOf("/") > -1) {
                                            y2DataVector.add(dataViewId);
                                        }
                                        else {
                                            y2SensorDataVector.add(dataViewId);
                                        }
                                        break;

                                    case 3:
                                        zDataVector.add(dataViewId);
                                        break;
                                    default:
                                        noneDataVector.add(dataViewId);
                                        break;
                                }
                            }
                        }
                    }

                    if (simpleActuatorName != null && !simpleActuatorName.isEmpty()) {
                        userEvent = true;
                        // CurrentScanDataModel.setActuatorName(scanServerName, simpleActuatorName);
                        setActuatorName(simpleActuatorName);
                        CurrentScanDataModel.addAttributeAxisMap(simpleActuatorName, Axis.X);
                    }

                    if (y1dataFitterAttribute != null && !y1dataFitterAttribute.isEmpty()) {
                        firefittedY1DataChanged(y1dataFitterAttribute);
                    }

                    if (y2dataFitterAttribute != null && !y2dataFitterAttribute.isEmpty()) {
                        firefittedY1DataChanged(y2dataFitterAttribute);
                    }

                    if (!y2DataVector.isEmpty()) {
                        userEvent = true;
                        setY2DataList(y2DataVector.toArray(new String[y2DataVector.size()]));
                    }
                    if (!y2SensorDataVector.isEmpty()) {
                        userEvent = true;
                        setY2SensorsDataList(y2SensorDataVector
                                .toArray(new String[y2SensorDataVector.size()]));
                    }
                    if (!y1DataVector.isEmpty()) {
                        userEvent = true;
                        setY1DataList(y1DataVector.toArray(new String[y1DataVector.size()]));
                    }
                    if (!y1SensorDataVector.isEmpty()) {
                        userEvent = true;
                        setY1SensorsDataList(y1SensorDataVector
                                .toArray(new String[y1SensorDataVector.size()]));
                    }
                    if (!zDataVector.isEmpty()) {
                        setZSensorsDataList(zDataVector.toArray(new String[zDataVector.size()]));
                    }
                    if (!noneDataVector.isEmpty()) {
                        setNoneSensorsDataList(noneDataVector.toArray(new String[noneDataVector
                                .size()]));
                    }

                }
            }
        }
        catch (SalsaPreferencesException e) {
            e.printStackTrace();

        }

        if (devicePreferences != null) {
            // System.out.println("setScanServerDeviceName " + devicePreferences.getScanServer());
            String scanServerName = devicePreferences.getScanServer();
            if (scanServerName != null) {
                scanServerName = scanServerName.toLowerCase();
                setScanServerDeviceName(scanServerName);
                start();
                // if (autostart) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.