qpc/doxygen/snippets/qep_qfsm_use.c

20 lines
570 B
C
Raw Normal View History

2013-09-23 14:34:35 -04:00
#include "qep.h" /* QEP/C public interface */
#include "qbomb.h" /* QBomb derived from QFsm */
2012-08-14 18:07:04 -04:00
2013-09-23 14:34:35 -04:00
static QBomb l_qbomb; /* an instance of QBomb FSM */
2012-08-14 18:07:04 -04:00
int main() {
2013-09-23 14:34:35 -04:00
QBomb_ctor(&l_bomb); /* QBomb "constructor" invokes QFsm_ctor() */
2012-08-14 18:07:04 -04:00
2013-09-23 14:34:35 -04:00
QMSM_INIT(&l_qbomb.super, (QEvt *)0); /* trigger initial transition */
2012-08-14 18:07:04 -04:00
2013-09-23 14:34:35 -04:00
for (;;) { /* event loop */
QEvt e;
2012-08-14 18:07:04 -04:00
. . .
/* wait for the next event and assign it to the event object e */
. . .
2013-09-23 14:34:35 -04:00
QMSM_DISPATCH(&l_qbomb.super, &e); /* dispatch e */
2012-08-14 18:07:04 -04:00
}
return 0;
}