From 5d6d890cfd10466d5d14ff5177adcc888baaa0e4 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期三, 17 十二月 2025 17:46:13 +0800
Subject: [PATCH] 新增了边界距离显示优化了设置页面布局
---
src/set/Setsys.java | 91 ++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 80 insertions(+), 11 deletions(-)
diff --git a/src/set/Setsys.java b/src/set/Setsys.java
index ff202d4..153ef58 100644
--- a/src/set/Setsys.java
+++ b/src/set/Setsys.java
@@ -4,11 +4,16 @@
import java.util.Properties;
public class Setsys {
+ public static final int DEFAULT_IDLE_TRAIL_DURATION_SECONDS = 60;
+
private String mowerId;
private String cuttingWidth;
private String simCardNumber;
+ private String handheldMarkerId;
private String firmwareVersion;
private String appVersion;
+ private int idleTrailDurationSeconds = DEFAULT_IDLE_TRAIL_DURATION_SECONDS;
+ private boolean boundaryLengthVisible = false; // 榛樿鍏抽棴鏄剧ず杈圭晫璺濈
private static final String PROPERTIES_FILE = "set.properties";
@@ -17,10 +22,11 @@
}
// 甯﹀弬鏋勯�犳柟娉�
- public Setsys(String mowerId, String cuttingWidth, String simCardNumber, String firmwareVersion, String appVersion) {
+ public Setsys(String mowerId, String cuttingWidth, String simCardNumber, String handheldMarkerId, String firmwareVersion, String appVersion) {
this.mowerId = mowerId;
this.cuttingWidth = cuttingWidth;
this.simCardNumber = simCardNumber;
+ this.handheldMarkerId = handheldMarkerId;
this.firmwareVersion = firmwareVersion;
this.appVersion = appVersion;
}
@@ -50,6 +56,14 @@
this.simCardNumber = simCardNumber;
}
+ public String getHandheldMarkerId() {
+ return handheldMarkerId;
+ }
+
+ public void setHandheldMarkerId(String handheldMarkerId) {
+ this.handheldMarkerId = handheldMarkerId;
+ }
+
public String getFirmwareVersion() {
return firmwareVersion;
}
@@ -66,6 +80,22 @@
this.appVersion = appVersion;
}
+ public int getIdleTrailDurationSeconds() {
+ return idleTrailDurationSeconds;
+ }
+
+ public void setIdleTrailDurationSeconds(int seconds) {
+ this.idleTrailDurationSeconds = sanitizeIdleTrailDuration(String.valueOf(seconds));
+ }
+
+ public boolean isBoundaryLengthVisible() {
+ return boundaryLengthVisible;
+ }
+
+ public void setBoundaryLengthVisible(boolean visible) {
+ this.boundaryLengthVisible = visible;
+ }
+
/**
* 鍒濆鍖栨柟娉� - 浠巔roperties鏂囦欢璇诲彇鏁版嵁
* 濡傛灉灞炴�у�间负-1锛岃〃绀烘病鏈夊�硷紝璁剧疆涓簄ull
@@ -79,17 +109,17 @@
this.mowerId = "-1".equals(props.getProperty("mowerId")) ? null : props.getProperty("mowerId");
this.cuttingWidth = "-1".equals(props.getProperty("cuttingWidth")) ? null : props.getProperty("cuttingWidth");
this.simCardNumber = "-1".equals(props.getProperty("simCardNumber")) ? null : props.getProperty("simCardNumber");
+ this.handheldMarkerId = "-1".equals(props.getProperty("handheldMarkerId")) ? null : props.getProperty("handheldMarkerId");
this.firmwareVersion = "-1".equals(props.getProperty("firmwareVersion")) ? null : props.getProperty("firmwareVersion");
this.appVersion = "-1".equals(props.getProperty("appVersion")) ? null : props.getProperty("appVersion");
-
- System.out.println("鏁版嵁鍒濆鍖栧畬鎴�");
-
- } catch (FileNotFoundException e) {
- System.err.println("灞炴�ф枃浠舵湭鎵惧埌: " + PROPERTIES_FILE);
+ this.idleTrailDurationSeconds = sanitizeIdleTrailDuration(props.getProperty("idleTrailDurationSeconds"));
+ String boundaryLengthVisibleStr = props.getProperty("boundaryLengthVisible");
+ this.boundaryLengthVisible = "true".equalsIgnoreCase(boundaryLengthVisibleStr);
+
+ } catch (FileNotFoundException e) {
// 鏂囦欢涓嶅瓨鍦ㄦ椂锛岃缃墍鏈夊睘鎬т负null
setAllPropertiesToNull();
- } catch (IOException e) {
- System.err.println("璇诲彇灞炴�ф枃浠舵椂鍑洪敊: " + e.getMessage());
+ } catch (IOException e) {
setAllPropertiesToNull();
}
}
@@ -112,15 +142,29 @@
case "simCardNumber":
this.simCardNumber = value;
break;
+ case "handheldMarkerId":
+ this.handheldMarkerId = value;
+ break;
case "firmwareVersion":
this.firmwareVersion = value;
break;
case "appVersion":
this.appVersion = value;
break;
+ case "idleTrailDurationSeconds":
+ int durationSeconds = sanitizeIdleTrailDuration(value);
+ this.idleTrailDurationSeconds = durationSeconds;
+ value = String.valueOf(durationSeconds);
+ break;
+ case "boundaryLengthVisible":
+ this.boundaryLengthVisible = "true".equalsIgnoreCase(value);
+ break;
+ case "mapScale":
+ // mapScale涓嶉渶瑕佸湪鍐呭瓨涓瓨鍌紝鐩存帴鏇存柊鍒版枃浠�
+ break;
default:
- System.err.println("鏈煡鐨勫睘鎬у悕: " + propertyName);
- return false;
+ // 瀵逛簬鍏朵粬灞炴�э紝涔熷厑璁哥洿鎺ユ洿鏂板埌鏂囦欢锛堜笉鎵撳嵃閿欒锛�
+ break;
}
// 鏇存柊properties鏂囦欢
@@ -146,7 +190,6 @@
// 鍐欏洖鏂囦欢
try (FileOutputStream output = new FileOutputStream(PROPERTIES_FILE)) {
props.store(output, "Mower Configuration Properties - Updated");
- System.out.println("灞炴�� " + propertyName + " 宸叉洿鏂颁负: " + value);
return true;
} catch (IOException e) {
System.err.println("鏇存柊灞炴�ф枃浠跺け璐�: " + e.getMessage());
@@ -154,6 +197,25 @@
}
}
+ private int sanitizeIdleTrailDuration(String raw) {
+ if (raw == null) {
+ return DEFAULT_IDLE_TRAIL_DURATION_SECONDS;
+ }
+ String trimmed = raw.trim();
+ if (trimmed.isEmpty() || "-1".equals(trimmed)) {
+ return DEFAULT_IDLE_TRAIL_DURATION_SECONDS;
+ }
+ try {
+ int value = Integer.parseInt(trimmed);
+ if (value < 5 || value > 600) {
+ return DEFAULT_IDLE_TRAIL_DURATION_SECONDS;
+ }
+ return value;
+ } catch (NumberFormatException ex) {
+ return DEFAULT_IDLE_TRAIL_DURATION_SECONDS;
+ }
+ }
+
/**
* 璁剧疆鎵�鏈夊睘鎬т负null
*/
@@ -161,8 +223,11 @@
this.mowerId = null;
this.cuttingWidth = null;
this.simCardNumber = null;
+ this.handheldMarkerId = null;
this.firmwareVersion = null;
this.appVersion = null;
+ this.idleTrailDurationSeconds = DEFAULT_IDLE_TRAIL_DURATION_SECONDS;
+ this.boundaryLengthVisible = false; // 榛樿鍏抽棴
}
/**
@@ -173,8 +238,10 @@
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);
}
// 鏍规嵁set.properties涓殑閿悕鑾峰彇瀵瑰簲鐨勫�硷紝娌℃湁鎴栦负-1鏃惰繑鍥瀗ull
@@ -205,8 +272,10 @@
"mowerId='" + mowerId + '\'' +
", cuttingWidth='" + cuttingWidth + '\'' +
", simCardNumber='" + simCardNumber + '\'' +
+ ", handheldMarkerId='" + handheldMarkerId + '\'' +
", firmwareVersion='" + firmwareVersion + '\'' +
", appVersion='" + appVersion + '\'' +
+ ", idleTrailDurationSeconds=" + idleTrailDurationSeconds +
'}';
}
}
\ No newline at end of file
--
Gitblit v1.10.0