From 6700283f9103a45bc087838ebf3eeeeb9022dd98 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期五, 19 十二月 2025 12:11:45 +0800
Subject: [PATCH] 新增了割草机长宽和割草安全距离属性

---
 src/gecaoji/Device.java |  194 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 194 insertions(+), 0 deletions(-)

diff --git a/src/gecaoji/Device.java b/src/gecaoji/Device.java
index 7b1c444..d37e21f 100644
--- a/src/gecaoji/Device.java
+++ b/src/gecaoji/Device.java
@@ -2,7 +2,10 @@
 import baseStation.BaseStation;
 import set.Setsys;
 import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
 import java.util.Locale;
 import java.util.Properties;
 
@@ -72,6 +75,20 @@
     // 鍗槦鍙暟
     private String differentialAge;
     // 宸垎鏃堕棿
+    private String selfCheckStatus = "-1";
+    // 鍓茶崏鏈鸿嚜妫�鐘舵��
+    private String mowerStartStatus = "-1";
+    // 鍓茶崏鏈哄惎鍔ㄧ姸鎬侊細1寮�鍚紝0鐔勭伀锛�-1鏈煡
+    private String mowerLightStatus = "-1";
+    // 鍓茶崏鏈虹伅寮�鍏崇姸鎬侊細1寮�鍚紝0鍏抽棴锛�-1鏈煡
+    private String mowerBladeHeight = "-1";
+    // 鍓茶崏鏈哄垁鐩橀珮搴︼細-1鏈煡
+    private String mowerWidth;
+    // 鍓茶崏鏈哄搴︼紝鍗曚綅绫�
+    private String mowerLength;
+    // 鍓茶崏鏈洪暱搴︼紝鍗曚綅绫�
+    private String mowingSafetyDistance;
+    // 鍓茶崏瀹夊叏璺濈锛屽崟浣嶇背
 
     private static final double METERS_PER_DEGREE_LAT = 111320.0d;
     
@@ -102,6 +119,61 @@
         applyDefaults(gecaoji);
     }
 
