qpc/doxygen/snippets/qep_qfsm_use.c

22 lines
606 B
C
Raw Normal View History

2015-12-24 14:33:20 -05:00
#include "qpc.h" /* QP/C public interface */
2019-02-10 21:00:39 -05:00
#include "bomb.h" /* Bomb derived from QHsm */
2012-08-14 18:07:04 -04:00
2019-02-10 21:00:39 -05:00
Q_DEFINE_THIS_FILE
static Bomb l_bomb; /* an instance of Bomb HSM */
2012-08-14 18:07:04 -04:00
int main() {
2015-12-24 14:33:20 -05:00
Bomb_ctor(&l_bomb); /* Bomb "constructor" invokes QFsm_ctor() */
2012-08-14 18:07:04 -04:00
2015-12-24 14:33:20 -05:00
QMSM_INIT(&l_bomb.super, (QEvt *)0); /* trigger initial transition */
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
for (;;) { /* event loop */
2013-09-23 14:34:35 -04:00
QEvt e;
2012-08-14 18:07:04 -04:00
. . .
/* wait for the next event and assign it to the event object e */
. . .
2015-12-24 14:33:20 -05:00
QMSM_DISPATCH(&l_bomb.super, &e); /* dispatch e */
2012-08-14 18:07:04 -04:00
}
2015-04-28 13:45:35 -04:00
return 0; /* never reached, needed for some compilers */
2012-08-14 18:07:04 -04:00
}