QMsmTst is a contrived state machine from Chapter 2 of the PSiCC2 book for testing the QMsm class implementation.
Oven state machine
(void)par; /* unused parameter */
PRINTF_S("%s;", "door-Closed");
PRINTF_S("%s;", "heater-On");
PRINTF_S("%s;", "heater-Off");
PRINTF_S("%s;", "toasting");
PRINTF_S("%s;", "baking");
PRINTF_S("%s;", "toaster-Off");
state that transitions to history
PRINTF_S("%s;", "door-Open,lamp-On");
PRINTF_S("%s;", "lamp-Off");
PRINTF_S("\n%s\n", "Bye! Bye!");
QF_onCleanup();
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 QHsm * const the_oven; /* opaque pointer to the oven MSM */
$declare(SMs::ToastOven_ctor)
#endif /* HISTORY_H */
#include "qpc.h"
#include "history.h"
#include "safe_std.h" /* portable "safe" <stdio.h>/<string.h> facilities */
#include <stdlib.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 = &l_oven.super.super; /* the opaque pointer */
$define(SMs::ToastOven_ctor)
$define(SMs::ToastOven)