/***************************************************************************** * Model: qhsmtst.qm * File: ./qhsmtst.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. *****************************************************************************/ /* @(/2/1) .................................................................*/ #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) { QState status_; switch (e->sig) { /* @(/1/0/1/1) */ case Q_ENTRY_SIG: { BSP_display("s-ENTRY;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1) */ case Q_EXIT_SIG: { BSP_display("s-EXIT;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1/0) */ case Q_INIT_SIG: { BSP_display("s-INIT;"); status_ = Q_TRAN(&QHsmTst_s11); 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;"); status_ = Q_HANDLED(); } else { status_ = Q_UNHANDLED(); } break; } /* @(/1/0/1/1/2) */ case E_SIG: { BSP_display("s-E;"); status_ = Q_TRAN(&QHsmTst_s11); break; } /* @(/1/0/1/1/3) */ case TERMINATE_SIG: { BSP_exit(); status_ = Q_HANDLED(); break; } default: { status_ = Q_SUPER(&QHsm_top); break; } } return status_; } /* @(/1/0/1/1/4) ...........................................................*/ static QState QHsmTst_s1(QHsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* @(/1/0/1/1/4) */ case Q_ENTRY_SIG: { BSP_display("s1-ENTRY;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1/4) */ case Q_EXIT_SIG: { BSP_display("s1-EXIT;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1/4/0) */ case Q_INIT_SIG: { BSP_display("s1-INIT;"); status_ = Q_TRAN(&QHsmTst_s11); break; } /* @(/1/0/1/1/4/1) */ case I_SIG: { BSP_display("s1-I;"); status_ = Q_HANDLED(); 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;"); status_ = Q_TRAN(&QHsmTst_s); } else { status_ = Q_UNHANDLED(); } break; } /* @(/1/0/1/1/4/3) */ case A_SIG: { BSP_display("s1-A;"); status_ = Q_TRAN(&QHsmTst_s1); break; } /* @(/1/0/1/1/4/4) */ case B_SIG: { BSP_display("s1-B;"); status_ = Q_TRAN(&QHsmTst_s11); break; } /* @(/1/0/1/1/4/5) */ case F_SIG: { BSP_display("s1-F;"); status_ = Q_TRAN(&QHsmTst_s211); break; } /* @(/1/0/1/1/4/6) */ case C_SIG: { BSP_display("s1-C;"); status_ = Q_TRAN(&QHsmTst_s2); break; } default: { status_ = Q_SUPER(&QHsmTst_s); break; } } return status_; } /* @(/1/0/1/1/4/7) .........................................................*/ static QState QHsmTst_s11(QHsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* @(/1/0/1/1/4/7) */ case Q_ENTRY_SIG: { BSP_display("s11-ENTRY;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1/4/7) */ case Q_EXIT_SIG: { BSP_display("s11-EXIT;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1/4/7/0) */ case H_SIG: { BSP_display("s11-H;"); status_ = Q_TRAN(&QHsmTst_s); 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;"); status_ = Q_TRAN(&QHsmTst_s1); } else { status_ = Q_UNHANDLED(); } break; } /* @(/1/0/1/1/4/7/2) */ case G_SIG: { BSP_display("s11-G;"); status_ = Q_TRAN(&QHsmTst_s211); break; } default: { status_ = Q_SUPER(&QHsmTst_s1); break; } } return status_; } /* @(/1/0/1/1/5) ...........................................................*/ static QState QHsmTst_s2(QHsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* @(/1/0/1/1/5) */ case Q_ENTRY_SIG: { BSP_display("s2-ENTRY;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1/5) */ case Q_EXIT_SIG: { BSP_display("s2-EXIT;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1/5/0) */ case Q_INIT_SIG: { BSP_display("s2-INIT;"); status_ = Q_TRAN(&QHsmTst_s211); 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;"); status_ = Q_HANDLED(); } else { status_ = Q_UNHANDLED(); } break; } /* @(/1/0/1/1/5/2) */ case F_SIG: { BSP_display("s2-F;"); status_ = Q_TRAN(&QHsmTst_s11); break; } /* @(/1/0/1/1/5/3) */ case C_SIG: { BSP_display("s2-C;"); status_ = Q_TRAN(&QHsmTst_s1); break; } default: { status_ = Q_SUPER(&QHsmTst_s); break; } } return status_; } /* @(/1/0/1/1/5/4) .........................................................*/ static QState QHsmTst_s21(QHsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* @(/1/0/1/1/5/4) */ case Q_ENTRY_SIG: { BSP_display("s21-ENTRY;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1/5/4) */ case Q_EXIT_SIG: { BSP_display("s21-EXIT;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1/5/4/0) */ case Q_INIT_SIG: { BSP_display("s21-INIT;"); status_ = Q_TRAN(&QHsmTst_s211); break; } /* @(/1/0/1/1/5/4/1) */ case G_SIG: { BSP_display("s21-G;"); status_ = Q_TRAN(&QHsmTst_s1); break; } /* @(/1/0/1/1/5/4/2) */ case A_SIG: { BSP_display("s21-A;"); status_ = Q_TRAN(&QHsmTst_s21); break; } /* @(/1/0/1/1/5/4/3) */ case B_SIG: { BSP_display("s21-B;"); status_ = Q_TRAN(&QHsmTst_s211); break; } default: { status_ = Q_SUPER(&QHsmTst_s2); break; } } return status_; } /* @(/1/0/1/1/5/4/4) .......................................................*/ static QState QHsmTst_s211(QHsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* @(/1/0/1/1/5/4/4) */ case Q_ENTRY_SIG: { BSP_display("s211-ENTRY;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1/5/4/4) */ case Q_EXIT_SIG: { BSP_display("s211-EXIT;"); status_ = Q_HANDLED(); break; } /* @(/1/0/1/1/5/4/4/0) */ case H_SIG: { BSP_display("s211-H;"); status_ = Q_TRAN(&QHsmTst_s); break; } /* @(/1/0/1/1/5/4/4/1) */ case D_SIG: { BSP_display("s211-D;"); status_ = Q_TRAN(&QHsmTst_s21); break; } default: { status_ = Q_SUPER(&QHsmTst_s21); break; } } return status_; }