#更新实时消息具体字段
This commit is contained in:
@@ -7,12 +7,14 @@ public class DeviceMapPushDTO {
|
|||||||
private String id;
|
private String id;
|
||||||
private double lat;
|
private double lat;
|
||||||
private double lng;
|
private double lng;
|
||||||
private double y; //yaw
|
private double y; // yaw
|
||||||
private String f; //fix_status
|
private String f; // fix_status
|
||||||
private double a; //altitude
|
private double a; // altitude
|
||||||
private String s;//status 运行状态
|
private String s;// status 运行状态
|
||||||
private Long t; //taskId 任务id
|
private Long t; // taskId 任务id
|
||||||
private double b; //电量
|
private double b; // 电量
|
||||||
private boolean ha = false;//hasAlarm 有无告警
|
private boolean ha = false;// hasAlarm 有无告警
|
||||||
|
|
||||||
|
private String cm;// 控制模式 manual_remote|auto
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,30 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class VehicleMessage {
|
public class VehicleMessage {
|
||||||
|
|
||||||
private double speed;
|
private double battery_percentage;// 实时电量百分比
|
||||||
private double battery_percentage;// 电量
|
private double battery_voltage;// 实时电压
|
||||||
private double battery_voltage;// 电压
|
|
||||||
private String motion;// moving|stopped|blocked
|
|
||||||
private boolean emergency_stop; // 急停状态
|
|
||||||
|
|
||||||
private double distance; // 里程数
|
private double left_motor_current;// 实时左电机电流
|
||||||
|
private double right_motor_current;// 实时右电机电流
|
||||||
|
private double left_motor_temperature;// 实时左电机温度
|
||||||
|
private double right_motor_temperature;// 实时右电机温度
|
||||||
|
private double main_temperature;// 实时主温度
|
||||||
|
private double yaw;// 实时航向角度
|
||||||
|
private double pitch;// 实时俯仰角度
|
||||||
|
private String heading_status;// 实时航向状态
|
||||||
|
private double total_work_area;// 累计作业面积
|
||||||
|
private double total_work_duration;// 累计作业时长
|
||||||
|
private double total_work_distance;// 累计作业里程
|
||||||
|
private String motion;// moving|stopped|blocked 运动状态
|
||||||
|
private Boolean emergency_stop; // 急停状态
|
||||||
|
|
||||||
|
private double left_target_rpm; // 实时左电机目标转速
|
||||||
|
private double right_target_rpm;// 实时右电机目标转速
|
||||||
|
private double left_measured_rpm;// 实时左电机测量转速
|
||||||
|
private double right_measured_rpm;// 实时右电机测量转速
|
||||||
|
private double left_motor_rpm;// 实时左电机转速
|
||||||
|
private double right_motor_rpm;// 实时右电机转速
|
||||||
|
private double roll;// 实时翻滚角度
|
||||||
|
private String control_mode;// 遥控器拨杆对应的当前控制模式
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.springframework.util.CollectionUtils;
|
|||||||
|
|
||||||
import com.maibu.core.domain.entity.SysSite;
|
import com.maibu.core.domain.entity.SysSite;
|
||||||
import com.maibu.core.enums.ErrorSource;
|
import com.maibu.core.enums.ErrorSource;
|
||||||
|
import com.maibu.core.host.VehicleMessage;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -59,6 +60,20 @@ public class SiteMemory {
|
|||||||
|
|
||||||
public static ConcurrentHashMap<String, DeviceMapPushDTO> deviceMapPushMap = new ConcurrentHashMap<>();
|
public static ConcurrentHashMap<String, DeviceMapPushDTO> deviceMapPushMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public static ConcurrentHashMap<String, VehicleMessage> vehicleMessageMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public VehicleMessage getVehicleMessage(String deviceId) {
|
||||||
|
return vehicleMessageMap.get(deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveVehicleMessage(String deviceId, VehicleMessage vehicleMessage) {
|
||||||
|
vehicleMessageMap.put(deviceId, vehicleMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeVehicleMessage(String deviceId) {
|
||||||
|
vehicleMessageMap.remove(deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, DeviceMapPushDTO> getAllDeviceMapPush() {
|
public Map<String, DeviceMapPushDTO> getAllDeviceMapPush() {
|
||||||
return deviceMapPushMap;
|
return deviceMapPushMap;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,6 +148,15 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
locationMessage.setDeviceId(deviceId);
|
locationMessage.setDeviceId(deviceId);
|
||||||
redisCache.setCacheObject(key, locationMessage);
|
redisCache.setCacheObject(key, locationMessage);
|
||||||
|
|
||||||
|
// todo 推送实时位置和状态消息到外部
|
||||||
|
try {
|
||||||
|
GlobalMemory.customMqttDeviceMonitor.publish(mqttClientId,
|
||||||
|
String.format(MqttTopic.DEVICE_LOCATION_MESSAGE_TOPIC, deviceId),
|
||||||
|
JsonUtils.toJsonString(locationRelTimeDTO));
|
||||||
|
} catch (MqttException e) {
|
||||||
|
log.error("位置实时数据推送失败: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("位置消息解析失败: deviceId={}, payload={}, error={}", deviceId, payload, e);
|
log.error("位置消息解析失败: deviceId={}, payload={}, error={}", deviceId, payload, e);
|
||||||
@@ -227,7 +236,6 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
DeviceMapPushDTO dto = new DeviceMapPushDTO();
|
DeviceMapPushDTO dto = new DeviceMapPushDTO();
|
||||||
dto.setA(Double.parseDouble(altitude.getValue()));
|
dto.setA(Double.parseDouble(altitude.getValue()));
|
||||||
dto.setId(deviceId);
|
dto.setId(deviceId);
|
||||||
// dto.setB();
|
|
||||||
// dto.setHa();
|
// dto.setHa();
|
||||||
dto.setF(fix_status.getValue());
|
dto.setF(fix_status.getValue());
|
||||||
dto.setS(status.getValue());
|
dto.setS(status.getValue());
|
||||||
@@ -235,6 +243,12 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
dto.setLng(Double.parseDouble(lng.getValue()));
|
dto.setLng(Double.parseDouble(lng.getValue()));
|
||||||
dto.setT(nettyDevice.getCurrentTaskId());
|
dto.setT(nettyDevice.getCurrentTaskId());
|
||||||
dto.setY(Double.parseDouble(yaw.getValue()));
|
dto.setY(Double.parseDouble(yaw.getValue()));
|
||||||
|
siteMemory.getVehicleMessage(deviceId);
|
||||||
|
VehicleMessage vehicleMessage = siteMemory.getVehicleMessage(deviceId);
|
||||||
|
if (vehicleMessage != null) {
|
||||||
|
dto.setCm(vehicleMessage.getControl_mode());
|
||||||
|
dto.setB(vehicleMessage.getBattery_percentage());
|
||||||
|
}
|
||||||
siteMemory.saveMapPushDTO(deviceId, dto);
|
siteMemory.saveMapPushDTO(deviceId, dto);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,17 +262,82 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
WebStatusMessageDTO webStatusMessageDTO = new WebStatusMessageDTO();
|
WebStatusMessageDTO webStatusMessageDTO = new WebStatusMessageDTO();
|
||||||
List<DeviceStatusDetail> transferData = new ArrayList<>();
|
List<DeviceStatusDetail> transferData = new ArrayList<>();
|
||||||
DeviceStatusDetail voltage = new DeviceStatusDetail();
|
DeviceStatusDetail voltage = new DeviceStatusDetail();
|
||||||
voltage.setName("voltage");
|
voltage.setName("battery_percentage");
|
||||||
voltage.setValue(String.valueOf(vehicleRelTimeDTO.getData().getBattery_voltage()));
|
voltage.setValue(String.valueOf(vehicleRelTimeDTO.getData().getBattery_percentage()));
|
||||||
voltage.setUnit("");
|
voltage.setUnit("");
|
||||||
|
|
||||||
transferData.add(voltage);
|
transferData.add(voltage);
|
||||||
|
|
||||||
DeviceStatusDetail speed = new DeviceStatusDetail();
|
DeviceStatusDetail battery_voltage = new DeviceStatusDetail();
|
||||||
speed.setName("speed");
|
battery_voltage.setName("battery_voltage");
|
||||||
speed.setValue(String.valueOf(vehicleRelTimeDTO.getData().getSpeed()));
|
battery_voltage.setValue(String.valueOf(vehicleRelTimeDTO.getData().getBattery_voltage()));
|
||||||
speed.setUnit("");
|
battery_voltage.setUnit("");
|
||||||
transferData.add(speed);
|
transferData.add(battery_voltage);
|
||||||
|
|
||||||
|
DeviceStatusDetail left_motor_current = new DeviceStatusDetail();
|
||||||
|
left_motor_current.setName("left_motor_current");
|
||||||
|
left_motor_current.setValue(String.valueOf(vehicleRelTimeDTO.getData().getLeft_motor_current()));
|
||||||
|
left_motor_current.setUnit("");
|
||||||
|
transferData.add(left_motor_current);
|
||||||
|
|
||||||
|
DeviceStatusDetail right_motor_current = new DeviceStatusDetail();
|
||||||
|
right_motor_current.setName("right_motor_current");
|
||||||
|
right_motor_current.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRight_motor_current()));
|
||||||
|
right_motor_current.setUnit("");
|
||||||
|
transferData.add(right_motor_current);
|
||||||
|
|
||||||
|
DeviceStatusDetail left_motor_temperature = new DeviceStatusDetail();
|
||||||
|
left_motor_temperature.setName("left_motor_temperature");
|
||||||
|
left_motor_temperature.setValue(String.valueOf(vehicleRelTimeDTO.getData().getLeft_motor_temperature()));
|
||||||
|
left_motor_temperature.setUnit("");
|
||||||
|
transferData.add(left_motor_temperature);
|
||||||
|
|
||||||
|
DeviceStatusDetail right_motor_temperature = new DeviceStatusDetail();
|
||||||
|
right_motor_temperature.setName("right_motor_temperature");
|
||||||
|
right_motor_temperature.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRight_motor_temperature()));
|
||||||
|
right_motor_temperature.setUnit("");
|
||||||
|
transferData.add(right_motor_temperature);
|
||||||
|
|
||||||
|
DeviceStatusDetail main_temperature = new DeviceStatusDetail();
|
||||||
|
main_temperature.setName("main_temperature");
|
||||||
|
main_temperature.setValue(String.valueOf(vehicleRelTimeDTO.getData().getMain_temperature()));
|
||||||
|
main_temperature.setUnit("");
|
||||||
|
transferData.add(main_temperature);
|
||||||
|
|
||||||
|
DeviceStatusDetail yaw = new DeviceStatusDetail();
|
||||||
|
yaw.setName("yaw");
|
||||||
|
yaw.setValue(String.valueOf(vehicleRelTimeDTO.getData().getYaw()));
|
||||||
|
yaw.setUnit("");
|
||||||
|
transferData.add(yaw);
|
||||||
|
|
||||||
|
DeviceStatusDetail pitch = new DeviceStatusDetail();
|
||||||
|
pitch.setName("pitch");
|
||||||
|
pitch.setValue(String.valueOf(vehicleRelTimeDTO.getData().getPitch()));
|
||||||
|
pitch.setUnit("");
|
||||||
|
transferData.add(pitch);
|
||||||
|
|
||||||
|
DeviceStatusDetail heading_status = new DeviceStatusDetail();
|
||||||
|
heading_status.setName("heading_status");
|
||||||
|
heading_status.setValue(String.valueOf(vehicleRelTimeDTO.getData().getHeading_status()));
|
||||||
|
heading_status.setUnit("");
|
||||||
|
transferData.add(heading_status);
|
||||||
|
|
||||||
|
DeviceStatusDetail total_work_area = new DeviceStatusDetail();
|
||||||
|
total_work_area.setName("total_work_area");
|
||||||
|
total_work_area.setValue(String.valueOf(vehicleRelTimeDTO.getData().getTotal_work_area()));
|
||||||
|
total_work_area.setUnit("");
|
||||||
|
transferData.add(total_work_area);
|
||||||
|
|
||||||
|
DeviceStatusDetail total_work_duration = new DeviceStatusDetail();
|
||||||
|
total_work_duration.setName("total_work_duration");
|
||||||
|
total_work_duration.setValue(String.valueOf(vehicleRelTimeDTO.getData().getTotal_work_duration()));
|
||||||
|
total_work_duration.setUnit("");
|
||||||
|
transferData.add(total_work_duration);
|
||||||
|
|
||||||
|
DeviceStatusDetail total_work_distance = new DeviceStatusDetail();
|
||||||
|
total_work_distance.setName("total_work_distance");
|
||||||
|
total_work_distance.setValue(String.valueOf(vehicleRelTimeDTO.getData().getTotal_work_distance()));
|
||||||
|
total_work_distance.setUnit("");
|
||||||
|
transferData.add(total_work_distance);
|
||||||
|
|
||||||
DeviceStatusDetail motion = new DeviceStatusDetail();
|
DeviceStatusDetail motion = new DeviceStatusDetail();
|
||||||
motion.setName("motion");
|
motion.setName("motion");
|
||||||
@@ -266,11 +345,59 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
motion.setUnit("");
|
motion.setUnit("");
|
||||||
transferData.add(motion);
|
transferData.add(motion);
|
||||||
|
|
||||||
DeviceStatusDetail percentage = new DeviceStatusDetail();
|
DeviceStatusDetail emergency_stop = new DeviceStatusDetail();
|
||||||
percentage.setName("percentage");
|
emergency_stop.setName("emergency_stop");
|
||||||
percentage.setValue(String.valueOf(vehicleRelTimeDTO.getData().getBattery_percentage()));
|
emergency_stop.setValue(String.valueOf(vehicleRelTimeDTO.getData().getEmergency_stop()));
|
||||||
percentage.setUnit("");
|
emergency_stop.setUnit("");
|
||||||
transferData.add(percentage);
|
transferData.add(emergency_stop);
|
||||||
|
|
||||||
|
DeviceStatusDetail left_target_rpm = new DeviceStatusDetail();
|
||||||
|
left_target_rpm.setName("left_target_rpm");
|
||||||
|
left_target_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getLeft_target_rpm()));
|
||||||
|
left_target_rpm.setUnit("");
|
||||||
|
transferData.add(left_target_rpm);
|
||||||
|
|
||||||
|
DeviceStatusDetail right_target_rpm = new DeviceStatusDetail();
|
||||||
|
right_target_rpm.setName("right_target_rpm");
|
||||||
|
right_target_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRight_target_rpm()));
|
||||||
|
right_target_rpm.setUnit("");
|
||||||
|
transferData.add(right_target_rpm);
|
||||||
|
|
||||||
|
DeviceStatusDetail left_measured_rpm = new DeviceStatusDetail();
|
||||||
|
left_measured_rpm.setName("left_measured_rpm");
|
||||||
|
left_measured_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getLeft_measured_rpm()));
|
||||||
|
left_measured_rpm.setUnit("");
|
||||||
|
transferData.add(left_measured_rpm);
|
||||||
|
|
||||||
|
DeviceStatusDetail right_measured_rpm = new DeviceStatusDetail();
|
||||||
|
right_measured_rpm.setName("right_measured_rpm");
|
||||||
|
right_measured_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRight_measured_rpm()));
|
||||||
|
right_measured_rpm.setUnit("");
|
||||||
|
transferData.add(right_measured_rpm);
|
||||||
|
|
||||||
|
DeviceStatusDetail left_motor_rpm = new DeviceStatusDetail();
|
||||||
|
left_motor_rpm.setName("left_motor_rpm");
|
||||||
|
left_motor_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getLeft_motor_rpm()));
|
||||||
|
left_motor_rpm.setUnit("");
|
||||||
|
transferData.add(left_motor_rpm);
|
||||||
|
|
||||||
|
DeviceStatusDetail right_motor_rpm = new DeviceStatusDetail();
|
||||||
|
right_motor_rpm.setName("right_motor_rpm");
|
||||||
|
right_motor_rpm.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRight_motor_rpm()));
|
||||||
|
right_motor_rpm.setUnit("");
|
||||||
|
transferData.add(right_motor_rpm);
|
||||||
|
|
||||||
|
DeviceStatusDetail roll = new DeviceStatusDetail();
|
||||||
|
roll.setName("roll");
|
||||||
|
roll.setValue(String.valueOf(vehicleRelTimeDTO.getData().getRoll()));
|
||||||
|
roll.setUnit("");
|
||||||
|
transferData.add(roll);
|
||||||
|
|
||||||
|
DeviceStatusDetail control_mode = new DeviceStatusDetail();
|
||||||
|
control_mode.setName("control_mode");
|
||||||
|
control_mode.setValue(String.valueOf(vehicleRelTimeDTO.getData().getControl_mode()));
|
||||||
|
control_mode.setUnit("");
|
||||||
|
transferData.add(control_mode);
|
||||||
|
|
||||||
webStatusMessageDTO.setData(transferData);
|
webStatusMessageDTO.setData(transferData);
|
||||||
webStatusMessageDTO.setType(MesType.deviceInfo);
|
webStatusMessageDTO.setType(MesType.deviceInfo);
|
||||||
@@ -287,7 +414,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
if (vehicleRelTimeDTO != null) {
|
if (vehicleRelTimeDTO != null) {
|
||||||
|
|
||||||
// todo 更新里程数 里程数 * 割幅0.8
|
// todo 更新里程数 里程数 * 割幅0.8
|
||||||
vehicleRelTimeDTO.getData().getDistance();
|
vehicleRelTimeDTO.getData().getTotal_work_distance();
|
||||||
NettyDevice nettyDevice = deviceSessionManager.getDevice(deviceId);
|
NettyDevice nettyDevice = deviceSessionManager.getDevice(deviceId);
|
||||||
if (nettyDevice != null) {
|
if (nettyDevice != null) {
|
||||||
Long orgId = nettyDevice.getDevice().getOrgId();
|
Long orgId = nettyDevice.getDevice().getOrgId();
|
||||||
@@ -299,9 +426,11 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
deviceRunStatistics = new DeviceRunStatistics();
|
deviceRunStatistics = new DeviceRunStatistics();
|
||||||
}
|
}
|
||||||
deviceRunStatistics.setDeviceId(deviceId);
|
deviceRunStatistics.setDeviceId(deviceId);
|
||||||
deviceRunStatistics.setDistance(vehicleRelTimeDTO.getData().getDistance());
|
deviceRunStatistics.setDistance(vehicleRelTimeDTO.getData().getTotal_work_distance());
|
||||||
deviceRunStatistics.setWorkArea(vehicleRelTimeDTO.getData().getDistance() * 0.8);
|
deviceRunStatistics.setWorkArea(vehicleRelTimeDTO.getData().getTotal_work_distance() * 0.8);
|
||||||
siteMemory.saveRunStatistics(deviceRunStatistics);
|
siteMemory.saveRunStatistics(deviceRunStatistics);
|
||||||
|
|
||||||
|
siteMemory.saveVehicleMessage(deviceId, vehicleRelTimeDTO.getData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,6 +447,14 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// todo 推送实时位置和状态消息到外部
|
||||||
|
try {
|
||||||
|
GlobalMemory.customMqttDeviceMonitor.publish(mqttClientId,
|
||||||
|
String.format(MqttTopic.DEVICE_VEHICLE_MESSAGE_TOPIC, deviceId),
|
||||||
|
JsonUtils.toJsonString(vehicleRelTimeDTO));
|
||||||
|
} catch (MqttException e) {
|
||||||
|
log.error("位置实时数据推送失败: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("实时消息解析失败: deviceId={}, payload={}, error={}", deviceId, payload, e.getMessage());
|
log.error("实时消息解析失败: deviceId={}, payload={}, error={}", deviceId, payload, e.getMessage());
|
||||||
@@ -371,7 +508,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
try {
|
try {
|
||||||
websocketMesDispather.dispather(x.getConnectorId(), JsonUtils.toJsonString(sendDto));
|
websocketMesDispather.dispather(x.getConnectorId(), JsonUtils.toJsonString(sendDto));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("实时数据websocket推送失败: connectorId={}, error={}", x.getConnectorId(),
|
log.error("实时数据websocket任务状态推送失败: connectorId={}, error={}", x.getConnectorId(),
|
||||||
e.getMessage());
|
e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,8 +519,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
String.format(MqttTopic.DEVICE_TASK_STATUS_TOPIC, taskId),
|
String.format(MqttTopic.DEVICE_TASK_STATUS_TOPIC, taskId),
|
||||||
JsonUtils.toJsonString(sendDto));
|
JsonUtils.toJsonString(sendDto));
|
||||||
} catch (MqttException e) {
|
} catch (MqttException e) {
|
||||||
// TODO Auto-generated catch block
|
log.error("实时数据websocket任务状态推送失败: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -451,7 +587,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
websocketMesDispather.dispather(x.getConnectorId(), JsonUtils.toJsonString(sendDto));
|
websocketMesDispather.dispather(x.getConnectorId(), JsonUtils.toJsonString(sendDto));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("实时数据websocket推送失败: connectorId={}, error={}", x.getConnectorId(),
|
log.error("实时数据websocket推送失败: connectorId={}, error={}", x.getConnectorId(),
|
||||||
e.getMessage());
|
e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -461,8 +597,7 @@ public class HostMessageHandler implements CustomMqttMessageHandler {
|
|||||||
String.format(MqttTopic.DEVICE_TASK_STATUS_TOPIC, device.getTask().getId()),
|
String.format(MqttTopic.DEVICE_TASK_STATUS_TOPIC, device.getTask().getId()),
|
||||||
JsonUtils.toJsonString(sendDto));
|
JsonUtils.toJsonString(sendDto));
|
||||||
} catch (MqttException e) {
|
} catch (MqttException e) {
|
||||||
// TODO Auto-generated catch block
|
log.error("实时数据websocket推送失败: deviceId={}, error={}", deviceId, e.getMessage(), e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ public class MqttTopic {
|
|||||||
/** 通用设备主题,建议使用 MOWER_* 系列主题 */
|
/** 通用设备主题,建议使用 MOWER_* 系列主题 */
|
||||||
public static final String DEVICE_STATUS_TOPIC = "device/%s/realTimeMessage";
|
public static final String DEVICE_STATUS_TOPIC = "device/%s/realTimeMessage";
|
||||||
|
|
||||||
public static final String DEVICE_LOCATION_TOPIC = "device/%s/locationMessage";
|
public static final String DEVICE_VEHICLE_MESSAGE_TOPIC = "device/%s/host/realTime/message";
|
||||||
|
|
||||||
|
public static final String DEVICE_LOCATION_MESSAGE_TOPIC = "device/%s/host/location/message";
|
||||||
/** 通用设备主题,建议使用 MOWER_* 系列主题 */
|
/** 通用设备主题,建议使用 MOWER_* 系列主题 */
|
||||||
public static final String DEVICE_TASK_STATUS_TOPIC = "task/%s/status";
|
public static final String DEVICE_TASK_STATUS_TOPIC = "task/%s/status";
|
||||||
/** 通用设备主题,建议使用 MOWER_* 系列主题 */
|
/** 通用设备主题,建议使用 MOWER_* 系列主题 */
|
||||||
|
|||||||
@@ -350,6 +350,7 @@ public class DeviceThreadService {
|
|||||||
}
|
}
|
||||||
// todo 删除实时消息推送里面的数据
|
// todo 删除实时消息推送里面的数据
|
||||||
siteMemory.removeMapPushDTO(deviceId);
|
siteMemory.removeMapPushDTO(deviceId);
|
||||||
|
siteMemory.removeVehicleMessage(deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
statusChangePush(deviceId, siteId, 0);
|
statusChangePush(deviceId, siteId, 0);
|
||||||
@@ -386,12 +387,14 @@ public class DeviceThreadService {
|
|||||||
if (slaveDevice != null) {
|
if (slaveDevice != null) {
|
||||||
slaveDevice.setOnlineStatus(1);
|
slaveDevice.setOnlineStatus(1);
|
||||||
slaveDevice.setDevice(device);
|
slaveDevice.setDevice(device);
|
||||||
|
statusChangePush(deviceId, device.getSiteId(), 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// todo 推送设备上线
|
// todo 推送设备上线
|
||||||
nettyDevice.status(1);
|
nettyDevice.status(1);
|
||||||
nettyDevice.setDevice(device);
|
nettyDevice.setDevice(device);
|
||||||
statusChangePush(deviceId, nettyDevice.getDevice().getSiteId(), 1);
|
nettyDevice.setConnectorStatus(ConnectorStatus.ACTIVE);
|
||||||
|
statusChangePush(deviceId, device.getSiteId(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class ControlUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] buildControlCommand(LawnMoverProtocolEntity entity) {
|
public static byte[] buildControlCommand(LawnMoverProtocolEntity entity) {
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(27);
|
ByteBuffer buffer = ByteBuffer.allocate(27); // 15
|
||||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||||
|
|
||||||
buffer.put(entity.getHeader1());
|
buffer.put(entity.getHeader1());
|
||||||
|
|||||||
Reference in New Issue
Block a user