mirror of
https://github.com/QuantumLeaps/qpc.git
synced 2025-01-21 06:53:11 +08:00
1361 lines
49 KiB
C
1361 lines
49 KiB
C
/*****************************************************************************
|
|
* Model: calc.qm
|
|
* File: ./calc.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.
|
|
*****************************************************************************/
|
|
/*${.::calc.c} .............................................................*/
|
|
#include "qpc.h" /* QP/C */
|
|
#include "bsp.h" /* board support package */
|
|
#include "calc.h" /* application */
|
|
|
|
/*${SMs::Calc} .............................................................*/
|
|
typedef struct {
|
|
/* protected: */
|
|
QMsm super;
|
|
|
|
/* private: */
|
|
double operand1;
|
|
uint8_t operator;
|
|
} 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_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_negated1 (Calc * const me, QEvt const * const e);
|
|
static QState Calc_negated1_e(Calc * const me);
|
|
static QState Calc_negated1_x(Calc * const me);
|
|
static QMState const Calc_negated1_s = {
|
|
&Calc_on_s, /* superstate */
|
|
Q_STATE_CAST(&Calc_negated1),
|
|
Q_ACTION_CAST(&Calc_negated1_e),
|
|
Q_ACTION_CAST(&Calc_negated1_x),
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
};
|
|
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_x(Calc * const me);
|
|
static QMState const Calc_operand1_s = {
|
|
&Calc_on_s, /* superstate */
|
|
Q_STATE_CAST(&Calc_operand1),
|
|
Q_ACTION_CAST(&Calc_operand1_e),
|
|
Q_ACTION_CAST(&Calc_operand1_x),
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
};
|
|
static QState Calc_zero1 (Calc * const me, QEvt const * const e);
|
|
static QState Calc_zero1_e(Calc * const me);
|
|
static QState Calc_zero1_x(Calc * const me);
|
|
static QMState const Calc_zero1_s = {
|
|
&Calc_operand1_s, /* superstate */
|
|
Q_STATE_CAST(&Calc_zero1),
|
|
Q_ACTION_CAST(&Calc_zero1_e),
|
|
Q_ACTION_CAST(&Calc_zero1_x),
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
};
|
|
static QState Calc_int1 (Calc * const me, QEvt const * const e);
|
|
static QState Calc_int1_e(Calc * const me);
|
|
static QState Calc_int1_x(Calc * const me);
|
|
static QMState const Calc_int1_s = {
|
|
&Calc_operand1_s, /* superstate */
|
|
Q_STATE_CAST(&Calc_int1),
|
|
Q_ACTION_CAST(&Calc_int1_e),
|
|
Q_ACTION_CAST(&Calc_int1_x),
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
};
|
|
static QState Calc_frac1 (Calc * const me, QEvt const * const e);
|
|
static QState Calc_frac1_e(Calc * const me);
|
|
static QState Calc_frac1_x(Calc * const me);
|
|
static QMState const Calc_frac1_s = {
|
|
&Calc_operand1_s, /* superstate */
|
|
Q_STATE_CAST(&Calc_frac1),
|
|
Q_ACTION_CAST(&Calc_frac1_e),
|
|
Q_ACTION_CAST(&Calc_frac1_x),
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
};
|
|
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_negated2 (Calc * const me, QEvt const * const e);
|
|
static QState Calc_negated2_e(Calc * const me);
|
|
static QState Calc_negated2_x(Calc * const me);
|
|
static QMState const Calc_negated2_s = {
|
|
&Calc_on_s, /* superstate */
|
|
Q_STATE_CAST(&Calc_negated2),
|
|
Q_ACTION_CAST(&Calc_negated2_e),
|
|
Q_ACTION_CAST(&Calc_negated2_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_x(Calc * const me);
|
|
static QMState const Calc_operand2_s = {
|
|
&Calc_on_s, /* superstate */
|
|
Q_STATE_CAST(&Calc_operand2),
|
|
Q_ACTION_CAST(&Calc_operand2_e),
|
|
Q_ACTION_CAST(&Calc_operand2_x),
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
};
|
|
static QState Calc_zero2 (Calc * const me, QEvt const * const e);
|
|
static QState Calc_zero2_e(Calc * const me);
|
|
static QState Calc_zero2_x(Calc * const me);
|
|
static QMState const Calc_zero2_s = {
|
|
&Calc_operand2_s, /* superstate */
|
|
Q_STATE_CAST(&Calc_zero2),
|
|
Q_ACTION_CAST(&Calc_zero2_e),
|
|
Q_ACTION_CAST(&Calc_zero2_x),
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
};
|
|
static QState Calc_int2 (Calc * const me, QEvt const * const e);
|
|
static QState Calc_int2_e(Calc * const me);
|
|
static QState Calc_int2_x(Calc * const me);
|
|
static QMState const Calc_int2_s = {
|
|
&Calc_operand2_s, /* superstate */
|
|
Q_STATE_CAST(&Calc_int2),
|
|
Q_ACTION_CAST(&Calc_int2_e),
|
|
Q_ACTION_CAST(&Calc_int2_x),
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
};
|
|
static QState Calc_frac2 (Calc * const me, QEvt const * const e);
|
|
static QState Calc_frac2_e(Calc * const me);
|
|
static QState Calc_frac2_x(Calc * const me);
|
|
static QMState const Calc_frac2_s = {
|
|
&Calc_operand2_s, /* superstate */
|
|
Q_STATE_CAST(&Calc_frac2),
|
|
Q_ACTION_CAST(&Calc_frac2_e),
|
|
Q_ACTION_CAST(&Calc_frac2_x),
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
};
|
|
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 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::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::negated1} ...........................................*/
|
|
/* ${SMs::Calc::SM::on::negated1} */
|
|
static QState Calc_negated1_e(Calc * const me) {
|
|
BSP_message("negated1-ENTRY;");
|
|
BSP_negate();
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_ENTRY(&Calc_negated1_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated1} */
|
|
static QState Calc_negated1_x(Calc * const me) {
|
|
BSP_message("negated1-EXIT;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_EXIT(&Calc_negated1_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated1} */
|
|
static QState Calc_negated1(Calc * const me, QEvt const * const e) {
|
|
QState status_;
|
|
switch (e->sig) {
|
|
/* ${SMs::Calc::SM::on::negated1::DIGIT_0} */
|
|
case DIGIT_0_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[4];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_zero1_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_negated1_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand1_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_zero1_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated1::DIGIT_1_9} */
|
|
case DIGIT_1_9_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[4];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_int1_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_negated1_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand1_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_int1_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated1::POINT} */
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[4];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_frac1_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_negated1_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand1_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_frac1_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated1::OPER} */
|
|
case OPER_SIG: {
|
|
/* ${SMs::Calc::SM::on::negated1::OPER::[e->key=='-']} */
|
|
if (Q_EVT_CAST(CalcEvt)->key_code == KEY_MINUS) {
|
|
;
|
|
status_ = QM_HANDLED();
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated1::OPER::[else]} */
|
|
else {
|
|
status_ = QM_HANDLED();
|
|
}
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated1::CE} */
|
|
case CE_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[4];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_begin_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_negated1_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_ready_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_begin_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_clear();
|
|
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_zero1_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_ready_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand1_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_zero1_e), /* entry */
|
|
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_int1_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_ready_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand1_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_int1_e), /* entry */
|
|
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_frac1_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_ready_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand1_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_frac1_e), /* entry */
|
|
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->operand1 = BSP_get_value();
|
|
me->operator = 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[4];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_negated1_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_begin_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_ready_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_negated1_e), /* entry */
|
|
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) {
|
|
BSP_message("operand1-ENTRY;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_ENTRY(&Calc_operand1_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1} */
|
|
static QState Calc_operand1_x(Calc * const me) {
|
|
BSP_message("operand1-EXIT;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_EXIT(&Calc_operand1_s);
|
|
}
|
|
/* ${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::CE} */
|
|
case CE_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[4];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_begin_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_operand1_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_ready_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_begin_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_clear();
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1::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_operand1_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_opEntered_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
me->operand1 = BSP_get_value();
|
|
me->operator = 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[4];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_result_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_operand1_x), /* exit */
|
|
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::operand1::zero1} ....................................*/
|
|
/* ${SMs::Calc::SM::on::operand1::zero1} */
|
|
static QState Calc_zero1_e(Calc * const me) {
|
|
BSP_message("zero1-ENTRY;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_ENTRY(&Calc_zero1_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1::zero1} */
|
|
static QState Calc_zero1_x(Calc * const me) {
|
|
BSP_message("zero1-EXIT;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_EXIT(&Calc_zero1_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1::zero1} */
|
|
static QState Calc_zero1(Calc * const me, QEvt const * const e) {
|
|
QState status_;
|
|
switch (e->sig) {
|
|
/* ${SMs::Calc::SM::on::operand1::zero1::DIGIT_0} */
|
|
case DIGIT_0_SIG: {
|
|
;
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1::zero1::DIGIT_1_9} */
|
|
case DIGIT_1_9_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_int1_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_zero1_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_int1_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1::zero1::POINT} */
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_frac1_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_zero1_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_frac1_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::on::operand1::int1} .....................................*/
|
|
/* ${SMs::Calc::SM::on::operand1::int1} */
|
|
static QState Calc_int1_e(Calc * const me) {
|
|
BSP_message("int1-ENTRY;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_ENTRY(&Calc_int1_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1::int1} */
|
|
static QState Calc_int1_x(Calc * const me) {
|
|
BSP_message("int1-EXIT;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_EXIT(&Calc_int1_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1::int1} */
|
|
static QState Calc_int1(Calc * const me, QEvt const * const e) {
|
|
QState status_;
|
|
switch (e->sig) {
|
|
/* ${SMs::Calc::SM::on::operand1::int1::POINT} */
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_frac1_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_int1_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_frac1_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_insert((int)'.');
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1::int1::DIGIT_0, DIGIT_1~} */
|
|
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::on::operand1::frac1} ....................................*/
|
|
/* ${SMs::Calc::SM::on::operand1::frac1} */
|
|
static QState Calc_frac1_e(Calc * const me) {
|
|
BSP_message("frac1-ENTRY;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_ENTRY(&Calc_frac1_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1::frac1} */
|
|
static QState Calc_frac1_x(Calc * const me) {
|
|
BSP_message("frac1-EXIT;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_EXIT(&Calc_frac1_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1::frac1} */
|
|
static QState Calc_frac1(Calc * const me, QEvt const * const e) {
|
|
QState status_;
|
|
switch (e->sig) {
|
|
/* ${SMs::Calc::SM::on::operand1::frac1::POINT} */
|
|
case POINT_SIG: {
|
|
;
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand1::frac1::DIGIT_0, DIGIT_1~} */
|
|
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::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_zero2_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_opEntered_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand2_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_zero2_e), /* entry */
|
|
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_int2_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_opEntered_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand2_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_int2_e), /* entry */
|
|
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_frac2_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_opEntered_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand2_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_frac2_e), /* entry */
|
|
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[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_negated2_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_opEntered_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_negated2_e), /* entry */
|
|
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::negated2} ...........................................*/
|
|
/* ${SMs::Calc::SM::on::negated2} */
|
|
static QState Calc_negated2_e(Calc * const me) {
|
|
BSP_message("negated2-ENTRY;");
|
|
BSP_negate();
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_ENTRY(&Calc_negated2_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated2} */
|
|
static QState Calc_negated2_x(Calc * const me) {
|
|
BSP_message("negated2-EXIT;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_EXIT(&Calc_negated2_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated2} */
|
|
static QState Calc_negated2(Calc * const me, QEvt const * const e) {
|
|
QState status_;
|
|
switch (e->sig) {
|
|
/* ${SMs::Calc::SM::on::negated2::DIGIT_0} */
|
|
case DIGIT_0_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[4];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_zero2_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_negated2_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand2_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_zero2_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated2::DIGIT_1_9} */
|
|
case DIGIT_1_9_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[4];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_int2_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_negated2_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand2_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_int2_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated2::POINT} */
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[4];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_frac2_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_negated2_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_operand2_e), /* entry */
|
|
Q_ACTION_CAST(&Calc_frac2_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated2::OPER} */
|
|
case OPER_SIG: {
|
|
/* ${SMs::Calc::SM::on::negated2::OPER::[e->key=='-']} */
|
|
if (Q_EVT_CAST(CalcEvt)->key_code == KEY_MINUS) {
|
|
;
|
|
status_ = QM_HANDLED();
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated2::OPER::[else]} */
|
|
else {
|
|
status_ = QM_HANDLED();
|
|
}
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::negated2::CE} */
|
|
case CE_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_opEntered_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_negated2_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_opEntered_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_clear();
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
return status_;
|
|
}
|
|
/*${SMs::Calc::SM::on::operand2} ...........................................*/
|
|
/* ${SMs::Calc::SM::on::operand2} */
|
|
static QState Calc_operand2_e(Calc * const me) {
|
|
BSP_message("operand2-ENTRY;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_ENTRY(&Calc_operand2_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2} */
|
|
static QState Calc_operand2_x(Calc * const me) {
|
|
BSP_message("operand2-EXIT;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_EXIT(&Calc_operand2_s);
|
|
}
|
|
/* ${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::CE} */
|
|
case CE_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_opEntered_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_operand2_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_opEntered_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_clear();
|
|
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->operand1, me->operator, BSP_get_value())) {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[4];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_result_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_operand2_x), /* exit */
|
|
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[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_error_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_operand2_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_error_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
status_ = QM_TRAN(&tatbl_);
|
|
}
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2::OPER} */
|
|
case OPER_SIG: {
|
|
/* ${SMs::Calc::SM::on::operand2::OPER::[BSP_eval()]} */
|
|
if (BSP_eval(me->operand1, me->operator, BSP_get_value())) {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_opEntered_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_operand2_x), /* exit */
|
|
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[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_error_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_operand2_x), /* exit */
|
|
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::on::operand2::zero2} ....................................*/
|
|
/* ${SMs::Calc::SM::on::operand2::zero2} */
|
|
static QState Calc_zero2_e(Calc * const me) {
|
|
BSP_message("zero2-ENTRY;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_ENTRY(&Calc_zero2_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2::zero2} */
|
|
static QState Calc_zero2_x(Calc * const me) {
|
|
BSP_message("zero2-EXIT;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_EXIT(&Calc_zero2_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2::zero2} */
|
|
static QState Calc_zero2(Calc * const me, QEvt const * const e) {
|
|
QState status_;
|
|
switch (e->sig) {
|
|
/* ${SMs::Calc::SM::on::operand2::zero2::DIGIT_0} */
|
|
case DIGIT_0_SIG: {
|
|
;
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2::zero2::DIGIT_1_9} */
|
|
case DIGIT_1_9_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_int2_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_zero2_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_int2_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2::zero2::POINT} */
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_frac2_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_zero2_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_frac2_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::on::operand2::int2} .....................................*/
|
|
/* ${SMs::Calc::SM::on::operand2::int2} */
|
|
static QState Calc_int2_e(Calc * const me) {
|
|
BSP_message("int2-ENTRY;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_ENTRY(&Calc_int2_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2::int2} */
|
|
static QState Calc_int2_x(Calc * const me) {
|
|
BSP_message("int2-EXIT;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_EXIT(&Calc_int2_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2::int2} */
|
|
static QState Calc_int2(Calc * const me, QEvt const * const e) {
|
|
QState status_;
|
|
switch (e->sig) {
|
|
/* ${SMs::Calc::SM::on::operand2::int2::POINT} */
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QMState const *target;
|
|
QActionHandler act[3];
|
|
} const tatbl_ = { /* transition-action table */
|
|
&Calc_frac2_s, /* target state */
|
|
{
|
|
Q_ACTION_CAST(&Calc_int2_x), /* exit */
|
|
Q_ACTION_CAST(&Calc_frac2_e), /* entry */
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
}
|
|
};
|
|
BSP_insert((int)'.');
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2::int2::DIGIT_0, DIGIT_1~} */
|
|
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::on::operand2::frac2} ....................................*/
|
|
/* ${SMs::Calc::SM::on::operand2::frac2} */
|
|
static QState Calc_frac2_e(Calc * const me) {
|
|
BSP_message("frac2-ENTRY;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_ENTRY(&Calc_frac2_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2::frac2} */
|
|
static QState Calc_frac2_x(Calc * const me) {
|
|
BSP_message("frac2-EXIT;");
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return QM_EXIT(&Calc_frac2_s);
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2::frac2} */
|
|
static QState Calc_frac2(Calc * const me, QEvt const * const e) {
|
|
QState status_;
|
|
switch (e->sig) {
|
|
/* ${SMs::Calc::SM::on::operand2::frac2::POINT} */
|
|
case POINT_SIG: {
|
|
;
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
/* ${SMs::Calc::SM::on::operand2::frac2::DIGIT_0, DIGIT_1~} */
|
|
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::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_;
|
|
}
|
|
|