删除旧的方案

This commit is contained in:
孙小云 2025-12-18 10:42:27 +08:00
parent 9903a75ae1
commit 425ba5eba4
136 changed files with 0 additions and 6621 deletions

View File

@ -1,400 +0,0 @@
# 条件分支执行指南
## 概述
框架现在支持基于状态回调结果的条件分支执行。指令自己维护下游节点关系,形成树状结构,可以根据执行结果(成功/失败)动态决定下一步执行哪个指令。
## 核心概念
### 1. Instruction 自维护下游节点
每个指令可以配置三种类型的下游指令:
```java
CheckDeviceInstruction checkInstruction = new CheckDeviceInstruction()
.onSuccess(new TakeOffInstruction()) // 成功时执行
.onFailure(new RepairDeviceInstruction()) // 失败时执行
.then(new LogInstruction()); // 无论成功失败都执行
```
**优先级**`then` (always) > `onSuccess/onFailure`
### 2. Transaction 持有根指令
Transaction 只需要持有根指令,指令树由指令自己维护:
```java
Transaction transaction = new Transaction("条件分支起飞", CommandType.TAKE_OFF)
.root(checkInstruction)
.setTimeout(120000);
```
### 3. 条件分支触发条件
只有当指令**配置了 `StateCallbackConfig`** 时,才会根据状态回调结果执行下游节点:
```java
@Override
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
return CallbackConfig.builder()
.topic("device/" + context.getSn() + "/state")
.fieldPath("droneState")
.expectedValue("FLYING")
.timeoutMs(60000)
.build();
}
```
**核心规则**
- **配置了 StateCallbackConfig** → 必须等待状态回调,下游节点的执行依赖于回调结果
- **没有配置 StateCallbackConfig** → 当前指令的结果即为事务结果,不会执行下游节点
### 4. 分支决策逻辑
当指令配置了状态回调时:
1. **状态回调成功** → 执行 `then``onSuccess` 配置的指令
2. **状态回调失败/超时** → 执行 `then``onFailure` 配置的指令
3. **如果找不到对应的下游指令** → 将状态回调结果作为事务结果返回
## 使用场景
### 场景1简单的成功/失败分支
```java
// 创建指令
TakeOffInstruction takeoffInstruction = new TakeOffInstruction();
RepairDeviceInstruction repairInstruction = new RepairDeviceInstruction();
// 配置指令树
CheckDeviceInstruction checkInstruction = new CheckDeviceInstruction()
.onSuccess(takeoffInstruction) // 状态正常 -> 起飞
.onFailure(repairInstruction // 状态异常 -> 修复
.then(takeoffInstruction)); // 修复后 -> 起飞
// 创建事务
Transaction transaction = new Transaction("条件分支起飞", CommandType.TAKE_OFF)
.root(checkInstruction);
```
**执行流程**
```
check (检查设备)
├─ 成功 → takeoff (起飞) → 结束
└─ 失败 → repair (修复) → takeoff (起飞) → 结束
```
### 场景2重试机制
```java
// 创建指令
StartMissionInstruction startMissionInstruction = new StartMissionInstruction();
EmergencyLandInstruction emergencyLandInstruction = new EmergencyLandInstruction();
// 重试起飞指令
RetryTakeOffInstruction retryInstruction = new RetryTakeOffInstruction()
.onSuccess(startMissionInstruction) // 重试成功 -> 开始任务
.onFailure(emergencyLandInstruction); // 重试失败 -> 紧急降落
// 起飞指令(带状态回调)
TakeOffWithStateCallbackInstruction takeoffInstruction = new TakeOffWithStateCallbackInstruction()
.onSuccess(startMissionInstruction) // 起飞成功 -> 开始任务
.onFailure(retryInstruction); // 起飞失败 -> 重试
// 创建事务
Transaction transaction = new Transaction("智能起飞", CommandType.TAKE_OFF)
.root(takeoffInstruction);
```
**执行流程**
```
takeoff (起飞)
├─ 成功 → start_mission (开始任务) → 结束
└─ 失败 → retry_takeoff (重试)
├─ 成功 → start_mission (开始任务) → 结束
└─ 失败 → emergency_land (紧急降落) → 结束
```
### 场景3状态回调结果直接作为事务结果
```java
// 只有一个指令,没有配置下游
TakeOffWithStateCallbackInstruction takeoffInstruction = new TakeOffWithStateCallbackInstruction();
// 注意:没有配置 onSuccess 或 onFailure
Transaction transaction = new Transaction("简单起飞", CommandType.TAKE_OFF)
.root(takeoffInstruction);
```
**执行流程**
```
takeoff (起飞,等待状态回调)
├─ 状态回调成功 → 事务成功(没有下游指令)
└─ 状态回调失败 → 事务失败(没有下游指令)
```
### 场景4复杂的多分支流程
```java
// 创建所有指令
OpenCoverInstruction openCoverInstruction = new OpenCoverInstruction();
CheckWeatherInstruction checkWeatherInstruction = new CheckWeatherInstruction();
TakeOffInstruction takeoffInstruction = new TakeOffInstruction();
ExecuteMissionInstruction executeMissionInstruction = new ExecuteMissionInstruction();
HandleBadWeatherInstruction handleBadWeatherInstruction = new HandleBadWeatherInstruction();
WaitInstruction waitInstruction = new WaitInstruction();
CloseCoverInstruction closeCoverInstruction = new CloseCoverInstruction();
// 配置指令树(从叶子节点开始构建)
waitInstruction.then(checkWeatherInstruction); // 等待后 -> 重新检查天气
handleBadWeatherInstruction
.onSuccess(waitInstruction) // 可以等待 -> 等待后重试
.onFailure(closeCoverInstruction); // 天气极差 -> 关闭舱门
takeoffInstruction
.onSuccess(executeMissionInstruction) // 起飞成功 -> 执行任务
.onFailure(closeCoverInstruction); // 起飞失败 -> 关闭舱门
checkWeatherInstruction
.onSuccess(takeoffInstruction) // 天气好 -> 起飞
.onFailure(handleBadWeatherInstruction); // 天气差 -> 处理
openCoverInstruction.then(checkWeatherInstruction); // 打开舱门 -> 检查天气
// 创建事务
Transaction transaction = new Transaction("智能任务执行", CommandType.START_MISSION)
.root(openCoverInstruction)
.setTimeout(300000);
```
**执行流程**
```
open_cover (打开舱门)
→ check_weather (检查天气)
├─ 天气好 → takeoff (起飞)
│ ├─ 成功 → execute_mission (执行任务) → 结束
│ └─ 失败 → close_cover (关闭舱门) → 结束
└─ 天气差 → handle_bad_weather (处理恶劣天气)
├─ 可等待 → wait_and_retry (等待) → check_weather (重新检查)
└─ 极差 → close_cover (关闭舱门) → 结束
```
## 指令实现要点
### 1. 继承 AbstractInstruction
所有指令都应该继承 `AbstractInstruction`,它提供了下游节点管理功能:
```java
public class MyInstruction extends AbstractInstruction {
@Override
public String getName() {
return "MY_INSTRUCTION";
}
@Override
public void executeRemoteCall(InstructionContext context) throws Exception {
// 发送MQTT指令
String sn = context.getSn();
mqttClient.publish("device/" + sn + "/command", "{\"cmd\":\"myCommand\"}");
}
@Override
public CallbackConfig getMethodCallbackConfig(InstructionContext context) {
// 方法回调等待指令ACK
return CallbackConfig.builder()
.topic("device/" + context.getSn() + "/response")
.fieldPath("cmd")
.expectedValue("myCommand")
.timeoutMs(10000)
.build();
}
@Override
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
// 状态回调:等待状态变化
// 配置了状态回调,则必须等待回调结果,下游节点的执行依赖于此
return CallbackConfig.builder()
.topic("device/" + context.getSn() + "/state")
.fieldPath("status")
.expectedValue("SUCCESS")
.timeoutMs(60000)
.build();
}
}
```
### 2. 使用自定义判断逻辑
```java
@Override
public CallbackConfig getStateCallbackConfig(InstructionContext context) {
return CallbackConfig.builder()
.topic("device/" + context.getSn() + "/state")
.customPredicate(messageBody -> {
// 自定义判断逻辑
Map<String, Object> data = (Map<String, Object>) messageBody;
String status = (String) data.get("status");
Integer errorCode = (Integer) data.get("errorCode");
// 只有状态为SUCCESS且错误码为0才算成功
return "SUCCESS".equals(status) && errorCode == 0;
})
.timeoutMs(60000)
.build();
}
```
### 3. 链式配置下游指令
```java
// 方式1直接链式配置
CheckDeviceInstruction checkInstruction = new CheckDeviceInstruction()
.onSuccess(new TakeOffInstruction())
.onFailure(new RepairDeviceInstruction());
// 方式2先创建再配置适合复杂场景
TakeOffInstruction takeoffInstruction = new TakeOffInstruction();
RepairDeviceInstruction repairInstruction = new RepairDeviceInstruction();
CheckDeviceInstruction checkInstruction = new CheckDeviceInstruction();
checkInstruction.onSuccess(takeoffInstruction);
checkInstruction.onFailure(repairInstruction);
// 方式3指令复用同一个指令实例可以被多个上游引用
TakeOffInstruction takeoffInstruction = new TakeOffInstruction();
CheckDeviceInstruction checkInstruction = new CheckDeviceInstruction()
.onSuccess(takeoffInstruction);
RepairDeviceInstruction repairInstruction = new RepairDeviceInstruction()
.then(takeoffInstruction); // 复用同一个 takeoff 实例
```
## 关键规则总结
1. **下游节点执行的前提**
- **必须配置 `StateCallbackConfig`** - 下游节点的执行强依赖状态回调
- **没有配置 `StateCallbackConfig`** - 当前指令的结果即为事务结果,不会执行下游节点
2. **分支优先级**
- `then` (always) > `onSuccess/onFailure`
- 如果配置了 `then`,则无论成功失败都执行该指令
3. **找不到下游指令时**
- 如果指令配置了状态回调
- 但找不到对应的下游指令(`onSuccess` 或 `onFailure`
- 则状态回调的结果直接作为事务结果返回
4. **指令执行失败**
- `canExecute()` 返回 false → 事务失败
- `executeRemoteCall()` 抛异常 → 事务失败
- `MethodCallbackConfig` 失败 → 事务失败
5. **超时处理**
- 方法回调超时 → 事务失败
- 状态回调超时 → 视为失败,执行 `onFailure``then` 配置的指令
- 如果没有配置失败分支,则事务失败
6. **循环检测**
- 框架不会自动检测循环
- 请确保事务超时时间足够长
- 避免无限循环(如 A → B → A
7. **指令复用**
- 同一个指令实例可以被多个上游指令引用
- 适用于多个分支最终汇聚到同一个指令的场景
## 调试技巧
1. **查看执行日志**
```
执行指令: instruction=CHECK_DEVICE
根据状态回调结果选择下一个指令: success=true, nextInstruction=TAKE_OFF
执行指令: instruction=TAKE_OFF
状态回调完成,无下一步指令,事务结束: success=true, instruction=TAKE_OFF
```
2. **使用 `onComplete` 回调记录指令执行结果**
```java
@Override
public void onComplete(InstructionContext context, InstructionResult result) {
log.info("指令执行完成: instruction={}, success={}, error={}",
getName(), result.isSuccess(), result.getErrorMessage());
}
```
3. **注册命令执行监听器**
```java
commandManager.registerCommandListener("debug-listener", (sn, result) -> {
log.info("命令执行完成: sn={}, commandType={}, success={}, failedInstruction={}",
sn, result.getCommandType(), result.isSuccess(), result.getFailedInstructionName());
});
```
## 最佳实践
1. **合理设置超时时间**
- 指令超时 < 事务超时
- 考虑重试次数和等待时间
2. **避免过深的分支嵌套**
- 建议分支深度不超过3层
- 复杂流程可以拆分为多个事务
3. **提供失败分支**
- 关键指令应该配置 `onFailure` 分支
- 避免因为一个指令失败导致整个事务失败
4. **合理复用指令实例**
- 多个分支汇聚到同一个指令时,复用同一个实例
- 减少对象创建,提高性能
5. **记录状态变化**
- 在指令的 `onComplete` 中记录执行结果
- 便于排查问题和优化流程
6. **从叶子节点开始构建**
- 复杂的指令树建议从叶子节点开始构建
- 先创建所有指令实例,再配置它们之间的关系
- 这样更容易理解和维护
## 架构优势
1. **职责清晰**:指令自己管理下游关系,符合单一职责原则
2. **结构简单**Transaction 只是一个容器,不需要维护复杂的节点映射
3. **易于理解**:指令树的关系直接体现在指令对象上
4. **灵活复用**:同一个指令实例可以被多个上游指令引用
5. **面向对象**:指令成为了真正的"自包含"实体
## 完整示例代码
```java
// 示例:带重试的智能起飞
public Transaction createSmartTakeoffTransaction() {
// 1. 创建所有指令实例
TakeOffInstruction takeoffInstruction = new TakeOffInstruction();
StartMissionInstruction startMissionInstruction = new StartMissionInstruction();
EmergencyLandInstruction emergencyLandInstruction = new EmergencyLandInstruction();
// 2. 配置重试逻辑
RetryTakeOffInstruction retryInstruction = new RetryTakeOffInstruction()
.onSuccess(startMissionInstruction)
.onFailure(emergencyLandInstruction);
// 3. 配置主起飞逻辑
CheckDeviceInstruction checkInstruction = new CheckDeviceInstruction()
.onSuccess(takeoffInstruction
.onSuccess(startMissionInstruction)
.onFailure(retryInstruction))
.onFailure(new RepairDeviceInstruction()
.then(takeoffInstruction));
// 4. 创建事务
return new Transaction("智能起飞", CommandType.TAKE_OFF)
.root(checkInstruction)
.setTimeout(180000);
}
```

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.action.airport;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.AirportState;
/**
* Base action for old offline handling; platform implementations extend this.
*/
public abstract class OfflineAction implements PlatformAction<AirportState, AirportEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.action.airport;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.AirportState;
/**
* Base action for old online handling; platform implementations extend this.
*/
public abstract class OnlineAction implements PlatformAction<AirportState, AirportEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.action.cover;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.CoverState;
/**
* Base action for closing the cover; platform implementations extend this.
*/
public abstract class CloseCoverAction implements PlatformAction<CoverState, CoverEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.action.cover;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.CoverState;
/**
* Base action for cover-closed handling; platform implementations extend this.
*/
public abstract class CoverClosedAction implements PlatformAction<CoverState, CoverEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.action.cover;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.CoverState;
/**
* Base action for cover-opened handling; platform implementations extend this.
*/
public abstract class CoverOpenedAction implements PlatformAction<CoverState, CoverEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.action.cover;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.CoverState;
/**
* Base action for opening the cover; platform implementations extend this.
*/
public abstract class OpenCoverAction implements PlatformAction<CoverState, CoverEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.action.debug;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.AirportState;
/**
* Base action for closing debug mode; platform implementations extend this.
*/
public abstract class CloseDebugModeAction implements PlatformAction<AirportState, AirportEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.action.debug;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.AirportState;
/**
* Base action for opening debug mode; platform implementations extend this.
*/
public abstract class OpenDebugModeAction implements PlatformAction<AirportState, AirportEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drc;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DrcState;
/**
* Base action for DRC enter handling; platform implementations extend this.
*/
public abstract class EnterAction implements PlatformAction<DrcState, DrcEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drc;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DrcState;
/**
* Base action for DRC entered handling; platform implementations extend this.
*/
public abstract class EnteredAction implements PlatformAction<DrcState, DrcEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drc;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DrcState;
/**
* Base action for DRC exit handling; platform implementations extend this.
*/
public abstract class ExitAction implements PlatformAction<DrcState, DrcEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drc;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DrcState;
/**
* Base action for DRC exited handling; platform implementations extend this.
*/
public abstract class ExitedAction implements PlatformAction<DrcState, DrcEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone arrive at destination handling; platform implementations extend this.
*/
public abstract class ArriveAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone cancel point operation handling; platform implementations extend this.
*/
public abstract class CancelPointAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone emergency stop handling; platform implementations extend this.
*/
public abstract class EmergencyStopAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone offline handling; platform implementations extend this.
*/
public abstract class OfflineAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone point flying completed handling; platform implementations extend this.
*/
public abstract class PointFlyingCompletedAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone point prepare completed handling; platform implementations extend this.
*/
public abstract class PointPrepareCompletedAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone point to flying handling; platform implementations extend this.
*/
public abstract class PointToFlyingAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone point to return handling; platform implementations extend this.
*/
public abstract class PointToReturnAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone prepare completed handling; platform implementations extend this.
*/
public abstract class PrepareCompletedAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone resume flying handling; platform implementations extend this.
*/
public abstract class ResumeFlyingAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone resume return handling; platform implementations extend this.
*/
public abstract class ResumeReturnAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone return completed handling; platform implementations extend this.
*/
public abstract class ReturnCompletedAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone return emergency stop handling; platform implementations extend this.
*/
public abstract class ReturnEmergencyStopAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone start flying handling; platform implementations extend this.
*/
public abstract class StartFlyingAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone start pointing operation handling; platform implementations extend this.
*/
public abstract class StartPointingAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone start prepare handling; platform implementations extend this.
*/
public abstract class StartPrepareAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.action.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.DroneState;
/**
* Base action for drone start return handling; platform implementations extend this.
*/
public abstract class StartReturnAction implements PlatformAction<DroneState, DroneEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.action.reboot;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.AirportState;
/**
* Base action for rebooting; platform implementations extend this.
*/
public abstract class RebootAction implements PlatformAction<AirportState, AirportEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.action.reboot;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.AirportState;
/**
* Base action for completing reboot; platform implementations extend this.
*/
public abstract class RebootCompletedAction implements PlatformAction<AirportState, AirportEvent> {
}

View File

@ -1,215 +0,0 @@
package com.tuoheng.old.config;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.factory.PlatformStrategyFactory;
import com.tuoheng.old.platform.strategy.AirportPlatformStrategy;
import com.tuoheng.old.status.AirportState;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.config.StateMachineFactory;
import java.util.EnumSet;
import java.util.UUID;
/**
* 机巢状态机配置多平台支持版本
* 通过PlatformStrategyFactory动态获取平台特定的GuardAction和Listener
*/
@Configuration
@Slf4j
public class AirportMachineConfig {
@Bean(name = "airportStateMachineFactory")
public StateMachineFactory<AirportState, AirportEvent> stateMachineFactory(
PlatformStrategyFactory platformStrategyFactory) throws Exception {
return new StateMachineFactory<AirportState, AirportEvent>() {
@Override
public StateMachine<AirportState, AirportEvent> getStateMachine() {
return null;
}
@Override
public StateMachine<AirportState, AirportEvent> getStateMachine(String machineId) {
try {
// 根据机巢SN获取平台策略
AirportPlatformStrategy strategy = platformStrategyFactory.getAirportStrategy(machineId);
StateMachineBuilder.Builder<AirportState, AirportEvent> builder = StateMachineBuilder.builder();
configureStateMachine(builder, strategy);
configureStates(builder);
configureTransitions(builder, strategy);
StateMachine<AirportState, AirportEvent> stateMachine = builder.build();
stateMachine.getExtendedState().getVariables().put("machineId", machineId);
return stateMachine;
} catch (Exception e) {
log.error("创建AIRPORT机巢状态机失败 - 机器ID: {}", machineId, e);
throw new RuntimeException("Failed to create state old for: " + machineId, e);
}
}
@Override
public StateMachine<AirportState, AirportEvent> getStateMachine(UUID uuid) {
return null;
}
};
}
private void configureStateMachine(
StateMachineBuilder.Builder<AirportState, AirportEvent> builder,
AirportPlatformStrategy strategy) throws Exception {
builder.configureConfiguration()
.withConfiguration()
.autoStartup(true)
.listener(strategy.getListener());
}
private void configureStates(StateMachineBuilder.Builder<AirportState, AirportEvent> builder) throws Exception {
builder.configureStates()
.withStates()
.initial(AirportState.UNKNOWN)
.states(EnumSet.of(
AirportState.UNKNOWN,
AirportState.OFFLINE,
AirportState.ONLINE,
AirportState.REBOOTING
))
.and()
.withStates()
.parent(AirportState.ONLINE)
.initial(AirportState.STANDBY)
.states(EnumSet.of(
AirportState.STANDBY,
AirportState.ENTERING_DEBUG_MODE,
AirportState.DEBUG_MODE,
AirportState.EXITING_DEBUG_MODE
));
}
private void configureTransitions(
StateMachineBuilder.Builder<AirportState, AirportEvent> builder,
AirportPlatformStrategy strategy) throws Exception {
builder.configureTransitions()
// ========== UNKNOWN 到所有状态的转换服务器重启后状态同步 ==========
// UNKNOWN -> OFFLINE
.withExternal()
.source(AirportState.UNKNOWN)
.target(AirportState.OFFLINE)
.event(AirportEvent.AIRPORT_OFFLINE)
.and()
// UNKNOWN -> ONLINE(STANDBY)
.withExternal()
.source(AirportState.UNKNOWN)
.target(AirportState.ONLINE)
.event(AirportEvent.AIRPORT_ONLINE)
.and()
// UNKNOWN -> STANDBY
.withExternal()
.source(AirportState.UNKNOWN)
.target(AirportState.STANDBY)
.event(AirportEvent.AIRPORT_ONLINE)
.and()
// UNKNOWN -> ENTERING_DEBUG_MODE
.withExternal()
.source(AirportState.UNKNOWN)
.target(AirportState.ENTERING_DEBUG_MODE)
.event(AirportEvent.DEBUG_MODE_OPEN)
.and()
// UNKNOWN -> DEBUG_MODE
.withExternal()
.source(AirportState.UNKNOWN)
.target(AirportState.DEBUG_MODE)
.event(AirportEvent.DEBUG_MODE_ENTERED)
.and()
// UNKNOWN -> EXITING_DEBUG_MODE
.withExternal()
.source(AirportState.UNKNOWN)
.target(AirportState.EXITING_DEBUG_MODE)
.event(AirportEvent.DEBUG_MODE_CLOSE)
.and()
// UNKNOWN -> REBOOTING
.withExternal()
.source(AirportState.UNKNOWN)
.target(AirportState.REBOOTING)
.event(AirportEvent.AIRPORT_REBOOT)
.and()
// ========== 正常状态转换 Guard Action ==========
// OFFLINE -> ONLINE(STANDBY)
.withExternal()
.source(AirportState.OFFLINE)
.target(AirportState.ONLINE)
.event(AirportEvent.AIRPORT_ONLINE)
.action(strategy.getOnlineAction())
.guard(strategy.getCanOnlineGuard())
.and()
// ONLINE -> OFFLINE
.withExternal()
.source(AirportState.ONLINE)
.target(AirportState.OFFLINE)
.event(AirportEvent.AIRPORT_OFFLINE)
.action(strategy.getOfflineAction())
.guard(strategy.getCanOfflineGuard())
.and()
// STANDBY -> ENTERING_DEBUG_MODE
.withExternal()
.source(AirportState.STANDBY)
.target(AirportState.ENTERING_DEBUG_MODE)
.event(AirportEvent.DEBUG_MODE_OPEN)
.action(strategy.getOpenDebugModeAction())
.guard(strategy.getIsNotDebugModeGuard())
.and()
// ENTERING_DEBUG_MODE -> DEBUG_MODE
.withExternal()
.source(AirportState.ENTERING_DEBUG_MODE)
.target(AirportState.DEBUG_MODE)
.event(AirportEvent.DEBUG_MODE_ENTERED)
.and()
// DEBUG_MODE -> EXITING_DEBUG_MODE
.withExternal()
.source(AirportState.DEBUG_MODE)
.target(AirportState.EXITING_DEBUG_MODE)
.event(AirportEvent.DEBUG_MODE_CLOSE)
.action(strategy.getCloseDebugModeAction())
.guard(strategy.getCanCloseDebugModeGuard())
.and()
// EXITING_DEBUG_MODE -> STANDBY
.withExternal()
.source(AirportState.EXITING_DEBUG_MODE)
.target(AirportState.STANDBY)
.event(AirportEvent.DEBUG_MODE_EXITED)
.and()
// DEBUG_MODE -> REBOOTING
.withExternal()
.source(AirportState.DEBUG_MODE)
.target(AirportState.REBOOTING)
.event(AirportEvent.AIRPORT_REBOOT)
.action(strategy.getRebootAction())
.guard(strategy.getIsDebugModeGuard())
.and()
// REBOOTING -> ONLINE(STANDBY)
.withExternal()
.source(AirportState.REBOOTING)
.target(AirportState.ONLINE)
.event(AirportEvent.REBOOT_COMPLETED)
.action(strategy.getRebootCompletedAction())
.guard(strategy.getIsRebootCompletedGuard());
}
}

View File

@ -1,178 +0,0 @@
package com.tuoheng.old.config;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.platform.factory.PlatformStrategyFactory;
import com.tuoheng.old.platform.strategy.CoverPlatformStrategy;
import com.tuoheng.old.status.CoverState;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.config.StateMachineFactory;
import java.util.EnumSet;
import java.util.UUID;
/**
* 舱门状态机配置多平台支持版本
* 通过PlatformStrategyFactory动态获取平台特定的GuardAction和Listener
*/
@Configuration
@Slf4j
public class CoverMachineConfig {
@Bean
public StateMachineFactory<CoverState, CoverEvent> coverStateMachineFactory(
PlatformStrategyFactory platformStrategyFactory) throws Exception {
return new StateMachineFactory<CoverState, CoverEvent>() {
@Override
public StateMachine<CoverState, CoverEvent> getStateMachine() {
return null;
}
@Override
public StateMachine<CoverState, CoverEvent> getStateMachine(String machineId) {
try {
// 根据机巢SN获取平台策略
CoverPlatformStrategy strategy = platformStrategyFactory.getCoverStrategy(machineId);
StateMachineBuilder.Builder<CoverState, CoverEvent> builder = StateMachineBuilder.builder();
configureCoverStateMachine(builder, strategy);
configureCoverStates(builder);
configureCoverTransitions(builder, strategy);
StateMachine<CoverState, CoverEvent> stateMachine = builder.build();
stateMachine.getExtendedState().getVariables().put("machineId", machineId);
return stateMachine;
} catch (Exception e) {
log.error("创建COVER状态机失败 - 机器ID: {}", machineId, e);
throw new RuntimeException("Failed to create cover state old for: " + machineId, e);
}
}
@Override
public StateMachine<CoverState, CoverEvent> getStateMachine(UUID uuid) {
return null;
}
};
}
private void configureCoverStateMachine(
StateMachineBuilder.Builder<CoverState, CoverEvent> builder,
CoverPlatformStrategy strategy) throws Exception {
builder.configureConfiguration()
.withConfiguration()
.autoStartup(true)
.listener(strategy.getListener());
}
private void configureCoverStates(StateMachineBuilder.Builder<CoverState, CoverEvent> builder) throws Exception {
builder.configureStates()
.withStates()
.initial(CoverState.UNKNOWN)
.states(EnumSet.allOf(CoverState.class));
}
private void configureCoverTransitions(
StateMachineBuilder.Builder<CoverState, CoverEvent> builder,
CoverPlatformStrategy strategy) throws Exception {
builder.configureTransitions()
// ========== UNKNOWN 到所有状态的转换服务器重启后状态同步 ==========
// UNKNOWN -> CLOSED
.withExternal()
.source(CoverState.UNKNOWN)
.target(CoverState.CLOSED)
.event(CoverEvent.CLOSED)
.and()
// UNKNOWN -> OPENING
.withExternal()
.source(CoverState.UNKNOWN)
.target(CoverState.OPENING)
.event(CoverEvent.OPEN)
.and()
// UNKNOWN -> OPENED
.withExternal()
.source(CoverState.UNKNOWN)
.target(CoverState.OPENED)
.event(CoverEvent.OPENED)
.and()
// UNKNOWN -> CLOSING
.withExternal()
.source(CoverState.UNKNOWN)
.target(CoverState.CLOSING)
.event(CoverEvent.CLOSE)
.and()
// UNKNOWN -> ERROR
.withExternal()
.source(CoverState.UNKNOWN)
.target(CoverState.ERROR)
.event(CoverEvent.ERROR)
.and()
// ========== 正常状态转换 Guard Action ==========
// CLOSED -> OPENING
.withExternal()
.source(CoverState.CLOSED)
.target(CoverState.OPENING)
.event(CoverEvent.OPEN)
.action(strategy.getOpenAction())
.guard(strategy.getCanOpenGuard())
.and()
// OPENING -> OPENED
.withExternal()
.source(CoverState.OPENING)
.target(CoverState.OPENED)
.event(CoverEvent.OPENED)
.action(strategy.getOpenedAction())
.guard(strategy.getIsOpenedGuard())
.and()
// OPENED -> CLOSING
.withExternal()
.source(CoverState.OPENED)
.target(CoverState.CLOSING)
.event(CoverEvent.CLOSE)
.action(strategy.getCloseAction())
.guard(strategy.getCanCloseGuard())
.and()
// CLOSING -> CLOSED
.withExternal()
.source(CoverState.CLOSING)
.target(CoverState.CLOSED)
.event(CoverEvent.CLOSED)
.action(strategy.getClosedAction())
.guard(strategy.getIsClosedGuard())
.and()
// ERROR handling
.withExternal()
.source(CoverState.OPENING)
.target(CoverState.ERROR)
.event(CoverEvent.ERROR)
.action(strategy.getErrorAction())
.and()
.withExternal()
.source(CoverState.CLOSING)
.target(CoverState.ERROR)
.event(CoverEvent.ERROR)
.action(strategy.getErrorAction())
.and()
// RESET from ERROR
.withExternal()
.source(CoverState.ERROR)
.target(CoverState.CLOSED)
.event(CoverEvent.RESET)
.action(strategy.getResetAction());
}
}

View File

@ -1,145 +0,0 @@
package com.tuoheng.old.config;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.platform.factory.PlatformStrategyFactory;
import com.tuoheng.old.platform.strategy.DrcPlatformStrategy;
import com.tuoheng.old.status.DrcState;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.config.StateMachineFactory;
import java.util.EnumSet;
import java.util.UUID;
/**
* DRC飞行控制模式状态机配置多平台支持版本
* 通过PlatformStrategyFactory动态获取平台特定的GuardAction和Listener
*/
@Configuration
@Slf4j
public class DrcMachineConfig {
@Bean(name = "drcStateMachineFactory")
public StateMachineFactory<DrcState, DrcEvent> drcStateMachineFactory(
PlatformStrategyFactory platformStrategyFactory) throws Exception {
return new StateMachineFactory<DrcState, DrcEvent>() {
@Override
public StateMachine<DrcState, DrcEvent> getStateMachine() {
return null;
}
@Override
public StateMachine<DrcState, DrcEvent> getStateMachine(String machineId) {
try {
// 根据机巢SN获取平台策略
DrcPlatformStrategy strategy = platformStrategyFactory.getDrcStrategy(machineId);
StateMachineBuilder.Builder<DrcState, DrcEvent> builder = StateMachineBuilder.builder();
configureDrcStateMachine(builder, strategy);
configureDrcStates(builder);
configureDrcTransitions(builder, strategy);
StateMachine<DrcState, DrcEvent> stateMachine = builder.build();
stateMachine.getExtendedState().getVariables().put("machineId", machineId);
return stateMachine;
} catch (Exception e) {
log.error("创建DRC状态机失败 - 机器ID: {}", machineId, e);
throw new RuntimeException("Failed to create DRC state old for: " + machineId, e);
}
}
@Override
public StateMachine<DrcState, DrcEvent> getStateMachine(UUID uuid) {
return null;
}
};
}
private void configureDrcStateMachine(
StateMachineBuilder.Builder<DrcState, DrcEvent> builder,
DrcPlatformStrategy strategy) throws Exception {
builder.configureConfiguration()
.withConfiguration()
.autoStartup(true)
.listener(strategy.getListener());
}
private void configureDrcStates(StateMachineBuilder.Builder<DrcState, DrcEvent> builder) throws Exception {
builder.configureStates()
.withStates()
.initial(DrcState.UNKNOWN)
.states(EnumSet.allOf(DrcState.class));
}
private void configureDrcTransitions(
StateMachineBuilder.Builder<DrcState, DrcEvent> builder,
DrcPlatformStrategy strategy) throws Exception {
builder.configureTransitions()
// ========== UNKNOWN 到所有状态的转换服务器重启后状态同步 ==========
// UNKNOWN -> EXITED
.withExternal()
.source(DrcState.UNKNOWN)
.target(DrcState.EXITED)
.event(DrcEvent.EXITED)
.and()
// UNKNOWN -> ENTERING
.withExternal()
.source(DrcState.UNKNOWN)
.target(DrcState.ENTERING)
.event(DrcEvent.ENTERING)
.and()
// UNKNOWN -> ENTERED
.withExternal()
.source(DrcState.UNKNOWN)
.target(DrcState.ENTERED)
.event(DrcEvent.ENTERED)
.and()
// UNKNOWN -> EXITING
.withExternal()
.source(DrcState.UNKNOWN)
.target(DrcState.EXITING)
.event(DrcEvent.EXITING)
.and()
// ========== 正常状态转换 Guard Action ==========
// EXITED -> ENTERING
.withExternal()
.source(DrcState.EXITED)
.target(DrcState.ENTERING)
.event(DrcEvent.ENTERING)
.action(strategy.getEnterAction())
.guard(strategy.getCanEnterGuard())
.and()
// ENTERING -> ENTERED
.withExternal()
.source(DrcState.ENTERING)
.target(DrcState.ENTERED)
.event(DrcEvent.ENTERED)
.action(strategy.getEnteredAction())
.and()
// ENTERED -> EXITING
.withExternal()
.source(DrcState.ENTERED)
.target(DrcState.EXITING)
.event(DrcEvent.EXITING)
.action(strategy.getExitAction())
.guard(strategy.getCanExitGuard())
.and()
// EXITING -> EXITED
.withExternal()
.source(DrcState.EXITING)
.target(DrcState.EXITED)
.event(DrcEvent.EXITED)
.action(strategy.getExitedAction());
}
}

View File

@ -1,393 +0,0 @@
package com.tuoheng.old.config;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.factory.PlatformStrategyFactory;
import com.tuoheng.old.platform.strategy.DronePlatformStrategy;
import com.tuoheng.old.status.DroneState;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.statemachine.StateMachine;
import org.springframework.statemachine.config.StateMachineBuilder;
import org.springframework.statemachine.config.StateMachineFactory;
import java.util.EnumSet;
import java.util.UUID;
/**
* 无人机状态机配置多平台支持版本
* 通过PlatformStrategyFactory动态获取平台特定的GuardAction和Listener
*/
@Configuration
@Slf4j
public class DroneMachineConfig {
@Bean(name = "droneStateMachineFactory")
public StateMachineFactory<DroneState, DroneEvent> droneStateMachineFactory(
PlatformStrategyFactory platformStrategyFactory) throws Exception {
return new StateMachineFactory<DroneState, DroneEvent>() {
@Override
public StateMachine<DroneState, DroneEvent> getStateMachine() {
return null;
}
@Override
public StateMachine<DroneState, DroneEvent> getStateMachine(String machineId) {
try {
// 根据无人机SN获取平台策略
DronePlatformStrategy strategy = platformStrategyFactory.getDroneStrategy(machineId);
StateMachineBuilder.Builder<DroneState, DroneEvent> builder = StateMachineBuilder.builder();
configureStateMachine(builder, strategy);
configureStates(builder);
configureTransitions(builder, strategy);
StateMachine<DroneState, DroneEvent> stateMachine = builder.build();
stateMachine.getExtendedState().getVariables().put("machineId", machineId);
return stateMachine;
} catch (Exception e) {
log.error("创建DRONE状态机失败 - 机器ID: {}", machineId, e);
throw new RuntimeException("Failed to create drone state old for: " + machineId, e);
}
}
@Override
public StateMachine<DroneState, DroneEvent> getStateMachine(UUID uuid) {
return null;
}
};
}
private void configureStateMachine(
StateMachineBuilder.Builder<DroneState, DroneEvent> builder,
DronePlatformStrategy strategy) throws Exception {
builder.configureConfiguration()
.withConfiguration()
.autoStartup(true)
.listener(strategy.getListener());
}
private void configureStates(StateMachineBuilder.Builder<DroneState, DroneEvent> builder) throws Exception {
builder.configureStates()
.withStates()
.initial(DroneState.UNKNOWN)
.states(EnumSet.of(
DroneState.UNKNOWN,
DroneState.OFFLINE,
DroneState.PREPARING,
DroneState.FLYING_PARENT,
DroneState.RETURNING_PARENT,
DroneState.POINTING_PARENT
))
// 飞行阶段子状态
.and()
.withStates()
.parent(DroneState.FLYING_PARENT)
.initial(DroneState.FLYING)
.states(EnumSet.of(
DroneState.FLYING,
DroneState.EMERGENCY_STOP,
DroneState.ARRIVED
))
// 返航阶段子状态
.and()
.withStates()
.parent(DroneState.RETURNING_PARENT)
.initial(DroneState.RETURNING)
.states(EnumSet.of(
DroneState.RETURNING,
DroneState.RETURN_EMERGENCY_STOP,
DroneState.RETURN_COMPLETED
))
// 指点操作子状态
.and()
.withStates()
.parent(DroneState.POINTING_PARENT)
.initial(DroneState.POINT_PREPARING)
.states(EnumSet.of(
DroneState.POINT_PREPARING,
DroneState.POINT_FLYING,
DroneState.POINT_COMPLETED,
DroneState.POINT_CANCELLED
));
}
private void configureTransitions(
StateMachineBuilder.Builder<DroneState, DroneEvent> builder,
DronePlatformStrategy strategy) throws Exception {
builder.configureTransitions()
// ========== UNKNOWN 到所有状态的转换服务器重启后状态同步 ==========
// UNKNOWN -> OFFLINE
.withExternal()
.source(DroneState.UNKNOWN)
.target(DroneState.OFFLINE)
.event(DroneEvent.DRONE_OFFLINE)
.and()
// UNKNOWN -> PREPARING
.withExternal()
.source(DroneState.UNKNOWN)
.target(DroneState.PREPARING)
.event(DroneEvent.START_PREPARE)
.and()
// UNKNOWN -> FLYING_PARENT
.withExternal()
.source(DroneState.UNKNOWN)
.target(DroneState.FLYING_PARENT)
.event(DroneEvent.START_FLYING)
.and()
// UNKNOWN -> RETURNING_PARENT
.withExternal()
.source(DroneState.UNKNOWN)
.target(DroneState.RETURNING_PARENT)
.event(DroneEvent.START_RETURN)
.and()
// ========== 基本状态转换 ==========
// OFFLINE -> PREPARING
.withExternal()
.source(DroneState.OFFLINE)
.target(DroneState.PREPARING)
.event(DroneEvent.START_PREPARE)
.action(strategy.getStartPrepareAction())
.and()
// PREPARING -> FLYING_PARENT
.withExternal()
.source(DroneState.PREPARING)
.target(DroneState.FLYING_PARENT)
.event(DroneEvent.PREPARE_COMPLETED)
.action(strategy.getPrepareCompletedAction())
.and()
// ========== 飞行阶段内部转换 ==========
// FLYING -> EMERGENCY_STOP
.withExternal()
.source(DroneState.FLYING)
.target(DroneState.EMERGENCY_STOP)
.event(DroneEvent.EMERGENCY_STOP)
.action(strategy.getEmergencyStopAction())
.and()
// EMERGENCY_STOP -> FLYING (恢复飞行)
.withExternal()
.source(DroneState.EMERGENCY_STOP)
.target(DroneState.FLYING)
.event(DroneEvent.RESUME_FLYING)
.action(strategy.getResumeFlyingAction())
.and()
// FLYING -> ARRIVED
.withExternal()
.source(DroneState.FLYING)
.target(DroneState.ARRIVED)
.event(DroneEvent.ARRIVE)
.action(strategy.getArriveAction())
.and()
// 注意EMERGENCY_STOP 不能直接到 ARRIVED根据注释限制
// ========== 飞行阶段 -> 指点操作 ==========
// FLYING -> POINTING_PARENT
.withExternal()
.source(DroneState.FLYING)
.target(DroneState.POINTING_PARENT)
.event(DroneEvent.START_POINTING)
.action(strategy.getStartPointingAction())
.guard(strategy.getCanPointGuard())
.and()
// EMERGENCY_STOP -> POINTING_PARENT
.withExternal()
.source(DroneState.EMERGENCY_STOP)
.target(DroneState.POINTING_PARENT)
.event(DroneEvent.START_POINTING)
.action(strategy.getStartPointingAction())
.guard(strategy.getCanPointGuard())
.and()
// ARRIVED -> POINTING_PARENT
.withExternal()
.source(DroneState.ARRIVED)
.target(DroneState.POINTING_PARENT)
.event(DroneEvent.START_POINTING)
.action(strategy.getStartPointingAction())
.guard(strategy.getCanPointGuard())
.and()
// ========== 飞行阶段 -> 返航 ==========
// FLYING -> RETURNING_PARENT
.withExternal()
.source(DroneState.FLYING)
.target(DroneState.RETURNING_PARENT)
.event(DroneEvent.START_RETURN)
.action(strategy.getStartReturnAction())
.and()
// EMERGENCY_STOP -> RETURNING_PARENT
.withExternal()
.source(DroneState.EMERGENCY_STOP)
.target(DroneState.RETURNING_PARENT)
.event(DroneEvent.START_RETURN)
.action(strategy.getStartReturnAction())
.and()
// ARRIVED -> RETURNING_PARENT
.withExternal()
.source(DroneState.ARRIVED)
.target(DroneState.RETURNING_PARENT)
.event(DroneEvent.START_RETURN)
.action(strategy.getStartReturnAction())
.and()
// ========== 返航阶段内部转换 ==========
// RETURNING -> RETURN_EMERGENCY_STOP
.withExternal()
.source(DroneState.RETURNING)
.target(DroneState.RETURN_EMERGENCY_STOP)
.event(DroneEvent.RETURN_EMERGENCY_STOP)
.action(strategy.getReturnEmergencyStopAction())
.and()
// RETURN_EMERGENCY_STOP -> RETURNING (恢复返航)
.withExternal()
.source(DroneState.RETURN_EMERGENCY_STOP)
.target(DroneState.RETURNING)
.event(DroneEvent.RESUME_RETURN)
.action(strategy.getResumeReturnAction())
.and()
// RETURNING -> RETURN_COMPLETED
.withExternal()
.source(DroneState.RETURNING)
.target(DroneState.RETURN_COMPLETED)
.event(DroneEvent.RETURN_COMPLETED)
.action(strategy.getReturnCompletedAction())
.and()
// 注意返航中不能指点根据注释限制
// 注意RETURN_COMPLETED 不能回退到 RETURNING RETURN_EMERGENCY_STOP根据注释限制
// ========== 返航急停 -> 指点操作 ==========
// RETURN_EMERGENCY_STOP -> POINTING_PARENT (一键起飞和航线飞行都可以指点)
.withExternal()
.source(DroneState.RETURN_EMERGENCY_STOP)
.target(DroneState.POINTING_PARENT)
.event(DroneEvent.START_POINTING)
.action(strategy.getStartPointingAction())
.guard(strategy.getCanPointGuard())
.and()
// ========== 指点操作内部转换 ==========
// POINT_PREPARING -> POINT_FLYING
.withExternal()
.source(DroneState.POINT_PREPARING)
.target(DroneState.POINT_FLYING)
.event(DroneEvent.POINT_PREPARE_COMPLETED)
.action(strategy.getPointPrepareCompletedAction())
.and()
// POINT_FLYING -> POINT_COMPLETED
.withExternal()
.source(DroneState.POINT_FLYING)
.target(DroneState.POINT_COMPLETED)
.event(DroneEvent.POINT_FLYING_COMPLETED)
.action(strategy.getPointFlyingCompletedAction())
.and()
// 任何指点阶段 -> POINT_CANCELLED
.withExternal()
.source(DroneState.POINT_PREPARING)
.target(DroneState.POINT_CANCELLED)
.event(DroneEvent.CANCEL_POINT)
.action(strategy.getCancelPointAction())
.and()
.withExternal()
.source(DroneState.POINT_FLYING)
.target(DroneState.POINT_CANCELLED)
.event(DroneEvent.CANCEL_POINT)
.action(strategy.getCancelPointAction())
.and()
.withExternal()
.source(DroneState.POINT_COMPLETED)
.target(DroneState.POINT_CANCELLED)
.event(DroneEvent.CANCEL_POINT)
.action(strategy.getCancelPointAction())
.and()
// ========== 指点操作 -> 飞行/返航 ==========
// POINT_COMPLETED -> FLYING
.withExternal()
.source(DroneState.POINT_COMPLETED)
.target(DroneState.FLYING)
.event(DroneEvent.POINT_TO_FLYING)
.action(strategy.getPointToFlyingAction())
.and()
// POINT_CANCELLED -> FLYING
.withExternal()
.source(DroneState.POINT_CANCELLED)
.target(DroneState.FLYING)
.event(DroneEvent.POINT_TO_FLYING)
.action(strategy.getPointToFlyingAction())
.and()
// POINT_COMPLETED -> RETURNING_PARENT
.withExternal()
.source(DroneState.POINT_COMPLETED)
.target(DroneState.RETURNING_PARENT)
.event(DroneEvent.POINT_TO_RETURN)
.action(strategy.getPointToReturnAction())
.and()
// POINT_CANCELLED -> RETURNING_PARENT
.withExternal()
.source(DroneState.POINT_CANCELLED)
.target(DroneState.RETURNING_PARENT)
.event(DroneEvent.POINT_TO_RETURN)
.action(strategy.getPointToReturnAction())
.and()
// POINT_COMPLETED -> RETURN_EMERGENCY_STOP
.withExternal()
.source(DroneState.POINT_COMPLETED)
.target(DroneState.RETURN_EMERGENCY_STOP)
.event(DroneEvent.RETURN_EMERGENCY_STOP)
.action(strategy.getReturnEmergencyStopAction())
.and()
// POINT_COMPLETED -> RETURN_COMPLETED
.withExternal()
.source(DroneState.POINT_COMPLETED)
.target(DroneState.RETURN_COMPLETED)
.event(DroneEvent.RETURN_COMPLETED)
.action(strategy.getReturnCompletedAction())
.and()
// ========== 离线处理 ==========
// 任何状态 -> OFFLINE
.withExternal()
.source(DroneState.FLYING_PARENT)
.target(DroneState.OFFLINE)
.event(DroneEvent.DRONE_OFFLINE)
.action(strategy.getOfflineAction())
.and()
.withExternal()
.source(DroneState.RETURNING_PARENT)
.target(DroneState.OFFLINE)
.event(DroneEvent.DRONE_OFFLINE)
.action(strategy.getOfflineAction())
.and()
.withExternal()
.source(DroneState.POINTING_PARENT)
.target(DroneState.OFFLINE)
.event(DroneEvent.DRONE_OFFLINE)
.action(strategy.getOfflineAction());
}
}

View File

@ -1,96 +0,0 @@
package com.tuoheng.old.demo;
import com.tuoheng.old.manager.ISystemManager;
import com.tuoheng.old.manager.factory.AirportSystemManagerFactory;
import com.tuoheng.old.platform.factory.PlatformStrategyFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
* 演示程序当前仅接入 DJI 平台
*/
public class MultiPlatformDemo {
public static void main(String[] args) throws InterruptedException {
// 创建 Spring 上下文
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
// 扫描所有组件
context.scan("com.tuoheng.old");
context.refresh();
// 获取必要的Bean
PlatformStrategyFactory strategyFactory = context.getBean(PlatformStrategyFactory.class);
AirportSystemManagerFactory managerFactory = context.getBean(AirportSystemManagerFactory.class);
System.out.println("\n========== DJI 机巢系统演示开始 ==========\n");
// ==================== 场景1: DJI 机巢上线 ====================
System.out.println("【场景1】DJI 机巢上线");
System.out.println("----------------------------------------");
String djiAirport = "airport-001"; // DJI平台
System.out.println("1. DJI机巢上线: " + djiAirport);
System.out.println(" 平台类型: " + strategyFactory.getPlatformType(djiAirport).getName());
ISystemManager djiManager = managerFactory.getManager(djiAirport);
djiManager.airportOnline(djiAirport);
System.out.println(" " + djiManager.getFullStatus(djiAirport));
System.out.println();
Thread.sleep(500);
// ==================== 场景2: DJI 开舱流程 ====================
System.out.println("【场景2】DJI 开舱流程");
System.out.println("----------------------------------------");
System.out.println("2. 开启调试模式: " + djiAirport);
djiManager.openDebugMode(djiAirport);
System.out.println(" " + djiManager.getFullStatus(djiAirport));
System.out.println();
Thread.sleep(500);
System.out.println("3. 开舱: " + djiAirport);
djiManager.openCover(djiAirport);
System.out.println(" " + djiManager.getFullStatus(djiAirport));
System.out.println();
Thread.sleep(500);
System.out.println("4. 舱门打开完成: " + djiAirport);
djiManager.coverOpened(djiAirport);
System.out.println(" " + djiManager.getFullStatus(djiAirport));
System.out.println();
Thread.sleep(500);
// ==================== 场景3: DJI 关舱流程 ====================
System.out.println("【场景3】DJI 关舱流程");
System.out.println("----------------------------------------");
System.out.println("5. 关舱: " + djiAirport);
djiManager.closeCover(djiAirport);
System.out.println(" " + djiManager.getFullStatus(djiAirport));
System.out.println();
Thread.sleep(500);
System.out.println("6. 舱门关闭完成: " + djiAirport);
djiManager.coverClosed(djiAirport);
System.out.println(" " + djiManager.getFullStatus(djiAirport));
System.out.println();
Thread.sleep(500);
// ==================== 场景4: 当前状态汇总 ====================
System.out.println("【场景4】当前状态汇总");
System.out.println("----------------------------------------");
System.out.println(String.format("%-20s %-15s %s", "机巢SN", "平台类型", "状态"));
System.out.println("------------------------------------------------------------");
System.out.println(String.format("%-20s %-15s %s",
djiAirport,
strategyFactory.getPlatformType(djiAirport).getName(),
djiManager.getFullStatus(djiAirport)));
System.out.println();
System.out.println("\n========== DJI 机巢系统演示结束 ==========\n");
context.close();
}
}

View File

@ -1,59 +0,0 @@
package com.tuoheng.old.events;
/**
* 机巢事件枚举
* 定义机巢状态机中的所有事件
*/
public enum AirportEvent {
// ==================== 机巢基本事件 ====================
/**
* 机巢上线事件
* 触发源: OSD心跳
*/
AIRPORT_ONLINE,
/**
* 机巢离线事件
* 触发源: OSD心跳
*/
AIRPORT_OFFLINE,
// ==================== 调试模式事件 ====================
/**
* 开启调试模式
* 触发源: 用户指令
*/
DEBUG_MODE_OPEN,
/**
* 进入调试模式完成
* 触发源: Events事件
*/
DEBUG_MODE_ENTERED,
/**
* 关闭调试模式
* 触发源: 用户指令/自动
*/
DEBUG_MODE_CLOSE,
/**
* 退出调试模式完成
* 触发源: Events事件
*/
DEBUG_MODE_EXITED,
// ==================== 机巢重启事件 ====================
/**
* 机巢重启指令
* 触发源: 用户指令
*/
AIRPORT_REBOOT,
/**
* 重启完成
* 触发源: Events事件
*/
REBOOT_COMPLETED
}

View File

@ -1,36 +0,0 @@
package com.tuoheng.old.events;
/**
* 舱门事件枚举
*/
public enum CoverEvent {
/**
* 开舱指令
*/
OPEN,
/**
* 开舱完成
*/
OPENED,
/**
* 关舱指令
*/
CLOSE,
/**
* 关舱完成
*/
CLOSED,
/**
* 舱门异常
*/
ERROR,
/**
* 重置舱门状态
*/
RESET
}

View File

@ -1,31 +0,0 @@
package com.tuoheng.old.events;
/**
* DRC飞行控制模式事件枚举
* 定义DRC状态机中的所有事件
*/
public enum DrcEvent {
/**
* 进入DRC模式指令
* 触发源: 用户指令
*/
ENTERING,
/**
* 进入DRC模式完成
* 触发源: Events事件
*/
ENTERED,
/**
* 退出DRC模式指令
* 触发源: 用户指令/自动
*/
EXITING,
/**
* 退出DRC模式完成
* 触发源: Events事件
*/
EXITED
}

View File

@ -1,121 +0,0 @@
package com.tuoheng.old.events;
/**
* 无人机事件枚举
* 定义无人机状态机中的所有事件
*/
public enum DroneEvent {
// ==================== 无人机基本事件 ====================
/**
* 无人机上线事件
* 触发源: OSD心跳
*/
DRONE_ONLINE,
/**
* 无人机离线事件
* 触发源: OSD心跳
*/
DRONE_OFFLINE,
// ==================== 准备阶段事件 ====================
/**
* 开始准备
* 触发源: 用户指令
*/
START_PREPARE,
/**
* 准备完成
* 触发源: Events事件
*/
PREPARE_COMPLETED,
// ==================== 飞行阶段事件 ====================
/**
* 开始飞行
* 触发源: 用户指令
*/
START_FLYING,
/**
* 急停飞行阶段
* 触发源: 用户指令/自动
*/
EMERGENCY_STOP,
/**
* 恢复飞行从急停恢复
* 触发源: 用户指令
*/
RESUME_FLYING,
/**
* 到达目的地
* 触发源: Events事件
*/
ARRIVE,
// ==================== 返航阶段事件 ====================
/**
* 开始返航
* 触发源: 用户指令/自动
*/
START_RETURN,
/**
* 急停返航阶段
* 触发源: 用户指令/自动
*/
RETURN_EMERGENCY_STOP,
/**
* 恢复返航从返航急停恢复
* 触发源: 用户指令
*/
RESUME_RETURN,
/**
* 返航完成
* 触发源: Events事件
*/
RETURN_COMPLETED,
// ==================== 指点操作事件 ====================
/**
* 开始指点操作
* 触发源: 用户指令
*/
START_POINTING,
/**
* 指点准备完成
* 触发源: Events事件
*/
POINT_PREPARE_COMPLETED,
/**
* 指点飞行完成
* 触发源: Events事件
*/
POINT_FLYING_COMPLETED,
/**
* 取消指点
* 触发源: 用户指令
*/
CANCEL_POINT,
/**
* 指点完成后返回飞行
* 触发源: 自动/用户指令
*/
POINT_TO_FLYING,
/**
* 指点完成后返航
* 触发源: 用户指令
*/
POINT_TO_RETURN
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.guard.airport;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.AirportState;
/**
* Base guard for checking if an old can go offline; platform implementations extend this.
*/
public abstract class CanOfflineGuard implements PlatformGuard<AirportState, AirportEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.guard.airport;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.AirportState;
/**
* Base guard for checking if an old can go online; platform implementations extend this.
*/
public abstract class CanOnlineGuard implements PlatformGuard<AirportState, AirportEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.guard.airport;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.AirportState;
/**
* Base guard for checking old online status; platform implementations extend this.
*/
public abstract class IsAirportOnlineGuard implements PlatformGuard<AirportState, AirportEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.guard.cover;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.CoverState;
/**
* Base guard for closing the cover; platform implementations extend this.
*/
public abstract class CanCloseCoverGuard implements PlatformGuard<CoverState, CoverEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.guard.cover;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.CoverState;
/**
* Base guard for opening the cover; platform implementations extend this.
*/
public abstract class CanOpenCoverGuard implements PlatformGuard<CoverState, CoverEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.guard.cover;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.CoverState;
/**
* Base guard for verifying the cover is closed; platform implementations extend this.
*/
public abstract class IsCoverClosedGuard implements PlatformGuard<CoverState, CoverEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.guard.cover;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.CoverState;
/**
* Base guard for verifying the cover is opened; platform implementations extend this.
*/
public abstract class IsCoverOpenedGuard implements PlatformGuard<CoverState, CoverEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.guard.debug;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.AirportState;
/**
* Base guard for closing debug mode; platform implementations extend this.
*/
public abstract class CanCloseDebugModeGuard implements PlatformGuard<AirportState, AirportEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.guard.debug;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.AirportState;
/**
* Base guard for checking debug mode; platform implementations extend this.
*/
public abstract class IsDebugModeGuard implements PlatformGuard<AirportState, AirportEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.guard.debug;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.AirportState;
/**
* Base guard for checking non-debug mode; platform implementations extend this.
*/
public abstract class IsNotDebugModeGuard implements PlatformGuard<AirportState, AirportEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.guard.drc;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.DrcState;
/**
* Base guard for checking if can enter DRC mode; platform implementations extend this.
*/
public abstract class CanEnterGuard implements PlatformGuard<DrcState, DrcEvent> {
}

View File

@ -1,11 +0,0 @@
package com.tuoheng.old.guard.drc;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.DrcState;
/**
* Base guard for checking if can exit DRC mode; platform implementations extend this.
*/
public abstract class CanExitGuard implements PlatformGuard<DrcState, DrcEvent> {
}

View File

@ -1,13 +0,0 @@
package com.tuoheng.old.guard.drone;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.DroneState;
/**
* Base guard for checking if drone can start pointing operation; platform implementations extend this.
* 检查无人机是否可以进行指点操作
* 注意返航中不可以指点
*/
public abstract class CanPointGuard implements PlatformGuard<DroneState, DroneEvent> {
}

View File

@ -1,12 +0,0 @@
package com.tuoheng.old.guard.reboot;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.status.AirportState;
/**
* Base guard for verifying reboot completion; platform implementations extend this.
*/
public abstract class IsRebootCompletedGuard implements PlatformGuard<AirportState, AirportEvent> {
}

View File

@ -1,135 +0,0 @@
package com.tuoheng.old.impl.dji;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.impl.dji.action.airport.*;
import com.tuoheng.old.impl.dji.guard.airport.*;
import com.tuoheng.old.impl.dji.listener.DjiAirportListener;
import com.tuoheng.old.platform.PlatformType;
import com.tuoheng.old.platform.strategy.AirportPlatformStrategy;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.platform.strategy.PlatformListener;
import com.tuoheng.old.status.AirportState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* DJI平台机巢策略实现
*/
@Component
public class DjiAirportPlatformStrategy implements AirportPlatformStrategy {
@Autowired
private DjiCanOnlineGuard canOnlineGuard;
@Autowired
private DjiCanOfflineGuard canOfflineGuard;
@Autowired
private DjiIsDebugModeGuard isDebugModeGuard;
@Autowired
private DjiIsNotDebugModeGuard isNotDebugModeGuard;
@Autowired
private DjiCanCloseDebugModeGuard canCloseDebugModeGuard;
@Autowired
private DjiIsRebootCompletedGuard isRebootCompletedGuard;
@Autowired
private DjiOnlineAction onlineAction;
@Autowired
private DjiOfflineAction offlineAction;
@Autowired
private DjiOpenDebugModeAction openDebugModeAction;
@Autowired
private DjiCloseDebugModeAction closeDebugModeAction;
@Autowired
private DjiRebootAction rebootAction;
@Autowired
private DjiRebootCompletedAction rebootCompletedAction;
/**
* DJI平台的Listener实例单例所有DJI机巢共享
*/
@Autowired
private DjiAirportListener djiListener;
@Override
public PlatformType getPlatformType() {
return PlatformType.DJI;
}
@Override
public PlatformGuard<AirportState, AirportEvent> getCanOnlineGuard() {
return canOnlineGuard;
}
@Override
public PlatformGuard<AirportState, AirportEvent> getCanOfflineGuard() {
return canOfflineGuard;
}
@Override
public PlatformGuard<AirportState, AirportEvent> getIsDebugModeGuard() {
return isDebugModeGuard;
}
@Override
public PlatformGuard<AirportState, AirportEvent> getIsNotDebugModeGuard() {
return isNotDebugModeGuard;
}
@Override
public PlatformGuard<AirportState, AirportEvent> getCanCloseDebugModeGuard() {
return canCloseDebugModeGuard;
}
@Override
public PlatformGuard<AirportState, AirportEvent> getIsRebootCompletedGuard() {
return isRebootCompletedGuard;
}
@Override
public PlatformAction<AirportState, AirportEvent> getOnlineAction() {
return onlineAction;
}
@Override
public PlatformAction<AirportState, AirportEvent> getOfflineAction() {
return offlineAction;
}
@Override
public PlatformAction<AirportState, AirportEvent> getOpenDebugModeAction() {
return openDebugModeAction;
}
@Override
public PlatformAction<AirportState, AirportEvent> getCloseDebugModeAction() {
return closeDebugModeAction;
}
@Override
public PlatformAction<AirportState, AirportEvent> getRebootAction() {
return rebootAction;
}
@Override
public PlatformAction<AirportState, AirportEvent> getRebootCompletedAction() {
return rebootCompletedAction;
}
@Override
public PlatformListener<AirportState, AirportEvent> getListener() {
// 返回DJI平台的Listener单例
// 所有DJI机巢共享这个Listener实例
return djiListener;
}
}

View File

@ -1,127 +0,0 @@
package com.tuoheng.old.impl.dji;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.manager.AbsSystemManager;
import com.tuoheng.old.platform.PlatformType;
import com.tuoheng.old.status.AirportState;
import com.tuoheng.old.status.CoverState;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 大疆平台机巢系统管理器实现
*/
@Component
@Slf4j
public class DjiAirportSystemManager extends AbsSystemManager {
@Override
public PlatformType getPlatformType() {
return PlatformType.DJI;
}
/**
* @param airportSn
* @return
*/
@Override
public boolean airportOnline(String airportSn) {
return airportService.sendEvent(airportSn, AirportEvent.AIRPORT_ONLINE);
}
/**
* @param airportSn
* @return
*/
@Override
public boolean airportOffline(String airportSn) {
return airportService.sendEvent(airportSn, AirportEvent.AIRPORT_OFFLINE);
}
@Override
public boolean openDebugMode(String airportSn) {
if (!airportService.isInState(airportSn, AirportState.ONLINE)) {
log.warn("机巢未在线,无法开启调试模式");
return false;
}
return airportService.sendEvent(airportSn, AirportEvent.DEBUG_MODE_OPEN);
}
@Override
public boolean closeDebugMode(String airportSn) {
return airportService.sendEvent(airportSn, AirportEvent.DEBUG_MODE_CLOSE);
}
@Override
public boolean openCover(String airportSn) {
if (!airportService.isInState(airportSn, AirportState.DEBUG_MODE)) {
log.warn("机巢: {} 必须在调试模式下才能开舱", airportSn);
return false;
}
if (coverService.isInState(airportSn, CoverState.OPENED)) {
log.info("舱门已经打开");
return false;
}
return coverService.sendEvent(airportSn, CoverEvent.OPEN);
}
@Override
public boolean coverOpened(String airportSn) {
return coverService.sendEvent(airportSn, CoverEvent.OPENED);
}
@Override
public boolean closeCover(String airportSn) {
if (!airportService.isInState(airportSn, AirportState.DEBUG_MODE)) {
log.warn("必须在调试模式下才能关舱");
return false;
}
if (coverService.isInState(airportSn, CoverState.CLOSED)) {
log.info("机巢: {} 舱门已经关闭", airportSn);
return false;
}
return coverService.sendEvent(airportSn, CoverEvent.CLOSE);
}
@Override
public boolean coverClosed(String airportSn) {
return coverService.sendEvent(airportSn, CoverEvent.CLOSED);
}
@Override
public boolean rebootAirport(String airportSn) {
if (!airportService.isInState(airportSn, AirportState.DEBUG_MODE)) {
log.warn("必须在调试模式下才能重启");
return false;
}
return airportService.sendEvent(airportSn, AirportEvent.AIRPORT_REBOOT);
}
@Override
public boolean rebootCompleted(String airportSn) {
return airportService.sendEvent(airportSn, AirportEvent.REBOOT_COMPLETED);
}
@Override
public AirportState getAirportState(String airportSn) {
return airportService.getCurrentState(airportSn);
}
@Override
public CoverState getCoverState(String airportSn) {
return coverService.getCurrentState(airportSn);
}
@Override
public String getFullStatus(String airportSn) {
AirportState airportState = getAirportState(airportSn);
CoverState coverState = getCoverState(airportSn);
return String.format("机巢状态: %s, 舱门状态: %s",
airportState != null ? airportState : "未知",
coverState != null ? coverState : "未知");
}
}

View File

@ -1,123 +0,0 @@
package com.tuoheng.old.impl.dji;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.impl.dji.action.cover.*;
import com.tuoheng.old.impl.dji.guard.cover.DjiCanCloseCoverGuard;
import com.tuoheng.old.impl.dji.guard.cover.DjiCanOpenCoverGuard;
import com.tuoheng.old.impl.dji.guard.cover.DjiIsCoverClosedGuard;
import com.tuoheng.old.impl.dji.guard.cover.DjiIsCoverOpenedGuard;
import com.tuoheng.old.impl.dji.listener.DjiCoverListener;
import com.tuoheng.old.platform.PlatformType;
import com.tuoheng.old.platform.strategy.CoverPlatformStrategy;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.platform.strategy.PlatformListener;
import com.tuoheng.old.status.CoverState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* DJI平台舱门策略实现
*/
@Component
public class DjiCoverPlatformStrategy implements CoverPlatformStrategy {
@Autowired
private DjiCanOpenCoverGuard canOpenGuard;
@Autowired
private DjiCanCloseCoverGuard canCloseGuard;
@Autowired
private DjiIsCoverOpenedGuard isOpenedGuard;
@Autowired
private DjiIsCoverClosedGuard isClosedGuard;
@Autowired
private DjiOpenCoverAction openAction;
@Autowired
private DjiCoverOpenedAction openedAction;
@Autowired
private DjiCloseCoverAction closeAction;
@Autowired
private DjiCoverClosedAction closedAction;
@Autowired
private DjiCoverErrorAction errorAction;
@Autowired
private DjiCoverResetAction resetAction;
/**
* DJI平台的舱门Listener实例单例所有DJI机巢共享
*/
@Autowired
private DjiCoverListener djiCoverListener ;
@Override
public PlatformType getPlatformType() {
return PlatformType.DJI;
}
@Override
public PlatformGuard<CoverState, CoverEvent> getCanOpenGuard() {
return canOpenGuard;
}
@Override
public PlatformGuard<CoverState, CoverEvent> getCanCloseGuard() {
return canCloseGuard;
}
@Override
public PlatformGuard<CoverState, CoverEvent> getIsOpenedGuard() {
return isOpenedGuard;
}
@Override
public PlatformGuard<CoverState, CoverEvent> getIsClosedGuard() {
return isClosedGuard;
}
@Override
public PlatformAction<CoverState, CoverEvent> getOpenAction() {
return openAction;
}
@Override
public PlatformAction<CoverState, CoverEvent> getOpenedAction() {
return openedAction;
}
@Override
public PlatformAction<CoverState, CoverEvent> getCloseAction() {
return closeAction;
}
@Override
public PlatformAction<CoverState, CoverEvent> getClosedAction() {
return closedAction;
}
@Override
public PlatformAction<CoverState, CoverEvent> getErrorAction() {
return errorAction;
}
@Override
public PlatformAction<CoverState, CoverEvent> getResetAction() {
return resetAction;
}
@Override
public PlatformListener<CoverState, CoverEvent> getListener() {
// 返回DJI平台的舱门Listener单例
// 所有DJI机巢共享这个Listener实例
return djiCoverListener;
}
}

View File

@ -1,86 +0,0 @@
package com.tuoheng.old.impl.dji;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.platform.PlatformType;
import com.tuoheng.old.impl.dji.action.drc.DjiEnterAction;
import com.tuoheng.old.impl.dji.action.drc.DjiEnteredAction;
import com.tuoheng.old.impl.dji.action.drc.DjiExitAction;
import com.tuoheng.old.impl.dji.action.drc.DjiExitedAction;
import com.tuoheng.old.impl.dji.guard.drc.DjiCanEnterGuard;
import com.tuoheng.old.impl.dji.guard.drc.DjiCanExitGuard;
import com.tuoheng.old.impl.dji.listener.DjiDrcListener;
import com.tuoheng.old.platform.strategy.DrcPlatformStrategy;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.platform.strategy.PlatformListener;
import com.tuoheng.old.status.DrcState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* DJI平台DRC策略实现
*/
@Component
public class DjiDrcPlatformStrategy implements DrcPlatformStrategy {
@Autowired
private DjiCanEnterGuard canEnterGuard;
@Autowired
private DjiCanExitGuard canExitGuard;
@Autowired
private DjiEnterAction enterAction;
@Autowired
private DjiEnteredAction enteredAction;
@Autowired
private DjiExitAction exitAction;
@Autowired
private DjiExitedAction exitedAction;
@Autowired
private DjiDrcListener djiDrcListener;
@Override
public PlatformType getPlatformType() {
return PlatformType.DJI;
}
@Override
public PlatformGuard<DrcState, DrcEvent> getCanEnterGuard() {
return canEnterGuard;
}
@Override
public PlatformGuard<DrcState, DrcEvent> getCanExitGuard() {
return canExitGuard;
}
@Override
public PlatformAction<DrcState, DrcEvent> getEnterAction() {
return enterAction;
}
@Override
public PlatformAction<DrcState, DrcEvent> getEnteredAction() {
return enteredAction;
}
@Override
public PlatformAction<DrcState, DrcEvent> getExitAction() {
return exitAction;
}
@Override
public PlatformAction<DrcState, DrcEvent> getExitedAction() {
return exitedAction;
}
@Override
public PlatformListener<DrcState, DrcEvent> getListener() {
return djiDrcListener;
}
}

View File

@ -1,179 +0,0 @@
package com.tuoheng.old.impl.dji;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.impl.dji.action.drone.*;
import com.tuoheng.old.platform.PlatformType;
import com.tuoheng.old.impl.dji.guard.drone.DjiCanPointGuard;
import com.tuoheng.old.impl.dji.listener.DjiDroneListener;
import com.tuoheng.old.platform.strategy.DronePlatformStrategy;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.platform.strategy.PlatformGuard;
import com.tuoheng.old.platform.strategy.PlatformListener;
import com.tuoheng.old.status.DroneState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* DJI平台无人机策略实现
*/
@Component
public class DjiDronePlatformStrategy implements DronePlatformStrategy {
@Autowired
private DjiCanPointGuard canPointGuard;
@Autowired
private DjiStartPrepareAction startPrepareAction;
@Autowired
private DjiPrepareCompletedAction prepareCompletedAction;
@Autowired
private DjiStartFlyingAction startFlyingAction;
@Autowired
private DjiEmergencyStopAction emergencyStopAction;
@Autowired
private DjiResumeFlyingAction resumeFlyingAction;
@Autowired
private DjiArriveAction arriveAction;
@Autowired
private DjiStartReturnAction startReturnAction;
@Autowired
private DjiReturnEmergencyStopAction returnEmergencyStopAction;
@Autowired
private DjiResumeReturnAction resumeReturnAction;
@Autowired
private DjiReturnCompletedAction returnCompletedAction;
@Autowired
private DjiStartPointingAction startPointingAction;
@Autowired
private DjiPointPrepareCompletedAction pointPrepareCompletedAction;
@Autowired
private DjiPointFlyingCompletedAction pointFlyingCompletedAction;
@Autowired
private DjiCancelPointAction cancelPointAction;
@Autowired
private DjiPointToFlyingAction pointToFlyingAction;
@Autowired
private DjiPointToReturnAction pointToReturnAction;
@Autowired
private DjiDroneOfflineAction offlineAction;
@Autowired
private DjiDroneListener djiDroneListener;
@Override
public PlatformType getPlatformType() {
return PlatformType.DJI;
}
@Override
public PlatformGuard<DroneState, DroneEvent> getCanPointGuard() {
return canPointGuard;
}
@Override
public PlatformAction<DroneState, DroneEvent> getStartPrepareAction() {
return startPrepareAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getPrepareCompletedAction() {
return prepareCompletedAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getStartFlyingAction() {
return startFlyingAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getEmergencyStopAction() {
return emergencyStopAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getResumeFlyingAction() {
return resumeFlyingAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getArriveAction() {
return arriveAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getStartReturnAction() {
return startReturnAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getReturnEmergencyStopAction() {
return returnEmergencyStopAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getResumeReturnAction() {
return resumeReturnAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getReturnCompletedAction() {
return returnCompletedAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getStartPointingAction() {
return startPointingAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getPointPrepareCompletedAction() {
return pointPrepareCompletedAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getPointFlyingCompletedAction() {
return pointFlyingCompletedAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getCancelPointAction() {
return cancelPointAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getPointToFlyingAction() {
return pointToFlyingAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getPointToReturnAction() {
return pointToReturnAction;
}
@Override
public PlatformAction<DroneState, DroneEvent> getOfflineAction() {
return offlineAction;
}
@Override
public PlatformListener<DroneState, DroneEvent> getListener() {
return djiDroneListener;
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.debug.CloseDebugModeAction;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiCloseDebugModeAction extends CloseDebugModeAction {
@Override
public String getName() {
return "DjiCloseDebugModeAction";
}
@Override
public void execute(StateContext<AirportState, AirportEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 关闭调试模式: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.airport.OfflineAction;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiOfflineAction extends OfflineAction {
@Override
public String getName() {
return "DjiOfflineAction";
}
@Override
public void execute(StateContext<AirportState, AirportEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 机巢离线: %s", machineId);
}
}

View File

@ -1,27 +0,0 @@
package com.tuoheng.old.impl.dji.action.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.airport.OnlineAction;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiOnlineAction extends OnlineAction {
@Override
public String getName() {
return "DjiOnlineAction";
}
@Override
public void execute(StateContext<AirportState, AirportEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 机巢上线: %s", machineId);
// DJI平台特定的上线逻辑
// 例如初始化DJI SDK连接注册设备等
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.debug.OpenDebugModeAction;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiOpenDebugModeAction extends OpenDebugModeAction {
@Override
public String getName() {
return "DjiOpenDebugModeAction";
}
@Override
public void execute(StateContext<AirportState, AirportEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 开启调试模式: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.reboot.RebootAction;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiRebootAction extends RebootAction {
@Override
public String getName() {
return "DjiRebootAction";
}
@Override
public void execute(StateContext<AirportState, AirportEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 机巢重启: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.reboot.RebootCompletedAction;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiRebootCompletedAction extends RebootCompletedAction {
@Override
public String getName() {
return "DjiRebootCompletedAction";
}
@Override
public void execute(StateContext<AirportState, AirportEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 重启完成: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.cover;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.cover.CloseCoverAction;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.status.CoverState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiCloseCoverAction extends CloseCoverAction {
@Override
public String getName() {
return "DjiCloseCoverAction";
}
@Override
public void execute(StateContext<CoverState, CoverEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 开始关舱: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.cover;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.cover.CoverClosedAction;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.status.CoverState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiCoverClosedAction extends CoverClosedAction {
@Override
public String getName() {
return "DjiCoverClosedAction";
}
@Override
public void execute(StateContext<CoverState, CoverEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 舱门已关闭: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.cover;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.CoverState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiCoverErrorAction implements PlatformAction<CoverState, CoverEvent> {
@Override
public String getName() {
return "DjiCoverErrorAction";
}
@Override
public void execute(StateContext<CoverState, CoverEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 舱门错误: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.cover;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.cover.CoverOpenedAction;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.status.CoverState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiCoverOpenedAction extends CoverOpenedAction {
@Override
public String getName() {
return "DjiCoverOpenedAction";
}
@Override
public void execute(StateContext<CoverState, CoverEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 舱门已打开: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.cover;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.platform.strategy.PlatformAction;
import com.tuoheng.old.status.CoverState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiCoverResetAction implements PlatformAction<CoverState, CoverEvent> {
@Override
public String getName() {
return "DjiCoverResetAction";
}
@Override
public void execute(StateContext<CoverState, CoverEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 舱门重置: %s", machineId);
}
}

View File

@ -1,26 +0,0 @@
package com.tuoheng.old.impl.dji.action.cover;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.cover.OpenCoverAction;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.status.CoverState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiOpenCoverAction extends OpenCoverAction {
@Override
public String getName() {
return "DjiOpenCoverAction";
}
@Override
public void execute(StateContext<CoverState, CoverEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 开始开舱: %s", machineId);
// DJI平台特定的开舱逻辑
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drc;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drc.EnterAction;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.status.DrcState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiEnterAction extends EnterAction {
@Override
public String getName() {
return "DjiEnterAction";
}
@Override
public void execute(StateContext<DrcState, DrcEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 进入DRC模式: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drc;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drc.EnteredAction;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.status.DrcState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiEnteredAction extends EnteredAction {
@Override
public String getName() {
return "DjiEnteredAction";
}
@Override
public void execute(StateContext<DrcState, DrcEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 已进入DRC模式: %s", machineId);
}
}

View File

@ -1,29 +0,0 @@
package com.tuoheng.old.impl.dji.action.drc;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drc.ExitAction;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.status.DrcState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiExitAction extends ExitAction {
@Override
public String getName() {
return "DjiExitAction";
}
@Override
public void execute(StateContext<DrcState, DrcEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] {} 退出DRC模式: %s 外部命令执行", machineId);
/**
* DjiExitAction 执行远程方法,远程方法执行成功则不抛出异常,否则抛出异常
*/
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drc;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drc.ExitedAction;
import com.tuoheng.old.events.DrcEvent;
import com.tuoheng.old.status.DrcState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiExitedAction extends ExitedAction {
@Override
public String getName() {
return "DjiExitedAction";
}
@Override
public void execute(StateContext<DrcState, DrcEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 已退出DRC模式: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.ArriveAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiArriveAction extends ArriveAction {
@Override
public String getName() {
return "DjiArriveAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机到达目的地: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.CancelPointAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiCancelPointAction extends CancelPointAction {
@Override
public String getName() {
return "DjiCancelPointAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机取消指点: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.OfflineAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiDroneOfflineAction extends OfflineAction {
@Override
public String getName() {
return "DjiDroneOfflineAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机离线: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.EmergencyStopAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiEmergencyStopAction extends EmergencyStopAction {
@Override
public String getName() {
return "DjiEmergencyStopAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机急停: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.PointFlyingCompletedAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiPointFlyingCompletedAction extends PointFlyingCompletedAction {
@Override
public String getName() {
return "DjiPointFlyingCompletedAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机指点飞行完成: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.PointPrepareCompletedAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiPointPrepareCompletedAction extends PointPrepareCompletedAction {
@Override
public String getName() {
return "DjiPointPrepareCompletedAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机指点准备完成: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.PointToFlyingAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiPointToFlyingAction extends PointToFlyingAction {
@Override
public String getName() {
return "DjiPointToFlyingAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机从指点返回飞行: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.PointToReturnAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiPointToReturnAction extends PointToReturnAction {
@Override
public String getName() {
return "DjiPointToReturnAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机从指点开始返航: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.PrepareCompletedAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiPrepareCompletedAction extends PrepareCompletedAction {
@Override
public String getName() {
return "DjiPrepareCompletedAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机准备完成: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.ResumeFlyingAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiResumeFlyingAction extends ResumeFlyingAction {
@Override
public String getName() {
return "DjiResumeFlyingAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机恢复飞行: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.ResumeReturnAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiResumeReturnAction extends ResumeReturnAction {
@Override
public String getName() {
return "DjiResumeReturnAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机恢复返航: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.ReturnCompletedAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiReturnCompletedAction extends ReturnCompletedAction {
@Override
public String getName() {
return "DjiReturnCompletedAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机返航完成: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.ReturnEmergencyStopAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiReturnEmergencyStopAction extends ReturnEmergencyStopAction {
@Override
public String getName() {
return "DjiReturnEmergencyStopAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机返航急停: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.StartFlyingAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiStartFlyingAction extends StartFlyingAction {
@Override
public String getName() {
return "DjiStartFlyingAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机开始飞行: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.StartPointingAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiStartPointingAction extends StartPointingAction {
@Override
public String getName() {
return "DjiStartPointingAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机开始指点操作: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.StartPrepareAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiStartPrepareAction extends StartPrepareAction {
@Override
public String getName() {
return "DjiStartPrepareAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机开始准备: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.action.drone;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.action.drone.StartReturnAction;
import com.tuoheng.old.events.DroneEvent;
import com.tuoheng.old.status.DroneState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiStartReturnAction extends StartReturnAction {
@Override
public String getName() {
return "DjiStartReturnAction";
}
@Override
public void execute(StateContext<DroneState, DroneEvent> context) {
String machineId = (String) context.getExtendedState().getVariables().get("machineId");
log.info("[DJI] 无人机开始返航: %s", machineId);
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.guard.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.guard.debug.CanCloseDebugModeGuard;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiCanCloseDebugModeGuard extends CanCloseDebugModeGuard {
@Override
public String getName() {
return "DjiCanCloseDebugModeGuard";
}
@Override
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
log.info("[DJI] 检查是否可以关闭调试模式");
return true;
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.guard.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.guard.airport.CanOfflineGuard;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiCanOfflineGuard extends CanOfflineGuard {
@Override
public String getName() {
return "DjiCanOfflineGuard";
}
@Override
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
log.info("[DJI] 检查机巢是否可以离线");
return true;
}
}

View File

@ -1,33 +0,0 @@
package com.tuoheng.old.impl.dji.guard.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.guard.airport.CanOnlineGuard;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
/**
* DJI平台 - 机巢上线Guard
*/
@Slf4j
@Component
public class DjiCanOnlineGuard extends CanOnlineGuard {
@Override
public String getName() {
return "DjiCanOnlineGuard";
}
@Override
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
// DJI平台特定的上线检查逻辑
log.info("[DJI] 检查机巢是否可以上线");
// 这里可以添加DJI平台特定的检查逻辑例如
// - 检查DJI设备连接状态
// - 检查DJI固件版本
// - 检查DJI授权状态
return true;
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.guard.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.guard.debug.IsDebugModeGuard;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiIsDebugModeGuard extends IsDebugModeGuard {
@Override
public String getName() {
return "DjiIsDebugModeGuard";
}
@Override
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
log.info("[DJI] 检查是否处于调试模式");
return true;
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.guard.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.guard.debug.IsNotDebugModeGuard;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiIsNotDebugModeGuard extends IsNotDebugModeGuard {
@Override
public String getName() {
return "DjiIsNotDebugModeGuard";
}
@Override
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
log.info("[DJI] 检查是否不在调试模式");
return true;
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.guard.airport;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.guard.reboot.IsRebootCompletedGuard;
import com.tuoheng.old.events.AirportEvent;
import com.tuoheng.old.status.AirportState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiIsRebootCompletedGuard extends IsRebootCompletedGuard {
@Override
public String getName() {
return "DjiIsRebootCompletedGuard";
}
@Override
public boolean evaluate(StateContext<AirportState, AirportEvent> context) {
log.info("[DJI] 检查重启是否完成");
return true;
}
}

View File

@ -1,25 +0,0 @@
package com.tuoheng.old.impl.dji.guard.cover;
import lombok.extern.slf4j.Slf4j;
import com.tuoheng.old.guard.cover.CanCloseCoverGuard;
import com.tuoheng.old.events.CoverEvent;
import com.tuoheng.old.status.CoverState;
import org.springframework.statemachine.StateContext;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class DjiCanCloseCoverGuard extends CanCloseCoverGuard {
@Override
public String getName() {
return "DjiCanCloseCoverGuard";
}
@Override
public boolean evaluate(StateContext<CoverState, CoverEvent> context) {
log.info("[DJI] 检查舱门是否可以关闭");
return true;
}
}

Some files were not shown because too many files have changed in this diff Show More