826220679@qq.com
7 小时以前 69b40096cb0ae965f2a3e92672b880edfe7d04d2
src/set/Setsys.java
@@ -14,6 +14,8 @@
    private String appVersion;
    private int idleTrailDurationSeconds = DEFAULT_IDLE_TRAIL_DURATION_SECONDS;
    private boolean boundaryLengthVisible = false;  // 默认关闭显示边界距离
    private boolean measurementModeEnabled = false;  // 默认关闭测量模式
    private boolean manualBoundaryDrawingMode = false;  // 默认关闭手动绘制边界模式
    
    private static final String PROPERTIES_FILE = "set.properties";
@@ -95,6 +97,22 @@
    public void setBoundaryLengthVisible(boolean visible) {
        this.boundaryLengthVisible = visible;
    }
    public boolean isMeasurementModeEnabled() {
        return measurementModeEnabled;
    }
    public void setMeasurementModeEnabled(boolean enabled) {
        this.measurementModeEnabled = enabled;
    }
    public boolean isManualBoundaryDrawingMode() {
        return manualBoundaryDrawingMode;
    }
    public void setManualBoundaryDrawingMode(boolean enabled) {
        this.manualBoundaryDrawingMode = enabled;
    }
    /**
     * 初始化方法 - 从properties文件读取数据
@@ -115,6 +133,10 @@
            this.idleTrailDurationSeconds = sanitizeIdleTrailDuration(props.getProperty("idleTrailDurationSeconds"));
            String boundaryLengthVisibleStr = props.getProperty("boundaryLengthVisible");
            this.boundaryLengthVisible = "true".equalsIgnoreCase(boundaryLengthVisibleStr);
            String measurementModeEnabledStr = props.getProperty("measurementModeEnabled");
            this.measurementModeEnabled = "true".equalsIgnoreCase(measurementModeEnabledStr);
            String manualBoundaryDrawingModeStr = props.getProperty("manualBoundaryDrawingMode");
            this.manualBoundaryDrawingMode = "true".equalsIgnoreCase(manualBoundaryDrawingModeStr);
                        
        } catch (FileNotFoundException e) {           
            // 文件不存在时,设置所有属性为null
@@ -159,6 +181,12 @@
            case "boundaryLengthVisible":
                this.boundaryLengthVisible = "true".equalsIgnoreCase(value);
                break;
            case "measurementModeEnabled":
                this.measurementModeEnabled = "true".equalsIgnoreCase(value);
                break;
            case "manualBoundaryDrawingMode":
                this.manualBoundaryDrawingMode = "true".equalsIgnoreCase(value);
                break;
            case "mapScale":
                // mapScale不需要在内存中存储,直接更新到文件
                break;
@@ -228,20 +256,23 @@
        this.appVersion = null;
        this.idleTrailDurationSeconds = DEFAULT_IDLE_TRAIL_DURATION_SECONDS;
        this.boundaryLengthVisible = false;  // 默认关闭
        this.measurementModeEnabled = false;  // 默认关闭测量模式
        this.manualBoundaryDrawingMode = false;  // 默认关闭手动绘制边界模式
    }
    /**
     * 显示当前所有属性值
     */
    public void displayProperties() {
        System.out.println("当前属性值:");
        System.out.println("mowerId: " + (mowerId != null ? mowerId : "未设置"));
        System.out.println("cuttingWidth: " + (cuttingWidth != null ? cuttingWidth : "未设置"));
        System.out.println("simCardNumber: " + (simCardNumber != null ? simCardNumber : "未设置"));
    System.out.println("handheldMarkerId: " + (handheldMarkerId != null ? handheldMarkerId : "未设置"));
        System.out.println("firmwareVersion: " + (firmwareVersion != null ? firmwareVersion : "未设置"));
        System.out.println("appVersion: " + (appVersion != null ? appVersion : "未设置"));
        System.out.println("idleTrailDurationSeconds: " + idleTrailDurationSeconds);
        // 显示属性功能已禁用
    }
    /**
     * 获取割草机编号
     * @return 割草机编号
     */
    public static String getMowerIdValue() {
        return getPropertyValue("mowerId");
    }
    // 根据set.properties中的键名获取对应的值,没有或为-1时返回null