QMsmTst is a contrived state machine from Chapter 2 of the PSiCC2 book for testing the QMsm class implementation.
Oven state machine
(void)e; /* avoid compiler warning */
printf("door-Closed;");
printf("heater-On;");
printf("heater-Off;");
printf("toasting;");
printf("baking;");
printf("toaster-Off;");
state that transitions to history
printf("door-Open,lamp-On;");
printf("lamp-Off;");
printf("-> final\nBye!Bye!\n");
_exit(0);
ToastOven *me = &l_oven;
QMsm_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 QMsm * const the_oven; /* opaque pointer to the oven MSM */
$declare(SMs::ToastOven_ctor)
#endif /* history_h */
#include "qep_port.h"
#include "qassert.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 -----------------------------------------*/
QMsm * const the_oven = (QMsm *)&l_oven; /* the opaque pointer */
$define(SMs::ToastOven_ctor)
$define(SMs::ToastOven)