/*${HSMs::QHsmTst::SM::s::s2::s21::s211} ...................................*/ static QState QHsmTst_s211(QHsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${HSMs::QHsmTst::SM::s::s2::s21::s211} */ case Q_ENTRY_SIG: { BSP_display("s211-ENTRY;"); status_ = Q_HANDLED(); break; } /* ${HSMs::QHsmTst::SM::s::s2::s21::s211} */ case Q_EXIT_SIG: { BSP_display("s211-EXIT;"); status_ = Q_HANDLED(); break; } /* ${HSMs::QHsmTst::SM::s::s2::s21::s211::H} */ case H_SIG: { BSP_display("s211-H;"); status_ = Q_TRAN(&QHsmTst_s); break; } /* ${HSMs::QHsmTst::SM::s::s2::s21::s211::D} */ case D_SIG: { BSP_display("s211-D;"); status_ = Q_TRAN(&QHsmTst_s21); break; } default: { status_ = Q_SUPER(&QHsmTst_s21); break; } } return status_; }
static QState QMsmTst_s211(QMsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* @(/1/0/1/1/5/4/4/0) */ case H_SIG: { static QActionHandler const act_[] = { Q_ACTION_CAST(&QMsmTst_s211_x), Q_ACTION_CAST(&QMsmTst_s21_x), Q_ACTION_CAST(&QMsmTst_s2_x), Q_ACTION_CAST(&QMsmTst_s_i), Q_ACTION_CAST(0) }; BSP_display("s211-H;"); status_ = QM_TRAN(&QMsmTst_s_s, &act_[0]); break; } /* @(/1/0/1/1/5/4/4/1) */ case D_SIG: { static QActionHandler const act_[] = { Q_ACTION_CAST(&QMsmTst_s211_x), Q_ACTION_CAST(&QMsmTst_s21_i), Q_ACTION_CAST(0) }; BSP_display("s211-D;"); status_ = QM_TRAN(&QMsmTst_s21_s, &act_[0]); break; } default: { status_ = QM_SUPER(); break; } } return status_; }
QState QHsmTst_WAITING(QHsmTst *me) { switch (Q_SIG(me)) { case Q_ENTRY_SIG: { if(elevOrders[currentFloor]) { arrivedAtFloor(currentFloor,waiting); tick5(); tick5(); BSP_display("timePassed10;"); BSP_display("waiting-ENTRY;"); arrivedAtFloor(currentFloor,waiting); } return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("waiting-EXIT;"); return Q_HANDLED(); } case GO_DOWN: { BSP_display("received-go-down;"); direct = DOWN; return Q_TRAN(&QHsmTst_MOVING); } case GO_UP: { BSP_display("received-go-up;"); direct = UP; return Q_TRAN(&QHsmTst_MOVING); } } return Q_SUPER(&QHsmTst_SUPER); }
//${HSMs::QHsmTst::SM::s::s2::s21::s211} ..................................... Q_STATE_DEF(QHsmTst, s211) { QP::QState status_; switch (e->sig) { //${HSMs::QHsmTst::SM::s::s2::s21::s211} case Q_ENTRY_SIG: { BSP_display("s211-ENTRY;"); status_ = Q_RET_HANDLED; break; } //${HSMs::QHsmTst::SM::s::s2::s21::s211} case Q_EXIT_SIG: { BSP_display("s211-EXIT;"); status_ = Q_RET_HANDLED; break; } //${HSMs::QHsmTst::SM::s::s2::s21::s211::H} case H_SIG: { BSP_display("s211-H;"); status_ = tran(&s); break; } //${HSMs::QHsmTst::SM::s::s2::s21::s211::D} case D_SIG: { BSP_display("s211-D;"); status_ = tran(&s21); break; } default: { status_ = super(&s21); break; } } return status_; }
/* @(/1/0/1/1/5/4/4) .......................................................*/ static QState QHsmTst_s211(QHsmTst * const me) { QState status_; switch (Q_SIG(me)) { /* @(/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_; }
//............................................................................ QState QHsmTst::s11(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s11-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s11-EXIT;"); return Q_HANDLED(); } case D_SIG: { // transition with a gurad if (me->m_foo) { BSP_display("s11-D;"); me->m_foo = 0; return Q_TRAN(&QHsmTst::s1); } break; } case G_SIG: { BSP_display("s11-G;"); return Q_TRAN(&QHsmTst::s211); } case H_SIG: { BSP_display("s11-H;"); return Q_TRAN(&QHsmTst::s); } } return Q_SUPER(&QHsmTst::s1); }
//............................................................................ QState QHsmTst::s(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s-EXIT;"); return Q_HANDLED(); } case Q_INIT_SIG: { BSP_display("s-INIT;"); return Q_TRAN(&QHsmTst::s11); } case E_SIG: { BSP_display("s-E;"); return Q_TRAN(&QHsmTst::s11); } case I_SIG: { // internal transition with a guard if (me->m_foo) { BSP_display("s-I;"); me->m_foo = 0; return Q_HANDLED(); } break; } case TERMINATE_SIG: { BSP_exit(); return Q_HANDLED(); } } return Q_SUPER(&QHsm::top); }
static QState QMsmTst_s11(QMsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* @(/1/0/1/1/4/7/0) */ case H_SIG: { static QActionHandler const act_[] = { Q_ACTION_CAST(&QMsmTst_s11_x), Q_ACTION_CAST(&QMsmTst_s1_x), Q_ACTION_CAST(&QMsmTst_s_i), Q_ACTION_CAST(0) }; BSP_display("s11-H;"); status_ = QM_TRAN(&QMsmTst_s_s, &act_[0]); break; } /* @(/1/0/1/1/4/7/1) */ case D_SIG: { /* @(/1/0/1/1/4/7/1/0) */ if (me->foo) { static QActionHandler const act_[] = { Q_ACTION_CAST(&QMsmTst_s11_x), Q_ACTION_CAST(&QMsmTst_s1_i), Q_ACTION_CAST(0) }; me->foo = 0U; BSP_display("s11-D;"); status_ = QM_TRAN(&QMsmTst_s1_s, &act_[0]); } else { status_ = QM_UNHANDLED(); } break; } /* @(/1/0/1/1/4/7/2) */ case G_SIG: { static QActionHandler const act_[] = { Q_ACTION_CAST(&QMsmTst_s11_x), Q_ACTION_CAST(&QMsmTst_s1_x), Q_ACTION_CAST(&QMsmTst_s2_e), Q_ACTION_CAST(&QMsmTst_s21_e), Q_ACTION_CAST(&QMsmTst_s211_e), Q_ACTION_CAST(0) }; BSP_display("s11-G;"); status_ = QM_TRAN(&QMsmTst_s211_s, &act_[0]); break; } default: { status_ = QM_SUPER(); break; } } return status_; }
/*${HSMs::QHsmTst::SM::s} ..................................................*/ static QState QHsmTst_s(QHsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${HSMs::QHsmTst::SM::s} */ case Q_ENTRY_SIG: { BSP_display("s-ENTRY;"); status_ = Q_HANDLED(); break; } /* ${HSMs::QHsmTst::SM::s} */ case Q_EXIT_SIG: { BSP_display("s-EXIT;"); status_ = Q_HANDLED(); break; } /* ${HSMs::QHsmTst::SM::s::initial} */ case Q_INIT_SIG: { BSP_display("s-INIT;"); status_ = Q_TRAN(&QHsmTst_s11); break; } /* ${HSMs::QHsmTst::SM::s::I} */ case I_SIG: { /* ${HSMs::QHsmTst::SM::s::I::[me->foo]} */ if (me->foo) { me->foo = 0U; BSP_display("s-I;"); status_ = Q_HANDLED(); } else { status_ = Q_UNHANDLED(); } break; } /* ${HSMs::QHsmTst::SM::s::E} */ case E_SIG: { BSP_display("s-E;"); status_ = Q_TRAN(&QHsmTst_s11); break; } /* ${HSMs::QHsmTst::SM::s::TERMINATE} */ case TERMINATE_SIG: { BSP_exit(); status_ = Q_HANDLED(); break; } default: { status_ = Q_SUPER(&QHsm_top); break; } } return status_; }
//${HSMs::QHsmTst::SM::s} .................................................... Q_STATE_DEF(QHsmTst, s) { QP::QState status_; switch (e->sig) { //${HSMs::QHsmTst::SM::s} case Q_ENTRY_SIG: { BSP_display("s-ENTRY;"); status_ = Q_RET_HANDLED; break; } //${HSMs::QHsmTst::SM::s} case Q_EXIT_SIG: { BSP_display("s-EXIT;"); status_ = Q_RET_HANDLED; break; } //${HSMs::QHsmTst::SM::s::initial} case Q_INIT_SIG: { BSP_display("s-INIT;"); status_ = tran(&s11); break; } //${HSMs::QHsmTst::SM::s::I} case I_SIG: { //${HSMs::QHsmTst::SM::s::I::[m_foo]} if (m_foo) { m_foo = 0U; BSP_display("s-I;"); status_ = Q_RET_HANDLED; } else { status_ = Q_RET_UNHANDLED; } break; } //${HSMs::QHsmTst::SM::s::E} case E_SIG: { BSP_display("s-E;"); status_ = tran(&s11); break; } //${HSMs::QHsmTst::SM::s::TERMINATE} case TERMINATE_SIG: { BSP_terminate(0); status_ = Q_RET_HANDLED; break; } default: { status_ = super(&top); break; } } return status_; }
/* @(/1/0/1/1) .............................................................*/ static QState QHsmTst_s(QHsmTst * const me) { QState status_; switch (Q_SIG(me)) { /* @(/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_; }
/*..........................................................................*/ QState QHsmSata_linkdown(QHsmSata *me, QEvent const *e) { switch (e->sig) { case Q_ENTRY_SIG: hw_reg_begin (me->port, INTC_LINK); hw_reg_update(me->port, C_DATA, 0x1); hw_reg_end (me->port); BSP_display("down-ENTRY;"); return Q_HANDLED(); case Q_EXIT_SIG: BSP_display("down-EXIT;"); return Q_HANDLED(); } return Q_SUPER(&QHsmSata_top); }
/*..........................................................................*/ QState Bomb4_timing(Bomb4 *me, QEvent const *e) { switch (e->sig) { case Q_ENTRY_SIG: { me->code = 0; /* clear the defuse code */ return Q_HANDLED(); } case UP_SIG: { me->code <<= 1; me->code |= 1; return Q_HANDLED(); } case DOWN_SIG: { me->code <<= 1; return Q_HANDLED(); } case ARM_SIG: { if (me->code == me->defuse) { return Q_TRAN(&Bomb4_setting); } return Q_HANDLED(); } case TICK_SIG: { if (((TickEvt const *)e)->fine_time == 0) { --me->timeout; BSP_display(me->timeout); if (me->timeout == 0) { BSP_boom(); /* destroy the bomb */ } } return Q_HANDLED(); } } return Q_IGNORED(); }
/*..........................................................................*/ void Bomb2_setting_UP(Bomb2 *me, Event const *e) { (void)e; /* avoid compiler warning about unused parameter */ if (me->timeout < 60) { ++me->timeout; BSP_display(me->timeout); } }
/*${HSMs::QHsmTst::SM} .....................................................*/ static QState QHsmTst_initial(QHsmTst * const me, QEvt const * const e) { /* ${HSMs::QHsmTst::SM::initial} */ (void)e; /* avoid compiler warning */ me->foo = 0U; BSP_display("top-INIT;"); return Q_TRAN(&QHsmTst_s2); }
//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //$define${HSMs::QHsmTst} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv //${HSMs::QHsmTst} ........................................................... //${HSMs::QHsmTst::SM} ....................................................... Q_STATE_DEF(QHsmTst, initial) { //${HSMs::QHsmTst::SM::initial} (void)e; // avoid compiler warning m_foo = 0U; BSP_display("top-INIT;"); QS_SIG_DICTIONARY(A_SIG, this); QS_SIG_DICTIONARY(B_SIG, this); QS_SIG_DICTIONARY(C_SIG, this); QS_SIG_DICTIONARY(D_SIG, this); QS_SIG_DICTIONARY(E_SIG, this); QS_SIG_DICTIONARY(F_SIG, this); QS_SIG_DICTIONARY(G_SIG, this); QS_SIG_DICTIONARY(H_SIG, this); QS_SIG_DICTIONARY(I_SIG, this); QS_SIG_DICTIONARY(TERMINATE_SIG, this); QS_SIG_DICTIONARY(IGNORE_SIG, this); QS_FUN_DICTIONARY(&s); QS_FUN_DICTIONARY(&s1); QS_FUN_DICTIONARY(&s11); QS_FUN_DICTIONARY(&s2); QS_FUN_DICTIONARY(&s21); QS_FUN_DICTIONARY(&s211); return tran(&s2); }
/* @(/1/0/1/1/4/7) .........................................................*/ static QState QHsmTst_s11(QHsmTst * const me) { QState status_; switch (Q_SIG(me)) { /* @(/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_; }
static QState QMsmTst_s2(QMsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* @(/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_ = QM_HANDLED(); } else { status_ = QM_UNHANDLED(); } break; } /* @(/1/0/1/1/5/2) */ case F_SIG: { static QActionHandler const act_[] = { Q_ACTION_CAST(&QMsmTst_s2_x), Q_ACTION_CAST(&QMsmTst_s1_e), Q_ACTION_CAST(&QMsmTst_s11_e), Q_ACTION_CAST(0) }; BSP_display("s2-F;"); status_ = QM_TRAN(&QMsmTst_s11_s, &act_[0]); break; } /* @(/1/0/1/1/5/3) */ case C_SIG: { static QActionHandler const act_[] = { Q_ACTION_CAST(&QMsmTst_s2_x), Q_ACTION_CAST(&QMsmTst_s1_e), Q_ACTION_CAST(&QMsmTst_s1_i), Q_ACTION_CAST(0) }; BSP_display("s2-C;"); status_ = QM_TRAN(&QMsmTst_s1_s, &act_[0]); break; } default: { status_ = QM_SUPER(); break; } } return status_; }
//${HSMs::QHsmTst::SM::s::s1::s11} ........................................... Q_STATE_DEF(QHsmTst, s11) { QP::QState status_; switch (e->sig) { //${HSMs::QHsmTst::SM::s::s1::s11} case Q_ENTRY_SIG: { BSP_display("s11-ENTRY;"); status_ = Q_RET_HANDLED; break; } //${HSMs::QHsmTst::SM::s::s1::s11} case Q_EXIT_SIG: { BSP_display("s11-EXIT;"); status_ = Q_RET_HANDLED; break; } //${HSMs::QHsmTst::SM::s::s1::s11::H} case H_SIG: { BSP_display("s11-H;"); status_ = tran(&s); break; } //${HSMs::QHsmTst::SM::s::s1::s11::D} case D_SIG: { //${HSMs::QHsmTst::SM::s::s1::s11::D::[m_foo]} if (m_foo) { m_foo = false; BSP_display("s11-D;"); status_ = tran(&s1); } else { status_ = Q_RET_UNHANDLED; } break; } //${HSMs::QHsmTst::SM::s::s1::s11::G} case G_SIG: { BSP_display("s11-G;"); status_ = tran(&s211); break; } default: { status_ = super(&s1); break; } } return status_; }
/*${HSMs::QHsmTst::SM::s::s1::s11} .........................................*/ static QState QHsmTst_s11(QHsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${HSMs::QHsmTst::SM::s::s1::s11} */ case Q_ENTRY_SIG: { BSP_display("s11-ENTRY;"); status_ = Q_HANDLED(); break; } /* ${HSMs::QHsmTst::SM::s::s1::s11} */ case Q_EXIT_SIG: { BSP_display("s11-EXIT;"); status_ = Q_HANDLED(); break; } /* ${HSMs::QHsmTst::SM::s::s1::s11::H} */ case H_SIG: { BSP_display("s11-H;"); status_ = Q_TRAN(&QHsmTst_s); break; } /* ${HSMs::QHsmTst::SM::s::s1::s11::D} */ case D_SIG: { /* ${HSMs::QHsmTst::SM::s::s1::s11::D::[me->foo]} */ if (me->foo) { me->foo = 0U; BSP_display("s11-D;"); status_ = Q_TRAN(&QHsmTst_s1); } else { status_ = Q_UNHANDLED(); } break; } /* ${HSMs::QHsmTst::SM::s::s1::s11::G} */ case G_SIG: { BSP_display("s11-G;"); status_ = Q_TRAN(&QHsmTst_s211); break; } default: { status_ = Q_SUPER(&QHsmTst_s1); break; } } return status_; }
static QState QMsmTst_s21_i(QMsmTst * const me) { static QActionHandler const act_[] = { Q_ACTION_CAST(&QMsmTst_s211_e), Q_ACTION_CAST(0) }; BSP_display("s21-INIT;"); return QM_INITIAL(&QMsmTst_s211_s, &act_[0]); }
void TimingState::onTICK(Bomb3 *context, uint8_t fine_time) const { if (fine_time == 0) { --context->m_timeout; BSP_display(context->m_timeout); if (context->m_timeout == 0) { BSP_boom(); // destroy the bomb } } }
/*..........................................................................*/ void Bomb2_timing_TICK(Bomb2 *me, Event const *e) { if (((TickEvt const *)e)->fine_time == 0) { --me->timeout; BSP_display(me->timeout); if (me->timeout == 0) { BSP_boom(); /* destroy the bomb */ } } }
/* @(/1/0/1/0) */ static QState QMsmTst_initial(QMsmTst * const me, QEvt const * const e) { static QActionHandler const act_[] = { Q_ACTION_CAST(&QMsmTst_s_e), Q_ACTION_CAST(&QMsmTst_s2_e), Q_ACTION_CAST(&QMsmTst_s2_i), Q_ACTION_CAST(0) }; (void)e; /* avoid compiler warning */ me->foo = 0U; BSP_display("top-INIT;"); return QM_INITIAL(&QMsmTst_s2_s, &act_[0]); }
//............................................................................ QState QHsmTst::s211(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s211-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s211-EXIT;"); return Q_HANDLED(); } case D_SIG: { BSP_display("s211-D;"); return Q_TRAN(&QHsmTst::s21); } case H_SIG: { BSP_display("s211-H;"); return Q_TRAN(&QHsmTst::s); } } return Q_SUPER(&QHsmTst::s21); }
QState QHsmTst_SUPER(QHsmTst *me) { switch (Q_SIG(me)) { case Q_ENTRY_SIG: { BSP_display("super-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("super-EXIT;"); return Q_HANDLED(); } case Q_INIT_SIG: { BSP_display("super-INIT;"); return Q_TRAN(&QHsmTst_WAITING); } } BSP_display("Super return to top"); return Q_SUPER(&QHsm_top); }
//............................................................................ QState QHsmTst::s21(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s21-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s21-EXIT;"); return Q_HANDLED(); } case Q_INIT_SIG: { BSP_display("s21-INIT;"); return Q_TRAN(&QHsmTst::s211); } case A_SIG: { BSP_display("s21-A;"); return Q_TRAN(&QHsmTst::s21); } case B_SIG: { BSP_display("s21-B;"); return Q_TRAN(&QHsmTst::s211); } case G_SIG: { BSP_display("s21-G;"); return Q_TRAN(&QHsmTst::s1); } } return Q_SUPER(&QHsmTst::s2); }
//............................................................................ QState QHsmTst::s2(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s2-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s2-EXIT;"); return Q_HANDLED(); } case Q_INIT_SIG: { BSP_display("s2-INIT;"); return Q_TRAN(&QHsmTst::s211); } case C_SIG: { BSP_display("s2-C;"); return Q_TRAN(&QHsmTst::s1); } case F_SIG: { BSP_display("s2-F;"); return Q_TRAN(&QHsmTst::s11); } case I_SIG: { // internal transition with a guard if (!me->m_foo) { BSP_display("s2-I;"); me->m_foo = (uint8_t)1; return Q_HANDLED(); } break; } } return Q_SUPER(&QHsmTst::s); }
//............................................................................ QState QHsmTst::s1(QHsmTst *me, QEvt const *e) { switch (e->sig) { case Q_ENTRY_SIG: { BSP_display("s1-ENTRY;"); return Q_HANDLED(); } case Q_EXIT_SIG: { BSP_display("s1-EXIT;"); return Q_HANDLED(); } case Q_INIT_SIG: { BSP_display("s1-INIT;"); return Q_TRAN(&QHsmTst::s11); } case A_SIG: { BSP_display("s1-A;"); return Q_TRAN(&QHsmTst::s1); } case B_SIG: { BSP_display("s1-B;"); return Q_TRAN(&QHsmTst::s11); } case C_SIG: { BSP_display("s1-C;"); return Q_TRAN(&QHsmTst::s2); } case D_SIG: { // transition with a gurad if (!me->m_foo) { BSP_display("s1-D;"); me->m_foo = 1; return Q_TRAN(&QHsmTst::s); } break; } case F_SIG: { BSP_display("s1-F;"); return Q_TRAN(&QHsmTst::s211); } case I_SIG: { // internal transition BSP_display("s1-I;"); return Q_HANDLED(); } } return Q_SUPER(&QHsmTst::s); }
static QState QMsmTst_s(QMsmTst * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* @(/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_ = QM_HANDLED(); } else { status_ = QM_UNHANDLED(); } break; } /* @(/1/0/1/1/2) */ case E_SIG: { static QActionHandler const act_[] = { Q_ACTION_CAST(&QMsmTst_s1_e), Q_ACTION_CAST(&QMsmTst_s11_e), Q_ACTION_CAST(0) }; BSP_display("s-E;"); status_ = QM_TRAN(&QMsmTst_s11_s, &act_[0]); break; } /* @(/1/0/1/1/3) */ case TERMINATE_SIG: { BSP_exit(); status_ = QM_HANDLED(); break; } default: { status_ = QM_SUPER(); break; } } return status_; }