This commit is contained in:
parent
b3b3b41f02
commit
ee02045c65
|
|
@ -7,6 +7,7 @@ import com.ruoyi.device.domain.api.*;
|
|||
import com.ruoyi.device.domain.model.*;
|
||||
import com.ruoyi.device.domain.model.thingsboard.AttributeMap;
|
||||
import com.ruoyi.device.domain.model.thingsboard.TelemetryMap;
|
||||
import com.ruoyi.device.domain.model.thingsboard.TelemetryValue;
|
||||
import com.ruoyi.device.domain.model.thingsboard.constants.DeviceAttributes;
|
||||
import com.ruoyi.device.domain.model.thingsboard.constants.DeviceTelemetry;
|
||||
import com.ruoyi.device.domain.model.weather.Weather;
|
||||
|
|
@ -575,10 +576,10 @@ public class BufferDeviceImpl implements IBufferDeviceService
|
|||
* 根据设备属性和遥测数据确定无人机状态
|
||||
*
|
||||
* @param attributeMap 无人机 属性映射
|
||||
* @param telemetryMap 机场 遥测数据映射
|
||||
* @param dockderTelemetryMap 机场 遥测数据映射
|
||||
* @return 无人机状态字符串
|
||||
*/
|
||||
private String determineAircraftStatus(AttributeMap attributeMap,TelemetryMap telemetryAirportMap,TelemetryMap telemetryMap) {
|
||||
private String determineAircraftStatus(AttributeMap attributeMap,TelemetryMap airportTelemetryMap,TelemetryMap dockderTelemetryMap) {
|
||||
// 先检查 MODE_CODE,判断是否处于任务中或调试状态
|
||||
// MODE_CODE 定义: {"0":"待机","1":"起飞准备","2":"起飞准备完毕","3":"手动飞行","4":"自动起飞",
|
||||
// "5":"航线飞行","6":"全景拍照","7":"智能跟随","8":"ADS-B 躲避","9":"自动返航",
|
||||
|
|
@ -588,11 +589,6 @@ public class BufferDeviceImpl implements IBufferDeviceService
|
|||
Integer modeCode = attributeMap.get(DeviceAttributes.MODE_CODE).orElse(null);
|
||||
|
||||
if (modeCode != null) {
|
||||
// 14 = 未连接,直接返回离线状态
|
||||
if (modeCode == 14) {
|
||||
return AircraftStatusEnum.OFFLINE.getCode();
|
||||
}
|
||||
|
||||
// 判断是否在任务中 (飞行相关状态: 1-12, 15-20)
|
||||
if (modeCode >= 1 && modeCode <= 12 || modeCode >= 15 && modeCode <= 20) {
|
||||
return AircraftStatusEnum.IN_MISSION.getCode();
|
||||
|
|
@ -600,32 +596,18 @@ public class BufferDeviceImpl implements IBufferDeviceService
|
|||
}
|
||||
|
||||
// {"0":"关闭","1":"打开","2":"半开","3":"舱盖状态异常"}
|
||||
Integer cover_state = telemetryMap.get(DeviceTelemetry.Cover_State)
|
||||
.map(telemetryValue -> telemetryValue.getValue())
|
||||
.orElse(null);
|
||||
Integer cover_state = dockderTelemetryMap.get(DeviceTelemetry.Cover_State)
|
||||
.map(TelemetryValue::getValue)
|
||||
.orElse(0);
|
||||
|
||||
Integer droneInDock = 1;
|
||||
|
||||
if (cover_state != null && cover_state == 0) {
|
||||
droneInDock = 1;
|
||||
}else {
|
||||
droneInDock = 0;
|
||||
}
|
||||
|
||||
// // 获取无人机是否在舱内: {"0":"舱外","1":"舱内"}
|
||||
// Integer droneInDock = telemetryMap.get(DeviceTelemetry.Drone_In_Dock)
|
||||
// .map(telemetryValue -> telemetryValue.getValue())
|
||||
// .orElse(null);
|
||||
|
||||
// 从 telemetryAirportMap 中取 total_flight_time, 如果时间是在一分钟以内更新的,则为开机,否则为关机
|
||||
|
||||
// 获取无人机是否开机: {"0":"关机","1":"开机"}
|
||||
Integer deviceOnlineStatus = telemetryMap.get(DeviceTelemetry.Sub_Device_Online_Status)
|
||||
.map(telemetryValue -> telemetryValue.getValue())
|
||||
Integer deviceOnlineStatus = dockderTelemetryMap.get(DeviceTelemetry.Sub_Device_Online_Status)
|
||||
.map(TelemetryValue::getValue)
|
||||
.orElse(null);
|
||||
|
||||
// 根据舱内/舱外和开机/关机状态确定无人机状态
|
||||
boolean isInCabin = droneInDock != null && droneInDock == 1;
|
||||
boolean isInCabin = cover_state == 0;
|
||||
boolean isPowerOn = deviceOnlineStatus != null && deviceOnlineStatus == 1;
|
||||
|
||||
if (isInCabin) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue