diff --git a/src/main/java/com/ruoyi/device/domain/impl/machine/vendor/tuoheng/TuohengVendorConfig.java b/src/main/java/com/ruoyi/device/domain/impl/machine/vendor/tuoheng/TuohengVendorConfig.java index 4e9ce2a..525ef8f 100644 --- a/src/main/java/com/ruoyi/device/domain/impl/machine/vendor/tuoheng/TuohengVendorConfig.java +++ b/src/main/java/com/ruoyi/device/domain/impl/machine/vendor/tuoheng/TuohengVendorConfig.java @@ -42,34 +42,34 @@ public class TuohengVendorConfig implements VendorConfig { @Override public boolean canExecuteCommand(MachineStates currentStates, CommandType commandType) { - return true; -// DroneState droneState = currentStates.getDroneState(); -// AirportState airportState = currentStates.getAirportState(); -// DebugModeState debugModeState = currentStates.getDebugModeState(); +// return true; + DroneState droneState = currentStates.getDroneState(); + AirportState airportState = currentStates.getAirportState(); + DebugModeState debugModeState = currentStates.getDebugModeState(); -// switch (commandType) { -// case POWER_ON: -// // 开机前置条件:机场在线、无人机关机 -// // 注:拓恒无人机没有调试模式概念 -// return airportState == AirportState.ONLINE -// && droneState == DroneState.POWER_OFF; -// -// case POWER_OFF: -// // 关机前置条件:机场在线、无人机在线(未飞行) -// return airportState == AirportState.ONLINE -// && droneState == DroneState.ONLINE; -// -// case TAKE_OFF: -// // 起飞前置条件:机场在线 -// return airportState == AirportState.ONLINE; -// -// case RETURN_HOME: -// // 返航前置条件:无人机飞行中 -// return true; -// -// default: -// return true; -// } + switch (commandType) { + case POWER_ON: + // 开机前置条件:机场在线、无人机关机 + // 注:拓恒无人机没有调试模式概念 + return airportState == AirportState.ONLINE + && droneState == DroneState.POWER_OFF; + + case POWER_OFF: + // 关机前置条件:机场在线、无人机在线(未飞行) + return airportState == AirportState.ONLINE + && droneState == DroneState.ONLINE; + + case TAKE_OFF: + // DroneState.POWER_OFF 需要关机; AirportState.ONLINE 判断来自于 /topic/v1/heartbeat/{sn}/message + return droneState == DroneState.POWER_OFF && airportState == AirportState.ONLINE; + + case RETURN_HOME: + // 返航前置条件:无人机飞行中 + return true; + + default: + return true; + } } @Override