添加调试模式这种中间状态

This commit is contained in:
孙小云 2025-12-15 20:09:39 +08:00
parent 51fe7cf816
commit a0160c237c
5 changed files with 64 additions and 13 deletions

View File

@ -83,7 +83,9 @@ public class AirportMachineConfig {
.initial(AirportState.STANDBY)
.states(EnumSet.of(
AirportState.STANDBY,
AirportState.DEBUG_MODE
AirportState.ENTERING_DEBUG_MODE,
AirportState.DEBUG_MODE,
AirportState.EXITING_DEBUG_MODE
));
}
@ -113,11 +115,25 @@ public class AirportMachineConfig {
.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_OPEN)
.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
@ -146,24 +162,38 @@ public class AirportMachineConfig {
.guard(strategy.getCanOfflineGuard())
.and()
// STANDBY -> DEBUG_MODE
// STANDBY -> ENTERING_DEBUG_MODE
.withExternal()
.source(AirportState.STANDBY)
.target(AirportState.DEBUG_MODE)
.target(AirportState.ENTERING_DEBUG_MODE)
.event(AirportEvent.DEBUG_MODE_OPEN)
.action(strategy.getOpenDebugModeAction())
.guard(strategy.getIsNotDebugModeGuard())
.and()
// DEBUG_MODE -> STANDBY
// 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.STANDBY)
.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)

View File

@ -107,12 +107,7 @@ public class CoverMachineConfig {
.event(CoverEvent.CLOSE)
.and()
// UNKNOWN -> HALF_OPEN
.withExternal()
.source(CoverState.UNKNOWN)
.target(CoverState.HALF_OPEN)
.event(CoverEvent.OPENED)
.and()
// UNKNOWN -> ERROR
.withExternal()

View File

@ -26,12 +26,24 @@ public enum AirportEvent {
*/
DEBUG_MODE_OPEN,
/**
* 进入调试模式完成
* 触发源: Events事件
*/
DEBUG_MODE_ENTERED,
/**
* 关闭调试模式
* 触发源: 用户指令/自动
*/
DEBUG_MODE_CLOSE,
/**
* 退出调试模式完成
* 触发源: Events事件
*/
DEBUG_MODE_EXITED,
// ==================== 机巢重启事件 ====================
/**
* 机巢重启指令

View File

@ -126,8 +126,12 @@ public abstract class AbstractAirportSystemManager implements AirportSystemManag
return AirportEvent.AIRPORT_ONLINE;
case OFFLINE:
return AirportEvent.AIRPORT_OFFLINE;
case DEBUG_MODE:
case ENTERING_DEBUG_MODE:
return AirportEvent.DEBUG_MODE_OPEN;
case DEBUG_MODE:
return AirportEvent.DEBUG_MODE_ENTERED;
case EXITING_DEBUG_MODE:
return AirportEvent.DEBUG_MODE_CLOSE;
case REBOOTING:
return AirportEvent.AIRPORT_REBOOT;
default:

View File

@ -24,11 +24,21 @@ public enum AirportState {
*/
STANDBY,
/**
* 进入调试模式中
*/
ENTERING_DEBUG_MODE,
/**
* 调试模式
*/
DEBUG_MODE,
/**
* 退出调试模式中
*/
EXITING_DEBUG_MODE,
/**
* 重启中
*/