hsm
hsm copied to clipboard
[FEATURE] Call a state activity
Problem
How to run a state activity when I'm on a given state ?
An action is instantaneous: it does not consume time (contrary to the activity). The activity can be seen as a thread that is preempted by any external events the state reacts to. https://cs.emis.de/LNI/Proceedings/Proceedings07/TowardEfficCode_3.pdf
struct MyState {
MyState(hsm::sm<MyFSM>& fsm)
: m_sfm(fsm)
{}
void tickActivity()
{
// do_something not blocking too much
// Allow m_fsm.process_event(EventXXX {});
}
sm::sm<MyFSM>& m_fsm;
};
main()
{
hsm::sm<MyFSM> fsm;
while (true)
{
fsm.tickActivity(); // Call the current state tickActivity()
pause(x_ms);
}
}