修改dock status

This commit is contained in:
孙小云 2026-02-06 11:16:20 +08:00
parent 384dac68a3
commit b7e7899958
1 changed files with 37 additions and 26 deletions

View File

@ -223,7 +223,7 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
dto.setDockStatus("OFFLINE");
log.info("心跳超时(>5分钟),设置机场状态为 OFFLINE");
} else {
// 心跳正常机场在线通过无人机mode判断是IDLE还是WORKING
// 心跳正常机场在线通过无人机mode和舱门状态判断是IDLE还是WORKING
String dockStatus = "IDLE"; // 默认空闲
if (aircraftIotDeviceId != null) {
@ -238,14 +238,25 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
log.info("无人机MODE值: {}", mode);
if ("auto".equalsIgnoreCase(mode)) {
dockStatus = "WORKING"; // auto模式表示正在执行任务
log.info("无人机处于auto模式设置机场状态为 WORKING");
// 获取舱门状态从机场遥测数据中获取
Integer doorStatus = telemetry.get(TuohengDeviceTelemetry.NEST_DOOR_STATUS)
.map(TelemetryValue::getValue)
.orElse(null);
log.info("机场舱门状态: {}", doorStatus);
// WORKING状态需要同时满足mode=="auto" 且舱门打开(doorStatus==0)
if ("auto".equalsIgnoreCase(mode) && doorStatus != null && doorStatus == 0) {
dockStatus = "WORKING"; // auto模式且舱门打开表示正在执行任务
log.info("无人机处于auto模式且舱门打开设置机场状态为 WORKING");
} else {
log.info("无人机处于{}模式,设置机场状态为 IDLE", mode);
if ("auto".equalsIgnoreCase(mode) && (doorStatus == null || doorStatus != 0)) {
log.info("无人机处于auto模式但舱门未打开(doorStatus={}), 设置机场状态为 IDLE", doorStatus);
} else {
log.info("无人机处于{}模式,设置机场状态为 IDLE", mode);
}
}
} catch (Exception e) {
log.warn("获取无人机mode失败默认设置为IDLE: {}", e.getMessage());
log.warn("获取无人机mode或舱门状态失败默认设置为IDLE: {}", e.getMessage());
}
} else {
log.info("机场未绑定无人机,设置机场状态为 IDLE");
@ -449,26 +460,26 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
.orElse("");
log.info("无人机 MODE 值: {}", mode);
// 获取 tsingal图传信号强度用于判断开关机
Integer tsingal = telemetry.get(TuohengDeviceTelemetry.TSINGAL)
.map(TelemetryValue::getValue)
.orElse(0);
log.info("无人机 TSINGAL 值: {}", tsingal);
boolean isPowerOn = tsingal > 60; // tsingal > 60 表示开机
log.info("无人机开关机状态: {}", isPowerOn ? "开机" : "关机");
// 判断逻辑
if ("auto".equalsIgnoreCase(mode)) {
// mode == "auto" 表示正在执行任务
dto.setAircraftStatus("IN_MISSION");
log.info("无人机处于 auto 模式,设置状态: IN_MISSION");
// 注意无人机详情接口无法获取机场舱门状态
// 如果 mode == "auto" 且开机推测为 IN_MISSION
// 否则根据开关机状态判断
String aircraftStatus;
if ("auto".equalsIgnoreCase(mode) && isPowerOn) {
// mode == "auto" 且开机推测正在执行任务
aircraftStatus = "IN_MISSION";
log.info("无人机处于 auto 模式且开机,推测状态: IN_MISSION");
} else {
// mode != "auto"根据 tsingal 判断开关机
// 注意无人机详情接口无法获取机场舱门状态只能根据开关机判断
// 获取 tsingal图传信号强度用于判断开关机
Integer tsingal = telemetry.get(TuohengDeviceTelemetry.TSINGAL)
.map(TelemetryValue::getValue)
.orElse(0);
log.info("无人机 TSINGAL 值: {}", tsingal);
boolean isPowerOn = tsingal > 60; // tsingal > 60 表示开机
log.info("无人机开关机状态: {}", isPowerOn ? "开机" : "关机");
// 无法获取舱门状态默认根据开关机状态判断
String aircraftStatus;
// 其他情况根据开关机状态判断默认舱内
if (isPowerOn) {
aircraftStatus = "POWER_ON_IN_CABIN";
log.info("开机状态,默认设置: POWER_ON_IN_CABIN");
@ -476,10 +487,10 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
aircraftStatus = "POWER_OFF_IN_CABIN";
log.info("关机状态,默认设置: POWER_OFF_IN_CABIN");
}
dto.setAircraftStatus(aircraftStatus);
}
dto.setAircraftStatus(aircraftStatus);
// 设置作业架次 - 暂时设置为0
dto.setMissionCount(0);
log.info("设置作业架次: 0");