抽象出策略模式,将大疆的逻辑单独拿出来
This commit is contained in:
parent
fa6ad4f8f9
commit
85b744b0f9
|
|
@ -1,20 +1,12 @@
|
||||||
package com.tuoheng.status.airport.action.airport;
|
package com.tuoheng.status.airport.action.airport;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.action.Action;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机巢离线动作
|
* Base action for airport offline handling; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class OfflineAction implements PlatformAction<AirportState, AirportEvent> {
|
||||||
public class OfflineAction implements Action<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
System.out.println("执行机巢离线操作");
|
|
||||||
// TODO: 实现机巢离线的具体逻辑
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,12 @@
|
||||||
package com.tuoheng.status.airport.action.airport;
|
package com.tuoheng.status.airport.action.airport;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.action.Action;
|
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class OnlineAction implements Action<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base action for airport online handling; platform implementations extend this.
|
||||||
|
*/
|
||||||
|
public abstract class OnlineAction implements PlatformAction<AirportState, AirportEvent> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
package com.tuoheng.status.airport.action.cover;
|
package com.tuoheng.status.airport.action.cover;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
||||||
import org.springframework.statemachine.StateContext;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.action.Action;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关舱动作
|
* Base action for closing the cover; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class CloseCoverAction implements PlatformAction<CoverState, CoverEvent> {
|
||||||
public class CloseCoverAction implements Action<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
System.out.println("执行关舱操作");
|
|
||||||
// TODO: 发送 cover_close 指令
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
package com.tuoheng.status.airport.action.cover;
|
package com.tuoheng.status.airport.action.cover;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
||||||
import org.springframework.statemachine.StateContext;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.action.Action;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 舱门关闭完成动作
|
* Base action for cover-closed handling; platform implementations extend this.
|
||||||
* 处理舱门完全关闭后的逻辑
|
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class CoverClosedAction implements PlatformAction<CoverState, CoverEvent> {
|
||||||
public class CoverClosedAction implements Action<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
System.out.println("舱门已完全关闭,执行后续处理");
|
|
||||||
// TODO: 舱门关闭完成后的处理逻辑(例如:记录日志、自动关闭调试模式等)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
package com.tuoheng.status.airport.action.cover;
|
package com.tuoheng.status.airport.action.cover;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
||||||
import org.springframework.statemachine.StateContext;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.action.Action;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 舱门打开完成动作
|
* Base action for cover-opened handling; platform implementations extend this.
|
||||||
* 处理舱门完全打开后的逻辑
|
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class CoverOpenedAction implements PlatformAction<CoverState, CoverEvent> {
|
||||||
public class CoverOpenedAction implements Action<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
System.out.println("舱门已完全打开,执行后续处理");
|
|
||||||
// TODO: 舱门打开完成后的处理逻辑(例如:记录日志、通知相关模块等)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
package com.tuoheng.status.airport.action.cover;
|
package com.tuoheng.status.airport.action.cover;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
||||||
import org.springframework.statemachine.StateContext;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.action.Action;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开舱动作
|
* Base action for opening the cover; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class OpenCoverAction implements PlatformAction<CoverState, CoverEvent> {
|
||||||
public class OpenCoverAction implements Action<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
System.out.println("执行开舱操作");
|
|
||||||
// TODO: 发送 cover_open 指令
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
package com.tuoheng.status.airport.action.debug;
|
package com.tuoheng.status.airport.action.debug;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.action.Action;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭调试模式动作
|
* Base action for closing debug mode; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class CloseDebugModeAction implements PlatformAction<AirportState, AirportEvent> {
|
||||||
public class CloseDebugModeAction implements Action<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
System.out.println("执行关闭调试模式操作");
|
|
||||||
// TODO: 发送 debug_mode_close 指令
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
package com.tuoheng.status.airport.action.debug;
|
package com.tuoheng.status.airport.action.debug;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.action.Action;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启调试模式动作
|
* Base action for opening debug mode; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class OpenDebugModeAction implements PlatformAction<AirportState, AirportEvent> {
|
||||||
public class OpenDebugModeAction implements Action<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
System.out.println("执行开启调试模式操作");
|
|
||||||
// TODO: 发送 debug_mode_open 指令
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,12 @@
|
||||||
package com.tuoheng.status.airport.action.reboot;
|
package com.tuoheng.status.airport.action.reboot;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.action.Action;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机巢重启动作
|
* Base action for rebooting; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class RebootAction implements PlatformAction<AirportState, AirportEvent> {
|
||||||
public class RebootAction implements Action<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
System.out.println("执行机巢重启操作");
|
|
||||||
// TODO: 发送 device_reboot 指令
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
package com.tuoheng.status.airport.action.reboot;
|
package com.tuoheng.status.airport.action.reboot;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.action.Action;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机巢重启完成动作
|
* Base action for completing reboot; platform implementations extend this.
|
||||||
* 处理机巢重启完成后的逻辑
|
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class RebootCompletedAction implements PlatformAction<AirportState, AirportEvent> {
|
||||||
public class RebootCompletedAction implements Action<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
System.out.println("机巢重启完成,执行初始化处理");
|
|
||||||
// TODO: 机巢重启完成后的处理逻辑(例如:重新初始化、恢复状态等)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,128 +0,0 @@
|
||||||
package com.tuoheng.status.airport.demo;
|
|
||||||
|
|
||||||
import com.tuoheng.status.airport.manager.AirportSystemManager;
|
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 机巢系统演示(组合状态机方案)
|
|
||||||
*/
|
|
||||||
public class AirportSystemDemo {
|
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
|
||||||
|
|
||||||
// 创建 Spring 上下文
|
|
||||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
|
|
||||||
|
|
||||||
// 扫描配置类、服务类和监听器类
|
|
||||||
context.scan("com.tuoheng.status.airport");
|
|
||||||
context.refresh();
|
|
||||||
|
|
||||||
// 获取 AirportSystemManager
|
|
||||||
AirportSystemManager systemManager = context.getBean(AirportSystemManager.class);
|
|
||||||
|
|
||||||
System.out.println("\n========== 机巢系统演示开始(组合状态机方案) ==========\n");
|
|
||||||
|
|
||||||
String airportSn = "airport-001";
|
|
||||||
|
|
||||||
// ==================== 场景1: 机巢上线 ====================
|
|
||||||
System.out.println("【场景1】机巢上线");
|
|
||||||
System.out.println("----------------------------------------");
|
|
||||||
systemManager.airportOnline(airportSn);
|
|
||||||
System.out.println(" " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
Thread.sleep(500);
|
|
||||||
|
|
||||||
// ==================== 场景2: 开舱流程 ====================
|
|
||||||
System.out.println("【场景2】开舱流程");
|
|
||||||
System.out.println("----------------------------------------");
|
|
||||||
|
|
||||||
System.out.println("1. 开启调试模式");
|
|
||||||
systemManager.openDebugMode(airportSn);
|
|
||||||
System.out.println(" " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
Thread.sleep(500);
|
|
||||||
|
|
||||||
System.out.println("2. 开舱");
|
|
||||||
systemManager.openCover(airportSn);
|
|
||||||
System.out.println(" " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
Thread.sleep(500);
|
|
||||||
|
|
||||||
System.out.println("3. 舱门打开完成");
|
|
||||||
systemManager.coverOpened(airportSn);
|
|
||||||
System.out.println(" " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
Thread.sleep(500);
|
|
||||||
|
|
||||||
// ==================== 场景3: 关舱流程 ====================
|
|
||||||
System.out.println("【场景3】关舱流程");
|
|
||||||
System.out.println("----------------------------------------");
|
|
||||||
|
|
||||||
System.out.println("4. 关舱");
|
|
||||||
systemManager.closeCover(airportSn);
|
|
||||||
System.out.println(" " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
Thread.sleep(500);
|
|
||||||
|
|
||||||
System.out.println("5. 舱门关闭完成");
|
|
||||||
systemManager.coverClosed(airportSn);
|
|
||||||
System.out.println(" " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
Thread.sleep(500);
|
|
||||||
|
|
||||||
System.out.println("6. 关闭调试模式");
|
|
||||||
systemManager.closeDebugMode(airportSn);
|
|
||||||
System.out.println(" " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
Thread.sleep(500);
|
|
||||||
|
|
||||||
// ==================== 场景4: 状态查询 ====================
|
|
||||||
System.out.println("【场景4】状态查询");
|
|
||||||
System.out.println("----------------------------------------");
|
|
||||||
System.out.println("机巢状态: " + systemManager.getAirportState(airportSn));
|
|
||||||
System.out.println("舱门状态: " + systemManager.getCoverState(airportSn));
|
|
||||||
System.out.println("完整状态: " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
|
|
||||||
// ==================== 场景5: 机巢重启 ====================
|
|
||||||
System.out.println("【场景5】机巢重启");
|
|
||||||
System.out.println("----------------------------------------");
|
|
||||||
|
|
||||||
System.out.println("7. 开启调试模式");
|
|
||||||
systemManager.openDebugMode(airportSn);
|
|
||||||
System.out.println(" " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
Thread.sleep(500);
|
|
||||||
|
|
||||||
System.out.println("8. 机巢重启");
|
|
||||||
systemManager.rebootAirport(airportSn);
|
|
||||||
System.out.println(" " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
Thread.sleep(500);
|
|
||||||
|
|
||||||
System.out.println("9. 重启完成");
|
|
||||||
systemManager.rebootCompleted(airportSn);
|
|
||||||
System.out.println(" " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
|
|
||||||
// ==================== 场景6: 错误处理 ====================
|
|
||||||
System.out.println("【场景6】错误处理(Guard拦截)");
|
|
||||||
System.out.println("----------------------------------------");
|
|
||||||
|
|
||||||
System.out.println("10. 尝试在待机状态下开舱(应该失败)");
|
|
||||||
boolean result = systemManager.openCover(airportSn);
|
|
||||||
System.out.println(" 操作结果: " + (result ? "成功" : "失败"));
|
|
||||||
System.out.println(" " + systemManager.getFullStatus(airportSn));
|
|
||||||
System.out.println();
|
|
||||||
|
|
||||||
System.out.println("\n========== 机巢系统演示结束 ==========\n");
|
|
||||||
|
|
||||||
System.out.println("✅ 组合状态机方案优势:");
|
|
||||||
System.out.println(" 1. 机巢状态和舱门状态独立管理");
|
|
||||||
System.out.println(" 2. 状态层级扁平,易于理解");
|
|
||||||
System.out.println(" 3. 易于扩展(可添加推杆、无人机等状态机)");
|
|
||||||
System.out.println(" 4. 职责清晰,维护方便");
|
|
||||||
|
|
||||||
context.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.tuoheng.status.airport.demo;
|
package com.tuoheng.status.airport.demo;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.manager.AirportSystemManager;
|
import com.tuoheng.status.airport.manager.AirportSystemManager;
|
||||||
import com.tuoheng.status.airport.platform.PlatformType;
|
|
||||||
import com.tuoheng.status.airport.platform.factory.PlatformStrategyFactory;
|
import com.tuoheng.status.airport.platform.factory.PlatformStrategyFactory;
|
||||||
import com.tuoheng.status.airport.platform.repository.AirportPlatformRepository;
|
import com.tuoheng.status.airport.platform.repository.AirportPlatformRepository;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
|
|
@ -22,7 +21,6 @@ public class MultiPlatformDemo {
|
||||||
context.refresh();
|
context.refresh();
|
||||||
|
|
||||||
// 获取必要的Bean
|
// 获取必要的Bean
|
||||||
AirportSystemManager systemManager = context.getBean(AirportSystemManager.class);
|
|
||||||
PlatformStrategyFactory strategyFactory = context.getBean(PlatformStrategyFactory.class);
|
PlatformStrategyFactory strategyFactory = context.getBean(PlatformStrategyFactory.class);
|
||||||
AirportPlatformRepository repository = context.getBean(AirportPlatformRepository.class);
|
AirportPlatformRepository repository = context.getBean(AirportPlatformRepository.class);
|
||||||
|
|
||||||
|
|
@ -38,22 +36,25 @@ public class MultiPlatformDemo {
|
||||||
|
|
||||||
System.out.println("1. DJI机巢上线: " + djiAirport);
|
System.out.println("1. DJI机巢上线: " + djiAirport);
|
||||||
System.out.println(" 平台类型: " + strategyFactory.getPlatformType(djiAirport).getName());
|
System.out.println(" 平台类型: " + strategyFactory.getPlatformType(djiAirport).getName());
|
||||||
systemManager.airportOnline(djiAirport);
|
AirportSystemManager djiManager = strategyFactory.getSystemManager(djiAirport);
|
||||||
System.out.println(" " + systemManager.getFullStatus(djiAirport));
|
djiManager.airportOnline(djiAirport);
|
||||||
|
System.out.println(" " + djiManager.getFullStatus(djiAirport));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
System.out.println("2. AUTEL机巢上线: " + autelAirport);
|
System.out.println("2. AUTEL机巢上线: " + autelAirport);
|
||||||
System.out.println(" 平台类型: " + strategyFactory.getPlatformType(autelAirport).getName());
|
System.out.println(" 平台类型: " + strategyFactory.getPlatformType(autelAirport).getName());
|
||||||
systemManager.airportOnline(autelAirport);
|
AirportSystemManager autelManager = strategyFactory.getSystemManager(autelAirport);
|
||||||
System.out.println(" " + systemManager.getFullStatus(autelAirport));
|
autelManager.airportOnline(autelAirport);
|
||||||
|
System.out.println(" " + autelManager.getFullStatus(autelAirport));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
System.out.println("3. 另一个DJI机巢上线: " + djiAirport2);
|
System.out.println("3. 另一个DJI机巢上线: " + djiAirport2);
|
||||||
System.out.println(" 平台类型: " + strategyFactory.getPlatformType(djiAirport2).getName());
|
System.out.println(" 平台类型: " + strategyFactory.getPlatformType(djiAirport2).getName());
|
||||||
systemManager.airportOnline(djiAirport2);
|
AirportSystemManager djiManager2 = strategyFactory.getSystemManager(djiAirport2);
|
||||||
System.out.println(" " + systemManager.getFullStatus(djiAirport2));
|
djiManager2.airportOnline(djiAirport2);
|
||||||
|
System.out.println(" " + djiManager2.getFullStatus(djiAirport2));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
|
|
@ -62,20 +63,20 @@ public class MultiPlatformDemo {
|
||||||
System.out.println("----------------------------------------");
|
System.out.println("----------------------------------------");
|
||||||
|
|
||||||
System.out.println("4. DJI机巢开启调试模式: " + djiAirport);
|
System.out.println("4. DJI机巢开启调试模式: " + djiAirport);
|
||||||
systemManager.openDebugMode(djiAirport);
|
djiManager.openDebugMode(djiAirport);
|
||||||
System.out.println(" " + systemManager.getFullStatus(djiAirport));
|
System.out.println(" " + djiManager.getFullStatus(djiAirport));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
System.out.println("5. DJI机巢开舱: " + djiAirport);
|
System.out.println("5. DJI机巢开舱: " + djiAirport);
|
||||||
systemManager.openCover(djiAirport);
|
djiManager.openCover(djiAirport);
|
||||||
System.out.println(" " + systemManager.getFullStatus(djiAirport));
|
System.out.println(" " + djiManager.getFullStatus(djiAirport));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
System.out.println("6. DJI机巢舱门打开完成: " + djiAirport);
|
System.out.println("6. DJI机巢舱门打开完成: " + djiAirport);
|
||||||
systemManager.coverOpened(djiAirport);
|
djiManager.coverOpened(djiAirport);
|
||||||
System.out.println(" " + systemManager.getFullStatus(djiAirport));
|
System.out.println(" " + djiManager.getFullStatus(djiAirport));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
|
|
@ -84,23 +85,23 @@ public class MultiPlatformDemo {
|
||||||
System.out.println("----------------------------------------");
|
System.out.println("----------------------------------------");
|
||||||
|
|
||||||
System.out.println("7. AUTEL机巢开启调试模式: " + autelAirport);
|
System.out.println("7. AUTEL机巢开启调试模式: " + autelAirport);
|
||||||
systemManager.openDebugMode(autelAirport);
|
autelManager.openDebugMode(autelAirport);
|
||||||
System.out.println(" " + systemManager.getFullStatus(autelAirport));
|
System.out.println(" " + autelManager.getFullStatus(autelAirport));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
System.out.println("8. AUTEL机巢开舱: " + autelAirport);
|
System.out.println("8. AUTEL机巢开舱: " + autelAirport);
|
||||||
systemManager.openCover(autelAirport);
|
autelManager.openCover(autelAirport);
|
||||||
System.out.println(" " + systemManager.getFullStatus(autelAirport));
|
System.out.println(" " + autelManager.getFullStatus(autelAirport));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
// ==================== 场景4: 查看所有机巢状态 ====================
|
// ==================== 场景4: 查看所有机巢状态 ====================
|
||||||
System.out.println("【场景4】查看所有机巢当前状态");
|
System.out.println("【场景4】查看所有机巢当前状态");
|
||||||
System.out.println("----------------------------------------");
|
System.out.println("----------------------------------------");
|
||||||
System.out.println("DJI机巢-001: " + systemManager.getFullStatus(djiAirport));
|
System.out.println("DJI机巢-001: " + djiManager.getFullStatus(djiAirport));
|
||||||
System.out.println("AUTEL机巢-002: " + systemManager.getFullStatus(autelAirport));
|
System.out.println("AUTEL机巢-002: " + autelManager.getFullStatus(autelAirport));
|
||||||
System.out.println("DJI机巢-003: " + systemManager.getFullStatus(djiAirport2));
|
System.out.println("DJI机巢-003: " + djiManager2.getFullStatus(djiAirport2));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
|
|
@ -109,14 +110,14 @@ public class MultiPlatformDemo {
|
||||||
System.out.println("----------------------------------------");
|
System.out.println("----------------------------------------");
|
||||||
|
|
||||||
System.out.println("9. DJI机巢关舱: " + djiAirport);
|
System.out.println("9. DJI机巢关舱: " + djiAirport);
|
||||||
systemManager.closeCover(djiAirport);
|
djiManager.closeCover(djiAirport);
|
||||||
System.out.println(" " + systemManager.getFullStatus(djiAirport));
|
System.out.println(" " + djiManager.getFullStatus(djiAirport));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
System.out.println("10. DJI机巢舱门关闭完成: " + djiAirport);
|
System.out.println("10. DJI机巢舱门关闭完成: " + djiAirport);
|
||||||
systemManager.coverClosed(djiAirport);
|
djiManager.coverClosed(djiAirport);
|
||||||
System.out.println(" " + systemManager.getFullStatus(djiAirport));
|
System.out.println(" " + djiManager.getFullStatus(djiAirport));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
|
|
||||||
|
|
@ -127,8 +128,9 @@ public class MultiPlatformDemo {
|
||||||
String yuneecAirport = "airport-004";
|
String yuneecAirport = "airport-004";
|
||||||
System.out.println("11. 注册YUNEEC平台机巢: " + yuneecAirport);
|
System.out.println("11. 注册YUNEEC平台机巢: " + yuneecAirport);
|
||||||
System.out.println(" 平台类型: " + strategyFactory.getPlatformType(yuneecAirport).getName());
|
System.out.println(" 平台类型: " + strategyFactory.getPlatformType(yuneecAirport).getName());
|
||||||
systemManager.airportOnline(yuneecAirport);
|
AirportSystemManager yuneecManager = strategyFactory.getSystemManager(yuneecAirport);
|
||||||
System.out.println(" " + systemManager.getFullStatus(yuneecAirport));
|
yuneecManager.airportOnline(yuneecAirport);
|
||||||
|
System.out.println(" " + yuneecManager.getFullStatus(yuneecAirport));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
// ==================== 场景7: 最终状态汇总 ====================
|
// ==================== 场景7: 最终状态汇总 ====================
|
||||||
|
|
@ -139,19 +141,19 @@ public class MultiPlatformDemo {
|
||||||
System.out.println(String.format("%-20s %-15s %s",
|
System.out.println(String.format("%-20s %-15s %s",
|
||||||
djiAirport,
|
djiAirport,
|
||||||
strategyFactory.getPlatformType(djiAirport).getName(),
|
strategyFactory.getPlatformType(djiAirport).getName(),
|
||||||
systemManager.getFullStatus(djiAirport)));
|
djiManager.getFullStatus(djiAirport)));
|
||||||
System.out.println(String.format("%-20s %-15s %s",
|
System.out.println(String.format("%-20s %-15s %s",
|
||||||
autelAirport,
|
autelAirport,
|
||||||
strategyFactory.getPlatformType(autelAirport).getName(),
|
strategyFactory.getPlatformType(autelAirport).getName(),
|
||||||
systemManager.getFullStatus(autelAirport)));
|
autelManager.getFullStatus(autelAirport)));
|
||||||
System.out.println(String.format("%-20s %-15s %s",
|
System.out.println(String.format("%-20s %-15s %s",
|
||||||
djiAirport2,
|
djiAirport2,
|
||||||
strategyFactory.getPlatformType(djiAirport2).getName(),
|
strategyFactory.getPlatformType(djiAirport2).getName(),
|
||||||
systemManager.getFullStatus(djiAirport2)));
|
djiManager2.getFullStatus(djiAirport2)));
|
||||||
System.out.println(String.format("%-20s %-15s %s",
|
System.out.println(String.format("%-20s %-15s %s",
|
||||||
yuneecAirport,
|
yuneecAirport,
|
||||||
strategyFactory.getPlatformType(yuneecAirport).getName(),
|
strategyFactory.getPlatformType(yuneecAirport).getName(),
|
||||||
systemManager.getFullStatus(yuneecAirport)));
|
yuneecManager.getFullStatus(yuneecAirport)));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
|
||||||
System.out.println("\n========== 多平台机巢系统演示结束 ==========\n");
|
System.out.println("\n========== 多平台机巢系统演示结束 ==========\n");
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
package com.tuoheng.status.airport.guard.airport;
|
package com.tuoheng.status.airport.guard.airport;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查机巢是否可以离线
|
* Base guard for checking if an airport can go offline; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class CanOfflineGuard implements PlatformGuard<AirportState, AirportEvent> {
|
||||||
public class CanOfflineGuard implements Guard<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
// TODO: 检查机巢是否可以安全离线(例如:无人机已降落、舱门已关闭等)
|
|
||||||
System.out.println("检查机巢是否可以离线");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
package com.tuoheng.status.airport.guard.airport;
|
package com.tuoheng.status.airport.guard.airport;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查机巢是否可以上线
|
* Base guard for checking if an airport can go online; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class CanOnlineGuard implements PlatformGuard<AirportState, AirportEvent> {
|
||||||
public class CanOnlineGuard implements Guard<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
// TODO: 检查机巢是否可以上线(例如:设备状态正常、网络连接正常等)
|
|
||||||
System.out.println("检查机巢是否可以上线");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
package com.tuoheng.status.airport.guard.airport;
|
package com.tuoheng.status.airport.guard.airport;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查机巢是否在线
|
* Base guard for checking airport online status; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class IsAirportOnlineGuard implements PlatformGuard<AirportState, AirportEvent> {
|
||||||
public class IsAirportOnlineGuard implements Guard<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
// TODO: 检查机巢是否在线
|
|
||||||
System.out.println("检查机巢是否在线");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,12 @@
|
||||||
package com.tuoheng.status.airport.guard.cover;
|
package com.tuoheng.status.airport.guard.cover;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
||||||
import org.springframework.statemachine.StateContext;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否可以关舱
|
* Base guard for closing the cover; platform implementations extend this.
|
||||||
* 条件:舱门状态不是已关闭
|
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class CanCloseCoverGuard implements PlatformGuard<CoverState, CoverEvent> {
|
||||||
public class CanCloseCoverGuard implements Guard<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
// TODO: 检查当前舱门状态不是已关闭
|
|
||||||
System.out.println("检查是否可以关舱");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,12 @@
|
||||||
package com.tuoheng.status.airport.guard.cover;
|
package com.tuoheng.status.airport.guard.cover;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
||||||
import org.springframework.statemachine.StateContext;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否可以开舱
|
* Base guard for opening the cover; platform implementations extend this.
|
||||||
* 条件:舱门状态不是已打开
|
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class CanOpenCoverGuard implements PlatformGuard<CoverState, CoverEvent> {
|
||||||
public class CanOpenCoverGuard implements Guard<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
// TODO: 检查当前舱门状态不是已打开
|
|
||||||
System.out.println("检查是否可以开舱");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,12 @@
|
||||||
package com.tuoheng.status.airport.guard.cover;
|
package com.tuoheng.status.airport.guard.cover;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
||||||
import org.springframework.statemachine.StateContext;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查舱门是否已完全关闭
|
* Base guard for verifying the cover is closed; platform implementations extend this.
|
||||||
* 用于验证 COVER_CLOSED 事件的有效性
|
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class IsCoverClosedGuard implements PlatformGuard<CoverState, CoverEvent> {
|
||||||
public class IsCoverClosedGuard implements Guard<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
// TODO: 检查舱门是否已完全关闭(通过OSD状态确认)
|
|
||||||
System.out.println("检查舱门是否已完全关闭");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,12 @@
|
||||||
package com.tuoheng.status.airport.guard.cover;
|
package com.tuoheng.status.airport.guard.cover;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
||||||
import org.springframework.statemachine.StateContext;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查舱门是否已完全打开
|
* Base guard for verifying the cover is opened; platform implementations extend this.
|
||||||
* 用于验证 COVER_OPENED 事件的有效性
|
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class IsCoverOpenedGuard implements PlatformGuard<CoverState, CoverEvent> {
|
||||||
public class IsCoverOpenedGuard implements Guard<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
// TODO: 检查舱门是否已完全打开(通过OSD状态确认)
|
|
||||||
System.out.println("检查舱门是否已完全打开");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
package com.tuoheng.status.airport.guard.debug;
|
package com.tuoheng.status.airport.guard.debug;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否可以关闭调试模式
|
* Base guard for closing debug mode; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class CanCloseDebugModeGuard implements PlatformGuard<AirportState, AirportEvent> {
|
||||||
public class CanCloseDebugModeGuard implements Guard<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
// TODO: 检查是否可以关闭调试模式(例如:没有正在进行的操作)
|
|
||||||
System.out.println("检查是否可以关闭调试模式");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
package com.tuoheng.status.airport.guard.debug;
|
package com.tuoheng.status.airport.guard.debug;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否处于调试模式
|
* Base guard for checking debug mode; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class IsDebugModeGuard implements PlatformGuard<AirportState, AirportEvent> {
|
||||||
public class IsDebugModeGuard implements Guard<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
// TODO: 检查当前是否处于调试模式
|
|
||||||
System.out.println("检查是否处于调试模式");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
package com.tuoheng.status.airport.guard.debug;
|
package com.tuoheng.status.airport.guard.debug;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查是否不处于调试模式
|
* Base guard for checking non-debug mode; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class IsNotDebugModeGuard implements PlatformGuard<AirportState, AirportEvent> {
|
||||||
public class IsNotDebugModeGuard implements Guard<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
// TODO: 检查当前不处于调试模式
|
|
||||||
System.out.println("检查是否不处于调试模式");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,12 @@
|
||||||
package com.tuoheng.status.airport.guard.reboot;
|
package com.tuoheng.status.airport.guard.reboot;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
|
||||||
import org.springframework.statemachine.guard.Guard;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查机巢重启是否完成
|
* Base guard for verifying reboot completion; platform implementations extend this.
|
||||||
*/
|
*/
|
||||||
@Component
|
public abstract class IsRebootCompletedGuard implements PlatformGuard<AirportState, AirportEvent> {
|
||||||
public class IsRebootCompletedGuard implements Guard<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean evaluate(StateContext<AirportState, AirportEvent> stateContext) {
|
|
||||||
// TODO: 检查机巢重启是否完成(通过Events事件确认)
|
|
||||||
System.out.println("检查机巢重启是否完成");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,9 @@ import org.springframework.stereotype.Component;
|
||||||
* 默认机巢状态监听器
|
* 默认机巢状态监听器
|
||||||
* 提供基础的状态变化监听功能,各平台可以继承并定制
|
* 提供基础的状态变化监听功能,各平台可以继承并定制
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
public class DefaultAirportListener implements PlatformListener<AirportState, AirportEvent> {
|
|
||||||
|
|
||||||
@Override
|
public abstract class DefaultAirportListener implements PlatformListener<AirportState, AirportEvent> {
|
||||||
public String getName() {
|
|
||||||
return "DefaultAirportListener";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(State<AirportState, AirportEvent> from, State<AirportState, AirportEvent> to) {
|
public void stateChanged(State<AirportState, AirportEvent> from, State<AirportState, AirportEvent> to) {
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ import org.springframework.stereotype.Component;
|
||||||
* 默认舱门状态监听器
|
* 默认舱门状态监听器
|
||||||
* 提供基础的状态变化监听功能,各平台可以继承并定制
|
* 提供基础的状态变化监听功能,各平台可以继承并定制
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
public class DefaultCoverListener implements PlatformListener<CoverState, CoverEvent> {
|
public abstract class DefaultCoverListener implements PlatformListener<CoverState, CoverEvent> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.tuoheng.status.airport.manager;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.platform.PlatformType;
|
||||||
|
import com.tuoheng.status.airport.service.AirportMachineService;
|
||||||
|
import com.tuoheng.status.airport.service.CoverMachineService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机巢系统管理器抽象类
|
||||||
|
* 提供通用的业务编排能力,具体实现可按需扩展
|
||||||
|
*/
|
||||||
|
public abstract class AbstractAirportSystemManager implements AirportSystemManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子类需要声明自己支持的平台类型
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public abstract PlatformType getPlatformType();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected AirportMachineService airportService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
protected CoverMachineService coverService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,154 +1,43 @@
|
||||||
package com.tuoheng.status.airport.manager;
|
package com.tuoheng.status.airport.manager;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.platform.PlatformType;
|
||||||
import com.tuoheng.status.airport.events.CoverEvent;
|
|
||||||
import com.tuoheng.status.airport.service.AirportMachineService;
|
|
||||||
import com.tuoheng.status.airport.service.CoverMachineService;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import com.tuoheng.status.airport.status.CoverState;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机巢系统管理器
|
* 机巢系统管理器接口
|
||||||
* 协调机巢状态机和舱门状态机
|
* 抽象对外能力,便于后续扩展不同实现
|
||||||
*/
|
*/
|
||||||
@Component
|
public interface AirportSystemManager {
|
||||||
public class AirportSystemManager {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AirportMachineService airportService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CoverMachineService coverService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 机巢上线
|
* 该Manager对应的平台类型
|
||||||
*/
|
*/
|
||||||
public boolean airportOnline(String airportSn) {
|
PlatformType getPlatformType();
|
||||||
return airportService.sendEvent(airportSn, AirportEvent.AIRPORT_ONLINE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
boolean airportOnline(String airportSn);
|
||||||
* 机巢离线
|
|
||||||
*/
|
|
||||||
public boolean airportOffline(String airportSn) {
|
|
||||||
return airportService.sendEvent(airportSn, AirportEvent.AIRPORT_OFFLINE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
boolean airportOffline(String airportSn);
|
||||||
* 开启调试模式
|
|
||||||
*/
|
|
||||||
public boolean openDebugMode(String airportSn) {
|
|
||||||
if (!airportService.isInState(airportSn, AirportState.ONLINE)) {
|
|
||||||
System.out.println("机巢未在线,无法开启调试模式");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return airportService.sendEvent(airportSn, AirportEvent.DEBUG_MODE_OPEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
boolean openDebugMode(String airportSn);
|
||||||
* 关闭调试模式
|
|
||||||
*/
|
|
||||||
public boolean closeDebugMode(String airportSn) {
|
|
||||||
return airportService.sendEvent(airportSn, AirportEvent.DEBUG_MODE_CLOSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
boolean closeDebugMode(String airportSn);
|
||||||
* 开舱
|
|
||||||
*/
|
|
||||||
public boolean openCover(String airportSn) {
|
|
||||||
// 检查机巢是否在调试模式
|
|
||||||
if (!airportService.isInState(airportSn, AirportState.DEBUG_MODE)) {
|
|
||||||
System.out.println("必须在调试模式下才能开舱");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查舱门是否已经打开
|
boolean openCover(String airportSn);
|
||||||
if (coverService.isInState(airportSn, CoverState.OPENED)) {
|
|
||||||
System.out.println("舱门已经打开");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送开舱指令到舱门状态机
|
boolean coverOpened(String airportSn);
|
||||||
return coverService.sendEvent(airportSn, CoverEvent.OPEN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
boolean closeCover(String airportSn);
|
||||||
* 舱门打开完成
|
|
||||||
*/
|
|
||||||
public boolean coverOpened(String airportSn) {
|
|
||||||
return coverService.sendEvent(airportSn, CoverEvent.OPENED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
boolean coverClosed(String airportSn);
|
||||||
* 关舱
|
|
||||||
*/
|
|
||||||
public boolean closeCover(String airportSn) {
|
|
||||||
// 检查机巢是否在调试模式
|
|
||||||
if (!airportService.isInState(airportSn, AirportState.DEBUG_MODE)) {
|
|
||||||
System.out.println("必须在调试模式下才能关舱");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查舱门是否已经关闭
|
boolean rebootAirport(String airportSn);
|
||||||
if (coverService.isInState(airportSn, CoverState.CLOSED)) {
|
|
||||||
System.out.println("舱门已经关闭");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 发送关舱指令到舱门状态机
|
boolean rebootCompleted(String airportSn);
|
||||||
return coverService.sendEvent(airportSn, CoverEvent.CLOSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
AirportState getAirportState(String airportSn);
|
||||||
* 舱门关闭完成
|
|
||||||
*/
|
|
||||||
public boolean coverClosed(String airportSn) {
|
|
||||||
return coverService.sendEvent(airportSn, CoverEvent.CLOSED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
CoverState getCoverState(String airportSn);
|
||||||
* 机巢重启
|
|
||||||
*/
|
|
||||||
public boolean rebootAirport(String airportSn) {
|
|
||||||
if (!airportService.isInState(airportSn, AirportState.DEBUG_MODE)) {
|
|
||||||
System.out.println("必须在调试模式下才能重启");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return airportService.sendEvent(airportSn, AirportEvent.AIRPORT_REBOOT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
String getFullStatus(String airportSn);
|
||||||
* 重启完成
|
|
||||||
*/
|
|
||||||
public boolean rebootCompleted(String airportSn) {
|
|
||||||
return airportService.sendEvent(airportSn, AirportEvent.REBOOT_COMPLETED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取机巢状态
|
|
||||||
*/
|
|
||||||
public AirportState getAirportState(String airportSn) {
|
|
||||||
return airportService.getCurrentState(airportSn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取舱门状态
|
|
||||||
*/
|
|
||||||
public CoverState getCoverState(String airportSn) {
|
|
||||||
return coverService.getCurrentState(airportSn);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取完整状态信息
|
|
||||||
*/
|
|
||||||
public String getFullStatus(String airportSn) {
|
|
||||||
AirportState airportState = getAirportState(airportSn);
|
|
||||||
CoverState coverState = getCoverState(airportSn);
|
|
||||||
|
|
||||||
return String.format("机巢状态: %s, 舱门状态: %s",
|
|
||||||
airportState != null ? airportState : "未知",
|
|
||||||
coverState != null ? coverState : "未知");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.tuoheng.status.airport.platform.factory;
|
package com.tuoheng.status.airport.platform.factory;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.manager.AirportSystemManager;
|
||||||
import com.tuoheng.status.airport.platform.PlatformType;
|
import com.tuoheng.status.airport.platform.PlatformType;
|
||||||
import com.tuoheng.status.airport.platform.repository.AirportPlatformRepository;
|
import com.tuoheng.status.airport.platform.repository.AirportPlatformRepository;
|
||||||
import com.tuoheng.status.airport.platform.strategy.AirportPlatformStrategy;
|
import com.tuoheng.status.airport.platform.strategy.AirportPlatformStrategy;
|
||||||
|
|
@ -35,6 +36,13 @@ public class PlatformStrategyFactory {
|
||||||
*/
|
*/
|
||||||
private final Map<PlatformType, CoverPlatformStrategy> coverStrategyMap = new ConcurrentHashMap<>();
|
private final Map<PlatformType, CoverPlatformStrategy> coverStrategyMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 存储各平台对应的系统管理器实现
|
||||||
|
* Key: PlatformType
|
||||||
|
* Value: AirportSystemManager实现
|
||||||
|
*/
|
||||||
|
private final Map<PlatformType, AirportSystemManager> managerMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册所有平台策略
|
* 注册所有平台策略
|
||||||
* Spring会自动注入所有实现了AirportPlatformStrategy和CoverPlatformStrategy的Bean
|
* Spring会自动注入所有实现了AirportPlatformStrategy和CoverPlatformStrategy的Bean
|
||||||
|
|
@ -42,7 +50,8 @@ public class PlatformStrategyFactory {
|
||||||
@Autowired
|
@Autowired
|
||||||
public void registerStrategies(
|
public void registerStrategies(
|
||||||
List<AirportPlatformStrategy> airportStrategies,
|
List<AirportPlatformStrategy> airportStrategies,
|
||||||
List<CoverPlatformStrategy> coverStrategies) {
|
List<CoverPlatformStrategy> coverStrategies,
|
||||||
|
List<AirportSystemManager> systemManagers) {
|
||||||
|
|
||||||
// 注册机巢策略
|
// 注册机巢策略
|
||||||
for (AirportPlatformStrategy strategy : airportStrategies) {
|
for (AirportPlatformStrategy strategy : airportStrategies) {
|
||||||
|
|
@ -57,6 +66,13 @@ public class PlatformStrategyFactory {
|
||||||
System.out.println(String.format("注册舱门平台策略: %s -> %s",
|
System.out.println(String.format("注册舱门平台策略: %s -> %s",
|
||||||
strategy.getPlatformType().getName(), strategy.getClass().getSimpleName()));
|
strategy.getPlatformType().getName(), strategy.getClass().getSimpleName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 注册系统管理器
|
||||||
|
for (AirportSystemManager manager : systemManagers) {
|
||||||
|
managerMap.put(manager.getPlatformType(), manager);
|
||||||
|
System.out.println(String.format("注册系统管理器: %s -> %s",
|
||||||
|
manager.getPlatformType().getName(), manager.getClass().getSimpleName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -111,6 +127,30 @@ public class PlatformStrategyFactory {
|
||||||
return strategy;
|
return strategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据机巢SN获取对应的平台系统管理器
|
||||||
|
*
|
||||||
|
* @param airportSn 机巢序列号
|
||||||
|
* @return 对应平台的AirportSystemManager实现
|
||||||
|
*/
|
||||||
|
public AirportSystemManager getSystemManager(String airportSn) {
|
||||||
|
PlatformType platformType = airportPlatformRepository.getPlatformType(airportSn);
|
||||||
|
|
||||||
|
if (platformType == null) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format("机巢未注册或平台类型未配置: %s", airportSn));
|
||||||
|
}
|
||||||
|
|
||||||
|
AirportSystemManager manager = managerMap.get(platformType);
|
||||||
|
|
||||||
|
if (manager == null) {
|
||||||
|
throw new IllegalArgumentException(
|
||||||
|
String.format("未找到平台系统管理器: %s (机巢: %s)", platformType.getName(), airportSn));
|
||||||
|
}
|
||||||
|
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据平台类型获取机巢平台策略
|
* 根据平台类型获取机巢平台策略
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji;
|
package com.tuoheng.status.airport.platform.impl.dji;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.listener.DefaultAirportListener;
|
import com.tuoheng.status.airport.platform.impl.dji.listener.DjiAirportListener;
|
||||||
import com.tuoheng.status.airport.platform.PlatformType;
|
import com.tuoheng.status.airport.platform.PlatformType;
|
||||||
import com.tuoheng.status.airport.platform.impl.dji.action.airport.*;
|
import com.tuoheng.status.airport.platform.impl.dji.action.airport.*;
|
||||||
import com.tuoheng.status.airport.platform.impl.dji.guard.airport.*;
|
import com.tuoheng.status.airport.platform.impl.dji.guard.airport.*;
|
||||||
|
|
@ -13,9 +13,6 @@ import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DJI平台机巢策略实现
|
* DJI平台机巢策略实现
|
||||||
*/
|
*/
|
||||||
|
|
@ -57,16 +54,11 @@ public class DjiAirportPlatformStrategy implements AirportPlatformStrategy {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DjiRebootCompletedAction rebootCompletedAction;
|
private DjiRebootCompletedAction rebootCompletedAction;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DJI平台的Listener实例(单例,所有DJI机巢共享)
|
* DJI平台的Listener实例(单例,所有DJI机巢共享)
|
||||||
*/
|
*/
|
||||||
private final PlatformListener<AirportState, AirportEvent> djiListener = new DefaultAirportListener() {
|
@Autowired
|
||||||
@Override
|
private DjiAirportListener djiListener;
|
||||||
public String getName() {
|
|
||||||
return "DjiAirportListener";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlatformType getPlatformType() {
|
public PlatformType getPlatformType() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
package com.tuoheng.status.airport.platform.impl.dji;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.manager.AbstractAirportSystemManager;
|
||||||
|
import com.tuoheng.status.airport.platform.PlatformType;
|
||||||
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 大疆平台机巢系统管理器实现
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class DjiAirportSystemManager extends AbstractAirportSystemManager {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlatformType getPlatformType() {
|
||||||
|
return PlatformType.DJI;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean airportOnline(String airportSn) {
|
||||||
|
return airportService.sendEvent(airportSn, AirportEvent.AIRPORT_ONLINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)) {
|
||||||
|
System.out.println("机巢未在线,无法开启调试模式");
|
||||||
|
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)) {
|
||||||
|
System.out.println("必须在调试模式下才能开舱");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (coverService.isInState(airportSn, CoverState.OPENED)) {
|
||||||
|
System.out.println("舱门已经打开");
|
||||||
|
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)) {
|
||||||
|
System.out.println("必须在调试模式下才能关舱");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (coverService.isInState(airportSn, CoverState.CLOSED)) {
|
||||||
|
System.out.println("舱门已经关闭");
|
||||||
|
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)) {
|
||||||
|
System.out.println("必须在调试模式下才能重启");
|
||||||
|
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 : "未知");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji;
|
package com.tuoheng.status.airport.platform.impl.dji;
|
||||||
|
|
||||||
import com.tuoheng.status.airport.events.CoverEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.listener.DefaultCoverListener;
|
import com.tuoheng.status.airport.platform.impl.dji.listener.DjiCoverListener;
|
||||||
import com.tuoheng.status.airport.platform.PlatformType;
|
import com.tuoheng.status.airport.platform.PlatformType;
|
||||||
import com.tuoheng.status.airport.platform.impl.dji.action.cover.*;
|
import com.tuoheng.status.airport.platform.impl.dji.action.cover.*;
|
||||||
import com.tuoheng.status.airport.platform.impl.dji.guard.cover.*;
|
import com.tuoheng.status.airport.platform.impl.dji.guard.cover.*;
|
||||||
|
|
@ -52,12 +52,8 @@ public class DjiCoverPlatformStrategy implements CoverPlatformStrategy {
|
||||||
/**
|
/**
|
||||||
* DJI平台的舱门Listener实例(单例,所有DJI机巢共享)
|
* DJI平台的舱门Listener实例(单例,所有DJI机巢共享)
|
||||||
*/
|
*/
|
||||||
private final PlatformListener<CoverState, CoverEvent> djiCoverListener = new com.tuoheng.status.airport.listener.DefaultCoverListener() {
|
@Autowired
|
||||||
@Override
|
private DjiCoverListener djiCoverListener ;
|
||||||
public String getName() {
|
|
||||||
return "DjiCoverListener";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlatformType getPlatformType() {
|
public PlatformType getPlatformType() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.action.debug.CloseDebugModeAction;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiCloseDebugModeAction implements PlatformAction<AirportState, AirportEvent> {
|
public class DjiCloseDebugModeAction extends CloseDebugModeAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.action.airport.OfflineAction;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiOfflineAction implements PlatformAction<AirportState, AirportEvent> {
|
public class DjiOfflineAction extends OfflineAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.action.airport.OnlineAction;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiOnlineAction implements PlatformAction<AirportState, AirportEvent> {
|
public class DjiOnlineAction extends OnlineAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.action.debug.OpenDebugModeAction;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiOpenDebugModeAction implements PlatformAction<AirportState, AirportEvent> {
|
public class DjiOpenDebugModeAction extends OpenDebugModeAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.action.reboot.RebootAction;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiRebootAction implements PlatformAction<AirportState, AirportEvent> {
|
public class DjiRebootAction extends RebootAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.action.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.action.reboot.RebootCompletedAction;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiRebootCompletedAction implements PlatformAction<AirportState, AirportEvent> {
|
public class DjiRebootCompletedAction extends RebootCompletedAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.action.cover;
|
package com.tuoheng.status.airport.platform.impl.dji.action.cover;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.action.cover.CloseCoverAction;
|
||||||
import com.tuoheng.status.airport.events.CoverEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
|
||||||
import com.tuoheng.status.airport.status.CoverState;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiCloseCoverAction implements PlatformAction<CoverState, CoverEvent> {
|
public class DjiCloseCoverAction extends CloseCoverAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.action.cover;
|
package com.tuoheng.status.airport.platform.impl.dji.action.cover;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.action.cover.CoverClosedAction;
|
||||||
import com.tuoheng.status.airport.events.CoverEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
|
||||||
import com.tuoheng.status.airport.status.CoverState;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiCoverClosedAction implements PlatformAction<CoverState, CoverEvent> {
|
public class DjiCoverClosedAction extends CoverClosedAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.action.cover;
|
package com.tuoheng.status.airport.platform.impl.dji.action.cover;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.action.cover.CoverOpenedAction;
|
||||||
import com.tuoheng.status.airport.events.CoverEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
|
||||||
import com.tuoheng.status.airport.status.CoverState;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiCoverOpenedAction implements PlatformAction<CoverState, CoverEvent> {
|
public class DjiCoverOpenedAction extends CoverOpenedAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.action.cover;
|
package com.tuoheng.status.airport.platform.impl.dji.action.cover;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.action.cover.OpenCoverAction;
|
||||||
import com.tuoheng.status.airport.events.CoverEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformAction;
|
|
||||||
import com.tuoheng.status.airport.status.CoverState;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiOpenCoverAction implements PlatformAction<CoverState, CoverEvent> {
|
public class DjiOpenCoverAction extends OpenCoverAction {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.guard.debug.CanCloseDebugModeGuard;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiCanCloseDebugModeGuard implements PlatformGuard<AirportState, AirportEvent> {
|
public class DjiCanCloseDebugModeGuard extends CanCloseDebugModeGuard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.guard.airport.CanOfflineGuard;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiCanOfflineGuard implements PlatformGuard<AirportState, AirportEvent> {
|
public class DjiCanOfflineGuard extends CanOfflineGuard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.guard.airport.CanOnlineGuard;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -10,7 +10,7 @@ import org.springframework.stereotype.Component;
|
||||||
* DJI平台 - 机巢上线Guard
|
* DJI平台 - 机巢上线Guard
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class DjiCanOnlineGuard implements PlatformGuard<AirportState, AirportEvent> {
|
public class DjiCanOnlineGuard extends CanOnlineGuard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.guard.debug.IsDebugModeGuard;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiIsDebugModeGuard implements PlatformGuard<AirportState, AirportEvent> {
|
public class DjiIsDebugModeGuard extends IsDebugModeGuard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.guard.debug.IsNotDebugModeGuard;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiIsNotDebugModeGuard implements PlatformGuard<AirportState, AirportEvent> {
|
public class DjiIsNotDebugModeGuard extends IsNotDebugModeGuard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
package com.tuoheng.status.airport.platform.impl.dji.guard.airport;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.guard.reboot.IsRebootCompletedGuard;
|
||||||
import com.tuoheng.status.airport.events.AirportEvent;
|
import com.tuoheng.status.airport.events.AirportEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
|
||||||
import com.tuoheng.status.airport.status.AirportState;
|
import com.tuoheng.status.airport.status.AirportState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiIsRebootCompletedGuard implements PlatformGuard<AirportState, AirportEvent> {
|
public class DjiIsRebootCompletedGuard extends IsRebootCompletedGuard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.guard.cover;
|
package com.tuoheng.status.airport.platform.impl.dji.guard.cover;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.guard.cover.CanCloseCoverGuard;
|
||||||
import com.tuoheng.status.airport.events.CoverEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
|
||||||
import com.tuoheng.status.airport.status.CoverState;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiCanCloseCoverGuard implements PlatformGuard<CoverState, CoverEvent> {
|
public class DjiCanCloseCoverGuard extends CanCloseCoverGuard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.guard.cover;
|
package com.tuoheng.status.airport.platform.impl.dji.guard.cover;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.guard.cover.CanOpenCoverGuard;
|
||||||
import com.tuoheng.status.airport.events.CoverEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
|
||||||
import com.tuoheng.status.airport.status.CoverState;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiCanOpenCoverGuard implements PlatformGuard<CoverState, CoverEvent> {
|
public class DjiCanOpenCoverGuard extends CanOpenCoverGuard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.guard.cover;
|
package com.tuoheng.status.airport.platform.impl.dji.guard.cover;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.guard.cover.IsCoverClosedGuard;
|
||||||
import com.tuoheng.status.airport.events.CoverEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
|
||||||
import com.tuoheng.status.airport.status.CoverState;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiIsCoverClosedGuard implements PlatformGuard<CoverState, CoverEvent> {
|
public class DjiIsCoverClosedGuard extends IsCoverClosedGuard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
package com.tuoheng.status.airport.platform.impl.dji.guard.cover;
|
package com.tuoheng.status.airport.platform.impl.dji.guard.cover;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.guard.cover.IsCoverOpenedGuard;
|
||||||
import com.tuoheng.status.airport.events.CoverEvent;
|
import com.tuoheng.status.airport.events.CoverEvent;
|
||||||
import com.tuoheng.status.airport.platform.strategy.PlatformGuard;
|
|
||||||
import com.tuoheng.status.airport.status.CoverState;
|
import com.tuoheng.status.airport.status.CoverState;
|
||||||
import org.springframework.statemachine.StateContext;
|
import org.springframework.statemachine.StateContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DjiIsCoverOpenedGuard implements PlatformGuard<CoverState, CoverEvent> {
|
public class DjiIsCoverOpenedGuard extends IsCoverOpenedGuard {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.tuoheng.status.airport.platform.impl.dji.listener;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.listener.DefaultAirportListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class DjiAirportListener extends DefaultAirportListener {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return "DjiAirportListener";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.tuoheng.status.airport.platform.impl.dji.listener;
|
||||||
|
|
||||||
|
import com.tuoheng.status.airport.listener.DefaultCoverListener;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class DjiCoverListener extends DefaultCoverListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName(){
|
||||||
|
return "DjiCoverListener";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue