修改无人机状态

This commit is contained in:
孙小云 2026-02-06 11:09:23 +08:00
parent 0b6724d31d
commit 384dac68a3
1 changed files with 27 additions and 29 deletions

View File

@ -350,34 +350,32 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
.orElse(""); .orElse("");
log.info("无人机 MODE 值: {}", mode); log.info("无人机 MODE 值: {}", mode);
// 判断逻辑 // 获取 tsingal图传信号强度用于判断开关机
if ("auto".equalsIgnoreCase(mode)) { Integer tsingal = aircraftTelemetry.get(TuohengDeviceTelemetry.TSINGAL)
// mode == "auto" 表示正在执行任务 .map(TelemetryValue::getValue)
dto.setAircraftStatus("IN_MISSION"); .orElse(0);
log.info("无人机处于 auto 模式,设置状态: IN_MISSION"); log.info("无人机 TSINGAL 值: {}", tsingal);
} else {
// mode != "auto"根据 tsingal nest_door_status 判断
// 获取 tsingal图传信号强度用于判断开关机 boolean isPowerOn = tsingal > 60; // tsingal > 60 表示开机
Integer tsingal = aircraftTelemetry.get(TuohengDeviceTelemetry.TSINGAL) log.info("无人机开关机状态: {}", isPowerOn ? "开机" : "关机");
// 获取 nest_door_status舱门状态
Integer doorStatus = null;
if (dockTelemetry != null) {
doorStatus = dockTelemetry.get(TuohengDeviceTelemetry.NEST_DOOR_STATUS)
.map(TelemetryValue::getValue) .map(TelemetryValue::getValue)
.orElse(0); .orElse(null);
log.info("无人机 TSINGAL 值: {}", tsingal); log.info("机场舱门状态: {}", doorStatus);
}
boolean isPowerOn = tsingal > 60; // tsingal > 60 表示开机 // 判断逻辑IN_MISSION 需要同时满足 mode=="auto" 且舱门打开
log.info("无人机开关机状态: {}", isPowerOn ? "开机" : "关机"); String aircraftStatus;
if ("auto".equalsIgnoreCase(mode) && doorStatus != null && doorStatus == 0) {
// 获取 nest_door_status舱门状态 // mode == "auto" 且舱门打开表示正在执行任务
Integer doorStatus = null; aircraftStatus = "IN_MISSION";
if (dockTelemetry != null) { log.info("无人机处于 auto 模式且舱门打开,设置状态: IN_MISSION");
doorStatus = dockTelemetry.get(TuohengDeviceTelemetry.NEST_DOOR_STATUS) } else {
.map(TelemetryValue::getValue) // 其他情况根据 tsingal nest_door_status 判断
.orElse(null);
log.info("机场舱门状态: {}", doorStatus);
}
// 根据舱门状态和开关机状态判断
String aircraftStatus;
if (doorStatus != null && doorStatus == 1) { if (doorStatus != null && doorStatus == 1) {
// 舱门关闭舱内 // 舱门关闭舱内
if (isPowerOn) { if (isPowerOn) {
@ -388,10 +386,10 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
log.info("舱门关闭 + 关机 → POWER_OFF_IN_CABIN"); log.info("舱门关闭 + 关机 → POWER_OFF_IN_CABIN");
} }
} else if (doorStatus != null && doorStatus == 0) { } else if (doorStatus != null && doorStatus == 0) {
// 舱门打开舱外 // 舱门打开舱外但不是 auto 模式
if (isPowerOn) { if (isPowerOn) {
aircraftStatus = "POWER_ON_OUT_CABIN"; aircraftStatus = "POWER_ON_OUT_CABIN";
log.info("舱门打开 + 开机 → POWER_ON_OUT_CABIN"); log.info("舱门打开 + 开机(非auto模式) → POWER_ON_OUT_CABIN");
} else { } else {
aircraftStatus = "POWER_OFF_OUT_CABIN"; aircraftStatus = "POWER_OFF_OUT_CABIN";
log.info("舱门打开 + 关机 → POWER_OFF_OUT_CABIN"); log.info("舱门打开 + 关机 → POWER_OFF_OUT_CABIN");
@ -406,10 +404,10 @@ public class TuohengBufferDeviceImpl implements IBufferDeviceService {
log.warn("无法获取舱门状态,默认设置: POWER_OFF_IN_CABIN"); log.warn("无法获取舱门状态,默认设置: POWER_OFF_IN_CABIN");
} }
} }
dto.setAircraftStatus(aircraftStatus);
} }
dto.setAircraftStatus(aircraftStatus);
// 设置作业架次 - 暂时设置为0拓恒设备可能没有这个数据 // 设置作业架次 - 暂时设置为0拓恒设备可能没有这个数据
dto.setMissionCount(0); dto.setMissionCount(0);
log.info("设置作业架次: 0 (拓恒设备暂无此数据)"); log.info("设置作业架次: 0 (拓恒设备暂无此数据)");