From c9b1d33979b3972fe6a82fa427b4ba9a20989112 Mon Sep 17 00:00:00 2001
From: 张世豪 <979909237@qq.com>
Date: 星期三, 24 十二月 2025 18:56:28 +0800
Subject: [PATCH] 新增mqtt相关功能
---
src/gecaoji/Device.java | 217 +++++++++++++++--
src/gecaoji/gecaojistatus.java | 68 +++++
set.properties | 12
src/Mqttmessage/Entity/GPSData.java | 143 +++++++++++
src/udpdell/UDPServer.java | 1
src/zhuye/Shouye.java | 11
user.properties | 2
src/zhuye/Coordinate.java | 41 +-
src/Mqttmessage/PushCallback.java | 9
src/gecaoji/GecaojiMeg.java | 124 ++++++++++
src/publicway/Gpstoxuzuobiao.java | 6
src/user/Usrdell.java | 8
src/set/Setsys.java | 8
src/Mqttmessage/Client.java | 13
src/denglu/Denglu.java | 7
15 files changed, 587 insertions(+), 83 deletions(-)
diff --git a/set.properties b/set.properties
index 321c62c..09c043b 100644
--- a/set.properties
+++ b/set.properties
@@ -1,5 +1,5 @@
-#Mower Configuration Properties - Updated
-#Wed Dec 24 17:17:31 CST 2025
+#Current work land selection updated
+#Wed Dec 24 18:54:38 CST 2025
appVersion=-1
boundaryLengthVisible=false
currentWorkLandNumber=LAND1
@@ -8,12 +8,12 @@
handheldMarkerId=1872
idleTrailDurationSeconds=60
manualBoundaryDrawingMode=false
-mapScale=0.78
+mapScale=1.34
measurementModeEnabled=false
-mowerId=860
+mowerId=6258
serialAutoConnect=true
serialBaudRate=115200
serialPortName=COM15
simCardNumber=-1
-viewCenterX=-148.00
-viewCenterY=424.51
+viewCenterX=-195.34
+viewCenterY=432.68
diff --git a/src/Mqttmessage/Client.java b/src/Mqttmessage/Client.java
index 90ff9f1..60be1c3 100644
--- a/src/Mqttmessage/Client.java
+++ b/src/Mqttmessage/Client.java
@@ -4,6 +4,9 @@
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
+import set.Setsys;
+import user.Usrdell;
+
/**
* MQTT瀹㈡埛绔伐鍏风被
* 鐢ㄤ簬杩炴帴MQTT鏈嶅姟鍣ㄥ苟璁㈤槄涓婚
@@ -94,12 +97,12 @@
* 绀轰緥鐢ㄦ硶
*/
- public static void test() {
+ public static void lianjiemqqt() {
try {
String host = "tcp://39.99.43.227:1883";
- String deiveID="6258";
- String clientId = "hxzkMQTT";
- String clientId2 = "hxzkMQTT2";
+ String deiveID=Setsys.getMowerIdValue();
+ String clientId =Usrdell.getUserEmail()+"mower";
+ String clientId2 =Usrdell.getUserEmail()+"response";
String topic = "mower/"+deiveID+"/gps";
String topic2 = "mower/"+deiveID+"/response";
Client mqttClient = new Client(host, topic, clientId);
@@ -111,7 +114,7 @@
mqttClient1.subscribe();
// 淇濇寔绋嬪簭杩愯
- //Thread.sleep(Long.MAX_VALUE);
+// Thread.sleep(Long.MAX_VALUE);
} catch (MqttException e) {
throw new RuntimeException(e);
}
diff --git a/src/Mqttmessage/Entity/GPSData.java b/src/Mqttmessage/Entity/GPSData.java
index 0b8882f..8f96c20 100644
--- a/src/Mqttmessage/Entity/GPSData.java
+++ b/src/Mqttmessage/Entity/GPSData.java
@@ -43,6 +43,8 @@
+
+
/**
@@ -83,6 +85,7 @@
private Integer self_check_status; // 鑷鐘舵�侊細1-瀹屾垚锛�0-鏈畬鎴�
private Integer error_code; // 閿欒浠g爜
private String error_message; // 閿欒淇℃伅
+ private String path_id_saved; // 瀛樺偍鐨勮矾寰処D
/**
* 甯﹀弬鏁扮殑鏋勯�犲嚱鏁�
@@ -95,10 +98,11 @@
* @param self_check_status 鑷鐘舵�侊細1-瀹屾垚锛�0-鏈畬鎴�
* @param error_code 閿欒浠g爜
* @param error_message 閿欒淇℃伅
+ * @param path_id_saved 瀛樺偍鐨勮矾寰処D
*/
public StatusInfo(Integer battery_level, Double battery_voltage, String operation_mode,
String motor_status, String blade_status, Integer blade_height,
- Integer self_check_status, Integer error_code, String error_message) {
+ Integer self_check_status, Integer error_code, String error_message, String path_id_saved) {
this.battery_level = battery_level;
this.battery_voltage = battery_voltage;
this.operation_mode = operation_mode;
@@ -108,7 +112,88 @@
this.self_check_status = self_check_status;
this.error_code = error_code;
this.error_message = error_message;
+ this.path_id_saved = path_id_saved;
}
+
+ public Integer getBattery_level() {
+ return battery_level;
+ }
+
+ public void setBattery_level(Integer battery_level) {
+ this.battery_level = battery_level;
+ }
+
+ public Double getBattery_voltage() {
+ return battery_voltage;
+ }
+
+ public void setBattery_voltage(Double battery_voltage) {
+ this.battery_voltage = battery_voltage;
+ }
+
+ public String getOperation_mode() {
+ return operation_mode;
+ }
+
+ public void setOperation_mode(String operation_mode) {
+ this.operation_mode = operation_mode;
+ }
+
+ public String getMotor_status() {
+ return motor_status;
+ }
+
+ public void setMotor_status(String motor_status) {
+ this.motor_status = motor_status;
+ }
+
+ public String getBlade_status() {
+ return blade_status;
+ }
+
+ public void setBlade_status(String blade_status) {
+ this.blade_status = blade_status;
+ }
+
+ public Integer getBlade_height() {
+ return blade_height;
+ }
+
+ public void setBlade_height(Integer blade_height) {
+ this.blade_height = blade_height;
+ }
+
+ public Integer getSelf_check_status() {
+ return self_check_status;
+ }
+
+ public void setSelf_check_status(Integer self_check_status) {
+ this.self_check_status = self_check_status;
+ }
+
+ public Integer getError_code() {
+ return error_code;
+ }
+
+ public void setError_code(Integer error_code) {
+ this.error_code = error_code;
+ }
+
+ public String getError_message() {
+ return error_message;
+ }
+
+ public void setError_message(String error_message) {
+ this.error_message = error_message;
+ }
+
+ public String getPath_id_saved() {
+ return path_id_saved;
+ }
+
+ public void setPath_id_saved(String path_id_saved) {
+ this.path_id_saved = path_id_saved;
+ }
}
/**
@@ -133,4 +218,60 @@
private String age; // 宸垎GPS鏁版嵁鏈熼檺
private String stationId; // 宸垎鍙傝�冨熀绔欐爣鍙�
}
+
+ public String getMsg_id() {
+ return msg_id;
+ }
+
+ public void setMsg_id(String msg_id) {
+ this.msg_id = msg_id;
+ }
+
+ public Long getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(Long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public String getDevice_id() {
+ return device_id;
+ }
+
+ public void setDevice_id(String device_id) {
+ this.device_id = device_id;
+ }
+
+ public String getData_type() {
+ return data_type;
+ }
+
+ public void setData_type(String data_type) {
+ this.data_type = data_type;
+ }
+
+ public IMUData getImu_data() {
+ return imu_data;
+ }
+
+ public void setImu_data(IMUData imu_data) {
+ this.imu_data = imu_data;
+ }
+
+ public StatusInfo getStatus() {
+ return status;
+ }
+
+ public void setStatus(StatusInfo status) {
+ this.status = status;
+ }
+
+ public GGAData getGgaData() {
+ return ggaData;
+ }
+
+ public void setGgaData(GGAData ggaData) {
+ this.ggaData = ggaData;
+ }
}
\ No newline at end of file
diff --git a/src/Mqttmessage/PushCallback.java b/src/Mqttmessage/PushCallback.java
index ab97989..12d7467 100644
--- a/src/Mqttmessage/PushCallback.java
+++ b/src/Mqttmessage/PushCallback.java
@@ -1,15 +1,13 @@
package Mqttmessage;
-
-
-
import Mqttmessage.Util.DeviceMessageParser;
+import gecaoji.gecaojistatus;
import Mqttmessage.Entity.GPSData;
+import Mqttmessage.Entity.GPSData.StatusInfo;
+
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import udpdell.UDPServer;
-
-
public class PushCallback implements MqttCallback {
@@ -30,6 +28,7 @@
//ResponseData responseData = DeviceMessageParser.parseResponseData(new String(message.getPayload()));//瑙f瀽鍝嶅簲鏁版嵁
String gpsRaw = gpsData.getGps_raw();
UDPServer.processSerialData(gpsRaw);
+ gecaojistatus.parseStatus(gpsData.getStatus());
}
}
diff --git a/src/denglu/Denglu.java b/src/denglu/Denglu.java
index 0769bd6..98117a5 100644
--- a/src/denglu/Denglu.java
+++ b/src/denglu/Denglu.java
@@ -8,6 +8,7 @@
import set.Setsys;
import udpdell.UDPServer;
import user.Usrdell;
+import Mqttmessage.Client;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
@@ -542,6 +543,12 @@
mainFrame.setVisible(true);
System.out.println("涓诲簲鐢ㄧ▼搴忓凡鍚姩");
+
+ // 鍚姩鍚庤繛鎺QTT
+ new Thread(() -> {
+ System.out.println("姝e湪杩炴帴MQTT鏈嶅姟鍣�...");
+ Client.lianjiemqqt();
+ }).start();
});
}
diff --git a/src/gecaoji/Device.java b/src/gecaoji/Device.java
index 9e26eff..9d1a1c3 100644
--- a/src/gecaoji/Device.java
+++ b/src/gecaoji/Device.java
@@ -68,21 +68,30 @@
// 鑸悜瑙�
private String pitch;
// 淇话瑙�
- private String battery;
- // 瀹炴椂鐢甸噺
+ private String roll; // 妯粴瑙� 瑙掑害
+ private String yaw; // 鍋忚埅瑙� 瑙掑害
+ private String battery_level; // 鐢垫睜鐢甸噺鐧惧垎姣�
+ private String battery_voltage; // 鐢垫睜鐢靛帇
+ private String operation_mode; // 鎿嶄綔妯″紡锛歮anual, auto, emergency_stop
+ private String motor_status; // 鐢垫満鐘舵�侊細stopped, running, error
+ private String blade_status; // 鍒�鐗囩姸鎬侊細stopped, rotating
+ private String path_id_saved; // 瀛樺偍鐨勮矾寰処D
+ private String error_code; // 閿欒浠g爜
+ private String error_message; // 閿欒淇℃伅
+
private String positioningStatus;
// 瀹氫綅鐘舵��
private String satelliteCount;
// 鍗槦鍙暟
private String differentialAge;
// 宸垎鏃堕棿
- private String selfCheckStatus = "-1";
+ private String self_check_status = "-1"; // 鏂板鑷鐘舵�侊細1-瀹屾垚锛�0-鏈畬鎴�
// 鍓茶崏鏈鸿嚜妫�鐘舵��
private String mowerStartStatus = "-1";
// 鍓茶崏鏈哄惎鍔ㄧ姸鎬侊細1寮�鍚紝0鐔勭伀锛�-1鏈煡
private String mowerLightStatus = "-1";
// 鍓茶崏鏈虹伅寮�鍏崇姸鎬侊細1寮�鍚紝0鍏抽棴锛�-1鏈煡
- private String mowerBladeHeight = "-1";
+ private String blade_height = "-1"; // 鍒�鐩橀珮搴� 鍘樼背
// 鍓茶崏鏈哄垁鐩橀珮搴︼細-1鏈煡
private String mowerWidth;
// 鍓茶崏鏈哄搴︼紝鍗曚綅绫�
@@ -154,14 +163,24 @@
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 (roll != null) properties.setProperty("roll", roll);
+ if (yaw != null) properties.setProperty("yaw", yaw);
+ if (battery_level != null) properties.setProperty("battery_level", battery_level);
+ if (battery_voltage != null) properties.setProperty("battery_voltage", battery_voltage);
+ if (operation_mode != null) properties.setProperty("operation_mode", operation_mode);
+ if (motor_status != null) properties.setProperty("motor_status", motor_status);
+ if (blade_status != null) properties.setProperty("blade_status", blade_status);
+ if (path_id_saved != null) properties.setProperty("path_id_saved", path_id_saved);
+ if (error_code != null) properties.setProperty("error_code", error_code);
+ if (error_message != null) properties.setProperty("error_message", error_message);
+
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 (self_check_status != null) properties.setProperty("self_check_status", self_check_status);
if (mowerStartStatus != null) properties.setProperty("mowerStartStatus", mowerStartStatus);
if (mowerLightStatus != null) properties.setProperty("mowerLightStatus", mowerLightStatus);
- if (mowerBladeHeight != null) properties.setProperty("mowerBladeHeight", mowerBladeHeight);
+ if (blade_height != null) properties.setProperty("blade_height", blade_height);
if (mowerWidth != null) properties.setProperty("mowerWidth", mowerWidth);
if (mowerLength != null) properties.setProperty("mowerLength", mowerLength);
if (mowingSafetyDistance != null) properties.setProperty("mowingSafetyDistance", mowingSafetyDistance);
@@ -200,14 +219,24 @@
target.realtimeSpeed = properties.getProperty("realtimeSpeed", "-1");
target.heading = properties.getProperty("heading", "-1");
target.pitch = properties.getProperty("pitch", "-1");
- target.battery = properties.getProperty("battery", "-1");
+ target.roll = properties.getProperty("roll", "-1");
+ target.yaw = properties.getProperty("yaw", "-1");
+ target.battery_level = properties.getProperty("battery_level", "-1");
+ target.battery_voltage = properties.getProperty("battery_voltage", "-1");
+ target.operation_mode = properties.getProperty("operation_mode", "-1");
+ target.motor_status = properties.getProperty("motor_status", "-1");
+ target.blade_status = properties.getProperty("blade_status", "-1");
+ target.path_id_saved = properties.getProperty("path_id_saved", "-1");
+ target.error_code = properties.getProperty("error_code", "-1");
+ target.error_message = properties.getProperty("error_message", "-1");
+
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.self_check_status = properties.getProperty("self_check_status", "-1");
target.mowerStartStatus = properties.getProperty("mowerStartStatus", "-1");
target.mowerLightStatus = properties.getProperty("mowerLightStatus", "-1");
- target.mowerBladeHeight = properties.getProperty("mowerBladeHeight", "-1");
+ target.blade_height = properties.getProperty("blade_height", "-1");
target.mowerWidth = properties.getProperty("mowerWidth", "-1");
target.mowerLength = properties.getProperty("mowerLength", "-1");
target.mowingSafetyDistance = properties.getProperty("mowingSafetyDistance", "-1");
@@ -238,14 +267,24 @@
target.realtimeSpeed = "-1";
target.heading = "-1";
target.pitch = "-1";
- target.battery = "-1";
+ target.roll = "-1";
+ target.yaw = "-1";
+ target.battery_level = "-1";
+ target.battery_voltage = "-1";
+ target.operation_mode = "-1";
+ target.motor_status = "-1";
+ target.blade_status = "-1";
+ target.path_id_saved = "-1";
+ target.error_code = "-1";
+ target.error_message = "-1";
+
target.positioningStatus = "-1";
target.satelliteCount = "-1";
target.differentialAge = "-1";
- target.selfCheckStatus = "-1";
+ target.self_check_status = "-1";
target.mowerStartStatus = "-1";
target.mowerLightStatus = "-1";
- target.mowerBladeHeight = "-1";
+ target.blade_height = "-1";
target.mowerWidth = "-1";
target.mowerLength = "-1";
target.mowingSafetyDistance = "-1";
@@ -335,8 +374,35 @@
case "pitch":
this.pitch = value;
return true;
- case "battery":
- this.battery = value;
+ case "roll":
+ this.roll = value;
+ return true;
+ case "yaw":
+ this.yaw = value;
+ return true;
+ case "battery_level":
+ this.battery_level = value;
+ return true;
+ case "battery_voltage":
+ this.battery_voltage = value;
+ return true;
+ case "operation_mode":
+ this.operation_mode = value;
+ return true;
+ case "motor_status":
+ this.motor_status = value;
+ return true;
+ case "blade_status":
+ this.blade_status = value;
+ return true;
+ case "path_id_saved":
+ this.path_id_saved = value;
+ return true;
+ case "error_code":
+ this.error_code = value;
+ return true;
+ case "error_message":
+ this.error_message = value;
return true;
case "positioningStatus":
this.positioningStatus = value;
@@ -347,8 +413,8 @@
case "differentialAge":
this.differentialAge = value;
return true;
- case "selfCheckStatus":
- this.selfCheckStatus = value;
+ case "self_check_status":
+ this.self_check_status = value;
return true;
case "mowerStartStatus":
this.mowerStartStatus = value;
@@ -356,8 +422,8 @@
case "mowerLightStatus":
this.mowerLightStatus = value;
return true;
- case "mowerBladeHeight":
- this.mowerBladeHeight = value;
+ case "blade_height":
+ this.blade_height = value;
return true;
case "mowerWidth":
this.mowerWidth = value;
@@ -458,7 +524,7 @@
}
satelliteCount = defaultIfEmpty(sanitizeField(fields, 7));
differentialAge = defaultIfEmpty(sanitizeField(fields, 13));
- battery = defaultIfEmpty(sanitizeField(fields, 16));
+ battery_level = defaultIfEmpty(sanitizeField(fields, 16));
pitch = defaultIfEmpty(sanitizeField(fields, 17));
realtimeSpeed = defaultIfEmpty(sanitizeField(fields, 18));
GupdateTime = String.valueOf(System.currentTimeMillis());
@@ -844,12 +910,84 @@
this.pitch = pitch;
}
- public String getBattery() { // 鑾峰彇瀹炴椂鐢甸噺
- return battery;
+ public String getRoll() {
+ return roll;
}
- public void setBattery(String battery) { // 璁剧疆瀹炴椂鐢甸噺
- this.battery = battery;
+ public void setRoll(String roll) {
+ this.roll = roll;
+ }
+
+ public String getYaw() {
+ return yaw;
+ }
+
+ public void setYaw(String yaw) {
+ this.yaw = yaw;
+ }
+
+ public String getBattery_level() {
+ return battery_level;
+ }
+
+ public void setBattery_level(String battery_level) {
+ this.battery_level = battery_level;
+ }
+
+ public String getBattery_voltage() {
+ return battery_voltage;
+ }
+
+ public void setBattery_voltage(String battery_voltage) {
+ this.battery_voltage = battery_voltage;
+ }
+
+ public String getOperation_mode() {
+ return operation_mode;
+ }
+
+ public void setOperation_mode(String operation_mode) {
+ this.operation_mode = operation_mode;
+ }
+
+ public String getMotor_status() {
+ return motor_status;
+ }
+
+ public void setMotor_status(String motor_status) {
+ this.motor_status = motor_status;
+ }
+
+ public String getBlade_status() {
+ return blade_status;
+ }
+
+ public void setBlade_status(String blade_status) {
+ this.blade_status = blade_status;
+ }
+
+ public String getPath_id_saved() {
+ return path_id_saved;
+ }
+
+ public void setPath_id_saved(String path_id_saved) {
+ this.path_id_saved = path_id_saved;
+ }
+
+ public String getError_code() {
+ return error_code;
+ }
+
+ public void setError_code(String error_code) {
+ this.error_code = error_code;
+ }
+
+ public String getError_message() {
+ return error_message;
+ }
+
+ public void setError_message(String error_message) {
+ this.error_message = error_message;
}
public String getPositioningStatus() { // 鑾峰彇瀹氫綅鐘舵��
@@ -876,12 +1014,12 @@
this.differentialAge = differentialAge;
}
- public String getSelfCheckStatus() { // 鑾峰彇鑷鐘舵��
- return selfCheckStatus;
+ public String getSelf_check_status() { // 鑾峰彇鑷鐘舵��
+ return self_check_status;
}
- public void setSelfCheckStatus(String selfCheckStatus) { // 璁剧疆鑷鐘舵��
- this.selfCheckStatus = selfCheckStatus;
+ public void setSelf_check_status(String self_check_status) { // 璁剧疆鑷鐘舵��
+ this.self_check_status = self_check_status;
}
public String getMowerStartStatus() { // 鑾峰彇鍓茶崏鏈哄惎鍔ㄧ姸鎬�
@@ -900,12 +1038,12 @@
this.mowerLightStatus = mowerLightStatus;
}
- public String getMowerBladeHeight() { // 鑾峰彇鍓茶崏鏈哄垁鐩橀珮搴�
- return mowerBladeHeight;
+ public String getBlade_height() { // 鑾峰彇鍓茶崏鏈哄垁鐩橀珮搴�
+ return blade_height;
}
- public void setMowerBladeHeight(String mowerBladeHeight) { // 璁剧疆鍓茶崏鏈哄垁鐩橀珮搴�
- this.mowerBladeHeight = mowerBladeHeight;
+ public void setBlade_height(String blade_height) { // 璁剧疆鍓茶崏鏈哄垁鐩橀珮搴�
+ this.blade_height = blade_height;
}
public String getMowerWidth() { // 鑾峰彇鍓茶崏鏈哄搴�
@@ -955,14 +1093,23 @@
", realtimeSpeed='" + realtimeSpeed + '\'' +
", heading='" + heading + '\'' +
", pitch='" + pitch + '\'' +
- ", battery='" + battery + '\'' +
+ ", roll='" + roll + '\'' +
+ ", yaw='" + yaw + '\'' +
+ ", battery_level='" + battery_level + '\'' +
+ ", battery_voltage='" + battery_voltage + '\'' +
+ ", operation_mode='" + operation_mode + '\'' +
+ ", motor_status='" + motor_status + '\'' +
+ ", blade_status='" + blade_status + '\'' +
+ ", path_id_saved='" + path_id_saved + '\'' +
+ ", error_code='" + error_code + '\'' +
+ ", error_message='" + error_message + '\'' +
", positioningStatus='" + positioningStatus + '\'' +
", satelliteCount='" + satelliteCount + '\'' +
", differentialAge='" + differentialAge + '\'' +
- ", selfCheckStatus='" + selfCheckStatus + '\'' +
+ ", self_check_status='" + self_check_status + '\'' +
", mowerStartStatus='" + mowerStartStatus + '\'' +
", mowerLightStatus='" + mowerLightStatus + '\'' +
- ", mowerBladeHeight='" + mowerBladeHeight + '\'' +
+ ", blade_height='" + blade_height + '\'' +
", mowerWidth='" + mowerWidth + '\'' +
", mowerLength='" + mowerLength + '\'' +
", mowingSafetyDistance='" + mowingSafetyDistance + '\'' +
diff --git a/src/gecaoji/GecaojiMeg.java b/src/gecaoji/GecaojiMeg.java
index e573211..589c883 100644
--- a/src/gecaoji/GecaojiMeg.java
+++ b/src/gecaoji/GecaojiMeg.java
@@ -27,6 +27,22 @@
private JLabel satelliteCountLabel;
private JLabel realtimeSpeedLabel;
private JLabel headingLabel;
+
+ // 鏂板灞炴�ф爣绛�
+ private JLabel pathIdLabel;
+ private JLabel batteryLevelLabel;
+ private JLabel batteryVoltageLabel;
+ private JLabel operationModeLabel;
+ private JLabel motorStatusLabel;
+ private JLabel bladeStatusLabel;
+ private JLabel bladeHeightLabel;
+ private JLabel selfCheckStatusLabel;
+ private JLabel errorCodeLabel;
+ private JLabel errorMessageLabel;
+ private JLabel rollLabel;
+ private JLabel pitchLabel;
+ private JLabel yawLabel;
+
private JLabel updateTimeLabel;
public GecaojiMeg(JPanel anchorPanel, Gecaoji mower) {
@@ -197,15 +213,57 @@
headingLabel.setFont(valueFont);
grid.add(headingLabel, gbc);
- // 绗叓琛�
- gbc.gridx = 0; gbc.gridy = 7;
+ // 鏂板灞炴�ф樉绀�
+ int currentRow = 7;
+
+ // 瀛樺偍鐨勮矾寰処D
+ addLabelRow(grid, gbc, currentRow++, "璺緞ID锛�", pathIdLabel = createValueLabel(), titleFont, valueFont);
+
+ // 鐢垫睜鐢甸噺
+ addLabelRow(grid, gbc, currentRow++, "鐢垫睜鐢甸噺锛�", batteryLevelLabel = createValueLabel(), titleFont, valueFont);
+
+ // 鐢垫睜鐢靛帇
+ addLabelRow(grid, gbc, currentRow++, "鐢垫睜鐢靛帇锛�", batteryVoltageLabel = createValueLabel(), titleFont, valueFont);
+
+ // 鎿嶄綔妯″紡
+ addLabelRow(grid, gbc, currentRow++, "鎿嶄綔妯″紡锛�", operationModeLabel = createValueLabel(), titleFont, valueFont);
+
+ // 鐢垫満鐘舵��
+ addLabelRow(grid, gbc, currentRow++, "鐢垫満鐘舵�侊細", motorStatusLabel = createValueLabel(), titleFont, valueFont);
+
+ // 鍒�鐗囩姸鎬�
+ addLabelRow(grid, gbc, currentRow++, "鍒�鐗囩姸鎬侊細", bladeStatusLabel = createValueLabel(), titleFont, valueFont);
+
+ // 鍒�鐩橀珮搴�
+ addLabelRow(grid, gbc, currentRow++, "鍒�鐩橀珮搴︼細", bladeHeightLabel = createValueLabel(), titleFont, valueFont);
+
+ // 鑷鐘舵��
+ addLabelRow(grid, gbc, currentRow++, "鑷鐘舵�侊細", selfCheckStatusLabel = createValueLabel(), titleFont, valueFont);
+
+ // 閿欒浠g爜
+ addLabelRow(grid, gbc, currentRow++, "閿欒浠g爜锛�", errorCodeLabel = createValueLabel(), titleFont, valueFont);
+
+ // 閿欒淇℃伅
+ addLabelRow(grid, gbc, currentRow++, "閿欒淇℃伅锛�", errorMessageLabel = createValueLabel(), titleFont, valueFont);
+
+ // 妯粴瑙�
+ addLabelRow(grid, gbc, currentRow++, "妯粴瑙掞細", rollLabel = createValueLabel(), titleFont, valueFont);
+
+ // 淇话瑙�
+ addLabelRow(grid, gbc, currentRow++, "淇话瑙掞細", pitchLabel = createValueLabel(), titleFont, valueFont);
+
+ // 鍋忚埅瑙�
+ addLabelRow(grid, gbc, currentRow++, "鍋忚埅瑙掞細", yawLabel = createValueLabel(), titleFont, valueFont);
+
+ // 鏇存柊鏃堕棿
+ gbc.gridx = 0; gbc.gridy = currentRow;
gbc.weightx = 0.3;
JLabel label8 = new JLabel("鏇存柊鏃堕棿锛�");
label8.setFont(titleFont);
label8.setForeground(new Color(102, 102, 102));
grid.add(label8, gbc);
- gbc.gridx = 1; gbc.gridy = 7;
+ gbc.gridx = 1; gbc.gridy = currentRow;
gbc.weightx = 0.7;
updateTimeLabel = createValueLabel();
updateTimeLabel.setFont(valueFont);
@@ -310,6 +368,21 @@
satelliteCountLabel = null;
realtimeSpeedLabel = null;
headingLabel = null;
+
+ pathIdLabel = null;
+ batteryLevelLabel = null;
+ batteryVoltageLabel = null;
+ operationModeLabel = null;
+ motorStatusLabel = null;
+ bladeStatusLabel = null;
+ bladeHeightLabel = null;
+ selfCheckStatusLabel = null;
+ errorCodeLabel = null;
+ errorMessageLabel = null;
+ rollLabel = null;
+ pitchLabel = null;
+ yawLabel = null;
+
updateTimeLabel = null;
}
@@ -333,6 +406,22 @@
satelliteCountLabel.setText(formatDeviceValue(device.getSatelliteCount()));
realtimeSpeedLabel.setText(formatDeviceValue(device.getRealtimeSpeed()));
headingLabel.setText(formatDeviceValue(device.getHeading()));
+
+ // 鏇存柊鏂板灞炴��
+ pathIdLabel.setText(formatDeviceValue(device.getPath_id_saved()));
+ batteryLevelLabel.setText(formatDeviceValue(device.getBattery_level()));
+ batteryVoltageLabel.setText(formatDeviceValue(device.getBattery_voltage()));
+ operationModeLabel.setText(formatDeviceValue(device.getOperation_mode()));
+ motorStatusLabel.setText(formatDeviceValue(device.getMotor_status()));
+ bladeStatusLabel.setText(formatDeviceValue(device.getBlade_status()));
+ bladeHeightLabel.setText(formatDeviceValue(device.getBlade_height()));
+ selfCheckStatusLabel.setText(formatDeviceValue(device.getSelf_check_status()));
+ errorCodeLabel.setText(formatDeviceValue(device.getError_code()));
+ errorMessageLabel.setText(formatDeviceValue(device.getError_message()));
+ rollLabel.setText(formatDeviceValue(device.getRoll()));
+ pitchLabel.setText(formatDeviceValue(device.getPitch()));
+ yawLabel.setText(formatDeviceValue(device.getYaw()));
+
updateTimeLabel.setText(formatTimestamp(device.getGupdateTime()));
}
@@ -344,6 +433,21 @@
if (satelliteCountLabel != null) satelliteCountLabel.setText(value);
if (realtimeSpeedLabel != null) realtimeSpeedLabel.setText(value);
if (headingLabel != null) headingLabel.setText(value);
+
+ if (pathIdLabel != null) pathIdLabel.setText(value);
+ if (batteryLevelLabel != null) batteryLevelLabel.setText(value);
+ if (batteryVoltageLabel != null) batteryVoltageLabel.setText(value);
+ if (operationModeLabel != null) operationModeLabel.setText(value);
+ if (motorStatusLabel != null) motorStatusLabel.setText(value);
+ if (bladeStatusLabel != null) bladeStatusLabel.setText(value);
+ if (bladeHeightLabel != null) bladeHeightLabel.setText(value);
+ if (selfCheckStatusLabel != null) selfCheckStatusLabel.setText(value);
+ if (errorCodeLabel != null) errorCodeLabel.setText(value);
+ if (errorMessageLabel != null) errorMessageLabel.setText(value);
+ if (rollLabel != null) rollLabel.setText(value);
+ if (pitchLabel != null) pitchLabel.setText(value);
+ if (yawLabel != null) yawLabel.setText(value);
+
if (updateTimeLabel != null) updateTimeLabel.setText(value);
}
@@ -406,4 +510,18 @@
return sanitized;
}
}
+
+ private void addLabelRow(JPanel grid, GridBagConstraints gbc, int row, String title, JLabel valueLabel, Font titleFont, Font valueFont) {
+ gbc.gridx = 0; gbc.gridy = row;
+ gbc.weightx = 0.3;
+ JLabel label = new JLabel(title);
+ label.setFont(titleFont);
+ label.setForeground(new Color(102, 102, 102));
+ grid.add(label, gbc);
+
+ gbc.gridx = 1; gbc.gridy = row;
+ gbc.weightx = 0.7;
+ valueLabel.setFont(valueFont);
+ grid.add(valueLabel, gbc);
+ }
}
\ No newline at end of file
diff --git a/src/gecaoji/gecaojistatus.java b/src/gecaoji/gecaojistatus.java
new file mode 100644
index 0000000..11a5eb6
--- /dev/null
+++ b/src/gecaoji/gecaojistatus.java
@@ -0,0 +1,68 @@
+package gecaoji;
+
+import Mqttmessage.Entity.GPSData.StatusInfo;
+
+/**
+ * 鍓茶崏鏈虹姸鎬佽В鏋愮被
+ * 鐢ㄤ簬瑙f瀽鏀跺埌鐨勫壊鑽夋満鐘舵�佹暟鎹�
+ */
+public class gecaojistatus {
+// "path_id_saved": 15865475, // 瀛樺偍鐨勮矾寰処D
+// "battery_level": 85, // 鐢垫睜鐢甸噺鐧惧垎姣�
+// "battery_voltage": 24.5, // 鐢垫睜鐢靛帇
+// "operation_mode": "auto", // 鎿嶄綔妯″紡锛歮anual, auto, emergency_stop
+// "motor_status": "running", // 鐢垫満鐘舵�侊細stopped, running, error
+// "blade_status": "rotating", // 鍒�鐗囩姸鎬侊細stopped, rotating
+// "blade_height": 10,//鍒�鐩橀珮搴� 鍘樼背
+// "self_check_status": 1, // 鏂板鑷鐘舵�侊細1-瀹屾垚锛�0-鏈畬鎴�
+// "error_code": 0, // 閿欒浠g爜
+// "error_message": "", // 閿欒淇℃伅
+
+
+
+ /**
+ * 瑙f瀽鐘舵�佹暟鎹瓧绗︿覆
+ * @param status 鎺ユ敹鍒扮殑鐘舵�佸璞�
+ */
+ public static void parseStatus(StatusInfo status) {
+ if (status != null) {
+ Device device = Device.getGecaoji();
+ if (device == null) {
+ return;
+ }
+
+ if (status.getPath_id_saved() != null) {
+ device.setPath_id_saved(String.valueOf(status.getPath_id_saved()));
+ }
+ if (status.getBattery_level() != null) {
+ device.setBattery_level(String.valueOf(status.getBattery_level()));
+ }
+ if (status.getBattery_voltage() != null) {
+ device.setBattery_voltage(String.valueOf(status.getBattery_voltage()));
+ }
+ if (status.getOperation_mode() != null) {
+ device.setOperation_mode(status.getOperation_mode());
+ }
+ if (status.getMotor_status() != null) {
+ device.setMotor_status(status.getMotor_status());
+ }
+ if (status.getBlade_status() != null) {
+ device.setBlade_status(status.getBlade_status());
+ }
+ if (status.getBlade_height() != null) {
+ device.setBlade_height(String.valueOf(status.getBlade_height()));
+ }
+ if (status.getSelf_check_status() != null) {
+ device.setSelf_check_status(String.valueOf(status.getSelf_check_status()));
+ }
+ if (status.getError_code() != null) {
+ device.setError_code(String.valueOf(status.getError_code()));
+ }
+ if (status.getError_message() != null) {
+ device.setError_message(status.getError_message());
+ }
+ }
+ }
+
+
+}
diff --git a/src/publicway/Gpstoxuzuobiao.java b/src/publicway/Gpstoxuzuobiao.java
index 072d319..f961447 100644
--- a/src/publicway/Gpstoxuzuobiao.java
+++ b/src/publicway/Gpstoxuzuobiao.java
@@ -33,7 +33,7 @@
* @return double[]{x, y} 鐩稿鍧愭爣
*/
public static double[] processGNGGAToXY(String gnggaData, double baseLat, double baseLon) {
- if (gnggaData == null || !gnggaData.contains("$GNGGA")) {
+ if (gnggaData == null) {
return null;
}
@@ -41,10 +41,10 @@
// 鏍煎紡: $GNGGA,hhmmss.ss,lat,latDir,lon,lonDir,quality,sats,hdop,alt,units,sep,units,age,refID*cs
String[] parts = gnggaData.split(",");
- // 鎵惧埌$GNGGA鐨勪綅缃�
+ // 鎵惧埌$GNGGA/$GPGGA/$GBGGA鐨勪綅缃�
int index = -1;
for(int i=0; i<parts.length; i++) {
- if (parts[i].contains("$GNGGA")) {
+ if (parts[i].contains("$GNGGA") || parts[i].contains("$GPGGA") || parts[i].contains("$GBGGA")) {
index = i;
break;
}
diff --git a/src/set/Setsys.java b/src/set/Setsys.java
index a9ac06d..bff9a33 100644
--- a/src/set/Setsys.java
+++ b/src/set/Setsys.java
@@ -274,6 +274,14 @@
System.out.println("idleTrailDurationSeconds: " + idleTrailDurationSeconds);
}
+ /**
+ * 鑾峰彇鍓茶崏鏈虹紪鍙�
+ * @return 鍓茶崏鏈虹紪鍙�
+ */
+ public static String getMowerIdValue() {
+ return getPropertyValue("mowerId");
+ }
+
// 鏍规嵁set.properties涓殑閿悕鑾峰彇瀵瑰簲鐨勫�硷紝娌℃湁鎴栦负-1鏃惰繑鍥瀗ull
public static String getPropertyValue(String key) {
if (key == null || key.trim().isEmpty()) {
diff --git a/src/udpdell/UDPServer.java b/src/udpdell/UDPServer.java
index e63131c..a39a094 100644
--- a/src/udpdell/UDPServer.java
+++ b/src/udpdell/UDPServer.java
@@ -104,6 +104,7 @@
/** 澶勭悊涓插彛鎺ユ敹鍒扮殑鏁版嵁 */
public static void processSerialData(String message) {
+ message=message.replace("GPGGA", "GNGGA");
String[] fields = message.split(",");
// 妫�鏌ュ瓧娈垫暟閲忔槸鍚﹀畬鏁�
if (fields.length < 15) {
diff --git a/src/user/Usrdell.java b/src/user/Usrdell.java
index 7133439..daafd0b 100644
--- a/src/user/Usrdell.java
+++ b/src/user/Usrdell.java
@@ -133,6 +133,14 @@
}
/**
+ * 鑾峰彇鐢ㄦ埛閭
+ * @return 鐢ㄦ埛閭
+ */
+ public static String getUserEmail() {
+ return getEmail();
+ }
+
+ /**
* 鑾峰彇璇█璁剧疆
* @return 璇█璁剧疆
*/
diff --git a/src/zhuye/Coordinate.java b/src/zhuye/Coordinate.java
index af2c5b3..644953d 100644
--- a/src/zhuye/Coordinate.java
+++ b/src/zhuye/Coordinate.java
@@ -79,34 +79,24 @@
/**
- * 瑙f瀽GNGGA鏁版嵁杩斿洖Coordinate瀵硅薄鍒楄〃锛堝寮虹増锛屽寘鍚珮绋嬫暟鎹級
+ * 瑙f瀽GNGGA/GPGGA/GBGGA鏁版嵁杩斿洖Coordinate瀵硅薄鍒楄〃锛堝寮虹増锛屽寘鍚珮绋嬫暟鎹級
*/
public static void parseGNGGAToCoordinateList(String gnggaData) {
if (!isStartSaveGngga || gnggaData == null || gnggaData.isEmpty()) {
return;
}
- // 澶勭悊瀹屾暣鐨凣NGGA鏁版嵁锛堝彲鑳藉寘鍚�$GNGGA鍓嶇紑锛�
String cleaned = gnggaData.trim();
- if (cleaned.startsWith("$GNGGA")) {
- // 濡傛灉鏁版嵁浠�$GNGGA寮�澶达紝鐩存帴瑙f瀽
- String record = cleaned.substring("$GNGGA".length());
+ // 浣跨敤姝e垯鍒嗗壊鏀寔澶氱澶撮儴
+ String[] records = cleaned.split("\\$(GN|GP|GB)GGA");
+ for (String record : records) {
+ if (record == null || record.trim().isEmpty()) {
+ continue;
+ }
Coordinate coord = parseSingleGnggaRecord(record, false);
if (coord != null) {
coordinates.add(coord);
}
- } else {
- // 澶勭悊鍙兘鍖呭惈澶氫釜$GNGGA璁板綍鐨勬儏鍐�
- String[] records = cleaned.split("\\$GNGGA");
- for (String record : records) {
- if (record == null || record.trim().isEmpty()) {
- continue; // 璺宠繃绌哄瓧绗︿覆锛坰plit浜х敓鐨勭涓�涓厓绱犲彲鑳芥槸绌虹殑锛�
- }
- Coordinate coord = parseSingleGnggaRecord(record, false);
- if (coord != null) {
- coordinates.add(coord);
- }
- }
}
}
@@ -123,9 +113,19 @@
return null;
}
- int markerIndex = cleaned.indexOf("$GNGGA");
+ int markerIndex = -1;
+ String[] headers = {"$GNGGA", "$GPGGA", "$GBGGA"};
+
+ // 鎵惧埌鏈�鏃╁嚭鐜扮殑澶撮儴
+ for (String header : headers) {
+ int idx = cleaned.indexOf(header);
+ if (idx >= 0 && (markerIndex == -1 || idx < markerIndex)) {
+ markerIndex = idx;
+ }
+ }
+
String record = markerIndex >= 0
- ? cleaned.substring(markerIndex + "$GNGGA".length())
+ ? cleaned.substring(markerIndex + 6) // 鎵�鏈夊ご閮ㄩ暱搴﹀潎涓�6
: cleaned;
Coordinate coordinate = parseSingleGnggaRecord(record, true);
@@ -168,7 +168,8 @@
return null;
}
- if (fixQuality != 4) {
+ // 淇敼涓哄厑璁搁潪RTK鍥哄畾瑙d篃鑳芥樉绀轰綅缃�(鍙涓嶆槸鏃犳晥瀹氫綅0鍗冲彲)
+ if (fixQuality == 0) {
return null;
}
diff --git a/src/zhuye/Shouye.java b/src/zhuye/Shouye.java
index 6ec9021..f7da141 100644
--- a/src/zhuye/Shouye.java
+++ b/src/zhuye/Shouye.java
@@ -113,10 +113,13 @@
private final Consumer<String> serialLineListener = line -> {
SwingUtilities.invokeLater(() -> {
updateDataPacketCountLabel();
- // 濡傛灉鏀跺埌$GNGGA鏁版嵁锛岀珛鍗虫洿鏂版嫋灏�
- if (line != null && line.trim().startsWith("$GNGGA")) {
- if (mapRenderer != null && !pathPreviewActive) {
- mapRenderer.forceUpdateIdleMowerTrail();
+ // 濡傛灉鏀跺埌GGA鏁版嵁锛岀珛鍗虫洿鏂版嫋灏�
+ if (line != null) {
+ String trimmed = line.trim();
+ if (trimmed.startsWith("$GNGGA") || trimmed.startsWith("$GPGGA") || trimmed.startsWith("$GBGGA")) {
+ if (mapRenderer != null && !pathPreviewActive) {
+ mapRenderer.forceUpdateIdleMowerTrail();
+ }
}
}
});
diff --git a/user.properties b/user.properties
index 3259eac..ed311c0 100644
--- a/user.properties
+++ b/user.properties
@@ -1,6 +1,6 @@
#Updated User Properties
#Wed Dec 24 17:05:38 CST 2025
-email=789
+email=7892584@qq.com
language=zh
lastLoginTime=1766567138180
password=123
--
Gitblit v1.10.0