张世豪
2 天以前 c9b1d33979b3972fe6a82fa427b4ba9a20989112
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package gecaoji;
 
import Mqttmessage.Entity.GPSData.StatusInfo;
 
/**
 * 割草机状态解析类
 * 用于解析收到的割草机状态数据
 */
public class gecaojistatus {
//    "path_id_saved": 15865475, // 存储的路径ID
//      "battery_level": 85, // 电池电量百分比
//      "battery_voltage": 24.5, // 电池电压
//      "operation_mode": "auto", // 操作模式:manual, 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, // 错误代码
//      "error_message": "", // 错误信息
    
 
 
    /**
     * 解析状态数据字符串
     * @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());
            }
        } 
    }
 
   
}