249 lines
8.0 KiB
C
Raw Normal View History

2012-08-14 18:07:04 -04:00
/*****************************************************************************
2014-04-06 11:43:13 -04:00
* Model: history.qm
* File: ./history.c
2012-08-14 18:07:04 -04:00
*
2014-04-06 11:43:13 -04:00
* 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.
2012-08-14 18:07:04 -04:00
*
* 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
2014-04-06 11:43:13 -04:00
* by the Free Software Foundation.
2012-08-14 18:07:04 -04:00
*
2014-04-06 11:43:13 -04:00
* 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.
2012-08-14 18:07:04 -04:00
*****************************************************************************/
2014-04-06 11:43:13 -04:00
/*${.::history.c} ..........................................................*/
2015-04-28 13:45:35 -04:00
#include "qpc.h"
2014-04-06 11:43:13 -04:00
#include "history.h"
2012-08-14 18:07:04 -04:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Q_DEFINE_THIS_FILE
2014-04-06 11:43:13 -04:00
/*${SMs::ToastOven} ........................................................*/
typedef struct {
/* protected: */
QHsm super;
/* private state histories */
QStateHandler 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_heating(ToastOven * const me, QEvt const * const e);
static QState ToastOven_toasting(ToastOven * const me, QEvt const * const e);
static QState ToastOven_baking(ToastOven * const me, QEvt const * const e);
static QState ToastOven_off(ToastOven * const me, QEvt const * const e);
static QState ToastOven_doorOpen(ToastOven * const me, QEvt const * const e);
static QState ToastOven_final(ToastOven * const me, QEvt const * const e);
2012-08-14 18:07:04 -04:00
2014-04-06 11:43:13 -04:00
static ToastOven l_oven; /* the only instance of the ToastOven class */
2012-08-14 18:07:04 -04:00
2014-04-06 11:43:13 -04:00
/* global-scope definitions -----------------------------------------*/
QHsm * const the_oven = (QHsm *)&l_oven; /* the opaque pointer */
/*${SMs::ToastOven_ctor} ...................................................*/
void ToastOven_ctor(void) {
ToastOven *me = &l_oven;
2012-08-14 18:07:04 -04:00
QHsm_ctor(&me->super, Q_STATE_CAST(&ToastOven_initial));
}
2014-04-06 11:43:13 -04:00
/*${SMs::ToastOven} ........................................................*/
/*${SMs::ToastOven::SM} ....................................................*/
2012-08-14 18:07:04 -04:00
static QState ToastOven_initial(ToastOven * const me, QEvt const * const e) {
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::initial} */
(void)e; /* avoid compiler warning */
/* state history attributes */
me->his_doorClosed = Q_STATE_CAST(&ToastOven_off);
2015-06-04 22:47:13 -04:00
return Q_TRAN(&ToastOven_doorClosed);
2012-08-14 18:07:04 -04:00
}
2014-04-06 11:43:13 -04:00
/*${SMs::ToastOven::SM::doorClosed} ........................................*/
static QState ToastOven_doorClosed(ToastOven * const me, QEvt const * const e) {
QState status_;
2012-08-14 18:07:04 -04:00
switch (e->sig) {
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorClosed} */
2012-08-14 18:07:04 -04:00
case Q_ENTRY_SIG: {
printf("door-Closed;");
2014-04-06 11:43:13 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorClosed} */
2012-08-14 18:07:04 -04:00
case Q_EXIT_SIG: {
2014-04-06 11:43:13 -04:00
me->his_doorClosed = QHsm_state(me); /* save history */
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorClosed::initial} */
2012-08-14 18:07:04 -04:00
case Q_INIT_SIG: {
2014-04-06 11:43:13 -04:00
status_ = Q_TRAN(&ToastOven_off);
break;
}
/* ${SMs::ToastOven::SM::doorClosed::TERMINATE} */
case TERMINATE_SIG: {
status_ = Q_TRAN(&ToastOven_final);
2012-08-14 18:07:04 -04:00
break;
}
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorClosed::OPEN} */
2012-08-14 18:07:04 -04:00
case OPEN_SIG: {
2014-04-06 11:43:13 -04:00
status_ = Q_TRAN(&ToastOven_doorOpen);
2012-08-14 18:07:04 -04:00
break;
}
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorClosed::TOAST} */
2012-08-14 18:07:04 -04:00
case TOAST_SIG: {
2014-04-06 11:43:13 -04:00
status_ = Q_TRAN(&ToastOven_toasting);
2012-08-14 18:07:04 -04:00
break;
}
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorClosed::BAKE} */
2012-08-14 18:07:04 -04:00
case BAKE_SIG: {
2014-04-06 11:43:13 -04:00
status_ = Q_TRAN(&ToastOven_baking);
2012-08-14 18:07:04 -04:00
break;
}
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorClosed::OFF} */
2012-08-14 18:07:04 -04:00
case OFF_SIG: {
2014-04-06 11:43:13 -04:00
status_ = Q_TRAN(&ToastOven_off);
2012-08-14 18:07:04 -04:00
break;
}
default: {
2014-04-06 11:43:13 -04:00
status_ = Q_SUPER(&QHsm_top);
2012-08-14 18:07:04 -04:00
break;
}
}
2014-04-06 11:43:13 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}
2014-04-06 11:43:13 -04:00
/*${SMs::ToastOven::SM::doorClosed::heating} ...............................*/
2012-08-14 18:07:04 -04:00
static QState ToastOven_heating(ToastOven * const me, QEvt const * const e) {
2014-04-06 11:43:13 -04:00
QState status_;
2012-08-14 18:07:04 -04:00
switch (e->sig) {
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorClosed::heating} */
2012-08-14 18:07:04 -04:00
case Q_ENTRY_SIG: {
printf("heater-On;");
2014-04-06 11:43:13 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorClosed::heating} */
2012-08-14 18:07:04 -04:00
case Q_EXIT_SIG: {
printf("heater-Off;");
2014-04-06 11:43:13 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
2015-09-04 12:08:22 -04:00
/* ${SMs::ToastOven::SM::doorClosed::heating::initial} */
case Q_INIT_SIG: {
status_ = Q_TRAN(&ToastOven_toasting);
break;
}
2012-08-14 18:07:04 -04:00
default: {
2014-04-06 11:43:13 -04:00
status_ = Q_SUPER(&ToastOven_doorClosed);
2012-08-14 18:07:04 -04:00
break;
}
}
2014-04-06 11:43:13 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}
2014-04-06 11:43:13 -04:00
/*${SMs::ToastOven::SM::doorClosed::heating::toasting} .....................*/
2012-08-14 18:07:04 -04:00
static QState ToastOven_toasting(ToastOven * const me, QEvt const * const e) {
2014-04-06 11:43:13 -04:00
QState status_;
2012-08-14 18:07:04 -04:00
switch (e->sig) {
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorClosed::heating::toasting} */
2012-08-14 18:07:04 -04:00
case Q_ENTRY_SIG: {
printf("toasting;");
2014-04-06 11:43:13 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
default: {
2014-04-06 11:43:13 -04:00
status_ = Q_SUPER(&ToastOven_heating);
2012-08-14 18:07:04 -04:00
break;
}
}
2014-04-06 11:43:13 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}
2014-04-06 11:43:13 -04:00
/*${SMs::ToastOven::SM::doorClosed::heating::baking} .......................*/
2012-08-14 18:07:04 -04:00
static QState ToastOven_baking(ToastOven * const me, QEvt const * const e) {
2014-04-06 11:43:13 -04:00
QState status_;
2012-08-14 18:07:04 -04:00
switch (e->sig) {
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorClosed::heating::baking} */
2012-08-14 18:07:04 -04:00
case Q_ENTRY_SIG: {
printf("baking;");
2014-04-06 11:43:13 -04:00
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&ToastOven_heating);
break;
}
}
return status_;
}
/*${SMs::ToastOven::SM::doorClosed::off} ...................................*/
static QState ToastOven_off(ToastOven * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
/* ${SMs::ToastOven::SM::doorClosed::off} */
case Q_ENTRY_SIG: {
printf("toaster-Off;");
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
default: {
2014-04-06 11:43:13 -04:00
status_ = Q_SUPER(&ToastOven_doorClosed);
2012-08-14 18:07:04 -04:00
break;
}
}
2014-04-06 11:43:13 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}
2014-04-06 11:43:13 -04:00
/*${SMs::ToastOven::SM::doorOpen} ..........................................*/
2012-08-14 18:07:04 -04:00
static QState ToastOven_doorOpen(ToastOven * const me, QEvt const * const e) {
2014-04-06 11:43:13 -04:00
QState status_;
2012-08-14 18:07:04 -04:00
switch (e->sig) {
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorOpen} */
2012-08-14 18:07:04 -04:00
case Q_ENTRY_SIG: {
printf("door-Open,lamp-On;");
2014-04-06 11:43:13 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorOpen} */
2012-08-14 18:07:04 -04:00
case Q_EXIT_SIG: {
printf("lamp-Off;");
2014-04-06 11:43:13 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
2014-04-06 11:43:13 -04:00
/* ${SMs::ToastOven::SM::doorOpen::CLOSE} */
2012-08-14 18:07:04 -04:00
case CLOSE_SIG: {
2014-04-06 11:43:13 -04:00
status_ = Q_TRAN_HIST(me->his_doorClosed);
2012-08-14 18:07:04 -04:00
break;
}
2015-06-04 22:47:13 -04:00
/* ${SMs::ToastOven::SM::doorOpen::TERMINATE} */
case TERMINATE_SIG: {
status_ = Q_TRAN(&ToastOven_final);
break;
}
2012-08-14 18:07:04 -04:00
default: {
2014-04-06 11:43:13 -04:00
status_ = Q_SUPER(&QHsm_top);
2012-08-14 18:07:04 -04:00
break;
}
}
2014-04-06 11:43:13 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}
2014-04-06 11:43:13 -04:00
/*${SMs::ToastOven::SM::final} .............................................*/
static QState ToastOven_final(ToastOven * const me, QEvt const * const e) {
QState status_;
switch (e->sig) {
/* ${SMs::ToastOven::SM::final} */
case Q_ENTRY_SIG: {
2015-06-04 22:47:13 -04:00
printf("\nBye! Bye!\n");
exit(0);
2014-04-06 11:43:13 -04:00
status_ = Q_HANDLED();
break;
}
default: {
status_ = Q_SUPER(&QHsm_top);
break;
2012-08-14 18:07:04 -04:00
}
}
2014-04-06 11:43:13 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}
2014-04-06 11:43:13 -04:00