qpc/doxygen/snippets/qep_qmsm_use.c

20 lines
586 B
C
Raw Normal View History

2015-04-28 13:45:35 -04:00
#include "qpc.h" /* QP/C public interface */
#include "calc.h" /* Calc derived from QMsm */
2013-09-23 14:34:35 -04:00
2015-04-28 13:45:35 -04:00
static Calc l_calc; /* an instance of Calc SM */
2013-09-23 14:34:35 -04:00
int main() {
2015-04-28 13:45:35 -04:00
Calc_ctor(&l_calc); /* Calc "constructor" invokes QMsm_ctor() */
2013-09-23 14:34:35 -04:00
2015-04-28 13:45:35 -04:00
QMSM_INIT(&l_calc.super, (QEvt *)0); /* trigger initial transition */
2013-09-23 14:34:35 -04:00
2015-04-28 13:45:35 -04:00
for (;;) { /* event loop */
2013-09-23 14:34:35 -04:00
QEvt e;
. . .
/* wait for the next event and assign it to the event object e */
. . .
2015-04-28 13:45:35 -04:00
QMSM_DISPATCH(&l_calc.super, &e); /* dispatch e */
2013-09-23 14:34:35 -04:00
}
2015-04-28 13:45:35 -04:00
return 0; /* never reached, needed for some compilers */
2013-09-23 14:34:35 -04:00
}