2014-04-13 21:35:34 -04:00
|
|
|
//****************************************************************************
|
|
|
|
// Model: history_qm.qm
|
|
|
|
// File: ./history.cpp
|
|
|
|
//
|
|
|
|
// 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.cpp} ..........................................................
|
|
|
|
#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} ..........................................................
|
|
|
|
class ToastOven : public QP::QMsm {
|
|
|
|
public:
|
|
|
|
ToastOven();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static QP::QState initial(ToastOven * const me, QP::QEvt const * const e);
|
|
|
|
static QP::QState doorClosed (ToastOven * const me, QP::QEvt const * const e);
|
|
|
|
static QP::QState doorClosed_e(ToastOven * const me);
|
|
|
|
static QP::QState doorClosed_x(ToastOven * const me);
|
|
|
|
static QP::QState doorClosed_i(ToastOven * const me);
|
|
|
|
static QP::QMState const doorClosed_s;
|
|
|
|
static QP::QState heating (ToastOven * const me, QP::QEvt const * const e);
|
|
|
|
static QP::QState heating_e(ToastOven * const me);
|
|
|
|
static QP::QState heating_x(ToastOven * const me);
|
|
|
|
static QP::QMState const heating_s;
|
|
|
|
static QP::QState toasting (ToastOven * const me, QP::QEvt const * const e);
|
|
|
|
static QP::QState toasting_e(ToastOven * const me);
|
|
|
|
static QP::QMState const toasting_s;
|
|
|
|
static QP::QState baking (ToastOven * const me, QP::QEvt const * const e);
|
|
|
|
static QP::QState baking_e(ToastOven * const me);
|
|
|
|
static QP::QMState const baking_s;
|
|
|
|
static QP::QState off (ToastOven * const me, QP::QEvt const * const e);
|
|
|
|
static QP::QState off_e(ToastOven * const me);
|
|
|
|
static QP::QMState const off_s;
|
|
|
|
static QP::QState doorOpen (ToastOven * const me, QP::QEvt const * const e);
|
|
|
|
static QP::QState doorOpen_e(ToastOven * const me);
|
|
|
|
static QP::QState doorOpen_x(ToastOven * const me);
|
|
|
|
static QP::QMState const doorOpen_s;
|
|
|
|
static QP::QState final (ToastOven * const me, QP::QEvt const * const e);
|
|
|
|
static QP::QState final_e(ToastOven * const me);
|
|
|
|
static QP::QMState const final_s;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QP::QMState const *his_doorClosed;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static ToastOven l_oven; // the only instance of the ToastOven class
|
|
|
|
|
|
|
|
// global-scope definitions ------------------------------------
|
|
|
|
QP::QMsm * const the_oven = &l_oven; // the opaque pointer
|
|
|
|
|
|
|
|
//${SMs::ToastOven} ..........................................................
|
|
|
|
//${SMs::ToastOven::ToastOven} ...............................................
|
|
|
|
ToastOven::ToastOven()
|
|
|
|
: QMsm(Q_STATE_CAST(&ToastOven::initial))
|
|
|
|
{}
|
|
|
|
|
|
|
|
//${SMs::ToastOven::SM} ......................................................
|
|
|
|
QP::QState ToastOven::initial(ToastOven * const me, QP::QEvt const * const e) {
|
|
|
|
static struct {
|
|
|
|
QP::QMState const *target;
|
|
|
|
QP::QActionHandler act[2];
|
|
|
|
} const tatbl_ = { // transition-action table
|
|
|
|
&doorOpen_s,
|
|
|
|
{
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_ACTION_CAST(&doorOpen_e), // entry
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// ${SMs::ToastOven::SM::initial}
|
|
|
|
(void)e; /* avoid compiler warning */
|
|
|
|
/* state history attributes */
|
|
|
|
me->his_doorClosed = &off_s;
|
|
|
|
return QM_TRAN_INIT(&tatbl_);
|
|
|
|
}
|
|
|
|
//${SMs::ToastOven::SM::doorClosed} ..........................................
|
|
|
|
QP::QMState const ToastOven::doorClosed_s = {
|
|
|
|
static_cast<QP::QMState const *>(0), // superstate (top)
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_STATE_CAST(&doorClosed),
|
|
|
|
Q_ACTION_CAST(&doorClosed_e),
|
|
|
|
Q_ACTION_CAST(&doorClosed_x),
|
|
|
|
Q_ACTION_CAST(&doorClosed_i)
|
2014-04-13 21:35:34 -04:00
|
|
|
};
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed}
|
|
|
|
QP::QState ToastOven::doorClosed_e(ToastOven * const me) {
|
|
|
|
printf("door-Closed;");
|
|
|
|
(void)me; // avoid compiler warning in case 'me' is not used
|
|
|
|
return QM_ENTRY(&doorClosed_s);
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed}
|
|
|
|
QP::QState ToastOven::doorClosed_x(ToastOven * const me) {
|
|
|
|
me->his_doorClosed = me->stateObj(); // save history
|
|
|
|
return QM_EXIT(&doorClosed_s);
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::initial}
|
|
|
|
QP::QState ToastOven::doorClosed_i(ToastOven * const me) {
|
|
|
|
static struct {
|
|
|
|
QP::QMState const *target;
|
|
|
|
QP::QActionHandler act[2];
|
|
|
|
} const tatbl_ = { // transition-action table
|
|
|
|
&off_s,
|
|
|
|
{
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_ACTION_CAST(&off_e), // entry
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::initial}
|
|
|
|
return QM_TRAN_INIT(&tatbl_);
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed}
|
|
|
|
QP::QState ToastOven::doorClosed(ToastOven * const me, QP::QEvt const * const e) {
|
|
|
|
QP::QState status_;
|
|
|
|
switch (e->sig) {
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::TERMINATE}
|
|
|
|
case TERMINATE_SIG: {
|
|
|
|
static struct {
|
|
|
|
QP::QMState const *target;
|
|
|
|
QP::QActionHandler act[3];
|
|
|
|
} const tatbl_ = { // transition-action table
|
|
|
|
&final_s,
|
|
|
|
{
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_ACTION_CAST(&doorClosed_x), // exit
|
|
|
|
Q_ACTION_CAST(&final_e), // entry
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::OPEN}
|
|
|
|
case OPEN_SIG: {
|
|
|
|
static struct {
|
|
|
|
QP::QMState const *target;
|
|
|
|
QP::QActionHandler act[3];
|
|
|
|
} const tatbl_ = { // transition-action table
|
|
|
|
&doorOpen_s,
|
|
|
|
{
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_ACTION_CAST(&doorClosed_x), // exit
|
|
|
|
Q_ACTION_CAST(&doorOpen_e), // entry
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::TOAST}
|
|
|
|
case TOAST_SIG: {
|
|
|
|
static struct {
|
|
|
|
QP::QMState const *target;
|
|
|
|
QP::QActionHandler act[3];
|
|
|
|
} const tatbl_ = { // transition-action table
|
|
|
|
&toasting_s,
|
|
|
|
{
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_ACTION_CAST(&heating_e), // entry
|
|
|
|
Q_ACTION_CAST(&toasting_e), // entry
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::BAKE}
|
|
|
|
case BAKE_SIG: {
|
|
|
|
static struct {
|
|
|
|
QP::QMState const *target;
|
|
|
|
QP::QActionHandler act[3];
|
|
|
|
} const tatbl_ = { // transition-action table
|
|
|
|
&baking_s,
|
|
|
|
{
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_ACTION_CAST(&heating_e), // entry
|
|
|
|
Q_ACTION_CAST(&baking_e), // entry
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::OFF}
|
|
|
|
case OFF_SIG: {
|
|
|
|
static struct {
|
|
|
|
QP::QMState const *target;
|
|
|
|
QP::QActionHandler act[2];
|
|
|
|
} const tatbl_ = { // transition-action table
|
|
|
|
&off_s,
|
|
|
|
{
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_ACTION_CAST(&off_e), // entry
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
status_ = QM_SUPER();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
//${SMs::ToastOven::SM::doorClosed::heating} .................................
|
|
|
|
QP::QMState const ToastOven::heating_s = {
|
|
|
|
&ToastOven::doorClosed_s, // superstate
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_STATE_CAST(&heating),
|
|
|
|
Q_ACTION_CAST(&heating_e),
|
|
|
|
Q_ACTION_CAST(&heating_x),
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0) // no intitial tran.
|
|
|
|
};
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::heating}
|
|
|
|
QP::QState ToastOven::heating_e(ToastOven * const me) {
|
|
|
|
printf("heater-On;");
|
|
|
|
(void)me; // avoid compiler warning in case 'me' is not used
|
|
|
|
return QM_ENTRY(&heating_s);
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::heating}
|
|
|
|
QP::QState ToastOven::heating_x(ToastOven * const me) {
|
|
|
|
printf("heater-Off;");
|
|
|
|
(void)me; // avoid compiler warning in case 'me' is not used
|
|
|
|
return QM_EXIT(&heating_s);
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::heating}
|
|
|
|
QP::QState ToastOven::heating(ToastOven * const me, QP::QEvt const * const e) {
|
|
|
|
QP::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} .......................
|
|
|
|
QP::QMState const ToastOven::toasting_s = {
|
|
|
|
&ToastOven::heating_s, // superstate
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_STATE_CAST(&toasting),
|
|
|
|
Q_ACTION_CAST(&toasting_e),
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0), // no exit action
|
|
|
|
Q_ACTION_CAST(0) // no intitial tran.
|
|
|
|
};
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::heating::toasting}
|
|
|
|
QP::QState ToastOven::toasting_e(ToastOven * const me) {
|
|
|
|
printf("toasting;");
|
|
|
|
(void)me; // avoid compiler warning in case 'me' is not used
|
|
|
|
return QM_ENTRY(&toasting_s);
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::heating::toasting}
|
|
|
|
QP::QState ToastOven::toasting(ToastOven * const me, QP::QEvt const * const e) {
|
|
|
|
QP::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} .........................
|
|
|
|
QP::QMState const ToastOven::baking_s = {
|
|
|
|
&ToastOven::heating_s, // superstate
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_STATE_CAST(&baking),
|
|
|
|
Q_ACTION_CAST(&baking_e),
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0), // no exit action
|
|
|
|
Q_ACTION_CAST(0) // no intitial tran.
|
|
|
|
};
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::heating::baking}
|
|
|
|
QP::QState ToastOven::baking_e(ToastOven * const me) {
|
|
|
|
printf("baking;");
|
|
|
|
(void)me; // avoid compiler warning in case 'me' is not used
|
|
|
|
return QM_ENTRY(&baking_s);
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::heating::baking}
|
|
|
|
QP::QState ToastOven::baking(ToastOven * const me, QP::QEvt const * const e) {
|
|
|
|
QP::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} .....................................
|
|
|
|
QP::QMState const ToastOven::off_s = {
|
|
|
|
&ToastOven::doorClosed_s, // superstate
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_STATE_CAST(&off),
|
|
|
|
Q_ACTION_CAST(&off_e),
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0), // no exit action
|
|
|
|
Q_ACTION_CAST(0) // no intitial tran.
|
|
|
|
};
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::off}
|
|
|
|
QP::QState ToastOven::off_e(ToastOven * const me) {
|
|
|
|
printf("toaster-Off;");
|
|
|
|
(void)me; // avoid compiler warning in case 'me' is not used
|
|
|
|
return QM_ENTRY(&off_s);
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorClosed::off}
|
|
|
|
QP::QState ToastOven::off(ToastOven * const me, QP::QEvt const * const e) {
|
|
|
|
QP::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} ............................................
|
|
|
|
QP::QMState const ToastOven::doorOpen_s = {
|
|
|
|
static_cast<QP::QMState const *>(0), // superstate (top)
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_STATE_CAST(&doorOpen),
|
|
|
|
Q_ACTION_CAST(&doorOpen_e),
|
|
|
|
Q_ACTION_CAST(&doorOpen_x),
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0) // no intitial tran.
|
|
|
|
};
|
|
|
|
// ${SMs::ToastOven::SM::doorOpen}
|
|
|
|
QP::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(&doorOpen_s);
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorOpen}
|
|
|
|
QP::QState ToastOven::doorOpen_x(ToastOven * const me) {
|
|
|
|
printf("lamp-Off;");
|
|
|
|
(void)me; // avoid compiler warning in case 'me' is not used
|
|
|
|
return QM_EXIT(&doorOpen_s);
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::doorOpen}
|
|
|
|
QP::QState ToastOven::doorOpen(ToastOven * const me, QP::QEvt const * const e) {
|
|
|
|
QP::QState status_;
|
|
|
|
switch (e->sig) {
|
|
|
|
// ${SMs::ToastOven::SM::doorOpen::CLOSE}
|
|
|
|
case CLOSE_SIG: {
|
|
|
|
static struct {
|
|
|
|
QP::QMState const *target;
|
|
|
|
QP::QActionHandler act[4];
|
|
|
|
} const tatbl_ = { // transition-action table
|
|
|
|
&doorClosed_s,
|
|
|
|
{
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_ACTION_CAST(&doorOpen_x), // exit
|
|
|
|
Q_ACTION_CAST(&doorClosed_e), // entry
|
2014-04-13 21:35:34 -04:00
|
|
|
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} ...............................................
|
|
|
|
QP::QMState const ToastOven::final_s = {
|
|
|
|
static_cast<QP::QMState const *>(0), // superstate (top)
|
2014-10-21 20:38:56 -04:00
|
|
|
Q_STATE_CAST(&final),
|
|
|
|
Q_ACTION_CAST(&final_e),
|
2014-04-13 21:35:34 -04:00
|
|
|
Q_ACTION_CAST(0), // no exit action
|
|
|
|
Q_ACTION_CAST(0) // no intitial tran.
|
|
|
|
};
|
|
|
|
// ${SMs::ToastOven::SM::final}
|
|
|
|
QP::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(&final_s);
|
|
|
|
}
|
|
|
|
// ${SMs::ToastOven::SM::final}
|
|
|
|
QP::QState ToastOven::final(ToastOven * const me, QP::QEvt const * const e) {
|
|
|
|
QP::QState status_;
|
|
|
|
switch (e->sig) {
|
|
|
|
default: {
|
|
|
|
status_ = QM_SUPER();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
|