370 lines
10 KiB
C
Raw Normal View History

2012-08-14 18:07:04 -04:00
/*****************************************************************************
* Model: qhsmtst.qm
2013-09-23 14:34:35 -04:00
* File: ./qhsmtst.c
2012-08-14 18:07:04 -04:00
*
2013-09-23 14:34:35 -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
*
2013-09-23 14:34:35 -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
* 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.
2012-08-14 18:07:04 -04:00
*****************************************************************************/
2013-09-23 14:34:35 -04:00
/* @(/2/1) .................................................................*/
2012-08-14 18:07:04 -04:00
#include "qep_port.h"
#include "qhsmtst.h"
/* @(/1/0) .................................................................*/
typedef struct QHsmTstTag {
/* protected: */
QHsm super;
/* private: */
uint8_t foo;
} QHsmTst;
/* protected: */
static QState QHsmTst_initial(QHsmTst * const me, QEvt const * const e);
static QState QHsmTst_s(QHsmTst * const me, QEvt const * const e);
static QState QHsmTst_s1(QHsmTst * const me, QEvt const * const e);
static QState QHsmTst_s11(QHsmTst * const me, QEvt const * const e);
static QState QHsmTst_s2(QHsmTst * const me, QEvt const * const e);
static QState QHsmTst_s21(QHsmTst * const me, QEvt const * const e);
static QState QHsmTst_s211(QHsmTst * const me, QEvt const * const e);
static QHsmTst l_hsmtst; /* the only instance of the QHsmTst class */
/* global-scope definitions ---------------------------------------*/
QHsm * const the_hsm = (QHsm *)&l_hsmtst; /* the opaque pointer */
/* @(/1/1) .................................................................*/
void QHsmTst_ctor(void) {
QHsmTst *me = &l_hsmtst;
QHsm_ctor(&me->super, Q_STATE_CAST(&QHsmTst_initial));
}
/* @(/1/0) .................................................................*/
/* @(/1/0/1) ...............................................................*/
/* @(/1/0/1/0) */
static QState QHsmTst_initial(QHsmTst * const me, QEvt const * const e) {
(void)e; /* avoid compiler warning */
me->foo = 0U;
BSP_display("top-INIT;");
return Q_TRAN(&QHsmTst_s2);
}
/* @(/1/0/1/1) .............................................................*/
static QState QHsmTst_s(QHsmTst * const me, QEvt const * const e) {
2013-09-23 14:34:35 -04:00
QState status_;
2012-08-14 18:07:04 -04:00
switch (e->sig) {
/* @(/1/0/1/1) */
case Q_ENTRY_SIG: {
BSP_display("s-ENTRY;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1) */
case Q_EXIT_SIG: {
BSP_display("s-EXIT;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/0) */
case Q_INIT_SIG: {
BSP_display("s-INIT;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s11);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/1) */
case I_SIG: {
/* @(/1/0/1/1/1/0) */
if (me->foo) {
me->foo = 0U;
BSP_display("s-I;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
}
else {
2013-09-23 14:34:35 -04:00
status_ = Q_UNHANDLED();
2012-08-14 18:07:04 -04:00
}
break;
}
/* @(/1/0/1/1/2) */
case E_SIG: {
BSP_display("s-E;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s11);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/3) */
case TERMINATE_SIG: {
BSP_exit();
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
default: {
2013-09-23 14:34:35 -04:00
status_ = Q_SUPER(&QHsm_top);
2012-08-14 18:07:04 -04:00
break;
}
}
2013-09-23 14:34:35 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}
/* @(/1/0/1/1/4) ...........................................................*/
static QState QHsmTst_s1(QHsmTst * const me, QEvt const * const e) {
2013-09-23 14:34:35 -04:00
QState status_;
2012-08-14 18:07:04 -04:00
switch (e->sig) {
/* @(/1/0/1/1/4) */
case Q_ENTRY_SIG: {
BSP_display("s1-ENTRY;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/4) */
case Q_EXIT_SIG: {
BSP_display("s1-EXIT;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/4/0) */
case Q_INIT_SIG: {
BSP_display("s1-INIT;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s11);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/4/1) */
case I_SIG: {
BSP_display("s1-I;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/4/2) */
case D_SIG: {
/* @(/1/0/1/1/4/2/0) */
if (!me->foo) {
me->foo = 1U;
BSP_display("s1-D;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s);
2012-08-14 18:07:04 -04:00
}
else {
2013-09-23 14:34:35 -04:00
status_ = Q_UNHANDLED();
2012-08-14 18:07:04 -04:00
}
break;
}
/* @(/1/0/1/1/4/3) */
case A_SIG: {
BSP_display("s1-A;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s1);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/4/4) */
case B_SIG: {
BSP_display("s1-B;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s11);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/4/5) */
case F_SIG: {
BSP_display("s1-F;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s211);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/4/6) */
case C_SIG: {
BSP_display("s1-C;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s2);
2012-08-14 18:07:04 -04:00
break;
}
default: {
2013-09-23 14:34:35 -04:00
status_ = Q_SUPER(&QHsmTst_s);
2012-08-14 18:07:04 -04:00
break;
}
}
2013-09-23 14:34:35 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}
/* @(/1/0/1/1/4/7) .........................................................*/
static QState QHsmTst_s11(QHsmTst * const me, QEvt const * const e) {
2013-09-23 14:34:35 -04:00
QState status_;
2012-08-14 18:07:04 -04:00
switch (e->sig) {
/* @(/1/0/1/1/4/7) */
case Q_ENTRY_SIG: {
BSP_display("s11-ENTRY;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/4/7) */
case Q_EXIT_SIG: {
BSP_display("s11-EXIT;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/4/7/0) */
case H_SIG: {
BSP_display("s11-H;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/4/7/1) */
case D_SIG: {
/* @(/1/0/1/1/4/7/1/0) */
if (me->foo) {
me->foo = 0U;
BSP_display("s11-D;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s1);
2012-08-14 18:07:04 -04:00
}
else {
2013-09-23 14:34:35 -04:00
status_ = Q_UNHANDLED();
2012-08-14 18:07:04 -04:00
}
break;
}
/* @(/1/0/1/1/4/7/2) */
case G_SIG: {
BSP_display("s11-G;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s211);
2012-08-14 18:07:04 -04:00
break;
}
default: {
2013-09-23 14:34:35 -04:00
status_ = Q_SUPER(&QHsmTst_s1);
2012-08-14 18:07:04 -04:00
break;
}
}
2013-09-23 14:34:35 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}
/* @(/1/0/1/1/5) ...........................................................*/
static QState QHsmTst_s2(QHsmTst * const me, QEvt const * const e) {
2013-09-23 14:34:35 -04:00
QState status_;
2012-08-14 18:07:04 -04:00
switch (e->sig) {
/* @(/1/0/1/1/5) */
case Q_ENTRY_SIG: {
BSP_display("s2-ENTRY;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5) */
case Q_EXIT_SIG: {
BSP_display("s2-EXIT;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5/0) */
case Q_INIT_SIG: {
BSP_display("s2-INIT;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s211);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5/1) */
case I_SIG: {
/* @(/1/0/1/1/5/1/0) */
if (!me->foo) {
me->foo = 1U;
BSP_display("s2-I;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
}
else {
2013-09-23 14:34:35 -04:00
status_ = Q_UNHANDLED();
2012-08-14 18:07:04 -04:00
}
break;
}
/* @(/1/0/1/1/5/2) */
case F_SIG: {
BSP_display("s2-F;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s11);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5/3) */
case C_SIG: {
BSP_display("s2-C;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s1);
2012-08-14 18:07:04 -04:00
break;
}
default: {
2013-09-23 14:34:35 -04:00
status_ = Q_SUPER(&QHsmTst_s);
2012-08-14 18:07:04 -04:00
break;
}
}
2013-09-23 14:34:35 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}
/* @(/1/0/1/1/5/4) .........................................................*/
static QState QHsmTst_s21(QHsmTst * const me, QEvt const * const e) {
2013-09-23 14:34:35 -04:00
QState status_;
2012-08-14 18:07:04 -04:00
switch (e->sig) {
/* @(/1/0/1/1/5/4) */
case Q_ENTRY_SIG: {
BSP_display("s21-ENTRY;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5/4) */
case Q_EXIT_SIG: {
BSP_display("s21-EXIT;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5/4/0) */
case Q_INIT_SIG: {
BSP_display("s21-INIT;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s211);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5/4/1) */
case G_SIG: {
BSP_display("s21-G;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s1);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5/4/2) */
case A_SIG: {
BSP_display("s21-A;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s21);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5/4/3) */
case B_SIG: {
BSP_display("s21-B;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s211);
2012-08-14 18:07:04 -04:00
break;
}
default: {
2013-09-23 14:34:35 -04:00
status_ = Q_SUPER(&QHsmTst_s2);
2012-08-14 18:07:04 -04:00
break;
}
}
2013-09-23 14:34:35 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}
/* @(/1/0/1/1/5/4/4) .......................................................*/
static QState QHsmTst_s211(QHsmTst * const me, QEvt const * const e) {
2013-09-23 14:34:35 -04:00
QState status_;
2012-08-14 18:07:04 -04:00
switch (e->sig) {
/* @(/1/0/1/1/5/4/4) */
case Q_ENTRY_SIG: {
BSP_display("s211-ENTRY;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5/4/4) */
case Q_EXIT_SIG: {
BSP_display("s211-EXIT;");
2013-09-23 14:34:35 -04:00
status_ = Q_HANDLED();
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5/4/4/0) */
case H_SIG: {
BSP_display("s211-H;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s);
2012-08-14 18:07:04 -04:00
break;
}
/* @(/1/0/1/1/5/4/4/1) */
case D_SIG: {
BSP_display("s211-D;");
2013-09-23 14:34:35 -04:00
status_ = Q_TRAN(&QHsmTst_s21);
2012-08-14 18:07:04 -04:00
break;
}
default: {
2013-09-23 14:34:35 -04:00
status_ = Q_SUPER(&QHsmTst_s21);
2012-08-14 18:07:04 -04:00
break;
}
}
2013-09-23 14:34:35 -04:00
return status_;
2012-08-14 18:07:04 -04:00
}