/*..........................................................................*/
QState Calc_int2(Calc * const me, QEvt const * const e) {
    QState status;
    switch (e->sig) {
        case Q_ENTRY_SIG: {
            BSP_message("int2-ENTRY;");
            status = Q_HANDLED();
            break;
        }
        case Q_EXIT_SIG: {
            BSP_message("int2-EXIT;");
            status = Q_HANDLED();
            break;
        }
        case DIGIT_0_SIG:                     /* intentionally fall through */
        case DIGIT_1_9_SIG: {
            BSP_insert(((CalcEvt const *)e)->key_code);
            status = Q_HANDLED();
            break;
        }
        case POINT_SIG: {
            BSP_insert(((CalcEvt const *)e)->key_code);
            status = Q_TRAN(&Calc_frac2);
            break;
        }
        default: {
            status = Q_SUPER(&Calc_operand2);
            break;
        }
    }
    return status;
}
Пример #2
0
/* ${SMs::Calc::SM::on::operand1::int1} */
static QState Calc_int1(Calc * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${SMs::Calc::SM::on::operand1::int1::POINT} */
        case POINT_SIG: {
            static struct {
                QMState const *target;
                QActionHandler act[3];
            } const tatbl_ = { /* transition-action table */
                &Calc_frac1_s, /* target state */
                {
                    Q_ACTION_CAST(&Calc_int1_x), /* exit */
                    Q_ACTION_CAST(&Calc_frac1_e), /* entry */
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            BSP_insert((int)'.');
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        /* ${SMs::Calc::SM::on::operand1::int1::DIGIT_0, DIGIT_1_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_;
}
/*..........................................................................*/
QState Calc_zero2(Calc * const me, QEvt const * const e) {
    QState status;
    switch (e->sig) {
        case Q_ENTRY_SIG: {
            BSP_message("zero2-ENTRY;");
            status = Q_HANDLED();
            break;
        }
        case Q_EXIT_SIG: {
            BSP_message("zero2-EXIT;");
            status = Q_HANDLED();
            break;
        }
        case DIGIT_0_SIG: {
            ;                                          /* explicitly ignore */
            status = Q_HANDLED();
            break;
        }
        case DIGIT_1_9_SIG: {
            BSP_insert(((CalcEvt const *)e)->key_code);
            status = Q_TRAN(&Calc_int2);
            break;
        }
        case POINT_SIG: {
            BSP_insert(((CalcEvt const *)e)->key_code);
            status = Q_TRAN(&Calc_frac2);
        }
        default: {
            status = Q_SUPER(&Calc_operand2);
            break;
        }
    }
    return status;
}
Пример #4
0
/* ${SMs::Calc::SM::on::operand1::zero1} */
static QState Calc_zero1(Calc * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${SMs::Calc::SM::on::operand1::zero1::DIGIT_0} */
        case DIGIT_0_SIG: {
            ;
            status_ = QM_HANDLED();
            break;
        }
        /* ${SMs::Calc::SM::on::operand1::zero1::DIGIT_1_9} */
        case DIGIT_1_9_SIG: {
            static struct {
                QMState const *target;
                QActionHandler act[3];
            } const tatbl_ = { /* transition-action table */
                &Calc_int1_s, /* target state */
                {
                    Q_ACTION_CAST(&Calc_zero1_x), /* exit */
                    Q_ACTION_CAST(&Calc_int1_e), /* entry */
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        /* ${SMs::Calc::SM::on::operand1::zero1::POINT} */
        case POINT_SIG: {
            static struct {
                QMState const *target;
                QActionHandler act[3];
            } const tatbl_ = { /* transition-action table */
                &Calc_frac1_s, /* target state */
                {
                    Q_ACTION_CAST(&Calc_zero1_x), /* exit */
                    Q_ACTION_CAST(&Calc_frac1_e), /* entry */
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            BSP_insert((int)'0');
            BSP_insert((int)'.');
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
/*..........................................................................*/
QState Calc_negated1(Calc * const me, QEvt const * const e) {
    QState status;
    switch (e->sig) {
        case Q_ENTRY_SIG: {
            BSP_message("negated1-ENTRY;");
            BSP_negate();
            status = Q_HANDLED();
            break;
        }
        case Q_EXIT_SIG: {
            BSP_message("negated1-EXIT;");
            status = Q_HANDLED();
            break;
        }
        case OPER_SIG: {
            if (((CalcEvt const *)e)->key_code == KEY_MINUS) {
                ;                                      /* explicitly ignore */
                status = Q_HANDLED();                      /* event handled */
            }
            else {
                status = Q_HANDLED();
            }
            break;
        }
        case CE_SIG: {
            BSP_clear();
            status = Q_TRAN(&Calc_begin);
            break;
        }
        case DIGIT_0_SIG: {
            BSP_insert(((CalcEvt const *)e)->key_code);
            status = Q_TRAN(&Calc_zero1);
            break;
        }
        case DIGIT_1_9_SIG: {
            BSP_insert(((CalcEvt const *)e)->key_code);
            status = Q_TRAN(&Calc_int1);
            break;
        }
        case POINT_SIG: {
            BSP_insert(((CalcEvt const *)e)->key_code);
            status = Q_TRAN(&Calc_frac1);
            break;
        }
        default: {
            status = Q_SUPER(&Calc_on);
            break;
        }
    }
    return status;
}
/*..........................................................................*/
QState Calc_ready(Calc * const me, QEvt const * const e) {
    QState status;
    switch (e->sig) {
        case Q_ENTRY_SIG: {
            BSP_message("ready-ENTRY;");
            status = Q_HANDLED();
            break;
        }
        case Q_EXIT_SIG: {
            BSP_message("ready-EXIT;");
            status = Q_HANDLED();
            break;
        }
        case Q_INIT_SIG: {
            BSP_message("ready-INIT;");
            status = Q_TRAN(&Calc_begin);
            break;
        }
        case DIGIT_0_SIG: {
            BSP_clear();
            status = Q_TRAN(&Calc_zero1);
            break;
        }
        case DIGIT_1_9_SIG: {
            BSP_clear();
            BSP_insert(((CalcEvt const *)e)->key_code);
            status = Q_TRAN(&Calc_int1);
            break;
        }
        case POINT_SIG: {
            BSP_clear();
            BSP_insert((int)'0');
            BSP_insert((int)'.');
            status = Q_TRAN(&Calc_frac1);
            break;
        }
        case OPER_SIG: {
            me->operand1 = BSP_get_value();
            me->operator = ((CalcEvt const *)e)->key_code;
            status = Q_TRAN(&Calc_opEntered);
            break;
        }
        default: {
            status = Q_SUPER(&Calc_on);
            break;
        }
    }
    return status;
}
/*..........................................................................*/
QState Calc_opEntered(Calc * const me, QEvt const * const e) {
    QState status;
    switch (e->sig) {
        case Q_ENTRY_SIG: {
            BSP_message("opEntered-ENTRY;");
            status = Q_HANDLED();
            break;
        }
        case Q_EXIT_SIG: {
            BSP_message("opEntered-EXIT;");
            status = Q_HANDLED();
            break;
        }
        case OPER_SIG: {
            if (((CalcEvt const *)e)->key_code == KEY_MINUS) {
                BSP_clear();
                status = Q_TRAN(&Calc_negated2);
            }
            break;
        }
        case DIGIT_0_SIG: {
            BSP_clear();
            status = Q_TRAN(&Calc_zero2);
            break;
        }
        case DIGIT_1_9_SIG: {
            BSP_clear();
            BSP_insert(((CalcEvt const *)e)->key_code);
            status = Q_TRAN(&Calc_int2);
            break;
        }
        case POINT_SIG: {
            BSP_clear();
            BSP_insert((int)'0');
            BSP_insert((int)'.');
            status = Q_TRAN(&Calc_frac2);
        }
        default: {
            status = Q_SUPER(&Calc_on);
            break;
        }
    }
    return status;
}
Пример #8
0
/* ${SMs::Calc::SM::on::operand1::frac1} */
static QState Calc_frac1(Calc * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${SMs::Calc::SM::on::operand1::frac1::POINT} */
        case POINT_SIG: {
            ;
            status_ = QM_HANDLED();
            break;
        }
        /* ${SMs::Calc::SM::on::operand1::frac1::DIGIT_0, DIGIT_1_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_;
}
Пример #9
0
/* ${SMs::Calc::SM::on::negated2} */
static QState Calc_negated2(Calc * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${SMs::Calc::SM::on::negated2::DIGIT_0} */
        case DIGIT_0_SIG: {
            static struct {
                QMState const *target;
                QActionHandler act[4];
            } const tatbl_ = { /* transition-action table */
                &Calc_zero2_s, /* target state */
                {
                    Q_ACTION_CAST(&Calc_negated2_x), /* exit */
                    Q_ACTION_CAST(&Calc_operand2_e), /* entry */
                    Q_ACTION_CAST(&Calc_zero2_e), /* entry */
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        /* ${SMs::Calc::SM::on::negated2::DIGIT_1_9} */
        case DIGIT_1_9_SIG: {
            static struct {
                QMState const *target;
                QActionHandler act[4];
            } const tatbl_ = { /* transition-action table */
                &Calc_int2_s, /* target state */
                {
                    Q_ACTION_CAST(&Calc_negated2_x), /* exit */
                    Q_ACTION_CAST(&Calc_operand2_e), /* entry */
                    Q_ACTION_CAST(&Calc_int2_e), /* entry */
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        /* ${SMs::Calc::SM::on::negated2::POINT} */
        case POINT_SIG: {
            static struct {
                QMState const *target;
                QActionHandler act[4];
            } const tatbl_ = { /* transition-action table */
                &Calc_frac2_s, /* target state */
                {
                    Q_ACTION_CAST(&Calc_negated2_x), /* exit */
                    Q_ACTION_CAST(&Calc_operand2_e), /* entry */
                    Q_ACTION_CAST(&Calc_frac2_e), /* entry */
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            BSP_insert(Q_EVT_CAST(CalcEvt)->key_code);
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        /* ${SMs::Calc::SM::on::negated2::OPER} */
        case OPER_SIG: {
            /* ${SMs::Calc::SM::on::negated2::OPER::[e->key=='-']} */
            if (Q_EVT_CAST(CalcEvt)->key_code == KEY_MINUS) {
                ;
                status_ = QM_HANDLED();
            }
            /* ${SMs::Calc::SM::on::negated2::OPER::[else]} */
            else {
                status_ = QM_HANDLED();
            }
            break;
        }
        /* ${SMs::Calc::SM::on::negated2::CE} */
        case CE_SIG: {
            static struct {
                QMState const *target;
                QActionHandler act[3];
            } const tatbl_ = { /* transition-action table */
                &Calc_opEntered_s, /* target state */
                {
                    Q_ACTION_CAST(&Calc_negated2_x), /* exit */
                    Q_ACTION_CAST(&Calc_opEntered_e), /* entry */
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            BSP_clear();
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}