Quantum Leaps 72c46c2993 5.3.0
2014-04-06 11:43:13 -04:00

378 lines
14 KiB
C

/*****************************************************************************
* Model: history_qm.qm
* File: ./history.c
*
* This code has been generated by QM tool (see state-machine.com/qm).
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
*
* This program is open source software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*****************************************************************************/
/*${.::history.c} ..........................................................*/
#include "qep_port.h"
#include "qassert.h"
#include "history.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Q_DEFINE_THIS_FILE
/*${SMs::ToastOven} ........................................................*/
typedef struct {
/* protected: */
QMsm super;
/* private state histories */
QMState const *his_doorClosed;
} ToastOven;
/* protected: */
static QState ToastOven_initial(ToastOven * const me, QEvt const * const e);
static QState ToastOven_doorClosed (ToastOven * const me, QEvt const * const e);
static QState ToastOven_doorClosed_e(ToastOven * const me);
static QState ToastOven_doorClosed_x(ToastOven * const me);
static QState ToastOven_doorClosed_i(ToastOven * const me);
static QMState const ToastOven_doorClosed_s = {
(QMState const *)0, /* superstate (top) */
Q_STATE_CAST(&ToastOven_doorClosed),
Q_ACTION_CAST(&ToastOven_doorClosed_e),
Q_ACTION_CAST(&ToastOven_doorClosed_x),
Q_ACTION_CAST(&ToastOven_doorClosed_i)
};
static QState ToastOven_heating (ToastOven * const me, QEvt const * const e);
static QState ToastOven_heating_e(ToastOven * const me);
static QState ToastOven_heating_x(ToastOven * const me);
static QMState const ToastOven_heating_s = {
&ToastOven_doorClosed_s, /* superstate */
Q_STATE_CAST(&ToastOven_heating),
Q_ACTION_CAST(&ToastOven_heating_e),
Q_ACTION_CAST(&ToastOven_heating_x),
Q_ACTION_CAST(0) /* no intitial tran. */
};
static QState ToastOven_toasting (ToastOven * const me, QEvt const * const e);
static QState ToastOven_toasting_e(ToastOven * const me);
static QMState const ToastOven_toasting_s = {
&ToastOven_heating_s, /* superstate */
Q_STATE_CAST(&ToastOven_toasting),
Q_ACTION_CAST(&ToastOven_toasting_e),
Q_ACTION_CAST(0), /* no exit action */
Q_ACTION_CAST(0) /* no intitial tran. */
};
static QState ToastOven_baking (ToastOven * const me, QEvt const * const e);
static QState ToastOven_baking_e(ToastOven * const me);
static QMState const ToastOven_baking_s = {
&ToastOven_heating_s, /* superstate */
Q_STATE_CAST(&ToastOven_baking),
Q_ACTION_CAST(&ToastOven_baking_e),
Q_ACTION_CAST(0), /* no exit action */
Q_ACTION_CAST(0) /* no intitial tran. */
};
static QState ToastOven_off (ToastOven * const me, QEvt const * const e);
static QState ToastOven_off_e(ToastOven * const me);
static QMState const ToastOven_off_s = {
&ToastOven_doorClosed_s, /* superstate */
Q_STATE_CAST(&ToastOven_off),
Q_ACTION_CAST(&ToastOven_off_e),
Q_ACTION_CAST(0), /* no exit action */
Q_ACTION_CAST(0) /* no intitial tran. */
};
static QState ToastOven_doorOpen (ToastOven * const me, QEvt const * const e);
static QState ToastOven_doorOpen_e(ToastOven * const me);
static QState ToastOven_doorOpen_x(ToastOven * const me);
static QMState const ToastOven_doorOpen_s = {
(QMState const *)0, /* superstate (top) */
Q_STATE_CAST(&ToastOven_doorOpen),
Q_ACTION_CAST(&ToastOven_doorOpen_e),
Q_ACTION_CAST(&ToastOven_doorOpen_x),
Q_ACTION_CAST(0) /* no intitial tran. */
};
static QState ToastOven_final (ToastOven * const me, QEvt const * const e);
static QState ToastOven_final_e(ToastOven * const me);
static QMState const ToastOven_final_s = {
(QMState const *)0, /* superstate (top) */
Q_STATE_CAST(&ToastOven_final),
Q_ACTION_CAST(&ToastOven_final_e),
Q_ACTION_CAST(0), /* no exit action */
Q_ACTION_CAST(0) /* no intitial tran. */
};
static ToastOven l_oven; /* the only instance of the ToastOven class */
/* global-scope definitions -----------------------------------------*/
QMsm * const the_oven = (QMsm *)&l_oven; /* the opaque pointer */
/*${SMs::ToastOven_ctor} ...................................................*/
void ToastOven_ctor(void) {
ToastOven *me = &l_oven;
QMsm_ctor(&me->super, Q_STATE_CAST(&ToastOven_initial));
}
/*${SMs::ToastOven} ........................................................*/
/*${SMs::ToastOven::SM} ....................................................*/
static QState ToastOven_initial(ToastOven * const me, QEvt const * const e) {
static struct {
QMState const *target;
QActionHandler act[2];
} const tatbl_ = { /* transition-action table */
&ToastOven_doorOpen_s, /* target state */
{
Q_ACTION_CAST(&ToastOven_doorOpen_e), /* entry */
Q_ACTION_CAST(0) /* zero terminator */
}
};
/* ${SMs::ToastOven::SM::initial} */
(void)e; /* avoid compiler warning */
/* state history attributes */
me->his_doorClosed = &ToastOven_off_s;
return QM_TRAN_INIT(&tatbl_);
}
/*${SMs::ToastOven::SM::doorClosed} ........................................*/
static QState ToastOven_doorClosed_e(ToastOven * const me) {
printf("door-Closed;");
(void)me; /* avoid compiler warning in case 'me' is not used */
return QM_ENTRY(&ToastOven_doorClosed_s);
}
static QState ToastOven_doorClosed_x(ToastOven * const me) {
me->his_doorClosed = QMsm_stateObj(me); /* save history */
return QM_EXIT(&ToastOven_doorClosed_s);
}
static QState ToastOven_doorClosed_i(ToastOven * const me) {
static struct {
QMState const *target;
QActionHandler act[2];
} const tatbl_ = { /* transition-action table */
&ToastOven_off_s, /* target state */
{
Q_ACTION_CAST(&ToastOven_off_e), /* entry */
Q_ACTION_CAST(0) /* zero terminator */
}
};
/* ${SMs::ToastOven::SM::doorClosed::initial} */
return QM_TRAN_INIT(&tatbl_);
}
static QState ToastOven_doorClosed(ToastOven * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
/* ${SMs::ToastOven::SM::doorClosed::TERMINATE} */
case TERMINATE_SIG: {
static struct {
QMState const *target;
QActionHandler act[3];
} const tatbl_ = { /* transition-action table */
&ToastOven_final_s, /* target state */
{
Q_ACTION_CAST(&ToastOven_doorClosed_x), /* exit */
Q_ACTION_CAST(&ToastOven_final_e), /* entry */
Q_ACTION_CAST(0) /* zero terminator */
}
};
status_ = QM_TRAN(&tatbl_);
break;
}
/* ${SMs::ToastOven::SM::doorClosed::OPEN} */
case OPEN_SIG: {
static struct {
QMState const *target;
QActionHandler act[3];
} const tatbl_ = { /* transition-action table */
&ToastOven_doorOpen_s, /* target state */
{
Q_ACTION_CAST(&ToastOven_doorClosed_x), /* exit */
Q_ACTION_CAST(&ToastOven_doorOpen_e), /* entry */
Q_ACTION_CAST(0) /* zero terminator */
}
};
status_ = QM_TRAN(&tatbl_);
break;
}
/* ${SMs::ToastOven::SM::doorClosed::TOAST} */
case TOAST_SIG: {
static struct {
QMState const *target;
QActionHandler act[3];
} const tatbl_ = { /* transition-action table */
&ToastOven_toasting_s, /* target state */
{
Q_ACTION_CAST(&ToastOven_heating_e), /* entry */
Q_ACTION_CAST(&ToastOven_toasting_e), /* entry */
Q_ACTION_CAST(0) /* zero terminator */
}
};
status_ = QM_TRAN(&tatbl_);
break;
}
/* ${SMs::ToastOven::SM::doorClosed::BAKE} */
case BAKE_SIG: {
static struct {
QMState const *target;
QActionHandler act[3];
} const tatbl_ = { /* transition-action table */
&ToastOven_baking_s, /* target state */
{
Q_ACTION_CAST(&ToastOven_heating_e), /* entry */
Q_ACTION_CAST(&ToastOven_baking_e), /* entry */
Q_ACTION_CAST(0) /* zero terminator */
}
};
status_ = QM_TRAN(&tatbl_);
break;
}
/* ${SMs::ToastOven::SM::doorClosed::OFF} */
case OFF_SIG: {
static struct {
QMState const *target;
QActionHandler act[2];
} const tatbl_ = { /* transition-action table */
&ToastOven_off_s, /* target state */
{
Q_ACTION_CAST(&ToastOven_off_e), /* entry */
Q_ACTION_CAST(0) /* zero terminator */
}
};
status_ = QM_TRAN(&tatbl_);
break;
}
default: {
status_ = QM_SUPER();
break;
}
}
return status_;
}
/*${SMs::ToastOven::SM::doorClosed::heating} ...............................*/
static QState ToastOven_heating_e(ToastOven * const me) {
printf("heater-On;");
(void)me; /* avoid compiler warning in case 'me' is not used */
return QM_ENTRY(&ToastOven_heating_s);
}
static QState ToastOven_heating_x(ToastOven * const me) {
printf("heater-Off;");
(void)me; /* avoid compiler warning in case 'me' is not used */
return QM_EXIT(&ToastOven_heating_s);
}
static QState ToastOven_heating(ToastOven * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
default: {
status_ = QM_SUPER();
break;
}
}
(void)me; /* avoid compiler warning in case 'me' is not used */
return status_;
}
/*${SMs::ToastOven::SM::doorClosed::heating::toasting} .....................*/
static QState ToastOven_toasting_e(ToastOven * const me) {
printf("toasting;");
(void)me; /* avoid compiler warning in case 'me' is not used */
return QM_ENTRY(&ToastOven_toasting_s);
}
static QState ToastOven_toasting(ToastOven * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
default: {
status_ = QM_SUPER();
break;
}
}
(void)me; /* avoid compiler warning in case 'me' is not used */
return status_;
}
/*${SMs::ToastOven::SM::doorClosed::heating::baking} .......................*/
static QState ToastOven_baking_e(ToastOven * const me) {
printf("baking;");
(void)me; /* avoid compiler warning in case 'me' is not used */
return QM_ENTRY(&ToastOven_baking_s);
}
static QState ToastOven_baking(ToastOven * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
default: {
status_ = QM_SUPER();
break;
}
}
(void)me; /* avoid compiler warning in case 'me' is not used */
return status_;
}
/*${SMs::ToastOven::SM::doorClosed::off} ...................................*/
static QState ToastOven_off_e(ToastOven * const me) {
printf("toaster-Off;");
(void)me; /* avoid compiler warning in case 'me' is not used */
return QM_ENTRY(&ToastOven_off_s);
}
static QState ToastOven_off(ToastOven * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
default: {
status_ = QM_SUPER();
break;
}
}
(void)me; /* avoid compiler warning in case 'me' is not used */
return status_;
}
/*${SMs::ToastOven::SM::doorOpen} ..........................................*/
static QState ToastOven_doorOpen_e(ToastOven * const me) {
printf("door-Open,lamp-On;");
(void)me; /* avoid compiler warning in case 'me' is not used */
return QM_ENTRY(&ToastOven_doorOpen_s);
}
static QState ToastOven_doorOpen_x(ToastOven * const me) {
printf("lamp-Off;");
(void)me; /* avoid compiler warning in case 'me' is not used */
return QM_EXIT(&ToastOven_doorOpen_s);
}
static QState ToastOven_doorOpen(ToastOven * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
/* ${SMs::ToastOven::SM::doorOpen::CLOSE} */
case CLOSE_SIG: {
static struct {
QMState const *target;
QActionHandler act[4];
} const tatbl_ = { /* transition-action table */
&ToastOven_doorClosed_s, /* target state */
{
Q_ACTION_CAST(&ToastOven_doorOpen_x), /* exit */
Q_ACTION_CAST(&ToastOven_doorClosed_e), /* entry */
Q_ACTION_CAST(0) /* zero terminator */
}
};
status_ = QM_TRAN_HIST(me->his_doorClosed, &tatbl_);
break;
}
default: {
status_ = QM_SUPER();
break;
}
}
return status_;
}
/*${SMs::ToastOven::SM::final} .............................................*/
static QState ToastOven_final_e(ToastOven * const me) {
printf("-> final\nBye!Bye!\n");
_exit(0);
(void)me; /* avoid compiler warning in case 'me' is not used */
return QM_ENTRY(&ToastOven_final_s);
}
static QState ToastOven_final(ToastOven * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
default: {
status_ = QM_SUPER();
break;
}
}
(void)me; /* avoid compiler warning in case 'me' is not used */
return status_;
}