添加飞控指令
This commit is contained in:
parent
67f465b364
commit
4a9f55a1b1
|
|
@ -125,22 +125,22 @@ public class TuohengVendorConfig implements VendorConfig {
|
|||
|
||||
// 遥感控制命令
|
||||
transactionMap.put(CommandType.FORWARD, new Transaction("前进", CommandType.FORWARD)
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengDroneControlInstruction("06", "前进"))
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengMoveForwardInstruction())
|
||||
.setTimeout(5000));
|
||||
transactionMap.put(CommandType.BACKWARD, new Transaction("后退", CommandType.BACKWARD)
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengDroneControlInstruction("07", "后退"))
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengMoveBackwardInstruction())
|
||||
.setTimeout(5000));
|
||||
transactionMap.put(CommandType.LEFT, new Transaction("左移", CommandType.LEFT)
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengDroneControlInstruction("04", "左移"))
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengMoveLeftInstruction())
|
||||
.setTimeout(5000));
|
||||
transactionMap.put(CommandType.RIGHT, new Transaction("右移", CommandType.RIGHT)
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengDroneControlInstruction("05", "右移"))
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengMoveRightInstruction())
|
||||
.setTimeout(5000));
|
||||
transactionMap.put(CommandType.ROTATE_LEFT, new Transaction("左旋", CommandType.ROTATE_LEFT)
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengDroneControlInstruction("10", "左旋"))
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengRotateLeftInstruction())
|
||||
.setTimeout(5000));
|
||||
transactionMap.put(CommandType.ROTATE_RIGHT, new Transaction("右旋", CommandType.ROTATE_RIGHT)
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengDroneControlInstruction("11", "右旋"))
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengRotateRightInstruction())
|
||||
.setTimeout(5000));
|
||||
transactionMap.put(CommandType.UP, new Transaction("上升", CommandType.UP)
|
||||
.root(new com.ruoyi.device.domain.impl.machine.vendor.tuoheng.instruction.TuohengDroneControlInstruction("08", "上升"))
|
||||
|
|
|
|||
|
|
@ -31,9 +31,16 @@ public class TuohengDroneControlInstruction extends AbstractInstruction {
|
|||
payload.put("code", "yaogan");
|
||||
payload.put("yaogan", commandValue);
|
||||
payload.put("value", commandValue);
|
||||
payload.put("messageID", System.currentTimeMillis());
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("timestamp", System.currentTimeMillis());
|
||||
payload.put("PWM", 35);
|
||||
|
||||
// 根据命令类型设置不同的 PWM 值
|
||||
int pwmValue = 35; // 默认值
|
||||
if ("04".equals(commandValue) || "05".equals(commandValue) || "06".equals(commandValue) || "07".equals(commandValue)) {
|
||||
pwmValue = 150; // 左移、右移、向前、向后
|
||||
}
|
||||
payload.put("PWM", pwmValue);
|
||||
|
||||
payload.put("desc", description);
|
||||
|
||||
String topic = "/topic/v1/airportDrone/" + sn + "/control";
|
||||
|
|
|
|||
|
|
@ -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 TuohengMoveBackwardInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_MOVE_BACKWARD";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒无人机向后指令: sn={}", sn);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("code", "yaogan");
|
||||
payload.put("PWM", 150);
|
||||
payload.put("yaogan", "07");
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("value", "07");
|
||||
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 TuohengMoveForwardInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_MOVE_FORWARD";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒无人机向前指令: sn={}", sn);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("code", "yaogan");
|
||||
payload.put("PWM", 150);
|
||||
payload.put("yaogan", "06");
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("value", "06");
|
||||
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 TuohengMoveLeftInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_MOVE_LEFT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒无人机左移指令: sn={}", sn);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("code", "yaogan");
|
||||
payload.put("PWM", 150);
|
||||
payload.put("yaogan", "04");
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("value", "04");
|
||||
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 TuohengMoveRightInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_MOVE_RIGHT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒无人机右移指令: sn={}", sn);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("code", "yaogan");
|
||||
payload.put("PWM", 150);
|
||||
payload.put("yaogan", "05");
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("value", "05");
|
||||
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 TuohengRotateLeftInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_ROTATE_LEFT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒无人机左旋指令: sn={}", sn);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("code", "yaogan");
|
||||
payload.put("PWM", 35);
|
||||
payload.put("yaogan", "10");
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("value", "10");
|
||||
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 TuohengRotateRightInstruction extends AbstractInstruction {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "TUOHENG_ROTATE_RIGHT";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeRemoteCall(InstructionContext context) throws Exception {
|
||||
String sn = context.getSn();
|
||||
log.info("发送拓恒无人机右旋指令: sn={}", sn);
|
||||
|
||||
JSONObject payload = new JSONObject();
|
||||
payload.put("code", "yaogan");
|
||||
payload.put("PWM", 35);
|
||||
payload.put("yaogan", "11");
|
||||
payload.put("messageID", context.getCommandParam("messageID", Long.class) != null ? context.getCommandParam("messageID") : System.currentTimeMillis());
|
||||
payload.put("value", "11");
|
||||
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