QHsmTst is a contrived state machine from Chapter 2 of the PSiCC2 book for testing all possible transition topologies with up to 4-levels of state nesting.
Oven state machine
(void)e; /* avoid compiler warning */
printf("door-Closed;");
printf("heater-On;");
printf("heater-Off;");
printf("toasting;");
printf("baking;");
printf("toaster-Off;");
printf("door-Open,lamp-On;");
printf("lamp-Off;");
printf("-> final\nBye!Bye!\n");
_exit(0);
ToastOven *me = &l_oven;
QHsm_ctor(&me->super, Q_STATE_CAST(&ToastOven_initial));
#ifndef history_h
#define history_h
enum ToastOvenSignals {
OPEN_SIG = Q_USER_SIG,
CLOSE_SIG,
TOAST_SIG,
BAKE_SIG,
OFF_SIG,
TERMINATE_SIG /* terminate the application */
};
extern QHsm * const the_oven; /* opaque pointer to the oven HSM */
$declare(SMs::ToastOven_ctor)
#endif /* history_h */
#include "qpc.h"
#include "history.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Q_DEFINE_THIS_FILE
$declare(SMs::ToastOven)
static ToastOven l_oven; /* the only instance of the ToastOven class */
/* global-scope definitions -----------------------------------------*/
QHsm * const the_oven = (QHsm *)&l_oven; /* the opaque pointer */
$define(SMs::ToastOven_ctor)
$define(SMs::ToastOven)