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());
|
}
|
}
|
}
|
|
|
}
|