ustinyfsm

This commit is contained in:
zjk
2025-04-06 21:53:41 +08:00
parent 811fbf2924
commit b113a0619b
4 changed files with 373 additions and 24 deletions
+43
View File
@@ -0,0 +1,43 @@
#include "fsm_tinyfsm.h"
#include "PowerManger.h"
// 初始化状态实现
void InitState::entry() {
// 初始化状态进入动作
PowerManger::printState("InitState", "Enter initialization state");
}
void InitState::react(InitEvent const & e) {
// 初始化状态处理逻辑
if (e.data->isInitialized) {
transit<StandbyState>();
}
}
// 待机状态实现
void StandbyState::entry() {
// 待机状态进入动作
PowerManger::printState("StandbyState", "Enter standby state");
}
void StandbyState::react(StandbyEvent const & e) {
// 待机状态处理逻辑
if (e.data->hasFault) {
transit<FaultState>();
}
// 其他待机状态处理...
}
// 故障状态实现
void FaultState::entry() {
// 故障状态进入动作
PowerManger::printState("FaultState", "Enter fault handling state");
}
void FaultState::react(FaultEvent const & e) {
// 故障状态处理逻辑
if (!e.data->hasFault) {
transit<StandbyState>();
}
// 其他故障处理逻辑...
}