mirror of
https://github.com/QuantumLeaps/qpcpp.git
synced 2025-01-28 06:02:56 +08:00
1430 lines
51 KiB
C++
1430 lines
51 KiB
C++
//****************************************************************************
|
|
// Model: calc2.qm
|
|
// File: ./calc2.cpp
|
|
//
|
|
// 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.
|
|
//****************************************************************************
|
|
//${.::calc2.cpp} ............................................................
|
|
#include "qep_port.h" // QEP/C interface
|
|
#include "bsp.h" // board support package
|
|
#include "calc2.h"
|
|
|
|
//${SMs::Calc2} ..............................................................
|
|
class Calc2 : public QP::QMsm {
|
|
private:
|
|
double m_operand1;
|
|
uint8_t m_operator;
|
|
|
|
public:
|
|
Calc2();
|
|
|
|
protected:
|
|
static QP::QState initial(Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState on (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState on_e(Calc2 * const me);
|
|
static QP::QState on_x(Calc2 * const me);
|
|
static QP::QState on_i(Calc2 * const me);
|
|
static QP::QMState const on_s;
|
|
static QP::QState error (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState error_e(Calc2 * const me);
|
|
static QP::QState error_x(Calc2 * const me);
|
|
static QP::QMState const error_s;
|
|
static QP::QState negated1 (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState negated1_e(Calc2 * const me);
|
|
static QP::QState negated1_x(Calc2 * const me);
|
|
static QP::QMState const negated1_s;
|
|
static QP::QState ready (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState ready_e(Calc2 * const me);
|
|
static QP::QState ready_x(Calc2 * const me);
|
|
static QP::QState ready_i(Calc2 * const me);
|
|
static QP::QMState const ready_s;
|
|
static QP::QState result (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState result_e(Calc2 * const me);
|
|
static QP::QState result_x(Calc2 * const me);
|
|
static QP::QMState const result_s;
|
|
static QP::QState begin (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState begin_e(Calc2 * const me);
|
|
static QP::QState begin_x(Calc2 * const me);
|
|
static QP::QMState const begin_s;
|
|
static QP::QState operand1 (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState operand1_e(Calc2 * const me);
|
|
static QP::QState operand1_x(Calc2 * const me);
|
|
static QP::QMState const operand1_s;
|
|
static QP::QState zero1 (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState zero1_e(Calc2 * const me);
|
|
static QP::QState zero1_x(Calc2 * const me);
|
|
static QP::QMState const zero1_s;
|
|
static QP::QState int1 (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState int1_e(Calc2 * const me);
|
|
static QP::QState int1_x(Calc2 * const me);
|
|
static QP::QMState const int1_s;
|
|
static QP::QState frac1 (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState frac1_e(Calc2 * const me);
|
|
static QP::QState frac1_x(Calc2 * const me);
|
|
static QP::QMState const frac1_s;
|
|
static QP::QState opEntered (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState opEntered_e(Calc2 * const me);
|
|
static QP::QState opEntered_x(Calc2 * const me);
|
|
static QP::QMState const opEntered_s;
|
|
static QP::QState negated2 (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState negated2_e(Calc2 * const me);
|
|
static QP::QState negated2_x(Calc2 * const me);
|
|
static QP::QMState const negated2_s;
|
|
static QP::QState operand2 (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState operand2_e(Calc2 * const me);
|
|
static QP::QState operand2_x(Calc2 * const me);
|
|
static QP::QMState const operand2_s;
|
|
static QP::QState zero2 (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState zero2_e(Calc2 * const me);
|
|
static QP::QState zero2_x(Calc2 * const me);
|
|
static QP::QMState const zero2_s;
|
|
static QP::QState int2 (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState int2_e(Calc2 * const me);
|
|
static QP::QState int2_x(Calc2 * const me);
|
|
static QP::QMState const int2_s;
|
|
static QP::QState frac2 (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState frac2_e(Calc2 * const me);
|
|
static QP::QState frac2_x(Calc2 * const me);
|
|
static QP::QMState const frac2_s;
|
|
static QP::QState final (Calc2 * const me, QP::QEvt const * const e);
|
|
static QP::QState final_e(Calc2 * const me);
|
|
static QP::QMState const final_s;
|
|
};
|
|
|
|
|
|
static Calc2 l_calc2; // the only instance of the Calc2 class
|
|
|
|
// global-scope definitions --------------------------------------
|
|
QP::QMsm * const the_calc = &l_calc2; // "opaque" pointer to MSM
|
|
|
|
//${SMs::Calc2} ..............................................................
|
|
//${SMs::Calc2::Calc2} .......................................................
|
|
Calc2::Calc2()
|
|
: QMsm(Q_STATE_CAST(&Calc2::initial))
|
|
{}
|
|
|
|
//${SMs::Calc2::SM} ..........................................................
|
|
QP::QState Calc2::initial(Calc2 * const me, QP::QEvt const * const e) {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&on_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::on_e), // entry
|
|
Q_ACTION_CAST(&Calc2::on_i), // initial tran.
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
// ${SMs::Calc2::SM::initial}
|
|
BSP_clear();
|
|
return QM_TRAN_INIT(&tatbl_);
|
|
}
|
|
//${SMs::Calc2::SM::on} ......................................................
|
|
QP::QMState const Calc2::on_s = {
|
|
static_cast<QP::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)
|
|
};
|
|
// ${SMs::Calc2::SM::on}
|
|
QP::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(&on_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on}
|
|
QP::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(&on_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::initial}
|
|
QP::QState Calc2::on_i(Calc2 * const me) {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&ready_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::ready_e), // entry
|
|
Q_ACTION_CAST(&Calc2::ready_i), // initial tran.
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
// ${SMs::Calc2::SM::on::initial}
|
|
BSP_message("on-INIT;");
|
|
return QM_TRAN_INIT(&tatbl_);
|
|
}
|
|
// ${SMs::Calc2::SM::on}
|
|
QP::QState Calc2::on(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::C}
|
|
case C_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&on_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::on_x), // exit
|
|
Q_ACTION_CAST(&Calc2::on_e), // entry
|
|
Q_ACTION_CAST(&Calc2::on_i), // initial tran.
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
BSP_clear();
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::OFF}
|
|
case OFF_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&final_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::on_x), // exit
|
|
Q_ACTION_CAST(&Calc2::final_e), // entry
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::error} ...............................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::error}
|
|
QP::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(&error_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::error}
|
|
QP::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(&error_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::error}
|
|
QP::QState Calc2::error(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::negated1} ............................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::negated1}
|
|
QP::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(&negated1_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::negated1}
|
|
QP::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(&negated1_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::negated1}
|
|
QP::QState Calc2::negated1(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::negated1::DIGIT_0}
|
|
case DIGIT_0_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&zero1_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::negated1::DIGIT_1_9}
|
|
case DIGIT_1_9_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&int1_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::negated1::POINT}
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&frac1_s,
|
|
{
|
|
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 {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&begin_s,
|
|
{
|
|
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();
|
|
break;
|
|
}
|
|
}
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::ready} ...............................................
|
|
QP::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)
|
|
};
|
|
// ${SMs::Calc2::SM::on::ready}
|
|
QP::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(&ready_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::ready}
|
|
QP::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(&ready_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::ready::initial}
|
|
QP::QState Calc2::ready_i(Calc2 * const me) {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[2];
|
|
} const tatbl_ = { // transition-action table
|
|
&begin_s,
|
|
{
|
|
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_);
|
|
}
|
|
// ${SMs::Calc2::SM::on::ready}
|
|
QP::QState Calc2::ready(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::ready::DIGIT_0}
|
|
case DIGIT_0_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&zero1_s,
|
|
{
|
|
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
|
|
}
|
|
};
|
|
BSP_clear();
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::ready::DIGIT_1_9}
|
|
case DIGIT_1_9_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&int1_s,
|
|
{
|
|
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
|
|
}
|
|
};
|
|
BSP_clear();
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::ready::POINT}
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&frac1_s,
|
|
{
|
|
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
|
|
}
|
|
};
|
|
BSP_clear();
|
|
BSP_insert((int)'0');
|
|
BSP_insert((int)'.');
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::ready::OPER}
|
|
case OPER_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&opEntered_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::ready_x), // exit
|
|
Q_ACTION_CAST(&Calc2::opEntered_e), // entry
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
me->m_operand1 = BSP_get_value();
|
|
me->m_operator = Q_EVT_CAST(CalcEvt)->key_code;
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::ready::CE}
|
|
case CE_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&ready_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::ready_x), // exit
|
|
Q_ACTION_CAST(&Calc2::ready_e), // entry
|
|
Q_ACTION_CAST(&Calc2::ready_i), // initial tran.
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
BSP_clear();
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::ready::result} .......................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::ready::result}
|
|
QP::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(&result_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::ready::result}
|
|
QP::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(&result_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::ready::result}
|
|
QP::QState Calc2::result(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::ready::begin} ........................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::ready::begin}
|
|
QP::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(&begin_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::ready::begin}
|
|
QP::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(&begin_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::ready::begin}
|
|
QP::QState Calc2::begin(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::ready::begin::OPER}
|
|
case OPER_SIG: {
|
|
// ${SMs::Calc2::SM::on::ready::begin::OPER::[e->key=='-']}
|
|
if (Q_EVT_CAST(CalcEvt)->key_code == KEY_MINUS) {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&negated1_s,
|
|
{
|
|
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_);
|
|
}
|
|
// ${SMs::Calc2::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::Calc2::SM::on::operand1} ............................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::operand1}
|
|
QP::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(&operand1_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1}
|
|
QP::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(&operand1_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1}
|
|
QP::QState Calc2::operand1(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::operand1::CE}
|
|
case CE_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&begin_s,
|
|
{
|
|
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
|
|
}
|
|
};
|
|
BSP_clear();
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::OPER}
|
|
case OPER_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&opEntered_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::operand1_x), // exit
|
|
Q_ACTION_CAST(&Calc2::opEntered_e), // entry
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
me->m_operand1 = BSP_get_value();
|
|
me->m_operator = Q_EVT_CAST(CalcEvt)->key_code;
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::EQUALS}
|
|
case EQUALS_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&result_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::operand1::zero1} .....................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::operand1::zero1}
|
|
QP::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(&zero1_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::zero1}
|
|
QP::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(&zero1_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::zero1}
|
|
QP::QState Calc2::zero1(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::operand1::zero1::DIGIT_0}
|
|
case DIGIT_0_SIG: {
|
|
;
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::zero1::DIGIT_1_9}
|
|
case DIGIT_1_9_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&int1_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::zero1::POINT}
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&frac1_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::operand1::int1} ......................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::operand1::int1}
|
|
QP::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(&int1_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::int1}
|
|
QP::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(&int1_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::int1}
|
|
QP::QState Calc2::int1(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::operand1::int1::POINT}
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&frac1_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::int1::DIGIT_0, DIGIT_1_9}
|
|
case DIGIT_0_SIG: /* intentionally fall through */
|
|
case DIGIT_1_9_SIG: {
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::operand1::frac1} .....................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::operand1::frac1}
|
|
QP::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(&frac1_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::frac1}
|
|
QP::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(&frac1_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::frac1}
|
|
QP::QState Calc2::frac1(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::operand1::frac1::POINT}
|
|
case POINT_SIG: {
|
|
;
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand1::frac1::DIGIT_0, DIGIT_1_9}
|
|
case DIGIT_0_SIG: /* intentionally fall through */
|
|
case DIGIT_1_9_SIG: {
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::opEntered} ...........................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::opEntered}
|
|
QP::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(&opEntered_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::opEntered}
|
|
QP::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(&opEntered_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::opEntered}
|
|
QP::QState Calc2::opEntered(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::opEntered::DIGIT_0}
|
|
case DIGIT_0_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&zero2_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::opEntered::DIGIT_1_9}
|
|
case DIGIT_1_9_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&int2_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::opEntered::POINT}
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&frac2_s,
|
|
{
|
|
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 {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&negated2_s,
|
|
{
|
|
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();
|
|
}
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::negated2} ............................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::negated2}
|
|
QP::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(&negated2_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::negated2}
|
|
QP::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(&negated2_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::negated2}
|
|
QP::QState Calc2::negated2(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::negated2::DIGIT_0}
|
|
case DIGIT_0_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&zero2_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::negated2::DIGIT_1_9}
|
|
case DIGIT_1_9_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&int2_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::negated2::POINT}
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&frac2_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::negated2::OPER}
|
|
case OPER_SIG: {
|
|
// ${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();
|
|
}
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::negated2::CE}
|
|
case CE_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&opEntered_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::negated2_x), // exit
|
|
Q_ACTION_CAST(&Calc2::opEntered_e), // entry
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
BSP_clear();
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::operand2} ............................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::operand2}
|
|
QP::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(&operand2_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2}
|
|
QP::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(&operand2_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2}
|
|
QP::QState Calc2::operand2(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::operand2::CE}
|
|
case CE_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&opEntered_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::operand2_x), // exit
|
|
Q_ACTION_CAST(&Calc2::opEntered_e), // entry
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
BSP_clear();
|
|
status_ = QM_TRAN(&tatbl_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::EQUALS}
|
|
case EQUALS_SIG: {
|
|
// ${SMs::Calc2::SM::on::operand2::EQUALS::[BSP_eval()]}
|
|
if (BSP_eval(me->m_operand1, me->m_operator, BSP_get_value())) {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&result_s,
|
|
{
|
|
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_);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::EQUALS::[else]}
|
|
else {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&error_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::operand2_x), // exit
|
|
Q_ACTION_CAST(&Calc2::error_e), // entry
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
status_ = QM_TRAN(&tatbl_);
|
|
}
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::OPER}
|
|
case OPER_SIG: {
|
|
// ${SMs::Calc2::SM::on::operand2::OPER::[BSP_eval()]}
|
|
if (BSP_eval(me->m_operand1, me->m_operator, BSP_get_value())) {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&opEntered_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::operand2_x), // exit
|
|
Q_ACTION_CAST(&Calc2::opEntered_e), // entry
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
status_ = QM_TRAN(&tatbl_);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::OPER::[else]}
|
|
else {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&error_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::operand2_x), // exit
|
|
Q_ACTION_CAST(&Calc2::error_e), // entry
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
status_ = QM_TRAN(&tatbl_);
|
|
}
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::PERCENT}
|
|
case PERCENT_SIG: {
|
|
// ${SMs::Calc2::SM::on::operand2::PERCENT::[BSP_eval()]}
|
|
if (BSP_eval(me->m_operand1, me->m_operator, BSP_get_value())) {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[4];
|
|
} const tatbl_ = { // transition-action table
|
|
&result_s,
|
|
{
|
|
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_);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::PERCENT::[else]}
|
|
else {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&error_s,
|
|
{
|
|
Q_ACTION_CAST(&Calc2::operand2_x), // exit
|
|
Q_ACTION_CAST(&Calc2::error_e), // entry
|
|
Q_ACTION_CAST(0) // zero terminator
|
|
}
|
|
};
|
|
status_ = QM_TRAN(&tatbl_);
|
|
}
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::operand2::zero2} .....................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::operand2::zero2}
|
|
QP::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(&zero2_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::zero2}
|
|
QP::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(&zero2_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::zero2}
|
|
QP::QState Calc2::zero2(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::operand2::zero2::DIGIT_0}
|
|
case DIGIT_0_SIG: {
|
|
;
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::zero2::DIGIT_1_9}
|
|
case DIGIT_1_9_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&int2_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::zero2::POINT}
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&frac2_s,
|
|
{
|
|
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;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::operand2::int2} ......................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::operand2::int2}
|
|
QP::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(&int2_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::int2}
|
|
QP::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(&int2_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::int2}
|
|
QP::QState Calc2::int2(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::operand2::int2::POINT}
|
|
case POINT_SIG: {
|
|
static struct {
|
|
QP::QMState const *target;
|
|
QP::QActionHandler act[3];
|
|
} const tatbl_ = { // transition-action table
|
|
&frac2_s,
|
|
{
|
|
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_);
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::int2::DIGIT_0, DIGIT_1_9}
|
|
case DIGIT_0_SIG: /* intentionally fall through */
|
|
case DIGIT_1_9_SIG: {
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::on::operand2::frac2} .....................................
|
|
QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::on::operand2::frac2}
|
|
QP::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(&frac2_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::frac2}
|
|
QP::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(&frac2_s);
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::frac2}
|
|
QP::QState Calc2::frac2(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
// ${SMs::Calc2::SM::on::operand2::frac2::POINT}
|
|
case POINT_SIG: {
|
|
;
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
// ${SMs::Calc2::SM::on::operand2::frac2::DIGIT_0, DIGIT_1_9}
|
|
case DIGIT_0_SIG: /* intentionally fall through */
|
|
case DIGIT_1_9_SIG: {
|
|
BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
|
|
status_ = QM_HANDLED();
|
|
break;
|
|
}
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return status_;
|
|
}
|
|
//${SMs::Calc2::SM::final} ...................................................
|
|
QP::QMState const Calc2::final_s = {
|
|
static_cast<QP::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.
|
|
};
|
|
// ${SMs::Calc2::SM::final}
|
|
QP::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(&final_s);
|
|
}
|
|
// ${SMs::Calc2::SM::final}
|
|
QP::QState Calc2::final(Calc2 * const me, QP::QEvt const * const e) {
|
|
QP::QState status_;
|
|
switch (e->sig) {
|
|
default: {
|
|
status_ = QM_SUPER();
|
|
break;
|
|
}
|
|
}
|
|
(void)me; /* avoid compiler warning in case 'me' is not used */
|
|
return status_;
|
|
}
|
|
|