Compare commits
2 Commits
2348168502
...
69bb49c869
| Author | SHA1 | Date |
|---|---|---|
|
|
69bb49c869 | |
|
|
47b6d88e2c |
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
package com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.AbstractInstruction;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.CallbackConfig;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.InstructionContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
public class TuohengGimbalControlInstruction extends AbstractInstruction {
|
||||
|
||||
private final String commandValue;
|
||||
private final String description;
|
||||
private final String evalue;
|
||||
private final String lightMode;
|
||||
|
||||
public TuohengGimbalControlInstruction(String commandValue, String description) {
|
||||
this(commandValue, description, null, null);
|
||||
}
|
||||
|
||||
public TuohengGimbalControlInstruction(String commandValue, String description, String evalue) {
|
||||
this(commandValue, description, evalue, null);
|
||||
}
|
||||
|
||||
public TuohengGimbalControlInstruction(String commandValue, String description, String evalue, String lightMode) {
|
||||
this.commandValue = commandValue;
|
||||
this.description = description;
|
||||
this.evalue = evalue;
|
||||
this.lightMode = lightMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_GIMBAL_CONTROL_" + commandValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒云台控制指令: sn={}, command={}, desc={}", sn, commandValue, description);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("code", "yuntai");
|
||||
payload.put("value", commandValue);
|
||||
payload.put("messageID", System.currentTimeMillis());
|
||||
payload.put("timestamp", System.currentTimeMillis());
|
||||
payload.put("desc", description);
|
||||
|
||||
// 添加可选参数
|
||||
if (evalue != null) {
|
||||
payload.put("evalue", evalue);
|
||||
}
|
||||
|
||||
if (lightMode != null) {
|
||||
payload.put("lightMode", lightMode);
|
||||
}
|
||||
|
||||
// 从上下文获取额外参数
|
||||
if (context.getCommandParam("evalue") != null) {
|
||||
payload.put("evalue", context.getCommandParam("evalue"));
|
||||
}
|
||||
if (context.getCommandParam("value") != null) {
|
||||
payload.put("value", context.getCommandParam("value"));
|
||||
}
|
||||
if (context.getCommandParam("messageID") != null) {
|
||||
payload.put("messageID", context.getCommandParam("messageID"));
|
||||
}
|
||||
//专门用于云台变焦命令的,用于指定相机的灯光模式。
|
||||
if (context.getCommandParam("lightMode") != null) {
|
||||
payload.put("lightMode", context.getCommandParam("lightMode"));
|
||||
}
|
||||
|
||||
String topic = "/topic/v1/airportDrone/" + sn + "/control";
|
||||
context.getMqttClient().sendMessage(topic, payload.toJSONString());
|
||||
log.info("云台控制指令发送成功: topic={}, payload={}", topic, payload.toJSONString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeoutMs() {
|
||||
return 5000;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
package com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.AbstractInstruction;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.CallbackConfig;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.InstructionContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TuohengGimbalMoveLeftInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_GIMBAL_MOVE_LEFT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
long messageID = context.getCommandParam("messageID", Long.class) != null ? (Long) context.getCommandParam("messageID") : System.currentTimeMillis();
|
||||
log.info("发送拓恒云台左移指令序列: sn={}, messageID={}", sn, messageID);
|
||||
|
||||
String topic = "/topic/v1/airportDrone/" + sn + "/control";
|
||||
|
||||
// 1. 发送云台转速设置命令
|
||||
JSONObject speedPayload = new JSONObject();
|
||||
speedPayload.put("code", "yuntai");
|
||||
speedPayload.put("messageID", messageID);
|
||||
speedPayload.put("evalue", context.getCommandParam("evalue") != null ? context.getCommandParam("evalue") : 90);
|
||||
speedPayload.put("value", "31");
|
||||
speedPayload.put("timestamp", System.currentTimeMillis());
|
||||
speedPayload.put("desc", "云台转速");
|
||||
context.getMqttClient().sendMessage(topic, speedPayload.toJSONString());
|
||||
log.info("云台转速设置指令发送成功: topic={}, payload={}", topic, speedPayload.toJSONString());
|
||||
|
||||
// 短暂延迟,确保命令按顺序执行
|
||||
Thread.sleep(100);
|
||||
|
||||
// 2. 发送云台左移命令
|
||||
JSONObject movePayload = new JSONObject();
|
||||
movePayload.put("code", "yuntai");
|
||||
movePayload.put("messageID", messageID);
|
||||
movePayload.put("evalue", context.getCommandParam("evalue") != null ? context.getCommandParam("evalue") : 90);
|
||||
movePayload.put("value", "03");
|
||||
movePayload.put("timestamp", System.currentTimeMillis());
|
||||
movePayload.put("desc", "云台左移");
|
||||
context.getMqttClient().sendMessage(topic, movePayload.toJSONString());
|
||||
log.info("云台左移指令发送成功: topic={}, payload={}", topic, movePayload.toJSONString());
|
||||
|
||||
// 短暂延迟,确保命令按顺序执行
|
||||
Thread.sleep(500);
|
||||
|
||||
// 3. 发送云台停止命令
|
||||
JSONObject stopPayload = new JSONObject();
|
||||
stopPayload.put("code", "yuntai");
|
||||
stopPayload.put("messageID", messageID);
|
||||
stopPayload.put("value", "09");
|
||||
stopPayload.put("timestamp", System.currentTimeMillis());
|
||||
stopPayload.put("desc", "云台停止");
|
||||
context.getMqttClient().sendMessage(topic, stopPayload.toJSONString());
|
||||
log.info("云台停止指令发送成功: topic={}, payload={}", topic, stopPayload.toJSONString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeoutMs() {
|
||||
return 3000;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
package com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.AbstractInstruction;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.CallbackConfig;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.InstructionContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TuohengGimbalMoveRightInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_GIMBAL_MOVE_RIGHT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
long messageID = context.getCommandParam("messageID", Long.class) != null ? (Long) context.getCommandParam("messageID") : System.currentTimeMillis();
|
||||
log.info("发送拓恒云台右移指令序列: sn={}, messageID={}", sn, messageID);
|
||||
|
||||
String topic = "/topic/v1/airportDrone/" + sn + "/control";
|
||||
|
||||
// 1. 发送云台转速设置命令
|
||||
JSONObject speedPayload = new JSONObject();
|
||||
speedPayload.put("code", "yuntai");
|
||||
speedPayload.put("messageID", messageID);
|
||||
speedPayload.put("evalue", context.getCommandParam("evalue") != null ? context.getCommandParam("evalue") : 90);
|
||||
speedPayload.put("value", "31");
|
||||
speedPayload.put("timestamp", System.currentTimeMillis());
|
||||
speedPayload.put("desc", "云台转速");
|
||||
context.getMqttClient().sendMessage(topic, speedPayload.toJSONString());
|
||||
log.info("云台转速设置指令发送成功: topic={}, payload={}", topic, speedPayload.toJSONString());
|
||||
|
||||
// 短暂延迟,确保命令按顺序执行
|
||||
Thread.sleep(100);
|
||||
|
||||
// 2. 发送云台右移命令
|
||||
JSONObject movePayload = new JSONObject();
|
||||
movePayload.put("code", "yuntai");
|
||||
movePayload.put("messageID", messageID);
|
||||
movePayload.put("evalue", context.getCommandParam("evalue") != null ? context.getCommandParam("evalue") : 90);
|
||||
movePayload.put("value", "04");
|
||||
movePayload.put("timestamp", System.currentTimeMillis());
|
||||
movePayload.put("desc", "云台右移");
|
||||
context.getMqttClient().sendMessage(topic, movePayload.toJSONString());
|
||||
log.info("云台右移指令发送成功: topic={}, payload={}", topic, movePayload.toJSONString());
|
||||
|
||||
// 短暂延迟,确保命令按顺序执行
|
||||
Thread.sleep(500);
|
||||
|
||||
// 3. 发送云台停止命令
|
||||
JSONObject stopPayload = new JSONObject();
|
||||
stopPayload.put("code", "yuntai");
|
||||
stopPayload.put("messageID", messageID);
|
||||
stopPayload.put("value", "09");
|
||||
stopPayload.put("timestamp", System.currentTimeMillis());
|
||||
stopPayload.put("desc", "云台停止");
|
||||
context.getMqttClient().sendMessage(topic, stopPayload.toJSONString());
|
||||
log.info("云台停止指令发送成功: topic={}, payload={}", topic, stopPayload.toJSONString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeoutMs() {
|
||||
return 3000;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.AbstractInstruction;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.CallbackConfig;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.InstructionContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TuohengGimbalPitchDownInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_GIMBAL_PITCH_DOWN";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
long messageID = context.getCommandParam("messageID", Long.class) != null ? (Long) context.getCommandParam("messageID") : System.currentTimeMillis();
|
||||
log.info("发送拓恒云台俯仰(下)指令序列: sn={}, messageID={}", sn, messageID);
|
||||
|
||||
String topic = "/topic/v1/airportDrone/" + sn + "/control";
|
||||
|
||||
// 1. 发送云台俯仰(下)命令
|
||||
JSONObject pitchPayload = new JSONObject();
|
||||
pitchPayload.put("code", "yuntai");
|
||||
pitchPayload.put("messageID", messageID);
|
||||
pitchPayload.put("evalue", context.getCommandParam("evalue") != null ? context.getCommandParam("evalue") : 90);
|
||||
pitchPayload.put("value", "02");
|
||||
pitchPayload.put("timestamp", System.currentTimeMillis());
|
||||
pitchPayload.put("desc", "云台俯仰(下)");
|
||||
context.getMqttClient().sendMessage(topic, pitchPayload.toJSONString());
|
||||
log.info("云台俯仰(下)指令发送成功: topic={}, payload={}", topic, pitchPayload.toJSONString());
|
||||
|
||||
// 短暂延迟,确保命令按顺序执行
|
||||
Thread.sleep(500);
|
||||
|
||||
// 2. 发送云台停止命令
|
||||
JSONObject stopPayload = new JSONObject();
|
||||
stopPayload.put("code", "yuntai");
|
||||
stopPayload.put("messageID", messageID);
|
||||
stopPayload.put("value", "09");
|
||||
stopPayload.put("timestamp", System.currentTimeMillis());
|
||||
stopPayload.put("desc", "云台停止");
|
||||
context.getMqttClient().sendMessage(topic, stopPayload.toJSONString());
|
||||
log.info("云台停止指令发送成功: topic={}, payload={}", topic, stopPayload.toJSONString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeoutMs() {
|
||||
return 3000;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.AbstractInstruction;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.CallbackConfig;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.InstructionContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TuohengGimbalPitchUpInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_GIMBAL_PITCH_UP";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
long messageID = context.getCommandParam("messageID", Long.class) != null ? (Long) context.getCommandParam("messageID") : System.currentTimeMillis();
|
||||
log.info("发送拓恒云台俯仰(上)指令序列: sn={}, messageID={}", sn, messageID);
|
||||
|
||||
String topic = "/topic/v1/airportDrone/" + sn + "/control";
|
||||
|
||||
// 1. 发送云台俯仰(上)命令
|
||||
JSONObject pitchPayload = new JSONObject();
|
||||
pitchPayload.put("code", "yuntai");
|
||||
pitchPayload.put("messageID", messageID);
|
||||
pitchPayload.put("evalue", context.getCommandParam("evalue") != null ? context.getCommandParam("evalue") : 90);
|
||||
pitchPayload.put("value", "01");
|
||||
pitchPayload.put("timestamp", System.currentTimeMillis());
|
||||
pitchPayload.put("desc", "云台俯仰(上)");
|
||||
context.getMqttClient().sendMessage(topic, pitchPayload.toJSONString());
|
||||
log.info("云台俯仰(上)指令发送成功: topic={}, payload={}", topic, pitchPayload.toJSONString());
|
||||
|
||||
// 短暂延迟,确保命令按顺序执行
|
||||
Thread.sleep(500);
|
||||
|
||||
// 2. 发送云台停止命令
|
||||
JSONObject stopPayload = new JSONObject();
|
||||
stopPayload.put("code", "yuntai");
|
||||
stopPayload.put("messageID", messageID);
|
||||
stopPayload.put("value", "09");
|
||||
stopPayload.put("timestamp", System.currentTimeMillis());
|
||||
stopPayload.put("desc", "云台停止");
|
||||
context.getMqttClient().sendMessage(topic, stopPayload.toJSONString());
|
||||
log.info("云台停止指令发送成功: topic={}, payload={}", topic, stopPayload.toJSONString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeoutMs() {
|
||||
return 3000;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.AbstractInstruction;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.CallbackConfig;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.InstructionContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TuohengGimbalResetInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_GIMBAL_RESET";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒云台复位指令: sn={}", sn);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("code", "yuntai");
|
||||
payload.put("value", "10");
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("timestamp", System.currentTimeMillis());
|
||||
payload.put("desc", "云台复位");
|
||||
|
||||
String topic = "/topic/v1/airportDrone/" + sn + "/control";
|
||||
context.getMqttClient().sendMessage(topic, payload.toJSONString());
|
||||
log.info("云台复位指令发送成功: topic={}, payload={}", topic, payload.toJSONString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeoutMs() {
|
||||
return 5000;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.AbstractInstruction;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.CallbackConfig;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.InstructionContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TuohengGimbalZoomInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_GIMBAL_ZOOM";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒云台变焦指令: sn={}", sn);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("lightMode", "visibleLight");
|
||||
payload.put("code", "yuntai");
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("evalue", context.getCommandParam("evalue") != null ? context.getCommandParam("evalue") : "3");
|
||||
payload.put("value", context.getCommandParam("value") != null ? context.getCommandParam("value") : "30");
|
||||
payload.put("timestamp", System.currentTimeMillis());
|
||||
payload.put("desc", "云台变焦");
|
||||
|
||||
String topic = "/topic/v1/airportDrone/" + sn + "/control";
|
||||
context.getMqttClient().sendMessage(topic, payload.toJSONString());
|
||||
log.info("云台变焦指令发送成功: topic={}, payload={}", topic, payload.toJSONString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeoutMs() {
|
||||
return 5000;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.AbstractInstruction;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.CallbackConfig;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.InstructionContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TuohengSwitchIRInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_SWITCH_IR";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒切换红外指令: sn={}", sn);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("code", "yuntai");
|
||||
payload.put("value", "22");
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("timestamp", System.currentTimeMillis());
|
||||
payload.put("desc", "红外");
|
||||
|
||||
String topic = "/topic/v1/airportDrone/" + sn + "/control";
|
||||
context.getMqttClient().sendMessage(topic, payload.toJSONString());
|
||||
log.info("切换红外指令发送成功: topic={}, payload={}", topic, payload.toJSONString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeoutMs() {
|
||||
return 5000;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.AbstractInstruction;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.CallbackConfig;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.InstructionContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TuohengSwitchVisibleLightInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_SWITCH_VISIBLE_LIGHT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒切换可见光指令: sn={}", sn);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("code", "yuntai");
|
||||
payload.put("value", "21");
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("timestamp", System.currentTimeMillis());
|
||||
payload.put("desc", "可见光");
|
||||
|
||||
String topic = "/topic/v1/airportDrone/" + sn + "/control";
|
||||
context.getMqttClient().sendMessage(topic, payload.toJSONString());
|
||||
log.info("切换可见光指令发送成功: topic={}, payload={}", topic, payload.toJSONString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeoutMs() {
|
||||
return 5000;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.AbstractInstruction;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.CallbackConfig;
|
||||
import com.ruoyi.device.domain.impl.machine.instruction.InstructionContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TuohengSwitchWideAngleInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_SWITCH_WIDE_ANGLE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒切换广角指令: sn={}", sn);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("code", "yuntai");
|
||||
payload.put("value", "23");
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("timestamp", System.currentTimeMillis());
|
||||
payload.put("desc", "广角");
|
||||
|
||||
String topic = "/topic/v1/airportDrone/" + sn + "/control";
|
||||
context.getMqttClient().sendMessage(topic, payload.toJSONString());
|
||||
log.info("切换广角指令发送成功: topic={}, payload={}", topic, payload.toJSONString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeoutMs() {
|
||||
return 5000;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue