From 69bb49c869abe0e14cb0a8632a9392a3e392c441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B0=8F=E4=BA=91?= Date: Sat, 28 Feb 2026 14:53:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=9C=BA=E5=9C=BA=E9=A3=9E?= =?UTF-8?q?=E8=A1=8C=E6=8E=A7=E5=88=B6=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/AircraftFlyController.java | 51 ++++++++++++++++++- .../impl/machine/command/CommandType.java | 47 ++++++++++++++++- .../vendor/tuoheng/TuohengVendorConfig.java | 37 ++++++++++++++ 3 files changed, 133 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/ruoyi/device/controller/AircraftFlyController.java b/src/main/java/com/ruoyi/device/controller/AircraftFlyController.java index bf79f80..742bf94 100644 --- a/src/main/java/com/ruoyi/device/controller/AircraftFlyController.java +++ b/src/main/java/com/ruoyi/device/controller/AircraftFlyController.java @@ -58,6 +58,28 @@ public class AircraftFlyController extends BaseController try { CommandType commandType; + java.util.Map params = new java.util.HashMap<>(); + + // 处理消息ID + if (request.getMessageID() != null) { + params.put("messageID", request.getMessageID()); + } else { + params.put("messageID", System.currentTimeMillis()); + } + + // 处理扩展参数 + if (request.getEvalue() != null) { + params.put("evalue", request.getEvalue()); + } + + if (request.getValue() != null) { + params.put("value", request.getValue()); + } + + if (request.getLightMode() != null) { + params.put("lightMode", request.getLightMode()); + } + switch (request.getCommand()) { case RETURN_HOME: commandType = CommandType.RETURN_HOME; @@ -86,13 +108,40 @@ public class AircraftFlyController extends BaseController case DOWN: commandType = CommandType.DOWN; break; + case SWITCH_VISIBLE_LIGHT: + commandType = CommandType.SWITCH_VISIBLE_LIGHT; + break; + case GIMBAL_ZOOM: + commandType = CommandType.GIMBAL_ZOOM; + break; + case SWITCH_IR: + commandType = CommandType.SWITCH_IR; + break; + case SWITCH_WIDE_ANGLE: + commandType = CommandType.SWITCH_WIDE_ANGLE; + break; + case GIMBAL_MOVE_RIGHT: + commandType = CommandType.GIMBAL_MOVE_RIGHT; + break; + case GIMBAL_MOVE_LEFT: + commandType = CommandType.GIMBAL_MOVE_LEFT; + break; + case GIMBAL_PITCH_UP: + commandType = CommandType.GIMBAL_PITCH_UP; + break; + case GIMBAL_PITCH_DOWN: + commandType = CommandType.GIMBAL_PITCH_DOWN; + break; + case GIMBAL_RESET: + commandType = CommandType.GIMBAL_RESET; + break; case EMERGENCY_STOP: return R.fail("急停命令暂不支持"); default: return R.fail("不支持的飞控命令"); } - CompletableFuture future = machineCommandManager.executeCommand(sn, commandType); + CompletableFuture future = machineCommandManager.executeCommand(sn, commandType, params); CommandResult result = future.get(); if (result.isSuccess()) { diff --git a/src/main/java/com/ruoyi/device/domain/impl/machine/command/CommandType.java b/src/main/java/com/ruoyi/device/domain/impl/machine/command/CommandType.java index 6c48c01..fc1cc0d 100644 --- a/src/main/java/com/ruoyi/device/domain/impl/machine/command/CommandType.java +++ b/src/main/java/com/ruoyi/device/domain/impl/machine/command/CommandType.java @@ -132,5 +132,50 @@ public enum CommandType { /** * 下降 */ - DOWN + DOWN, + + /** + * 切换可见光 + */ + SWITCH_VISIBLE_LIGHT, + + /** + * 云台变焦 + */ + GIMBAL_ZOOM, + + /** + * 切换红外 + */ + SWITCH_IR, + + /** + * 切换广角 + */ + SWITCH_WIDE_ANGLE, + + /** + * 云台右移 + */ + GIMBAL_MOVE_RIGHT, + + /** + * 云台左移 + */ + GIMBAL_MOVE_LEFT, + + /** + * 云台俯仰(上) + */ + GIMBAL_PITCH_UP, + + /** + * 云台俯仰(下) + */ + GIMBAL_PITCH_DOWN, + + /** + * 云台复位 + */ + GIMBAL_RESET } 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 6c90a5b..3dc3d86 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 @@ -149,6 +149,43 @@ public class TuohengVendorConfig implements VendorConfig { .root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengDroneControlInstruction("09", "下降")) .setTimeout(5000)); + // 云台控制命令 + transactionMap.put(CommandType.SWITCH_VISIBLE_LIGHT, new Transaction("切换可见光", CommandType.SWITCH_VISIBLE_LIGHT) + .root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengSwitchVisibleLightInstruction()) + .setTimeout(5000)); + + transactionMap.put(CommandType.GIMBAL_ZOOM, new Transaction("云台变焦", CommandType.GIMBAL_ZOOM) + .root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengGimbalZoomInstruction()) + .setTimeout(5000)); + + transactionMap.put(CommandType.SWITCH_IR, new Transaction("切换红外", CommandType.SWITCH_IR) + .root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengSwitchIRInstruction()) + .setTimeout(5000)); + + transactionMap.put(CommandType.SWITCH_WIDE_ANGLE, new Transaction("切换广角", CommandType.SWITCH_WIDE_ANGLE) + .root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengSwitchWideAngleInstruction()) + .setTimeout(5000)); + + transactionMap.put(CommandType.GIMBAL_MOVE_RIGHT, new Transaction("云台右移", CommandType.GIMBAL_MOVE_RIGHT) + .root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengGimbalMoveRightInstruction()) + .setTimeout(5000)); + + transactionMap.put(CommandType.GIMBAL_MOVE_LEFT, new Transaction("云台左移", CommandType.GIMBAL_MOVE_LEFT) + .root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengGimbalMoveLeftInstruction()) + .setTimeout(5000)); + + transactionMap.put(CommandType.GIMBAL_PITCH_UP, new Transaction("云台俯仰(上)", CommandType.GIMBAL_PITCH_UP) + .root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengGimbalPitchUpInstruction()) + .setTimeout(5000)); + + transactionMap.put(CommandType.GIMBAL_PITCH_DOWN, new Transaction("云台俯仰(下)", CommandType.GIMBAL_PITCH_DOWN) + .root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengGimbalPitchDownInstruction()) + .setTimeout(5000)); + + transactionMap.put(CommandType.GIMBAL_RESET, new Transaction("云台复位", CommandType.GIMBAL_RESET) + .root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengGimbalResetInstruction()) + .setTimeout(5000)); + log.info("拓恒厂家配置初始化完成,共配置{}个命令", transactionMap.size()); } } \ No newline at end of file