/***************************************************************************** * Model: calc1_sub.qm * File: ./calc1_sub.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. *****************************************************************************/ /*${.::calc1_sub.c} ........................................................*/ #include "qep_port.h" /* QEP/C interface */ #include "bsp.h" /* board support package */ #include "calc1_sub.h" /* application */ /*${SMs::Calc} .............................................................*/ typedef struct { /* protected: */ QMsm super; /* private: */ double op1; uint8_t oper; /* private submachines */ struct SM_operand { QMState super; QActionHandler const ce; /* eXit-Point segment */ } const *sub_operand; } Calc; /* protected: */ static QState Calc_initial(Calc * const me, QEvt const * const e); static QState Calc_on (Calc * const me, QEvt const * const e); static QState Calc_on_e(Calc * const me); static QState Calc_on_x(Calc * const me); static QState Calc_on_i(Calc * const me); static QMState const Calc_on_s = { (QMState const *)0, /* superstate (top) */ Q_STATE_CAST(&Calc_on), Q_ACTION_CAST(&Calc_on_e), Q_ACTION_CAST(&Calc_on_x), Q_ACTION_CAST(&Calc_on_i) }; static QState Calc_ready (Calc * const me, QEvt const * const e); static QState Calc_ready_e(Calc * const me); static QState Calc_ready_x(Calc * const me); static QState Calc_ready_i(Calc * const me); static QMState const Calc_ready_s = { &Calc_on_s, /* superstate */ Q_STATE_CAST(&Calc_ready), Q_ACTION_CAST(&Calc_ready_e), Q_ACTION_CAST(&Calc_ready_x), Q_ACTION_CAST(&Calc_ready_i) }; static QState Calc_result (Calc * const me, QEvt const * const e); static QState Calc_result_e(Calc * const me); static QState Calc_result_x(Calc * const me); static QMState const Calc_result_s = { &Calc_ready_s, /* superstate */ Q_STATE_CAST(&Calc_result), Q_ACTION_CAST(&Calc_result_e), Q_ACTION_CAST(&Calc_result_x), Q_ACTION_CAST(0) /* no intitial tran. */ }; static QState Calc_begin (Calc * const me, QEvt const * const e); static QState Calc_begin_e(Calc * const me); static QState Calc_begin_x(Calc * const me); static QMState const Calc_begin_s = { &Calc_ready_s, /* superstate */ Q_STATE_CAST(&Calc_begin), Q_ACTION_CAST(&Calc_begin_e), Q_ACTION_CAST(&Calc_begin_x), Q_ACTION_CAST(0) /* no intitial tran. */ }; static QState Calc_operand1 (Calc * const me, QEvt const * const e); static QState Calc_operand1_e(Calc * const me); static QState Calc_operand1_ce(Calc * const me); static struct SM_operand const Calc_operand1_s = { { &Calc_on_s, /* superstate */ Q_STATE_CAST(&Calc_operand1), Q_ACTION_CAST(&Calc_operand1_e), Q_ACTION_CAST(0), /* no exit action */ Q_ACTION_CAST(0) /* no intitial tran. */ } ,Q_ACTION_CAST(&Calc_operand1_ce) }; static QState Calc_opEntered (Calc * const me, QEvt const * const e); static QState Calc_opEntered_e(Calc * const me); static QState Calc_opEntered_x(Calc * const me); static QMState const Calc_opEntered_s = { &Calc_on_s, /* superstate */ Q_STATE_CAST(&Calc_opEntered), Q_ACTION_CAST(&Calc_opEntered_e), Q_ACTION_CAST(&Calc_opEntered_x), Q_ACTION_CAST(0) /* no intitial tran. */ }; static QState Calc_error (Calc * const me, QEvt const * const e); static QState Calc_error_e(Calc * const me); static QState Calc_error_x(Calc * const me); static QMState const Calc_error_s = { &Calc_on_s, /* superstate */ Q_STATE_CAST(&Calc_error), Q_ACTION_CAST(&Calc_error_e), Q_ACTION_CAST(&Calc_error_x), Q_ACTION_CAST(0) /* no intitial tran. */ }; static QState Calc_operand2 (Calc * const me, QEvt const * const e); static QState Calc_operand2_e(Calc * const me); static QState Calc_operand2_ce(Calc * const me); static struct SM_operand const Calc_operand2_s = { { &Calc_on_s, /* superstate */ Q_STATE_CAST(&Calc_operand2), Q_ACTION_CAST(&Calc_operand2_e), Q_ACTION_CAST(0), /* no exit action */ Q_ACTION_CAST(0) /* no intitial tran. */ } ,Q_ACTION_CAST(&Calc_operand2_ce) }; static QState Calc_final (Calc * const me, QEvt const * const e); static QState Calc_final_e(Calc * const me); static QMState const Calc_final_s = { (QMState const *)0, /* superstate (top) */ Q_STATE_CAST(&Calc_final), Q_ACTION_CAST(&Calc_final_e), Q_ACTION_CAST(0), /* no exit action */ Q_ACTION_CAST(0) /* no intitial tran. */ }; static QState Calc_operand (Calc * const me, QEvt const * const e); static QState Calc_operand_e(Calc * const me); static QState Calc_operand_x(Calc * const me); static QMState const Calc_operand_s = { (QMState const *)0, /* superstate unused */ Q_STATE_CAST(&Calc_operand), Q_ACTION_CAST(&Calc_operand_e), Q_ACTION_CAST(&Calc_operand_x), Q_ACTION_CAST(0) /* no intitial tran. */ }; static QState Calc_operand_zero_ep(Calc * const me); static QState Calc_operand_intgr_ep(Calc * const me); static QState Calc_operand_frac_ep(Calc * const me); static QState Calc_operand_neg_ep(Calc * const me); static QState Calc_operand_zero (Calc * const me, QEvt const * const e); static QState Calc_operand_zero_e(Calc * const me); static QState Calc_operand_zero_x(Calc * const me); static QMState const Calc_operand_zero_s = { &Calc_operand_s, /* superstate */ Q_STATE_CAST(&Calc_operand_zero), Q_ACTION_CAST(&Calc_operand_zero_e), Q_ACTION_CAST(&Calc_operand_zero_x), Q_ACTION_CAST(0) /* no intitial tran. */ }; static QState Calc_operand_intgr (Calc * const me, QEvt const * const e); static QState Calc_operand_intgr_e(Calc * const me); static QState Calc_operand_intgr_x(Calc * const me); static QMState const Calc_operand_intgr_s = { &Calc_operand_s, /* superstate */ Q_STATE_CAST(&Calc_operand_intgr), Q_ACTION_CAST(&Calc_operand_intgr_e), Q_ACTION_CAST(&Calc_operand_intgr_x), Q_ACTION_CAST(0) /* no intitial tran. */ }; static QState Calc_operand_frac (Calc * const me, QEvt const * const e); static QState Calc_operand_frac_e(Calc * const me); static QState Calc_operand_frac_x(Calc * const me); static QMState const Calc_operand_frac_s = { &Calc_operand_s, /* superstate */ Q_STATE_CAST(&Calc_operand_frac), Q_ACTION_CAST(&Calc_operand_frac_e), Q_ACTION_CAST(&Calc_operand_frac_x), Q_ACTION_CAST(0) /* no intitial tran. */ }; static QState Calc_operand_neg (Calc * const me, QEvt const * const e); static QState Calc_operand_neg_e(Calc * const me); static QState Calc_operand_neg_x(Calc * const me); static QMState const Calc_operand_neg_s = { &Calc_operand_s, /* superstate */ Q_STATE_CAST(&Calc_operand_neg), Q_ACTION_CAST(&Calc_operand_neg_e), Q_ACTION_CAST(&Calc_operand_neg_x), Q_ACTION_CAST(0) /* no intitial tran. */ }; static Calc l_calc; /* the only instance of the Calc class */ /* global-scope definitions ---------------------------------------*/ QMsm * const the_calc = &l_calc.super; /* "opaque" pointer to MSM */ /*${SMs::Calc_ctor} ........................................................*/ void Calc_ctor(void) { Calc *me = &l_calc; QMsm_ctor(&me->super, Q_STATE_CAST(&Calc_initial)); } /*${SMs::Calc} .............................................................*/ /*${SMs::Calc::SM} .........................................................*/ static QState Calc_initial(Calc * const me, QEvt const * const e) { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_on_s, /* target state */ { Q_ACTION_CAST(&Calc_on_e), /* entry */ Q_ACTION_CAST(&Calc_on_i), /* init.tran. */ Q_ACTION_CAST(0) /* zero terminator */ } }; /* ${SMs::Calc::SM::initial} */ BSP_clear(); (void)e; /* unused parameter */ return QM_TRAN_INIT(&tatbl_); } /*${SMs::Calc::SM::on} .....................................................*/ /* ${SMs::Calc::SM::on} */ static QState Calc_on_e(Calc * const me) { BSP_message("on-ENTRY;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_on_s); } /* ${SMs::Calc::SM::on} */ static QState Calc_on_x(Calc * const me) { BSP_message("on-EXIT;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_EXIT(&Calc_on_s); } /* ${SMs::Calc::SM::on::initial} */ static QState Calc_on_i(Calc * const me) { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_ready_s, /* target state */ { Q_ACTION_CAST(&Calc_ready_e), /* entry */ Q_ACTION_CAST(&Calc_ready_i), /* init.tran. */ Q_ACTION_CAST(0) /* zero terminator */ } }; /* ${SMs::Calc::SM::on::initial} */ BSP_message("on-INIT;"); return QM_TRAN_INIT(&tatbl_); } /* ${SMs::Calc::SM::on} */ static QState Calc_on(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${SMs::Calc::SM::on::C} */ case C_SIG: { static struct { QMState const *target; QActionHandler act[4]; } const tatbl_ = { /* transition-action table */ &Calc_on_s, /* target state */ { Q_ACTION_CAST(&Calc_on_x), /* exit */ Q_ACTION_CAST(&Calc_on_e), /* entry */ Q_ACTION_CAST(&Calc_on_i), /* init.tran. */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_clear(); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::on::OFF} */ case OFF_SIG: { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_final_s, /* target state */ { Q_ACTION_CAST(&Calc_on_x), /* exit */ Q_ACTION_CAST(&Calc_final_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; status_ = QM_TRAN(&tatbl_); break; } default: { status_ = QM_SUPER(); break; } } return status_; } /*${SMs::Calc::SM::on::ready} ..............................................*/ /* ${SMs::Calc::SM::on::ready} */ static QState Calc_ready_e(Calc * const me) { BSP_message("ready-ENTRY;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_ready_s); } /* ${SMs::Calc::SM::on::ready} */ static QState Calc_ready_x(Calc * const me) { BSP_message("ready-EXIT;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_EXIT(&Calc_ready_s); } /* ${SMs::Calc::SM::on::ready::initial} */ static QState Calc_ready_i(Calc * const me) { static struct { QMState const *target; QActionHandler act[2]; } const tatbl_ = { /* transition-action table */ &Calc_begin_s, /* target state */ { Q_ACTION_CAST(&Calc_begin_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; /* ${SMs::Calc::SM::on::ready::initial} */ BSP_message("ready-INIT;"); return QM_TRAN_INIT(&tatbl_); } /* ${SMs::Calc::SM::on::ready} */ static QState Calc_ready(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${SMs::Calc::SM::on::ready::DIGIT_0} */ case DIGIT_0_SIG: { static struct { QMState const *target; QActionHandler act[4]; } const tatbl_ = { /* transition-action table */ &Calc_operand1_s.super, /* target state */ { Q_ACTION_CAST(&Calc_ready_x), /* exit */ Q_ACTION_CAST(&Calc_operand1_e), /* entry */ Q_ACTION_CAST(&Calc_operand_zero_ep), /* EP */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_clear(); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::on::ready::DIGIT_1_9} */ case DIGIT_1_9_SIG: { static struct { QMState const *target; QActionHandler act[4]; } const tatbl_ = { /* transition-action table */ &Calc_operand1_s.super, /* target state */ { Q_ACTION_CAST(&Calc_ready_x), /* exit */ Q_ACTION_CAST(&Calc_operand1_e), /* entry */ Q_ACTION_CAST(&Calc_operand_intgr_ep), /* EP */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_clear(); BSP_insert(Q_EVT_CAST(CalcEvt)->key_code); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::on::ready::POINT} */ case POINT_SIG: { static struct { QMState const *target; QActionHandler act[4]; } const tatbl_ = { /* transition-action table */ &Calc_operand1_s.super, /* target state */ { Q_ACTION_CAST(&Calc_ready_x), /* exit */ Q_ACTION_CAST(&Calc_operand1_e), /* entry */ Q_ACTION_CAST(&Calc_operand_frac_ep), /* EP */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_clear(); BSP_insert((int)'0'); BSP_insert((int)'.'); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::on::ready::OPER} */ case OPER_SIG: { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_opEntered_s, /* target state */ { Q_ACTION_CAST(&Calc_ready_x), /* exit */ Q_ACTION_CAST(&Calc_opEntered_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; me->op1 = BSP_get_value(); me->oper = Q_EVT_CAST(CalcEvt)->key_code; status_ = QM_TRAN(&tatbl_); break; } default: { status_ = QM_SUPER(); break; } } return status_; } /*${SMs::Calc::SM::on::ready::result} ......................................*/ /* ${SMs::Calc::SM::on::ready::result} */ static QState Calc_result_e(Calc * const me) { BSP_message("result-ENTRY;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_result_s); } /* ${SMs::Calc::SM::on::ready::result} */ static QState Calc_result_x(Calc * const me) { BSP_message("result-EXIT;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_EXIT(&Calc_result_s); } /* ${SMs::Calc::SM::on::ready::result} */ static QState Calc_result(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { default: { status_ = QM_SUPER(); break; } } (void)me; /* avoid compiler warning in case 'me' is not used */ return status_; } /*${SMs::Calc::SM::on::ready::begin} .......................................*/ /* ${SMs::Calc::SM::on::ready::begin} */ static QState Calc_begin_e(Calc * const me) { BSP_message("begin-ENTRY;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_begin_s); } /* ${SMs::Calc::SM::on::ready::begin} */ static QState Calc_begin_x(Calc * const me) { BSP_message("begin-EXIT;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_EXIT(&Calc_begin_s); } /* ${SMs::Calc::SM::on::ready::begin} */ static QState Calc_begin(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${SMs::Calc::SM::on::ready::begin::OPER} */ case OPER_SIG: { /* ${SMs::Calc::SM::on::ready::begin::OPER::[e->key=='-']} */ if (Q_EVT_CAST(CalcEvt)->key_code == KEY_MINUS) { static struct { QMState const *target; QActionHandler act[5]; } const tatbl_ = { /* transition-action table */ &Calc_operand1_s.super, /* target state */ { Q_ACTION_CAST(&Calc_begin_x), /* exit */ Q_ACTION_CAST(&Calc_ready_x), /* exit */ Q_ACTION_CAST(&Calc_operand1_e), /* entry */ Q_ACTION_CAST(&Calc_operand_neg_ep), /* EP */ Q_ACTION_CAST(0) /* zero terminator */ } }; status_ = QM_TRAN(&tatbl_); } /* ${SMs::Calc::SM::on::ready::begin::OPER::[else]} */ else { status_ = QM_HANDLED(); } break; } default: { status_ = QM_SUPER(); break; } } (void)me; /* avoid compiler warning in case 'me' is not used */ return status_; } /*${SMs::Calc::SM::on::operand1} ...........................................*/ /* ${SMs::Calc::SM::on::operand1} */ static QState Calc_operand1_e(Calc * const me) { me->sub_operand = &Calc_operand1_s; /* attach submachine */ return Calc_operand_e(me); /* enter submachine */ } /* ${SMs::Calc::SM::on::operand1} */ static QState Calc_operand1_ce(Calc * const me) { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_begin_s, /* target state */ { Q_ACTION_CAST(&Calc_ready_e), /* entry */ Q_ACTION_CAST(&Calc_begin_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; return QM_TRAN(&tatbl_); } /* ${SMs::Calc::SM::on::operand1} */ static QState Calc_operand1(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${SMs::Calc::SM::on::operand1::OPER} */ case OPER_SIG: { static struct { QMState const *target; QActionHandler act[2]; } const tatbl_ = { /* transition-action table */ &Calc_opEntered_s, /* target state */ { Q_ACTION_CAST(&Calc_opEntered_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; me->op1 = BSP_get_value(); me->oper = Q_EVT_CAST(CalcEvt)->key_code; status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::on::operand1::EQUALS} */ case EQUALS_SIG: { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_result_s, /* target state */ { Q_ACTION_CAST(&Calc_ready_e), /* entry */ Q_ACTION_CAST(&Calc_result_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; status_ = QM_TRAN(&tatbl_); break; } default: { status_ = QM_SUPER(); break; } } return status_; } /*${SMs::Calc::SM::on::opEntered} ..........................................*/ /* ${SMs::Calc::SM::on::opEntered} */ static QState Calc_opEntered_e(Calc * const me) { BSP_message("opEntered-ENTRY;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_opEntered_s); } /* ${SMs::Calc::SM::on::opEntered} */ static QState Calc_opEntered_x(Calc * const me) { BSP_message("opEntered-EXIT;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_EXIT(&Calc_opEntered_s); } /* ${SMs::Calc::SM::on::opEntered} */ static QState Calc_opEntered(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${SMs::Calc::SM::on::opEntered::DIGIT_0} */ case DIGIT_0_SIG: { static struct { QMState const *target; QActionHandler act[4]; } const tatbl_ = { /* transition-action table */ &Calc_operand2_s.super, /* target state */ { Q_ACTION_CAST(&Calc_opEntered_x), /* exit */ Q_ACTION_CAST(&Calc_operand2_e), /* entry */ Q_ACTION_CAST(&Calc_operand_zero_ep), /* EP */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_clear(); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::on::opEntered::DIGIT_1_9} */ case DIGIT_1_9_SIG: { static struct { QMState const *target; QActionHandler act[4]; } const tatbl_ = { /* transition-action table */ &Calc_operand2_s.super, /* target state */ { Q_ACTION_CAST(&Calc_opEntered_x), /* exit */ Q_ACTION_CAST(&Calc_operand2_e), /* entry */ Q_ACTION_CAST(&Calc_operand_intgr_ep), /* EP */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_clear(); BSP_insert(Q_EVT_CAST(CalcEvt)->key_code); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::on::opEntered::POINT} */ case POINT_SIG: { static struct { QMState const *target; QActionHandler act[4]; } const tatbl_ = { /* transition-action table */ &Calc_operand2_s.super, /* target state */ { Q_ACTION_CAST(&Calc_opEntered_x), /* exit */ Q_ACTION_CAST(&Calc_operand2_e), /* entry */ Q_ACTION_CAST(&Calc_operand_frac_ep), /* EP */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_clear(); BSP_insert((int)'0'); BSP_insert((int)'.'); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::on::opEntered::OPER} */ case OPER_SIG: { /* ${SMs::Calc::SM::on::opEntered::OPER::[e->key=='-']} */ if (Q_EVT_CAST(CalcEvt)->key_code == KEY_MINUS) { static struct { QMState const *target; QActionHandler act[4]; } const tatbl_ = { /* transition-action table */ &Calc_operand2_s.super, /* target state */ { Q_ACTION_CAST(&Calc_opEntered_x), /* exit */ Q_ACTION_CAST(&Calc_operand2_e), /* entry */ Q_ACTION_CAST(&Calc_operand_neg_ep), /* EP */ Q_ACTION_CAST(0) /* zero terminator */ } }; status_ = QM_TRAN(&tatbl_); } /* ${SMs::Calc::SM::on::opEntered::OPER::[else]} */ else { status_ = QM_HANDLED(); } break; } default: { status_ = QM_SUPER(); break; } } (void)me; /* avoid compiler warning in case 'me' is not used */ return status_; } /*${SMs::Calc::SM::on::error} ..............................................*/ /* ${SMs::Calc::SM::on::error} */ static QState Calc_error_e(Calc * const me) { BSP_message("error-ENTRY;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_error_s); } /* ${SMs::Calc::SM::on::error} */ static QState Calc_error_x(Calc * const me) { BSP_message("error-EXIT;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_EXIT(&Calc_error_s); } /* ${SMs::Calc::SM::on::error} */ static QState Calc_error(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { default: { status_ = QM_SUPER(); break; } } (void)me; /* avoid compiler warning in case 'me' is not used */ return status_; } /*${SMs::Calc::SM::on::operand2} ...........................................*/ /* ${SMs::Calc::SM::on::operand2} */ static QState Calc_operand2_e(Calc * const me) { me->sub_operand = &Calc_operand2_s; /* attach submachine */ return Calc_operand_e(me); /* enter submachine */ } /* ${SMs::Calc::SM::on::operand2} */ static QState Calc_operand2_ce(Calc * const me) { static struct { QMState const *target; QActionHandler act[2]; } const tatbl_ = { /* transition-action table */ &Calc_opEntered_s, /* target state */ { Q_ACTION_CAST(&Calc_opEntered_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; return QM_TRAN(&tatbl_); } /* ${SMs::Calc::SM::on::operand2} */ static QState Calc_operand2(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${SMs::Calc::SM::on::operand2::OPER} */ case OPER_SIG: { /* ${SMs::Calc::SM::on::operand2::OPER::[BSP_eval()]} */ if (BSP_eval(me->op1, me->oper, BSP_get_value())) { static struct { QMState const *target; QActionHandler act[2]; } const tatbl_ = { /* transition-action table */ &Calc_opEntered_s, /* target state */ { Q_ACTION_CAST(&Calc_opEntered_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; status_ = QM_TRAN(&tatbl_); } /* ${SMs::Calc::SM::on::operand2::OPER::[else]} */ else { static struct { QMState const *target; QActionHandler act[2]; } const tatbl_ = { /* transition-action table */ &Calc_error_s, /* target state */ { Q_ACTION_CAST(&Calc_error_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; status_ = QM_TRAN(&tatbl_); } break; } /* ${SMs::Calc::SM::on::operand2::EQUALS} */ case EQUALS_SIG: { /* ${SMs::Calc::SM::on::operand2::EQUALS::[BSP_eval()]} */ if (BSP_eval(me->op1, me->oper, BSP_get_value())) { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_result_s, /* target state */ { Q_ACTION_CAST(&Calc_ready_e), /* entry */ Q_ACTION_CAST(&Calc_result_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; status_ = QM_TRAN(&tatbl_); } /* ${SMs::Calc::SM::on::operand2::EQUALS::[else]} */ else { static struct { QMState const *target; QActionHandler act[2]; } const tatbl_ = { /* transition-action table */ &Calc_error_s, /* target state */ { Q_ACTION_CAST(&Calc_error_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; status_ = QM_TRAN(&tatbl_); } break; } default: { status_ = QM_SUPER(); break; } } return status_; } /*${SMs::Calc::SM::final} ..................................................*/ /* ${SMs::Calc::SM::final} */ static QState Calc_final_e(Calc * const me) { BSP_message("final-ENTRY;"); BSP_exit(); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_final_s); } /* ${SMs::Calc::SM::final} */ static QState Calc_final(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { default: { status_ = QM_SUPER(); break; } } (void)me; /* avoid compiler warning in case 'me' is not used */ return status_; } /*${SMs::Calc::SM::operand} ................................................*/ #if (((~QP_RELEASE & 0xFFFFFFFFU) % 0x3E8U) < 570) #error Required QP/C version 5.7.0 or higher. #endif /* ${SMs::Calc::SM::operand} */ static QState Calc_operand_e(Calc * const me) { BSP_message("operand-ENTRY;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_operand_s); } /* ${SMs::Calc::SM::operand} */ static QState Calc_operand_x(Calc * const me) { BSP_message("operand-EXIT;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_EXIT(&Calc_operand_s); } /* ${SMs::Calc::SM::operand} */ static QState Calc_operand(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${SMs::Calc::SM::operand::CE} */ case CE_SIG: { static struct { QMState const *target; QActionHandler act[2]; } const tatbl_ = { /* transition-action table */ &Calc_operand_s, /* target state */ { Q_ACTION_CAST(&Calc_operand_x), /* exit */ Q_ACTION_CAST(0) /* zero terminator */ } }; status_ = QM_TRAN_XP(me->sub_operand->ce, &tatbl_); break; } default: { status_ = QM_SUPER_SUB(&me->sub_operand->super); break; } } return status_; } /* ${SMs::Calc::SM::operand::zero} */ static QState Calc_operand_zero_ep(Calc * const me) { static struct { QMState const *target; QActionHandler act[2]; } const tatbl_ = { /* transition-action table */ &Calc_operand_zero_s, /* target state */ { Q_ACTION_CAST(&Calc_operand_zero_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_message("EP:zero;"); return QM_TRAN_EP(&tatbl_); } /* ${SMs::Calc::SM::operand::intgr} */ static QState Calc_operand_intgr_ep(Calc * const me) { static struct { QMState const *target; QActionHandler act[2]; } const tatbl_ = { /* transition-action table */ &Calc_operand_intgr_s, /* target state */ { Q_ACTION_CAST(&Calc_operand_intgr_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_message("EP:intgr;"); return QM_TRAN_EP(&tatbl_); } /* ${SMs::Calc::SM::operand::frac} */ static QState Calc_operand_frac_ep(Calc * const me) { static struct { QMState const *target; QActionHandler act[2]; } const tatbl_ = { /* transition-action table */ &Calc_operand_frac_s, /* target state */ { Q_ACTION_CAST(&Calc_operand_frac_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_message("EP:frac;"); return QM_TRAN_EP(&tatbl_); } /* ${SMs::Calc::SM::operand::neg} */ static QState Calc_operand_neg_ep(Calc * const me) { static struct { QMState const *target; QActionHandler act[2]; } const tatbl_ = { /* transition-action table */ &Calc_operand_neg_s, /* target state */ { Q_ACTION_CAST(&Calc_operand_neg_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_message("EP:neg;"); return QM_TRAN_EP(&tatbl_); } /*${SMs::Calc::SM::operand::zero} ..........................................*/ /* ${SMs::Calc::SM::operand::zero} */ static QState Calc_operand_zero_e(Calc * const me) { BSP_message("zero-ENTRY;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_operand_zero_s); } /* ${SMs::Calc::SM::operand::zero} */ static QState Calc_operand_zero_x(Calc * const me) { BSP_message("zero-EXIT;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_EXIT(&Calc_operand_zero_s); } /* ${SMs::Calc::SM::operand::zero} */ static QState Calc_operand_zero(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${SMs::Calc::SM::operand::zero::DIGIT_0} */ case DIGIT_0_SIG: { ; status_ = QM_HANDLED(); break; } /* ${SMs::Calc::SM::operand::zero::DIGIT_1_9} */ case DIGIT_1_9_SIG: { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_operand_intgr_s, /* target state */ { Q_ACTION_CAST(&Calc_operand_zero_x), /* exit */ Q_ACTION_CAST(&Calc_operand_intgr_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_insert(Q_EVT_CAST(CalcEvt)->key_code); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::operand::zero::POINT} */ case POINT_SIG: { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_operand_frac_s, /* target state */ { Q_ACTION_CAST(&Calc_operand_zero_x), /* exit */ Q_ACTION_CAST(&Calc_operand_frac_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_insert((int)'0'); BSP_insert((int)'.'); status_ = QM_TRAN(&tatbl_); break; } default: { status_ = QM_SUPER(); break; } } return status_; } /*${SMs::Calc::SM::operand::intgr} .........................................*/ /* ${SMs::Calc::SM::operand::intgr} */ static QState Calc_operand_intgr_e(Calc * const me) { BSP_message("intgr-ENTRY;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_operand_intgr_s); } /* ${SMs::Calc::SM::operand::intgr} */ static QState Calc_operand_intgr_x(Calc * const me) { BSP_message("intgr-EXIT;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_EXIT(&Calc_operand_intgr_s); } /* ${SMs::Calc::SM::operand::intgr} */ static QState Calc_operand_intgr(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${SMs::Calc::SM::operand::intgr::POINT} */ case POINT_SIG: { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_operand_frac_s, /* target state */ { Q_ACTION_CAST(&Calc_operand_intgr_x), /* exit */ Q_ACTION_CAST(&Calc_operand_frac_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_insert((int)'.'); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::operand::intgr::DIGIT_0, DIGIT_1_9} */ case DIGIT_0_SIG: /* intentionally fall through */ case DIGIT_1_9_SIG: { BSP_insert(Q_EVT_CAST(CalcEvt)->key_code); status_ = QM_HANDLED(); break; } default: { status_ = QM_SUPER(); break; } } (void)me; /* avoid compiler warning in case 'me' is not used */ return status_; } /*${SMs::Calc::SM::operand::frac} ..........................................*/ /* ${SMs::Calc::SM::operand::frac} */ static QState Calc_operand_frac_e(Calc * const me) { BSP_message("frac-ENTRY;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_operand_frac_s); } /* ${SMs::Calc::SM::operand::frac} */ static QState Calc_operand_frac_x(Calc * const me) { BSP_message("frac-EXIT;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_EXIT(&Calc_operand_frac_s); } /* ${SMs::Calc::SM::operand::frac} */ static QState Calc_operand_frac(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${SMs::Calc::SM::operand::frac::POINT} */ case POINT_SIG: { ; status_ = QM_HANDLED(); break; } /* ${SMs::Calc::SM::operand::frac::DIGIT_0, DIGIT_1_9} */ case DIGIT_0_SIG: /* intentionally fall through */ case DIGIT_1_9_SIG: { BSP_insert(Q_EVT_CAST(CalcEvt)->key_code); status_ = QM_HANDLED(); break; } default: { status_ = QM_SUPER(); break; } } (void)me; /* avoid compiler warning in case 'me' is not used */ return status_; } /*${SMs::Calc::SM::operand::neg} ...........................................*/ /* ${SMs::Calc::SM::operand::neg} */ static QState Calc_operand_neg_e(Calc * const me) { BSP_message("neg-ENTRY;"); BSP_negate(); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_ENTRY(&Calc_operand_neg_s); } /* ${SMs::Calc::SM::operand::neg} */ static QState Calc_operand_neg_x(Calc * const me) { BSP_message("neg-EXIT;"); (void)me; /* avoid compiler warning in case 'me' is not used */ return QM_EXIT(&Calc_operand_neg_s); } /* ${SMs::Calc::SM::operand::neg} */ static QState Calc_operand_neg(Calc * const me, QEvt const * const e) { QState status_; switch (e->sig) { /* ${SMs::Calc::SM::operand::neg::DIGIT_0} */ case DIGIT_0_SIG: { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_operand_zero_s, /* target state */ { Q_ACTION_CAST(&Calc_operand_neg_x), /* exit */ Q_ACTION_CAST(&Calc_operand_zero_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_insert(Q_EVT_CAST(CalcEvt)->key_code); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::operand::neg::DIGIT_1_9} */ case DIGIT_1_9_SIG: { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_operand_intgr_s, /* target state */ { Q_ACTION_CAST(&Calc_operand_neg_x), /* exit */ Q_ACTION_CAST(&Calc_operand_intgr_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_insert(Q_EVT_CAST(CalcEvt)->key_code); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::operand::neg::POINT} */ case POINT_SIG: { static struct { QMState const *target; QActionHandler act[3]; } const tatbl_ = { /* transition-action table */ &Calc_operand_frac_s, /* target state */ { Q_ACTION_CAST(&Calc_operand_neg_x), /* exit */ Q_ACTION_CAST(&Calc_operand_frac_e), /* entry */ Q_ACTION_CAST(0) /* zero terminator */ } }; BSP_insert(Q_EVT_CAST(CalcEvt)->key_code); status_ = QM_TRAN(&tatbl_); break; } /* ${SMs::Calc::SM::operand::neg::OPER} */ case OPER_SIG: { /* ${SMs::Calc::SM::operand::neg::OPER::[e->key=='-']} */ if (Q_EVT_CAST(CalcEvt)->key_code == KEY_MINUS) { ; status_ = QM_HANDLED(); } /* ${SMs::Calc::SM::operand::neg::OPER::[else]} */ else { status_ = QM_HANDLED(); } break; } default: { status_ = QM_SUPER(); break; } } (void)me; /* avoid compiler warning in case 'me' is not used */ return status_; }