修改类结构

This commit is contained in:
孙小云 2025-12-18 13:47:41 +08:00
parent c8099d90bd
commit a6ae930598
3 changed files with 11 additions and 30 deletions

View File

@ -20,33 +20,6 @@ public abstract class AbstractInstruction implements Instruction {
*/
private Instruction alwaysNextInstruction;
@Override
public boolean canExecute(InstructionContext context) {
// 默认可以执行
return true;
}
@Override
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
// 默认不需要方法回调
return null;
}
@Override
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
// 默认不需要状态回调
return null;
}
@Override
public long getTimeoutMs() {
return 60000; // 默认60秒
}
@Override
public void onComplete(InstructionContext context, InstructionResult result) {
// 默认空实现
}
@Override
public Instruction getOnSuccessInstruction() {

View File

@ -17,12 +17,15 @@ public interface Instruction {
/**
* a. 判断是否可以执行该指令
*/
boolean canExecute(InstructionContext context);
default boolean canExecute(InstructionContext context){
return true;
}
/**
* b. 执行远程调用如MQTT发送
*/
void executeRemoteCall(InstructionContext context) throws Exception;
default void executeRemoteCall(InstructionContext context) throws Exception{
}
/**
* c. 获取方法回调配置可选

View File

@ -2,6 +2,10 @@ package com.tuoheng.machine.vendor.dji;
import com.tuoheng.machine.command.CommandType;
import com.tuoheng.machine.command.Transaction;
import com.tuoheng.machine.instruction.AbstractInstruction;
import com.tuoheng.machine.instruction.CallbackConfig;
import com.tuoheng.machine.instruction.Instruction;
import com.tuoheng.machine.instruction.InstructionContext;
import com.tuoheng.machine.state.*;
import com.tuoheng.machine.vendor.VendorConfig;
import com.tuoheng.machine.vendor.dji.instruction.*;
@ -82,7 +86,8 @@ public class DjiVendorConfig implements VendorConfig {
Transaction takeOffTransaction = new Transaction("起飞", CommandType.TAKE_OFF)
.root(new DjiTakeOffInstruction())
.setTimeout(10000);
transactionMap.put(CommandType.TAKE_OFF, takeOffTransaction);
transactionMap.put(takeOffTransaction.getCommandType(), takeOffTransaction);
log.info("大疆厂家配置初始化完成,共配置{}个命令", transactionMap.size());