+    /**
+     * 淇濆瓨鎵�鏈夊睘鎬у埌device.properties鏂囦欢
+     */
+    public void saveToProperties() {
+        Properties properties = new Properties();
+        
+        // 鍔犺浇鐜版湁灞炴�э紙淇濈暀鍏朵粬灞炴�э級
+        try (FileInputStream input = new FileInputStream("device.properties")) {
+            properties.load(input);
+        } catch (IOException e) {
+            // 濡傛灉鏂囦欢涓嶅瓨鍦紝缁х画鍒涘缓鏂版枃浠�
+        }
+        
+        // 璁剧疆鎵�鏈夎澶囧睘鎬�
+        if (mowerName != null) properties.setProperty("mowerName", mowerName);
+        if (mowerModel != null) properties.setProperty("mowerModel", mowerModel);
+        if (mowerNumber != null) properties.setProperty("mowerNumber", mowerNumber);
+        if (mowingWidth != null) properties.setProperty("mowingWidth", mowingWidth);
+        if (mowingHeight != null) properties.setProperty("mowingHeight", mowingHeight);
+        if (baseStationNumber != null) properties.setProperty("baseStationNumber", baseStationNumber);
+        if (baseStationCardNumber != null) properties.setProperty("baseStationCardNumber", baseStationCardNumber);
+        if (baseStationCoordinates != null) properties.setProperty("baseStationCoordinates", baseStationCoordinates);
+        if (deviceCardnumber != null) properties.setProperty("deviceCardnumber", deviceCardnumber);
+        if (createTime != null) properties.setProperty("createTime", createTime);
+        if (GupdateTime != null) properties.setProperty("GupdateTime", GupdateTime);
+        if (BupdateTime != null) properties.setProperty("BupdateTime", BupdateTime);
+        if (realtimeLatitude != null) properties.setProperty("realtimeLatitude", realtimeLatitude);
+        if (realtimeLongitude != null) properties.setProperty("realtimeLongitude", realtimeLongitude);
+        if (realtimeAltitude != null) properties.setProperty("realtimeAltitude", realtimeAltitude);
+        if (realtimeX != null) properties.setProperty("realtimeX", realtimeX);
+        if (realtimeY != null) properties.setProperty("realtimeY", realtimeY);
+        if (realtimeSpeed != null) properties.setProperty("realtimeSpeed", realtimeSpeed);
+        if (heading != null) properties.setProperty("heading", heading);
+        if (pitch != null) properties.setProperty("pitch", pitch);
+        if (battery != null) properties.setProperty("battery", battery);
+        if (positioningStatus != null) properties.setProperty("positioningStatus", positioningStatus);
+        if (satelliteCount != null) properties.setProperty("satelliteCount", satelliteCount);
+        if (differentialAge != null) properties.setProperty("differentialAge", differentialAge);
+        if (selfCheckStatus != null) properties.setProperty("selfCheckStatus", selfCheckStatus);
+        if (mowerStartStatus != null) properties.setProperty("mowerStartStatus", mowerStartStatus);
+        if (mowerLightStatus != null) properties.setProperty("mowerLightStatus", mowerLightStatus);
+        if (mowerBladeHeight != null) properties.setProperty("mowerBladeHeight", mowerBladeHeight);
+        if (mowerWidth != null) properties.setProperty("mowerWidth", mowerWidth);
+        if (mowerLength != null) properties.setProperty("mowerLength", mowerLength);
+        if (mowingSafetyDistance != null) properties.setProperty("mowingSafetyDistance", mowingSafetyDistance);
+        
+        // 淇濆瓨鍒版枃浠�
+        try (FileOutputStream output = new FileOutputStream("device.properties");
+             OutputStreamWriter writer = new OutputStreamWriter(output, StandardCharsets.UTF_8)) {
+            properties.store(writer, "Updated device properties");
+        } catch (IOException ex) {
+            System.err.println("鏃犳硶淇濆瓨 device.properties: " + ex.getMessage());
+        }
+    }
+
     private void loadPropertiesInto(Device target, Properties properties) {
         if (target == null) {
             return;
@@ -131,6 +203,13 @@
         target.positioningStatus = properties.getProperty("positioningStatus", "-1");
         target.satelliteCount = properties.getProperty("satelliteCount", "-1");
         target.differentialAge = properties.getProperty("differentialAge", "-1");
+        target.selfCheckStatus = properties.getProperty("selfCheckStatus", "-1");
+        target.mowerStartStatus = properties.getProperty("mowerStartStatus", "-1");
+        target.mowerLightStatus = properties.getProperty("mowerLightStatus", "-1");
+        target.mowerBladeHeight = properties.getProperty("mowerBladeHeight", "-1");
+        target.mowerWidth = properties.getProperty("mowerWidth", "-1");
+        target.mowerLength = properties.getProperty("mowerLength", "-1");
+        target.mowingSafetyDistance = properties.getProperty("mowingSafetyDistance", "-1");
     }
 
     private void applyDefaults(Device target) {
@@ -162,6 +241,13 @@
         target.positioningStatus = "-1";
         target.satelliteCount = "-1";
         target.differentialAge = "-1";
+        target.selfCheckStatus = "-1";
+        target.mowerStartStatus = "-1";
+        target.mowerLightStatus = "-1";
+        target.mowerBladeHeight = "-1";
+        target.mowerWidth = "-1";
+        target.mowerLength = "-1";
+        target.mowingSafetyDistance = "-1";
     }
 
     public static synchronized Device initializeActiveDevice(String mowerId) { // 鏍规嵁璁惧ID鍒濆鍖栨椿璺冭澶�
@@ -260,6 +346,27 @@
             case "differentialAge":
                 this.differentialAge = value;
                 return true;
+            case "selfCheckStatus":
+                this.selfCheckStatus = value;
+                return true;
+            case "mowerStartStatus":
+                this.mowerStartStatus = value;
+                return true;
+            case "mowerLightStatus":
+                this.mowerLightStatus = value;
+                return true;
+            case "mowerBladeHeight":
+                this.mowerBladeHeight = value;
+                return true;
+            case "mowerWidth":
+                this.mowerWidth = value;
+                return true;
+            case "mowerLength":
+                this.mowerLength = value;
+                return true;
+            case "mowingSafetyDistance":
+                this.mowingSafetyDistance = value;
+                return true;
             default:
                 System.err.println("鏈煡瀛楁: " + fieldName);
                 return false;
@@ -384,6 +491,30 @@
         GupdateTime = String.valueOf(System.currentTimeMillis());
 
         updateRelativeCoordinates(latitudeValue, latitudeHemisphere, longitudeValue, longitudeHemisphere);
+        
+        // 涓插彛鏀跺埌GNGGA鏁版嵁鍚庯紝瑙﹀彂鎷栧熬鏇存柊
+        notifyMowerTrailUpdate();
+    }
+    
+    /**
+     * 閫氱煡鍦板浘娓叉煋鍣ㄦ洿鏂板壊鑽夋満鎷栧熬
+     * 褰撲覆鍙f敹鍒癎NGGA鏁版嵁骞舵洿鏂颁綅缃悗璋冪敤
+     */
+    private void notifyMowerTrailUpdate() {
+        try {
+            // 閫氳繃Shouye.getInstance()鑾峰彇瀹炰緥锛岄伩鍏嶅惊鐜緷璧�
+            zhuye.Shouye shouye = zhuye.Shouye.getInstance();
+            if (shouye != null) {
+                zhuye.MapRenderer mapRenderer = shouye.getMapRenderer();
+                if (mapRenderer != null) {
+                    // 璋冪敤鏇存柊鎷栧熬鏂规硶
+                    mapRenderer.forceUpdateIdleMowerTrail();
+                }
+            }
+        } catch (Exception e) {
+            // 濡傛灉璋冪敤澶辫触锛岄潤榛樺鐞嗭紙涓嶅奖鍝嶄富瑕佸姛鑳斤級
+            // System.err.println("閫氱煡鎷栧熬鏇存柊澶辫触: " + e.getMessage());
+        }
     }
 
     private void updateRelativeCoordinates(String latValue, String latHemisphere,
@@ -696,6 +827,62 @@
         this.differentialAge = differentialAge;
     }
 
+    public String getSelfCheckStatus() { // 鑾峰彇鑷鐘舵��
+        return selfCheckStatus;
+    }
+
+    public void setSelfCheckStatus(String selfCheckStatus) { // 璁剧疆鑷鐘舵��
+        this.selfCheckStatus = selfCheckStatus;
+    }
+
+    public String getMowerStartStatus() { // 鑾峰彇鍓茶崏鏈哄惎鍔ㄧ姸鎬�
+        return mowerStartStatus;
+    }
+
+    public void setMowerStartStatus(String mowerStartStatus) { // 璁剧疆鍓茶崏鏈哄惎鍔ㄧ姸鎬�
+        this.mowerStartStatus = mowerStartStatus;
+    }
+
+    public String getMowerLightStatus() { // 鑾峰彇鍓茶崏鏈虹伅寮�鍏崇姸鎬�
+        return mowerLightStatus;
+    }
+
+    public void setMowerLightStatus(String mowerLightStatus) { // 璁剧疆鍓茶崏鏈虹伅寮�鍏崇姸鎬�
+        this.mowerLightStatus = mowerLightStatus;
+    }
+
+    public String getMowerBladeHeight() { // 鑾峰彇鍓茶崏鏈哄垁鐩橀珮搴�
+        return mowerBladeHeight;
+    }
+
+    public void setMowerBladeHeight(String mowerBladeHeight) { // 璁剧疆鍓茶崏鏈哄垁鐩橀珮搴�
+        this.mowerBladeHeight = mowerBladeHeight;
+    }
+
+    public String getMowerWidth() { // 鑾峰彇鍓茶崏鏈哄搴�
+        return mowerWidth;
+    }
+
+    public void setMowerWidth(String mowerWidth) { // 璁剧疆鍓茶崏鏈哄搴�
+        this.mowerWidth = mowerWidth;
+    }
+
+    public String getMowerLength() { // 鑾峰彇鍓茶崏鏈洪暱搴�
+        return mowerLength;
+    }
+
+    public void setMowerLength(String mowerLength) { // 璁剧疆鍓茶崏鏈洪暱搴�
+        this.mowerLength = mowerLength;
+    }
+
+    public String getMowingSafetyDistance() { // 鑾峰彇鍓茶崏瀹夊叏璺濈
+        return mowingSafetyDistance;
+    }
+
+    public void setMowingSafetyDistance(String mowingSafetyDistance) { // 璁剧疆鍓茶崏瀹夊叏璺濈
+        this.mowingSafetyDistance = mowingSafetyDistance;
+    }
+
     @Override
     public String toString() { // 杈撳嚭瀵硅薄淇℃伅
         return "Device{" +
@@ -723,6 +910,13 @@
                 ", positioningStatus='" + positioningStatus + '\'' +
                 ", satelliteCount='" + satelliteCount + '\'' +
                 ", differentialAge='" + differentialAge + '\'' +
+                ", selfCheckStatus='" + selfCheckStatus + '\'' +
+                ", mowerStartStatus='" + mowerStartStatus + '\'' +
+                ", mowerLightStatus='" + mowerLightStatus + '\'' +
+                ", mowerBladeHeight='" + mowerBladeHeight + '\'' +
+                ", mowerWidth='" + mowerWidth + '\'' +
+                ", mowerLength='" + mowerLength + '\'' +
+                ", mowingSafetyDistance='" + mowingSafetyDistance + '\'' +
                 '}';
     }
 }
\ No newline at end of file

--
Gitblit v1.10.0