This commit is contained in:
parent
6eb29ba1f4
commit
87cdb465d9
|
|
@ -271,7 +271,6 @@ public class TuohengService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步无人机开关机状态
|
* 同步无人机开关机状态
|
||||||
* 注意:只有关机时才更新状态,其他情况保持当前状态不变
|
|
||||||
*/
|
*/
|
||||||
private void syncDronePowerState(String deviceSn, TuohengRealTimeData data) {
|
private void syncDronePowerState(String deviceSn, TuohengRealTimeData data) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -284,9 +283,30 @@ public class TuohengService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 只有关机时才更新状态为 POWER_OFF
|
// 根据 bPowerON 值更新无人机状态
|
||||||
// 其他情况(开机、飞行中等)保持当前状态不变
|
// 1 = 开机, 2 = 关机
|
||||||
if (powerOn == 2) {
|
if (powerOn == 1) {
|
||||||
|
// 开机时,只有在特定状态下才更新为 ONLINE
|
||||||
|
// 只有从 POWER_OFF、UNKNOWN、ARRIVED、RETURNING 这些状态才能转为 ONLINE
|
||||||
|
MachineStates currentStates = stateManager.getMachineStates(deviceSn);
|
||||||
|
if (currentStates != null && currentStates.getDroneState() != null) {
|
||||||
|
DroneState currentState = currentStates.getDroneState();
|
||||||
|
if (currentState == DroneState.POWER_OFF ||
|
||||||
|
currentState == DroneState.UNKNOWN ||
|
||||||
|
currentState == DroneState.ARRIVED ||
|
||||||
|
currentState == DroneState.RETURNING) {
|
||||||
|
stateManager.setDroneState(deviceSn, DroneState.ONLINE);
|
||||||
|
log.debug("同步无人机开机状态: sn={}, powerOn={}, 从 {} 更新为 ONLINE",
|
||||||
|
deviceSn, powerOn, currentState);
|
||||||
|
} else {
|
||||||
|
log.debug("无人机已开机,但当前状态为 {},不更新为 ONLINE", currentState);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果没有当前状态,直接设置为 ONLINE
|
||||||
|
stateManager.setDroneState(deviceSn, DroneState.ONLINE);
|
||||||
|
log.debug("同步无人机开机状态: sn={}, powerOn=, 初始化为 ONLINE", deviceSn, powerOn);
|
||||||
|
}
|
||||||
|
} else if (powerOn == 2) {
|
||||||
stateManager.setDroneState(deviceSn, DroneState.POWER_OFF);
|
stateManager.setDroneState(deviceSn, DroneState.POWER_OFF);
|
||||||
log.debug("同步无人机关机状态: sn={}, powerOn={}", deviceSn, powerOn);
|
log.debug("同步无人机关机状态: sn={}, powerOn={}", deviceSn, powerOn);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue