添加调试模式这种中间状态
This commit is contained in:
parent
51fe7cf816
commit
a0160c237c
|
|
@ -83,7 +83,9 @@ public class AirportMachineConfig {
|
||||||
.initial(AirportState.STANDBY)
|
.initial(AirportState.STANDBY)
|
||||||
.states(EnumSet.of(
|
.states(EnumSet.of(
|
||||||
AirportState.STANDBY,
|
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)
|
.event(AirportEvent.AIRPORT_ONLINE)
|
||||||
.and()
|
.and()
|
||||||
|
|
||||||
|
// UNKNOWN -> ENTERING_DEBUG_MODE
|
||||||
|
.withExternal()
|
||||||
|
.source(AirportState.UNKNOWN)
|
||||||
|
.target(AirportState.ENTERING_DEBUG_MODE)
|
||||||
|
.event(AirportEvent.DEBUG_MODE_OPEN)
|
||||||
|
.and()
|
||||||
|
|
||||||
// UNKNOWN -> DEBUG_MODE
|
// UNKNOWN -> DEBUG_MODE
|
||||||
.withExternal()
|
.withExternal()
|
||||||
.source(AirportState.UNKNOWN)
|
.source(AirportState.UNKNOWN)
|
||||||
.target(AirportState.DEBUG_MODE)
|
.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()
|
.and()
|
||||||
|
|
||||||
// UNKNOWN -> REBOOTING
|
// UNKNOWN -> REBOOTING
|
||||||
|
|
@ -146,24 +162,38 @@ public class AirportMachineConfig {
|
||||||
.guard(strategy.getCanOfflineGuard())
|
.guard(strategy.getCanOfflineGuard())
|
||||||
.and()
|
.and()
|
||||||
|
|
||||||
// STANDBY -> DEBUG_MODE
|
// STANDBY -> ENTERING_DEBUG_MODE
|
||||||
.withExternal()
|
.withExternal()
|
||||||
.source(AirportState.STANDBY)
|
.source(AirportState.STANDBY)
|
||||||
.target(AirportState.DEBUG_MODE)
|
.target(AirportState.ENTERING_DEBUG_MODE)
|
||||||
.event(AirportEvent.DEBUG_MODE_OPEN)
|
.event(AirportEvent.DEBUG_MODE_OPEN)
|
||||||
.action(strategy.getOpenDebugModeAction())
|
.action(strategy.getOpenDebugModeAction())
|
||||||
.guard(strategy.getIsNotDebugModeGuard())
|
.guard(strategy.getIsNotDebugModeGuard())
|
||||||
.and()
|
.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()
|
.withExternal()
|
||||||
.source(AirportState.DEBUG_MODE)
|
.source(AirportState.DEBUG_MODE)
|
||||||
.target(AirportState.STANDBY)
|
.target(AirportState.EXITING_DEBUG_MODE)
|
||||||
.event(AirportEvent.DEBUG_MODE_CLOSE)
|
.event(AirportEvent.DEBUG_MODE_CLOSE)
|
||||||
.action(strategy.getCloseDebugModeAction())
|
.action(strategy.getCloseDebugModeAction())
|
||||||
.guard(strategy.getCanCloseDebugModeGuard())
|
.guard(strategy.getCanCloseDebugModeGuard())
|
||||||
.and()
|
.and()
|
||||||
|
|
||||||
|
// EXITING_DEBUG_MODE -> STANDBY
|
||||||
|
.withExternal()
|
||||||
|
.source(AirportState.EXITING_DEBUG_MODE)
|
||||||
|
.target(AirportState.STANDBY)
|
||||||
|
.event(AirportEvent.DEBUG_MODE_EXITED)
|
||||||
|
.and()
|
||||||
|
|
||||||
// DEBUG_MODE -> REBOOTING
|
// DEBUG_MODE -> REBOOTING
|
||||||
.withExternal()
|
.withExternal()
|
||||||
.source(AirportState.DEBUG_MODE)
|
.source(AirportState.DEBUG_MODE)
|
||||||
|
|
|
||||||
|
|
@ -107,12 +107,7 @@ public class CoverMachineConfig {
|
||||||
.event(CoverEvent.CLOSE)
|
.event(CoverEvent.CLOSE)
|
||||||
.and()
|
.and()
|
||||||
|
|
||||||
// UNKNOWN -> HALF_OPEN
|
|
||||||
.withExternal()
|
|
||||||
.source(CoverState.UNKNOWN)
|
|
||||||
.target(CoverState.HALF_OPEN)
|
|
||||||
.event(CoverEvent.OPENED)
|
|
||||||
.and()
|
|
||||||
|
|
||||||
// UNKNOWN -> ERROR
|
// UNKNOWN -> ERROR
|
||||||
.withExternal()
|
.withExternal()
|
||||||
|
|
|
||||||
|
|
@ -26,12 +26,24 @@ public enum AirportEvent {
|
||||||
*/
|
*/
|
||||||
DEBUG_MODE_OPEN,
|
DEBUG_MODE_OPEN,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进入调试模式完成
|
||||||
|
* 触发源: Events事件
|
||||||
|
*/
|
||||||
|
DEBUG_MODE_ENTERED,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭调试模式
|
* 关闭调试模式
|
||||||
* 触发源: 用户指令/自动
|
* 触发源: 用户指令/自动
|
||||||
*/
|
*/
|
||||||
DEBUG_MODE_CLOSE,
|
DEBUG_MODE_CLOSE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退出调试模式完成
|
||||||
|
* 触发源: Events事件
|
||||||
|
*/
|
||||||
|
DEBUG_MODE_EXITED,
|
||||||
|
|
||||||
// ==================== 机巢重启事件 ====================
|
// ==================== 机巢重启事件 ====================
|
||||||
/**
|
/**
|
||||||
* 机巢重启指令
|
* 机巢重启指令
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,12 @@ public abstract class AbstractAirportSystemManager implements AirportSystemManag
|
||||||
return AirportEvent.AIRPORT_ONLINE;
|
return AirportEvent.AIRPORT_ONLINE;
|
||||||
case OFFLINE:
|
case OFFLINE:
|
||||||
return AirportEvent.AIRPORT_OFFLINE;
|
return AirportEvent.AIRPORT_OFFLINE;
|
||||||
case DEBUG_MODE:
|
case ENTERING_DEBUG_MODE:
|
||||||
return AirportEvent.DEBUG_MODE_OPEN;
|
return AirportEvent.DEBUG_MODE_OPEN;
|
||||||
|
case DEBUG_MODE:
|
||||||
|
return AirportEvent.DEBUG_MODE_ENTERED;
|
||||||
|
case EXITING_DEBUG_MODE:
|
||||||
|
return AirportEvent.DEBUG_MODE_CLOSE;
|
||||||
case REBOOTING:
|
case REBOOTING:
|
||||||
return AirportEvent.AIRPORT_REBOOT;
|
return AirportEvent.AIRPORT_REBOOT;
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,21 @@ public enum AirportState {
|
||||||
*/
|
*/
|
||||||
STANDBY,
|
STANDBY,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进入调试模式中
|
||||||
|
*/
|
||||||
|
ENTERING_DEBUG_MODE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调试模式
|
* 调试模式
|
||||||
*/
|
*/
|
||||||
DEBUG_MODE,
|
DEBUG_MODE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退出调试模式中
|
||||||
|
*/
|
||||||
|
EXITING_DEBUG_MODE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重启中
|
* 重启中
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue