处理机场飞行控制数据

This commit is contained in:
孙小云 2026-02-28 14:53:07 +08:00
parent 47b6d88e2c
commit 69bb49c869
3 changed files with 133 additions and 2 deletions

View File

@ -58,6 +58,28 @@ public class AircraftFlyController extends BaseController
try {
CommandType commandType;
java.util.Map<String, Object> 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<CommandResult> future = machineCommandManager.executeCommand(sn, commandType);
CompletableFuture<CommandResult> future = machineCommandManager.executeCommand(sn, commandType, params);
CommandResult result = future.get();
if (result.isSuccess()) {

View File

@ -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
}

View File

@ -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());
}
}