2012-08-14 18:07:04 -04:00
|
|
|
/*****************************************************************************
|
2014-04-06 11:43:13 -04:00
|
|
|
* Model: calc2.qm
|
|
|
|
* File: ./calc2.c
|
2012-08-14 18:07:04 -04:00
|
|
|
*
|
2014-04-06 11:43:13 -04:00
|
|
|
* This code has been generated by QM tool (see state-machine.com/qm).
|
|
|
|
* DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
|
2012-08-14 18:07:04 -04:00
|
|
|
*
|
|
|
|
* 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
|
2014-04-06 11:43:13 -04:00
|
|
|
* by the Free Software Foundation.
|
2012-08-14 18:07:04 -04:00
|
|
|
*
|
2014-04-06 11:43:13 -04:00
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
2012-08-14 18:07:04 -04:00
|
|
|
*****************************************************************************/
|
2014-04-06 11:43:13 -04:00
|
|
|
/*${.::calc2.c} ............................................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
#include "qpc.h" /* QP/C */
|
|
|
|
#include "bsp.h" /* board support package */
|
|
|
|
#include "calc2.h" /* application */
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2014-04-06 11:43:13 -04:00
|
|
|
/*${SMs::Calc2} ............................................................*/
|
|
|
|
typedef struct {
|
|
|
|
/* protected: */
|
|
|
|
QMsm super;
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2014-04-06 11:43:13 -04:00
|
|
|
/* private: */
|
|
|
|
double operand1;
|
|
|
|
uint8_t operator;
|
|
|
|
} Calc2;
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2014-04-06 11:43:13 -04:00
|
|
|
/* protected: */
|
|
|
|
static QState Calc2_initial(Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_on (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_on_e(Calc2 * const me);
|
|
|
|
static QState Calc2_on_x(Calc2 * const me);
|
|
|
|
static QState Calc2_on_i(Calc2 * const me);
|
|
|
|
static QMState const Calc2_on_s = {
|
|
|
|
(QMState const *)0, /* superstate (top) */
|
|
|
|
Q_STATE_CAST(&Calc2_on),
|
|
|
|
Q_ACTION_CAST(&Calc2_on_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_on_x),
|
|
|
|
Q_ACTION_CAST(&Calc2_on_i)
|
|
|
|
};
|
|
|
|
static QState Calc2_error (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_error_e(Calc2 * const me);
|
|
|
|
static QState Calc2_error_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_error_s = {
|
|
|
|
&Calc2_on_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_error),
|
|
|
|
Q_ACTION_CAST(&Calc2_error_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_error_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_negated1 (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_negated1_e(Calc2 * const me);
|
|
|
|
static QState Calc2_negated1_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_negated1_s = {
|
|
|
|
&Calc2_on_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_negated1),
|
|
|
|
Q_ACTION_CAST(&Calc2_negated1_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_negated1_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_ready (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_ready_e(Calc2 * const me);
|
|
|
|
static QState Calc2_ready_x(Calc2 * const me);
|
|
|
|
static QState Calc2_ready_i(Calc2 * const me);
|
|
|
|
static QMState const Calc2_ready_s = {
|
|
|
|
&Calc2_on_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_ready),
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_x),
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_i)
|
|
|
|
};
|
|
|
|
static QState Calc2_result (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_result_e(Calc2 * const me);
|
|
|
|
static QState Calc2_result_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_result_s = {
|
|
|
|
&Calc2_ready_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_result),
|
|
|
|
Q_ACTION_CAST(&Calc2_result_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_result_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_begin (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_begin_e(Calc2 * const me);
|
|
|
|
static QState Calc2_begin_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_begin_s = {
|
|
|
|
&Calc2_ready_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_begin),
|
|
|
|
Q_ACTION_CAST(&Calc2_begin_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_begin_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_operand1 (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_operand1_e(Calc2 * const me);
|
|
|
|
static QState Calc2_operand1_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_operand1_s = {
|
|
|
|
&Calc2_on_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_operand1),
|
|
|
|
Q_ACTION_CAST(&Calc2_operand1_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_operand1_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_zero1 (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_zero1_e(Calc2 * const me);
|
|
|
|
static QState Calc2_zero1_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_zero1_s = {
|
|
|
|
&Calc2_operand1_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_zero1),
|
|
|
|
Q_ACTION_CAST(&Calc2_zero1_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_zero1_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_int1 (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_int1_e(Calc2 * const me);
|
|
|
|
static QState Calc2_int1_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_int1_s = {
|
|
|
|
&Calc2_operand1_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_int1),
|
|
|
|
Q_ACTION_CAST(&Calc2_int1_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_int1_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_frac1 (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_frac1_e(Calc2 * const me);
|
|
|
|
static QState Calc2_frac1_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_frac1_s = {
|
|
|
|
&Calc2_operand1_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_frac1),
|
|
|
|
Q_ACTION_CAST(&Calc2_frac1_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_frac1_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_opEntered (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_opEntered_e(Calc2 * const me);
|
|
|
|
static QState Calc2_opEntered_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_opEntered_s = {
|
|
|
|
&Calc2_on_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_opEntered),
|
|
|
|
Q_ACTION_CAST(&Calc2_opEntered_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_opEntered_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_negated2 (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_negated2_e(Calc2 * const me);
|
|
|
|
static QState Calc2_negated2_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_negated2_s = {
|
|
|
|
&Calc2_on_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_negated2),
|
|
|
|
Q_ACTION_CAST(&Calc2_negated2_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_negated2_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_operand2 (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_operand2_e(Calc2 * const me);
|
|
|
|
static QState Calc2_operand2_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_operand2_s = {
|
|
|
|
&Calc2_on_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_operand2),
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_zero2 (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_zero2_e(Calc2 * const me);
|
|
|
|
static QState Calc2_zero2_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_zero2_s = {
|
|
|
|
&Calc2_operand2_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_zero2),
|
|
|
|
Q_ACTION_CAST(&Calc2_zero2_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_zero2_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_int2 (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_int2_e(Calc2 * const me);
|
|
|
|
static QState Calc2_int2_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_int2_s = {
|
|
|
|
&Calc2_operand2_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_int2),
|
|
|
|
Q_ACTION_CAST(&Calc2_int2_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_int2_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_frac2 (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_frac2_e(Calc2 * const me);
|
|
|
|
static QState Calc2_frac2_x(Calc2 * const me);
|
|
|
|
static QMState const Calc2_frac2_s = {
|
|
|
|
&Calc2_operand2_s, /* superstate */
|
|
|
|
Q_STATE_CAST(&Calc2_frac2),
|
|
|
|
Q_ACTION_CAST(&Calc2_frac2_e),
|
|
|
|
Q_ACTION_CAST(&Calc2_frac2_x),
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
|
|
|
static QState Calc2_final (Calc2 * const me, QEvt const * const e);
|
|
|
|
static QState Calc2_final_e(Calc2 * const me);
|
|
|
|
static QMState const Calc2_final_s = {
|
|
|
|
(QMState const *)0, /* superstate (top) */
|
|
|
|
Q_STATE_CAST(&Calc2_final),
|
|
|
|
Q_ACTION_CAST(&Calc2_final_e),
|
|
|
|
Q_ACTION_CAST(0), /* no exit action */
|
|
|
|
Q_ACTION_CAST(0) /* no intitial tran. */
|
|
|
|
};
|
2012-08-14 18:07:04 -04:00
|
|
|
|
|
|
|
|
2014-04-06 11:43:13 -04:00
|
|
|
static Calc2 l_calc2; /* the only instance of the Calc class */
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2014-04-06 11:43:13 -04:00
|
|
|
/* global-scope definitions ---------------------------------------*/
|
|
|
|
QMsm * const the_calc = &l_calc2.super; /* "opaque" pointer to MSM */
|
|
|
|
|
|
|
|
/*${SMs::Calc2_ctor} .......................................................*/
|
|
|
|
void Calc2_ctor(void) {
|
|
|
|
Calc2 *me = &l_calc2;
|
|
|
|
QMsm_ctor(&me->super, Q_STATE_CAST(&Calc2_initial));
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2} ............................................................*/
|
|
|
|
/*${SMs::Calc2::SM} ........................................................*/
|
|
|
|
static QState Calc2_initial(Calc2 * const me, QEvt const * const e) {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_on_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_on_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_on_i), /* init.tran. */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/* ${SMs::Calc2::SM::initial} */
|
2012-08-14 18:07:04 -04:00
|
|
|
BSP_clear();
|
2015-04-28 13:45:35 -04:00
|
|
|
(void)e; /* avoid compiler warning about unused parameter */
|
2014-04-06 11:43:13 -04:00
|
|
|
return QM_TRAN_INIT(&tatbl_);
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2::SM::on} ....................................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_on_e(Calc2 * const me) {
|
|
|
|
BSP_message("on-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_on_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_on_x(Calc2 * const me) {
|
|
|
|
BSP_message("on-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_on_s);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::initial} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_on_i(Calc2 * const me) {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_ready_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_i), /* init.tran. */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/* ${SMs::Calc2::SM::on::initial} */
|
|
|
|
BSP_message("on-INIT;");
|
|
|
|
return QM_TRAN_INIT(&tatbl_);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_on(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::C} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case C_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_on_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_on_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_on_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_on_i), /* init.tran. */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
2012-08-14 18:07:04 -04:00
|
|
|
BSP_clear();
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::OFF} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case OFF_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_final_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_on_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_final_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2::SM::on::error} .............................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::error} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_error_e(Calc2 * const me) {
|
|
|
|
BSP_message("error-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_error_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::error} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_error_x(Calc2 * const me) {
|
|
|
|
BSP_message("error-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_error_s);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::error} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_error(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/*${SMs::Calc2::SM::on::negated1} ..........................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_negated1_e(Calc2 * const me) {
|
|
|
|
BSP_message("negated1-ENTRY;");
|
|
|
|
BSP_negate();
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_negated1_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_negated1_x(Calc2 * const me) {
|
|
|
|
BSP_message("negated1-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_negated1_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_negated1(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated1::DIGIT_0} */
|
|
|
|
case DIGIT_0_SIG: {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_zero1_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_negated1_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_zero1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated1::DIGIT_1_9} */
|
|
|
|
case DIGIT_1_9_SIG: {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_int1_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_negated1_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_int1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated1::POINT} */
|
|
|
|
case POINT_SIG: {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_frac1_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_negated1_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_frac1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* ${SMs::Calc2::SM::on::negated1::OPER} */
|
|
|
|
case OPER_SIG: {
|
|
|
|
/* ${SMs::Calc2::SM::on::negated1::OPER::[e->key=='-']} */
|
|
|
|
if (Q_EVT_CAST(CalcEvt)->key_code == KEY_MINUS) {
|
|
|
|
;
|
|
|
|
status_ = QM_HANDLED();
|
|
|
|
}
|
|
|
|
/* ${SMs::Calc2::SM::on::negated1::OPER::[else]} */
|
|
|
|
else {
|
|
|
|
status_ = QM_HANDLED();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* ${SMs::Calc2::SM::on::negated1::CE} */
|
|
|
|
case CE_SIG: {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_begin_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_negated1_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_begin_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_clear();
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
}
|
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2::SM::on::ready} .............................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_ready_e(Calc2 * const me) {
|
|
|
|
BSP_message("ready-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_ready_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_ready_x(Calc2 * const me) {
|
|
|
|
BSP_message("ready-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_ready_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::initial} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_ready_i(Calc2 * const me) {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[2];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_begin_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_begin_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/* ${SMs::Calc2::SM::on::ready::initial} */
|
|
|
|
BSP_message("ready-INIT;");
|
|
|
|
return QM_TRAN_INIT(&tatbl_);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_ready(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
|
|
|
switch (e->sig) {
|
|
|
|
/* ${SMs::Calc2::SM::on::ready::DIGIT_0} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case DIGIT_0_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_zero1_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_zero1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
2012-08-14 18:07:04 -04:00
|
|
|
BSP_clear();
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::DIGIT_1_9} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case DIGIT_1_9_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_int1_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_int1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
2012-08-14 18:07:04 -04:00
|
|
|
BSP_clear();
|
2014-04-06 11:43:13 -04:00
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::POINT} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case POINT_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_frac1_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_frac1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
2012-08-14 18:07:04 -04:00
|
|
|
BSP_clear();
|
|
|
|
BSP_insert((int)'0');
|
|
|
|
BSP_insert((int)'.');
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::OPER} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case OPER_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_opEntered_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_opEntered_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
2012-08-14 18:07:04 -04:00
|
|
|
me->operand1 = BSP_get_value();
|
2014-04-06 11:43:13 -04:00
|
|
|
me->operator = Q_EVT_CAST(CalcEvt)->key_code;
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2::SM::on::ready::result} .....................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::result} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_result_e(Calc2 * const me) {
|
|
|
|
BSP_message("result-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_result_s);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::result} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_result_x(Calc2 * const me) {
|
|
|
|
BSP_message("result-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_result_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::result} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_result(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2::SM::on::ready::begin} ......................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::begin} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_begin_e(Calc2 * const me) {
|
|
|
|
BSP_message("begin-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_begin_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::begin} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_begin_x(Calc2 * const me) {
|
|
|
|
BSP_message("begin-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_begin_s);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::begin} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_begin(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::begin::OPER} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case OPER_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::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 */
|
|
|
|
&Calc2_negated1_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_begin_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_negated1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::ready::begin::OPER::[else]} */
|
2012-08-14 18:07:04 -04:00
|
|
|
else {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_HANDLED();
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/*${SMs::Calc2::SM::on::operand1} ..........................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_operand1_e(Calc2 * const me) {
|
|
|
|
BSP_message("operand1-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_operand1_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_operand1_x(Calc2 * const me) {
|
|
|
|
BSP_message("operand1-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_operand1_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_operand1(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::CE} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case CE_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_begin_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_operand1_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_begin_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
2012-08-14 18:07:04 -04:00
|
|
|
BSP_clear();
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::OPER} */
|
|
|
|
case OPER_SIG: {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_opEntered_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_operand1_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_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_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::EQUALS} */
|
|
|
|
case EQUALS_SIG: {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_result_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_operand1_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_result_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2::SM::on::operand1::zero1} ...................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::zero1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_zero1_e(Calc2 * const me) {
|
|
|
|
BSP_message("zero1-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_zero1_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::zero1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_zero1_x(Calc2 * const me) {
|
|
|
|
BSP_message("zero1-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_zero1_s);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::zero1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_zero1(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::zero1::DIGIT_0} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case DIGIT_0_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
;
|
|
|
|
status_ = QM_HANDLED();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::zero1::DIGIT_1_9} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case DIGIT_1_9_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_int1_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_zero1_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_int1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::zero1::POINT} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case POINT_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_frac1_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_zero1_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_frac1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert((int)'0');
|
|
|
|
BSP_insert((int)'.');
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
return status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/*${SMs::Calc2::SM::on::operand1::int1} ....................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::int1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_int1_e(Calc2 * const me) {
|
|
|
|
BSP_message("int1-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_int1_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::int1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_int1_x(Calc2 * const me) {
|
|
|
|
BSP_message("int1-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_int1_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::int1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_int1(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::int1::POINT} */
|
|
|
|
case POINT_SIG: {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_frac1_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_int1_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_frac1_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert((int)'.');
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::int1::DIGIT_0, DIGIT_1~} */
|
2014-04-06 11:43:13 -04:00
|
|
|
case DIGIT_0_SIG: /* intentionally fall through */
|
|
|
|
case DIGIT_1_9_SIG: {
|
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_HANDLED();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2::SM::on::operand1::frac1} ...................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::frac1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_frac1_e(Calc2 * const me) {
|
|
|
|
BSP_message("frac1-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_frac1_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::frac1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_frac1_x(Calc2 * const me) {
|
|
|
|
BSP_message("frac1-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_frac1_s);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::frac1} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_frac1(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::frac1::POINT} */
|
|
|
|
case POINT_SIG: {
|
|
|
|
;
|
|
|
|
status_ = QM_HANDLED();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand1::frac1::DIGIT_0, DIGIT_1~} */
|
2014-04-06 11:43:13 -04:00
|
|
|
case DIGIT_0_SIG: /* intentionally fall through */
|
2012-08-14 18:07:04 -04:00
|
|
|
case DIGIT_1_9_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_HANDLED();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2::SM::on::opEntered} .........................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::opEntered} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_opEntered_e(Calc2 * const me) {
|
|
|
|
BSP_message("opEntered-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_opEntered_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::opEntered} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_opEntered_x(Calc2 * const me) {
|
|
|
|
BSP_message("opEntered-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_opEntered_s);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::opEntered} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_opEntered(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::opEntered::DIGIT_0} */
|
|
|
|
case DIGIT_0_SIG: {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_zero2_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_opEntered_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_zero2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_clear();
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::opEntered::DIGIT_1_9} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case DIGIT_1_9_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_int2_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_opEntered_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_int2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_clear();
|
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::opEntered::POINT} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case POINT_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_frac2_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_opEntered_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_frac2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_clear();
|
|
|
|
BSP_insert((int)'0');
|
|
|
|
BSP_insert((int)'.');
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* ${SMs::Calc2::SM::on::opEntered::OPER} */
|
|
|
|
case OPER_SIG: {
|
|
|
|
/* ${SMs::Calc2::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 */
|
|
|
|
&Calc2_negated2_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_opEntered_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_negated2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
|
|
|
}
|
|
|
|
/* ${SMs::Calc2::SM::on::opEntered::OPER::[else]} */
|
|
|
|
else {
|
|
|
|
status_ = QM_HANDLED();
|
|
|
|
}
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2::SM::on::negated2} ..........................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_negated2_e(Calc2 * const me) {
|
|
|
|
BSP_message("negated2-ENTRY;");
|
|
|
|
BSP_negate();
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_negated2_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_negated2_x(Calc2 * const me) {
|
|
|
|
BSP_message("negated2-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_negated2_s);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_negated2(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated2::DIGIT_0} */
|
|
|
|
case DIGIT_0_SIG: {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_zero2_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_negated2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_zero2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated2::DIGIT_1_9} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case DIGIT_1_9_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_int2_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_negated2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_int2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated2::POINT} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case POINT_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_frac2_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_negated2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_frac2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated2::OPER} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case OPER_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated2::OPER::[e->key=='-']} */
|
|
|
|
if (Q_EVT_CAST(CalcEvt)->key_code == KEY_MINUS) {
|
|
|
|
;
|
|
|
|
status_ = QM_HANDLED();
|
|
|
|
}
|
|
|
|
/* ${SMs::Calc2::SM::on::negated2::OPER::[else]} */
|
|
|
|
else {
|
|
|
|
status_ = QM_HANDLED();
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::negated2::CE} */
|
|
|
|
case CE_SIG: {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_opEntered_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_negated2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_opEntered_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
2012-08-14 18:07:04 -04:00
|
|
|
BSP_clear();
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2013-02-12 10:04:39 -05:00
|
|
|
break;
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2::SM::on::operand2} ..........................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_operand2_e(Calc2 * const me) {
|
|
|
|
BSP_message("operand2-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_operand2_s);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_operand2_x(Calc2 * const me) {
|
|
|
|
BSP_message("operand2-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_operand2_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_operand2(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::CE} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case CE_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_opEntered_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_opEntered_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
2012-08-14 18:07:04 -04:00
|
|
|
BSP_clear();
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::EQUALS} */
|
|
|
|
case EQUALS_SIG: {
|
|
|
|
/* ${SMs::Calc2::SM::on::operand2::EQUALS::[BSP_eval()]} */
|
2012-08-14 18:07:04 -04:00
|
|
|
if (BSP_eval(me->operand1, me->operator, BSP_get_value())) {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_result_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_result_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::EQUALS::[else]} */
|
2012-08-14 18:07:04 -04:00
|
|
|
else {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_error_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_error_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::OPER} */
|
|
|
|
case OPER_SIG: {
|
|
|
|
/* ${SMs::Calc2::SM::on::operand2::OPER::[BSP_eval()]} */
|
2012-08-14 18:07:04 -04:00
|
|
|
if (BSP_eval(me->operand1, me->operator, BSP_get_value())) {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_opEntered_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_opEntered_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::OPER::[else]} */
|
2012-08-14 18:07:04 -04:00
|
|
|
else {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_error_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_error_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::PERCENT} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case PERCENT_SIG: {
|
|
|
|
double operand2 = 0.0;
|
|
|
|
switch (me->operator) {
|
|
|
|
case KEY_PLUS:
|
|
|
|
case KEY_MINUS: {
|
|
|
|
operand2 = (me->operand1 * BSP_get_value())/100.0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case KEY_MULT:
|
|
|
|
case KEY_DIVIDE: {
|
|
|
|
operand2 = BSP_get_value()/100.0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::PERCENT::[BSP_eval()]} */
|
2012-08-14 18:07:04 -04:00
|
|
|
if (BSP_eval(me->operand1, me->operator, operand2)) {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[4];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_result_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_ready_e), /* entry */
|
|
|
|
Q_ACTION_CAST(&Calc2_result_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::PERCENT::[else]} */
|
2012-08-14 18:07:04 -04:00
|
|
|
else {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_error_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_operand2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_error_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
return status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/*${SMs::Calc2::SM::on::operand2::zero2} ...................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::zero2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_zero2_e(Calc2 * const me) {
|
|
|
|
BSP_message("zero2-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_zero2_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::zero2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_zero2_x(Calc2 * const me) {
|
|
|
|
BSP_message("zero2-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_zero2_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::zero2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_zero2(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::zero2::DIGIT_0} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case DIGIT_0_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
;
|
|
|
|
status_ = QM_HANDLED();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::zero2::DIGIT_1_9} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case DIGIT_1_9_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_int2_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_zero2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_int2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::zero2::POINT} */
|
2012-08-14 18:07:04 -04:00
|
|
|
case POINT_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_frac2_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_zero2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_frac2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert((int)'0');
|
|
|
|
BSP_insert((int)'.');
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
|
|
|
break;
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
return status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/*${SMs::Calc2::SM::on::operand2::int2} ....................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::int2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_int2_e(Calc2 * const me) {
|
|
|
|
BSP_message("int2-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_int2_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::int2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_int2_x(Calc2 * const me) {
|
|
|
|
BSP_message("int2-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_int2_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::int2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_int2(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::int2::POINT} */
|
|
|
|
case POINT_SIG: {
|
|
|
|
static struct {
|
|
|
|
QMState const *target;
|
|
|
|
QActionHandler act[3];
|
|
|
|
} const tatbl_ = { /* transition-action table */
|
|
|
|
&Calc2_frac2_s, /* target state */
|
|
|
|
{
|
|
|
|
Q_ACTION_CAST(&Calc2_int2_x), /* exit */
|
|
|
|
Q_ACTION_CAST(&Calc2_frac2_e), /* entry */
|
|
|
|
Q_ACTION_CAST(0) /* zero terminator */
|
|
|
|
}
|
|
|
|
};
|
|
|
|
BSP_insert((int)'.');
|
|
|
|
status_ = QM_TRAN(&tatbl_);
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::int2::DIGIT_0, DIGIT_1~} */
|
2014-04-06 11:43:13 -04:00
|
|
|
case DIGIT_0_SIG: /* intentionally fall through */
|
2012-08-14 18:07:04 -04:00
|
|
|
case DIGIT_1_9_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_HANDLED();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return status_;
|
|
|
|
}
|
|
|
|
/*${SMs::Calc2::SM::on::operand2::frac2} ...................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::frac2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_frac2_e(Calc2 * const me) {
|
|
|
|
BSP_message("frac2-ENTRY;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_frac2_s);
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::frac2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_frac2_x(Calc2 * const me) {
|
|
|
|
BSP_message("frac2-EXIT;");
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_EXIT(&Calc2_frac2_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::frac2} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_frac2(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
2014-04-06 11:43:13 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::frac2::POINT} */
|
|
|
|
case POINT_SIG: {
|
|
|
|
;
|
|
|
|
status_ = QM_HANDLED();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::on::operand2::frac2::DIGIT_0, DIGIT_1~} */
|
2014-04-06 11:43:13 -04:00
|
|
|
case DIGIT_0_SIG: /* intentionally fall through */
|
2012-08-14 18:07:04 -04:00
|
|
|
case DIGIT_1_9_SIG: {
|
2014-04-06 11:43:13 -04:00
|
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
|
|
status_ = QM_HANDLED();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
/*${SMs::Calc2::SM::final} .................................................*/
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::final} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_final_e(Calc2 * const me) {
|
|
|
|
BSP_message("final-ENTRY;");
|
|
|
|
BSP_exit();
|
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return QM_ENTRY(&Calc2_final_s);
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
/* ${SMs::Calc2::SM::final} */
|
2014-04-06 11:43:13 -04:00
|
|
|
static QState Calc2_final(Calc2 * const me, QEvt const * const e) {
|
|
|
|
QState status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
switch (e->sig) {
|
|
|
|
default: {
|
2014-04-06 11:43:13 -04:00
|
|
|
status_ = QM_SUPER();
|
2012-08-14 18:07:04 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-04-06 11:43:13 -04:00
|
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
|
|
return status_;
|
2012-08-14 18:07:04 -04:00
|
|
|
}
|
|
|
|
|