qpc/doxygen/snippets/qep_qmsm_use.c

22 lines
614 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
2019-02-10 21:00:39 -05:00
Q_DEFINE_THIS_FILE
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
2020-10-01 12:48:48 -04:00
QHSM_INIT(&l_calc.super, (void *)0, 0U); /* 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 */
. . .
2020-10-01 12:48:48 -04:00
QHSM_DISPATCH(&l_calc.super, &e, 0U); /* 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
}