예제 #1
0
QP::QState Philo::hungry(Philo * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // @(/3/0/2/2/0)
        case EAT_SIG: {
            // @(/3/0/2/2/0/0)
            if (Q_EVT_CAST(TableEvt)->philoNum == PHILO_ID(me)) {
                static QP::QActionHandler const act_[] = {
                    Q_ACTION_CAST(&Philo::eating_e),
                    Q_ACTION_CAST(0)
                };
                status_ = QM_TRAN(&eating_s, act_);
            }
            else {
                status_ = QM_UNHANDLED();
            }
            break;
        }
        // @(/3/0/2/2/1)
        case DONE_SIG: {
            /* DONE must be for other Philos than this one */
            Q_ASSERT(Q_EVT_CAST(TableEvt)->philoNum != PHILO_ID(me));
            status_ = QM_HANDLED();
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #2
0
// @(/3/0/2/2) ...............................................................
QP::QState Philo::hungry(Philo * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // @(/3/0/2/2)
        case Q_ENTRY_SIG: {
            AO_Table->POST(Q_NEW(TableEvt, HUNGRY_SIG, PHILO_ID(me)), me);
            status_ = Q_HANDLED();
            break;
        }
        // @(/3/0/2/2/0)
        case EAT_SIG: {
            // @(/3/0/2/2/0/0)
            if (Q_EVT_CAST(TableEvt)->philoNum == PHILO_ID(me)) {
                status_ = Q_TRAN(&Philo::eating);
            }
            else {
                status_ = Q_UNHANDLED();
            }
            break;
        }
        // @(/3/0/2/2/1)
        case DONE_SIG: {
            /* DONE must be for other Philos than this one */
            Q_ASSERT(Q_EVT_CAST(TableEvt)->philoNum != PHILO_ID(me));
            status_ = Q_HANDLED();
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm::top);
            break;
        }
    }
    return status_;
}
예제 #3
0
파일: table.cpp 프로젝트: alisonjoe/qpcpp
//${AOs::Table::SM::active::paused} ..........................................
QP::QState Table::paused(Table * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // ${AOs::Table::SM::active::paused}
        case Q_ENTRY_SIG: {
            BSP::displayPaused(1U);
            status_ = Q_HANDLED();
            break;
        }
        // ${AOs::Table::SM::active::paused}
        case Q_EXIT_SIG: {
            BSP::displayPaused(0U);
            status_ = Q_HANDLED();
            break;
        }
        // ${AOs::Table::SM::active::paused::SERVE}
        case SERVE_SIG: {
            status_ = Q_TRAN(&serving);
            break;
        }
        // ${AOs::Table::SM::active::paused::HUNGRY}
        case HUNGRY_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // philo ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!me->m_isHungry[n]));
            me->m_isHungry[n] = true;
            BSP::displayPhilStat(n, HUNGRY);
            status_ = Q_HANDLED();
            break;
        }
        // ${AOs::Table::SM::active::paused::DONE}
        case DONE_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // phil ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!me->m_isHungry[n]));

            BSP::displayPhilStat(n, THINKING);
            uint8_t m = LEFT(n);
            /* both forks of Phil[n] must be used */
            Q_ASSERT((me->m_fork[n] == USED) && (me->m_fork[m] == USED));

            me->m_fork[m] = FREE;
            me->m_fork[n] = FREE;
            status_ = Q_HANDLED();
            break;
        }
        default: {
            status_ = Q_SUPER(&active);
            break;
        }
    }
    return status_;
}
예제 #4
0
//${AOs::Table::SM::active::paused} ..........................................
Q_STATE_DEF(Table, paused) {
    QP::QState status_;
    switch (e->sig) {
        //${AOs::Table::SM::active::paused}
        case Q_ENTRY_SIG: {
            BSP_displayPaused(1U);
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Table::SM::active::paused}
        case Q_EXIT_SIG: {
            BSP_displayPaused(0U);
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Table::SM::active::paused::PAUSE}
        case PAUSE_SIG: {
            status_ = tran(&serving);
            break;
        }
        //${AOs::Table::SM::active::paused::HUNGRY}
        case HUNGRY_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // philo ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!m_isHungry[n]));
            m_isHungry[n] = true;
            BSP_displayPhilStat(n, HUNGRY);
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Table::SM::active::paused::DONE}
        case DONE_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // phil ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!m_isHungry[n]));

            BSP_displayPhilStat(n, THINKING);
            uint8_t m = LEFT(n);
            /* both forks of Phil[n] must be used */
            Q_ASSERT((m_fork[n] == USED) && (m_fork[m] == USED));

            m_fork[m] = FREE;
            m_fork[n] = FREE;
            status_ = Q_RET_HANDLED;
            break;
        }
        default: {
            status_ = super(&active);
            break;
        }
    }
    return status_;
}
예제 #5
0
파일: table.cpp 프로젝트: alisonjoe/qpcpp
// ${AOs::Table::SM::active::paused}
QP::QState Table::paused(Table * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // ${AOs::Table::SM::active::paused::PAUSE}
        case PAUSE_SIG: {
            static struct {
                QP::QMState const *target;
                QP::QActionHandler act[3];
            } const tatbl_ = { // transition-action table
                &serving_s,
                {
                    Q_ACTION_CAST(&paused_x), // exit
                    Q_ACTION_CAST(&serving_e), // entry
                    Q_ACTION_CAST(0)  // zero terminator
                }
            };
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        // ${AOs::Table::SM::active::paused::HUNGRY}
        case HUNGRY_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // philo ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!me->m_isHungry[n]));
            me->m_isHungry[n] = true;
            BSP_displayPhilStat(n, HUNGRY);
            status_ = QM_HANDLED();
            break;
        }
        // ${AOs::Table::SM::active::paused::DONE}
        case DONE_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // phil ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!me->m_isHungry[n]));

            BSP_displayPhilStat(n, THINKING);
            uint8_t m = LEFT(n);
            /* both forks of Phil[n] must be used */
            Q_ASSERT((me->m_fork[n] == USED) && (me->m_fork[m] == USED));

            me->m_fork[m] = FREE;
            me->m_fork[n] = FREE;
            status_ = QM_HANDLED();
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #6
0
/* ${AOs::Philo::SM::eating} */
static QState Philo_eating(Philo * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${AOs::Philo::SM::eating::TIMEOUT} */
        case TIMEOUT_SIG: {
            static struct {
                QMState const *target;
                QActionHandler act[3];
            } const tatbl_ = { /* transition-action table */
                &Philo_thinking_s, /* target state */
                {
                    Q_ACTION_CAST(&Philo_eating_x), /* exit */
                    Q_ACTION_CAST(&Philo_thinking_e), /* entry */
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        /* ${AOs::Philo::SM::eating::EAT, DONE} */
        case EAT_SIG: /* intentionally fall through */
        case DONE_SIG: {
            /* EAT or DONE must be for other Philos than this one */
            Q_ASSERT(Q_EVT_CAST(TableEvt)->philoNum != PHILO_ID(me));
            status_ = QM_HANDLED();
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #7
0
파일: calc.c 프로젝트: KnightSch/qpc
/* ${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_;
}
예제 #8
0
파일: calc.c 프로젝트: KnightSch/qpc
/* ${SMs::Calc::SM::on::ready::begin} */
static QState Calc_begin(Calc * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${SMs::Calc::SM::on::ready::begin::OPER} */
        case OPER_SIG: {
            /* ${SMs::Calc::SM::on::ready::begin::OPER::[e->key=='-']} */
            if (Q_EVT_CAST(CalcEvt)->key_code == KEY_MINUS) {
                static struct {
                    QMState const *target;
                    QActionHandler act[4];
                } const tatbl_ = { /* transition-action table */
                    &Calc_negated1_s, /* target state */
                    {
                        Q_ACTION_CAST(&Calc_begin_x), /* exit */
                        Q_ACTION_CAST(&Calc_ready_x), /* exit */
                        Q_ACTION_CAST(&Calc_negated1_e), /* entry */
                        Q_ACTION_CAST(0) /* zero terminator */
                    }
                };
                status_ = QM_TRAN(&tatbl_);
            }
            /* ${SMs::Calc::SM::on::ready::begin::OPER::[else]} */
            else {
                status_ = QM_HANDLED();
            }
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    (void)me; /* avoid compiler warning in case 'me' is not used */
    return status_;
}
예제 #9
0
// @(/3/0/2/1) ...............................................................
QP::QState Philo::thinking(Philo * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // @(/3/0/2/1)
        case Q_ENTRY_SIG: {
            me->m_timeEvt.armX(think_time());
            status_ = Q_HANDLED();
            break;
        }
        // @(/3/0/2/1)
        case Q_EXIT_SIG: {
            (void)me->m_timeEvt.disarm();
            status_ = Q_HANDLED();
            break;
        }
        // @(/3/0/2/1/0)
        case TIMEOUT_SIG: {
            status_ = Q_TRAN(&Philo::hungry);
            break;
        }
        // @(/3/0/2/1/1)
        case EAT_SIG: // intentionally fall through
        case DONE_SIG: {
            /* EAT or DONE must be for other Philos than this one */
            Q_ASSERT(Q_EVT_CAST(TableEvt)->philoNum != PHILO_ID(me));
            status_ = Q_HANDLED();
            break;
        }
        default: {
            status_ = Q_SUPER(&QHsm::top);
            break;
        }
    }
    return status_;
}
예제 #10
0
QP::QState Philo::eating(Philo * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // @(/3/0/2/3/0)
        case TIMEOUT_SIG: {
            static QP::QActionHandler const act_[] = {
                Q_ACTION_CAST(&Philo::eating_x),
                Q_ACTION_CAST(&Philo::thinking_e),
                Q_ACTION_CAST(0)
            };
            status_ = QM_TRAN(&thinking_s, act_);
            break;
        }
        // @(/3/0/2/3/1)
        case EAT_SIG: /* intentionally fall through */
        case DONE_SIG: {
            /* EAT or DONE must be for other Philos than this one */
            Q_ASSERT(Q_EVT_CAST(TableEvt)->philoNum != PHILO_ID(me));
            status_ = QM_HANDLED();
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #11
0
/* @(/2/4/3/1) .............................................................*/
static QState Mine2_unused(Mine2 * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* @(/2/4/3/1/0) */
        case MINE_PLANT_SIG: {
            me->x = Q_EVT_CAST(ObjectPosEvt)->x;
            me->y = Q_EVT_CAST(ObjectPosEvt)->y;
            status_ = QM_TRAN(&Mine2_planted_s, &QMsm_emptyAction_[0]);
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #12
0
static QState Ship_active(Ship * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* @(/2/1/4/1/1) */
        case PLAYER_SHIP_MOVE_SIG: {
            me->x = Q_EVT_CAST(ObjectPosEvt)->x;
            me->y = Q_EVT_CAST(ObjectPosEvt)->y;
            status_ = QM_HANDLED();
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #13
0
파일: ship.cpp 프로젝트: dongkc/rtu_drv
// @(/2/1/5/1) ...............................................................
QP::QState Ship::active(Ship * const me, QP::QEvt const * const e) {
    QP::QState status;
    switch (e->sig) {
        // @(/2/1/5/1/0)
        case Q_INIT_SIG: {
            status = Q_TRAN(&Ship::parked);
            break;
        }
        // @(/2/1/5/1/1)
        case PLAYER_SHIP_MOVE_SIG: {
            me->m_x = Q_EVT_CAST(ObjectPosEvt)->x;
            me->m_y = Q_EVT_CAST(ObjectPosEvt)->y;
            status = Q_HANDLED();
            break;
        }
        default: {
            status = Q_SUPER(&QHsm::top);
            break;
        }
    }
    return status;
}
/* @(/2/1/4/1) .............................................................*/
static QState Ship_active(Ship * const me, QEvt const * const e) {
    QState status;
    switch (e->sig) {
        /* @(/2/1/4/1/0) */
        case Q_INIT_SIG: {
            status = Q_TRAN(&Ship_parked);
            break;
        }
        /* @(/2/1/4/1/1) */
        case PLAYER_SHIP_MOVE_SIG: {
            me->x = Q_EVT_CAST(ObjectPosEvt)->x;
            me->y = Q_EVT_CAST(ObjectPosEvt)->y;
            status = Q_HANDLED();
            break;
        }
        default: {
            status = Q_SUPER(&QHsm_top);
            break;
        }
    }
    return status;
}
예제 #15
0
파일: calc.c 프로젝트: KnightSch/qpc
/* ${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_;
}
예제 #16
0
/* ${AOs::Philo::SM::hungry} */
static QState Philo_hungry(Philo * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${AOs::Philo::SM::hungry::EAT} */
        case EAT_SIG: {
            /* ${AOs::Philo::SM::hungry::EAT::[Q_EVT_CAST(Tabl~} */
            if (Q_EVT_CAST(TableEvt)->philoNum == PHILO_ID(me)) {
                static struct {
                    QMState const *target;
                    QActionHandler act[2];
                } const tatbl_ = { /* transition-action table */
                    &Philo_eating_s, /* target state */
                    {
                        Q_ACTION_CAST(&Philo_eating_e), /* entry */
                        Q_ACTION_CAST(0) /* zero terminator */
                    }
                };
                status_ = QM_TRAN(&tatbl_);
            }
            else {
                status_ = QM_UNHANDLED();
            }
            break;
        }
        /* ${AOs::Philo::SM::hungry::DONE} */
        case DONE_SIG: {
            /* DONE must be for other Philos than this one */
            Q_ASSERT(Q_EVT_CAST(TableEvt)->philoNum != PHILO_ID(me));
            status_ = QM_HANDLED();
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #17
0
/* ${AOs::Mine2::SM::unused} */
static QState Mine2_unused(Mine2 * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${AOs::Mine2::SM::unused::MINE_PLANT} */
        case MINE_PLANT_SIG: {
            static QMTranActTable const tatbl_ = { /* transition-action table */
                &Mine2_planted_s,
                {
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            me->x = Q_EVT_CAST(ObjectPosEvt)->x;
            me->y = Q_EVT_CAST(ObjectPosEvt)->y;
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #18
0
파일: missile.c 프로젝트: juhnowski/LM3S811
/* ${AOs::Missile::SM::armed} */
static QState Missile_armed(Missile * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${AOs::Missile::SM::armed::MISSILE_FIRE} */
        case MISSILE_FIRE_SIG: {
            static QMTranActTable const tatbl_ = { /* transition-action table */
                &Missile_flying_s,
                {
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            me->x = Q_EVT_CAST(ObjectPosEvt)->x;
            me->y = Q_EVT_CAST(ObjectPosEvt)->y;
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #19
0
//${Components::Alarm::SM::off} ..............................................
Q_STATE_DEF(Alarm, off) {
    QP::QState status_;
    switch (e->sig) {
        //${Components::Alarm::SM::off}
        case Q_ENTRY_SIG: {
            // while in the off state, the alarm is kept in decimal format
            m_alarm_time = (m_alarm_time/60)*100 + m_alarm_time%60;
            BSP_showTime24H("*** Alarm OFF ", m_alarm_time, 100U);
            status_ = Q_RET_HANDLED;
            break;
        }
        //${Components::Alarm::SM::off}
        case Q_EXIT_SIG: {
            // upon exit, the alarm is converted to binary format
            m_alarm_time = (m_alarm_time/100U)*60U + m_alarm_time%100U;
            status_ = Q_RET_HANDLED;
            break;
        }
        //${Components::Alarm::SM::off::ALARM_ON}
        case ALARM_ON_SIG: {
            //${Components::Alarm::SM::off::ALARM_ON::[alarminrange?]}
            if ((m_alarm_time / 100U < 24U)
                && (m_alarm_time % 100U < 60U))
            {
                status_ = tran(&on);
            }
            //${Components::Alarm::SM::off::ALARM_ON::[else]}
            else {
                m_alarm_time = 0U;
                BSP_showTime24H("*** Alarm reset", m_alarm_time, 100U);
                status_ = Q_RET_HANDLED;
            }
            break;
        }
        //${Components::Alarm::SM::off::ALARM_SET}
        case ALARM_SET_SIG: {
            // while setting, the alarm is kept in decimal format
            m_alarm_time =
                 (10U * m_alarm_time + Q_EVT_CAST(SetEvt)->digit) % 10000U;
            BSP_showTime24H("*** Alarm reset ",  m_alarm_time, 100U);
            status_ = Q_RET_HANDLED;
            break;
        }
        default: {
            status_ = super(&top);
            break;
        }
    }
    return status_;
}
예제 #20
0
//${AOs::Philo::SM::hungry} ..................................................
Q_STATE_DEF(Philo, hungry) {
    QP::QState status_;
    switch (e->sig) {
        //${AOs::Philo::SM::hungry}
        case Q_ENTRY_SIG: {
            TableEvt *pe = Q_NEW(TableEvt, HUNGRY_SIG);
            pe->philoNum = PHILO_ID(this);
            AO_Table->POST(pe, this);
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Philo::SM::hungry::EAT}
        case EAT_SIG: {
            //${AOs::Philo::SM::hungry::EAT::[Q_EVT_CAST(TableEvt)->philoNum=~}
            if (Q_EVT_CAST(TableEvt)->philoNum == PHILO_ID(this)) {
                status_ = tran(&eating);
            }
            else {
                status_ = Q_RET_UNHANDLED;
            }
            break;
        }
        //${AOs::Philo::SM::hungry::DONE}
        case DONE_SIG: {
            /* DONE must be for other Philos than this one */
            Q_ASSERT(Q_EVT_CAST(TableEvt)->philoNum != PHILO_ID(this));
            status_ = Q_RET_HANDLED;
            break;
        }
        default: {
            status_ = super(&top);
            break;
        }
    }
    return status_;
}
예제 #21
0
//${Components::Alarm::SM::on} ...............................................
Q_STATE_DEF(Alarm, on) {
    QP::QState status_;
    switch (e->sig) {
        //${Components::Alarm::SM::on}
        case Q_ENTRY_SIG: {
            BSP_showTime24H("*** Alarm ON ",  m_alarm_time, 60U);
            status_ = Q_RET_HANDLED;
            break;
        }
        //${Components::Alarm::SM::on::ALARM_OFF}
        case ALARM_OFF_SIG: {
            status_ = tran(&off);
            break;
        }
        //${Components::Alarm::SM::on::ALARM_SET}
        case ALARM_SET_SIG: {
            BSP_showMsg("*** Cannot set Alarm when it is ON");
            status_ = Q_RET_HANDLED;
            break;
        }
        //${Components::Alarm::SM::on::TIME}
        case TIME_SIG: {
            //${Components::Alarm::SM::on::TIME::[Q_EVT_CAST(TimeEvt)->current_ti~}
            if (Q_EVT_CAST(TimeEvt)->current_time == m_alarm_time) {
                BSP_showMsg("ALARM!!!");

                // asynchronously post the event to the container AO
                APP_alarmClock->POST(Q_NEW(QEvt, ALARM_SIG), this);
                status_ = Q_RET_HANDLED;
            }
            else {
                status_ = Q_RET_UNHANDLED;
            }
            break;
        }
        default: {
            status_ = super(&top);
            break;
        }
    }
    return status_;
}
예제 #22
0
//${AOs::Philo::SM::thinking} ................................................
Q_STATE_DEF(Philo, thinking) {
    QP::QState status_;
    switch (e->sig) {
        //${AOs::Philo::SM::thinking}
        case Q_ENTRY_SIG: {
            m_timeEvt.armX(think_time(), 0U);
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Philo::SM::thinking}
        case Q_EXIT_SIG: {
            (void)m_timeEvt.disarm();
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Philo::SM::thinking::TIMEOUT}
        case TIMEOUT_SIG: {
            status_ = tran(&hungry);
            break;
        }
        //${AOs::Philo::SM::thinking::EAT, DONE}
        case EAT_SIG: // intentionally fall through
        case DONE_SIG: {
            // EAT or DONE must be for other Philos than this one
            Q_ASSERT(Q_EVT_CAST(TableEvt)->philoNum != PHILO_ID(this));
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Philo::SM::thinking::TEST}
        case TEST_SIG: {
            status_ = Q_RET_HANDLED;
            break;
        }
        default: {
            status_ = super(&top);
            break;
        }
    }
    return status_;
}
예제 #23
0
파일: calc.c 프로젝트: KnightSch/qpc
/* ${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_;
}
예제 #24
0
/* ${AOs::Ship::SM::active::flying} */
static QState Ship_flying(Ship * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${AOs::Ship::SM::active::flying::TIME_TICK} */
        case TIME_TICK_SIG: {
            /* tell the Tunnel to draw the Ship and test for hits */
            ObjectImageEvt *oie = Q_NEW(ObjectImageEvt, SHIP_IMG_SIG);
            oie->x   = me->x;
            oie->y   = me->y;
            oie->bmp = SHIP_BMP;
            QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);

            ++me->score; /* increment the score for surviving another tick */

            if ((me->score % 10U) == 0U) { /* is the score "round"? */
                ScoreEvt *sev = Q_NEW(ScoreEvt, SCORE_SIG);
                sev->score = me->score;
                QACTIVE_POST(AO_Tunnel, (QEvt *)sev, me);
            }
            status_ = QM_HANDLED();
            break;
        }
        /* ${AOs::Ship::SM::active::flying::PLAYER_TRIGGER} */
        case PLAYER_TRIGGER_SIG: {
            ObjectPosEvt *ope = Q_NEW(ObjectPosEvt, MISSILE_FIRE_SIG);
            ope->x = me->x;
            ope->y = me->y + SHIP_HEIGHT - 1U;
            QACTIVE_POST(AO_Missile, (QEvt *)ope, me);
            status_ = QM_HANDLED();
            break;
        }
        /* ${AOs::Ship::SM::active::flying::DESTROYED_MINE} */
        case DESTROYED_MINE_SIG: {
            me->score += Q_EVT_CAST(ScoreEvt)->score;
            /* the score will be sent to the Tunnel by the next TIME_TICK */
            status_ = QM_HANDLED();
            break;
        }
        /* ${AOs::Ship::SM::active::flying::HIT_WALL} */
        case HIT_WALL_SIG: {
            static struct {
                QMState const *target;
                QActionHandler act[2];
            } const tatbl_ = { /* transition-action table */
                &Ship_exploding_s, /* target state */
                {
                    Q_ACTION_CAST(&Ship_exploding_e), /* entry */
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        /* ${AOs::Ship::SM::active::flying::HIT_MINE} */
        case HIT_MINE_SIG: {
            static struct {
                QMState const *target;
                QActionHandler act[2];
            } const tatbl_ = { /* transition-action table */
                &Ship_exploding_s, /* target state */
                {
                    Q_ACTION_CAST(&Ship_exploding_e), /* entry */
                    Q_ACTION_CAST(0) /* zero terminator */
                }
            };
            status_ = QM_TRAN(&tatbl_);
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #25
0
파일: ship.cpp 프로젝트: dongkc/rtu_drv
// @(/2/1/5/1/3) .............................................................
QP::QState Ship::flying(Ship * const me, QP::QEvt const * const e) {
    QP::QState status;
    switch (e->sig) {
        // @(/2/1/5/1/3)
        case Q_ENTRY_SIG: {
            me->m_score = 0U; /* reset the score */
            ScoreEvt *sev = Q_NEW(ScoreEvt, SCORE_SIG);
            sev->score = me->m_score;
            AO_Tunnel->POST(sev, me);
            status = Q_HANDLED();
            break;
        }
        // @(/2/1/5/1/3/0)
        case TIME_TICK_SIG: {
            // tell the Tunnel to draw the Ship and test for hits
            ObjectImageEvt *oie = Q_NEW(ObjectImageEvt, SHIP_IMG_SIG);
            oie->x   = me->m_x;
            oie->y   = me->m_y;
            oie->bmp = SHIP_BMP;
            AO_Tunnel->POST(oie, me);

            ++me->m_score; // increment the score for surviving another tick

            if ((me->m_score % 10U) == 0U) { // is the score "round"?
                ScoreEvt *sev = Q_NEW(ScoreEvt, SCORE_SIG);
                sev->score = me->m_score;
                AO_Tunnel->POST(sev, me);
            }
            status = Q_HANDLED();
            break;
        }
        // @(/2/1/5/1/3/1)
        case PLAYER_TRIGGER_SIG: {
            ObjectPosEvt *ope = Q_NEW(ObjectPosEvt, MISSILE_FIRE_SIG);
            ope->x = me->m_x;
            ope->y = me->m_y + SHIP_HEIGHT - 1U;
            AO_Missile->POST(ope, me);
            status = Q_HANDLED();
            break;
        }
        // @(/2/1/5/1/3/2)
        case DESTROYED_MINE_SIG: {
            me->m_score += Q_EVT_CAST(ScoreEvt)->score;
            // the score will be sent to the Tunnel by the next TIME_TICK
            status = Q_HANDLED();
            break;
        }
        // @(/2/1/5/1/3/3)
        case HIT_WALL_SIG: {
            status = Q_TRAN(&Ship::exploding);
            break;
        }
        // @(/2/1/5/1/3/4)
        case HIT_MINE_SIG: {
            status = Q_TRAN(&Ship::exploding);
            break;
        }
        default: {
            status = Q_SUPER(&Ship::active);
            break;
        }
    }
    return status;
}
예제 #26
0
static QState Ship_flying(Ship * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* @(/2/1/4/1/3/0) */
        case TIME_TICK_SIG: {
            /* tell the Tunnel to draw the Ship and test for hits */
            ObjectImageEvt *oie = Q_NEW(ObjectImageEvt, SHIP_IMG_SIG);
            oie->x   = me->x;
            oie->y   = me->y;
            oie->bmp = SHIP_BMP;
            QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);

            ++me->score; /* increment the score for surviving another tick */

            if ((me->score % 10U) == 0U) { /* is the score "round"? */
                ScoreEvt *sev = Q_NEW(ScoreEvt, SCORE_SIG);
                sev->score = me->score;
                QACTIVE_POST(AO_Tunnel, (QEvt *)sev, me);
            }
            status_ = QM_HANDLED();
            break;
        }
        /* @(/2/1/4/1/3/1) */
        case PLAYER_TRIGGER_SIG: {
            ObjectPosEvt *ope = Q_NEW(ObjectPosEvt, MISSILE_FIRE_SIG);
            ope->x = me->x;
            ope->y = me->y + SHIP_HEIGHT - 1U;
            QACTIVE_POST(AO_Missile, (QEvt *)ope, me);
            status_ = QM_HANDLED();
            break;
        }
        /* @(/2/1/4/1/3/2) */
        case DESTROYED_MINE_SIG: {
            me->score += Q_EVT_CAST(ScoreEvt)->score;
            /* the score will be sent to the Tunnel by the next TIME_TICK */
            status_ = QM_HANDLED();
            break;
        }
        /* @(/2/1/4/1/3/3) */
        case HIT_WALL_SIG: {
            static QActionHandler const act_[] = {
                Q_ACTION_CAST(&Ship_exploding_e),
                Q_ACTION_CAST(0)
            };
            status_ = QM_TRAN(&Ship_exploding_s, &act_[0]);
            break;
        }
        /* @(/2/1/4/1/3/4) */
        case HIT_MINE_SIG: {
            static QActionHandler const act_[] = {
                Q_ACTION_CAST(&Ship_exploding_e),
                Q_ACTION_CAST(0)
            };
            status_ = QM_TRAN(&Ship_exploding_s, &act_[0]);
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #27
0
/* @(/2/4/3/2/1) ...........................................................*/
static QState Mine2_planted(Mine2 * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* @(/2/4/3/2/1/0) */
        case TIME_TICK_SIG: {
            /* @(/2/4/3/2/1/0/0) */
            if (me->x >= GAME_SPEED_X) {
                ObjectImageEvt *oie;
                 me->x -= GAME_SPEED_X; /* move the mine 1 step */
                /* tell the Tunnel to draw the Mine */
                oie = Q_NEW(ObjectImageEvt, MINE_IMG_SIG);
                oie->x   = me->x;
                oie->y   = me->y;
                oie->bmp = MINE2_BMP;
                QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);
                status_ = QM_HANDLED();
            }
            /* @(/2/4/3/2/1/0/1) */
            else {
                static QActionHandler const act_[] = {
                    Q_ACTION_CAST(&Mine2_used_x),
                    Q_ACTION_CAST(0)
                };
                status_ = QM_TRAN(&Mine2_unused_s, &act_[0]);
            }
            break;
        }
        /* @(/2/4/3/2/1/1) */
        case SHIP_IMG_SIG: {
            uint8_t x   = Q_EVT_CAST(ObjectImageEvt)->x;
            uint8_t y   = Q_EVT_CAST(ObjectImageEvt)->y;
            uint8_t bmp = Q_EVT_CAST(ObjectImageEvt)->bmp;
            /* @(/2/4/3/2/1/1/0) */
            if (do_bitmaps_overlap(MINE2_BMP, me->x, me->y, bmp, x, y)) {
                static QActionHandler const act_[] = {
                    Q_ACTION_CAST(&Mine2_used_x),
                    Q_ACTION_CAST(0)
                };
                static MineEvt const mine1_hit = {
                    { HIT_MINE_SIG, 0U, 0U }, /* the QEvt base instance */
                    2U  /* type of the mine (2 for Mine type-2) */
                };
                 QACTIVE_POST(AO_Ship, (QEvt *)&mine1_hit, me);
                 /* go straight to 'disabled' and let the Ship do
                 * the exploding */
                status_ = QM_TRAN(&Mine2_unused_s, &act_[0]);
            }
            else {
                status_ = QM_UNHANDLED();
            }
            break;
        }
        /* @(/2/4/3/2/1/2) */
        case MISSILE_IMG_SIG: {
            uint8_t x   = Q_EVT_CAST(ObjectImageEvt)->x;
            uint8_t y   = Q_EVT_CAST(ObjectImageEvt)->y;
            uint8_t bmp = Q_EVT_CAST(ObjectImageEvt)->bmp;
            /* @(/2/4/3/2/1/2/0) */
            if (do_bitmaps_overlap(MINE2_MISSILE_BMP, me->x, me->y, bmp, x, y)) {
                static QActionHandler const act_[] = {
                    Q_ACTION_CAST(&Mine2_exploding_e),
                    Q_ACTION_CAST(0)
                };
                /* NOTE: Mine type-2 is nastier than Mine type-1.
                * The type-2 mine can hit the Ship with any of its
                * "tentacles". However, it can be destroyed by the
                * Missile only by hitting its center, defined as
                * a smaller bitmap MINE2_MISSILE_BMP.
                */
                static ScoreEvt const mine2_destroyed = {
                    { DESTROYED_MINE_SIG, 0U, 0U },  /* the QEvt base instance */
                    45U  /* score for destroying Mine type-2 */
                };
                QACTIVE_POST(AO_Missile, (QEvt *)&mine2_destroyed, me);
                status_ = QM_TRAN(&Mine2_exploding_s, &act_[0]);
            }
            else {
                status_ = QM_UNHANDLED();
            }
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #28
0
//${AOs::Table::SM::active::serving} .........................................
Q_STATE_DEF(Table, serving) {
    QP::QState status_;
    switch (e->sig) {
        //${AOs::Table::SM::active::serving}
        case Q_ENTRY_SIG: {
            for (uint8_t n = 0U; n < N_PHILO; ++n) { // give permissions to eat...
                if (m_isHungry[n]
                    && (m_fork[LEFT(n)] == FREE)
                    && (m_fork[n] == FREE))
                {
                    m_fork[LEFT(n)] = USED;
                    m_fork[n] = USED;
                    QP::QF::PUBLISH(Q_NEW(TableEvt, EAT_SIG, n), this);
                    m_isHungry[n] = false;
                    BSP_displayPhilStat(n, EATING);
                }
            }
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Table::SM::active::serving::HUNGRY}
        case HUNGRY_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // phil ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!m_isHungry[n]));

            BSP_displayPhilStat(n, HUNGRY);
            uint8_t m = LEFT(n);
            //${AOs::Table::SM::active::serving::HUNGRY::[bothfree]}
            if ((m_fork[m] == FREE) && (m_fork[n] == FREE)) {
                m_fork[m] = USED;
                m_fork[n] = USED;
                QP::QF::PUBLISH(Q_NEW(TableEvt, EAT_SIG, n), this);
                BSP_displayPhilStat(n, EATING);
                status_ = Q_RET_HANDLED;
            }
            //${AOs::Table::SM::active::serving::HUNGRY::[else]}
            else {
                m_isHungry[n] = true;
                status_ = Q_RET_HANDLED;
            }
            break;
        }
        //${AOs::Table::SM::active::serving::DONE}
        case DONE_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // phil ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!m_isHungry[n]));

            BSP_displayPhilStat(n, THINKING);
            uint8_t m = LEFT(n);
            // both forks of Phil[n] must be used
            Q_ASSERT((m_fork[n] == USED) && (m_fork[m] == USED));

            m_fork[m] = FREE;
            m_fork[n] = FREE;
            m = RIGHT(n); // check the right neighbor

            if (m_isHungry[m] && (m_fork[m] == FREE)) {
                m_fork[n] = USED;
                m_fork[m] = USED;
                m_isHungry[m] = false;
                QP::QF::PUBLISH(Q_NEW(TableEvt, EAT_SIG, m), this);
                BSP_displayPhilStat(m, EATING);
            }
            m = LEFT(n); // check the left neighbor
            n = LEFT(m); // left fork of the left neighbor
            if (m_isHungry[m] && (m_fork[n] == FREE)) {
                m_fork[m] = USED;
                m_fork[n] = USED;
                m_isHungry[m] = false;
                QP::QF::PUBLISH(Q_NEW(TableEvt, EAT_SIG, m), this);
                BSP_displayPhilStat(m, EATING);
            }
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Table::SM::active::serving::EAT}
        case EAT_SIG: {
            Q_ERROR();
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Table::SM::active::serving::PAUSE}
        case PAUSE_SIG: {
            status_ = tran(&paused);
            break;
        }
        default: {
            status_ = super(&active);
            break;
        }
    }
    return status_;
}
예제 #29
0
/* ${AOs::Mine2::SM::used::planted} */
static QState Mine2_planted(Mine2 * const me, QEvt const * const e) {
    QState status_;
    switch (e->sig) {
        /* ${AOs::Mine2::SM::used::planted::TIME_TICK} */
        case TIME_TICK_SIG: {
            /* ${AOs::Mine2::SM::used::planted::TIME_TICK::[me->x>=GAME_S~]} */
            if (me->x >= GAME_SPEED_X) {
                ObjectImageEvt *oie;
                 me->x -= GAME_SPEED_X; /* move the mine 1 step */
                /* tell the Tunnel to draw the Mine */
                oie = Q_NEW(ObjectImageEvt, MINE_IMG_SIG);
                oie->x   = me->x;
                oie->y   = me->y;
                oie->bmp = MINE2_BMP;
                QACTIVE_POST(AO_Tunnel, (QEvt *)oie, me);
                status_ = QM_HANDLED();
            }
            /* ${AOs::Mine2::SM::used::planted::TIME_TICK::[else]} */
            else {
                static struct {
                    QMState const *target;
                    QActionHandler act[2];
                } const tatbl_ = { /* transition-action table */
                    &Mine2_unused_s, /* target state */
                    {
                        Q_ACTION_CAST(&Mine2_used_x), /* exit */
                        Q_ACTION_CAST(0) /* zero terminator */
                    }
                };
                status_ = QM_TRAN(&tatbl_);
            }
            break;
        }
        /* ${AOs::Mine2::SM::used::planted::SHIP_IMG} */
        case SHIP_IMG_SIG: {
            uint8_t x   = Q_EVT_CAST(ObjectImageEvt)->x;
            uint8_t y   = Q_EVT_CAST(ObjectImageEvt)->y;
            uint8_t bmp = Q_EVT_CAST(ObjectImageEvt)->bmp;
            /* ${AOs::Mine2::SM::used::planted::SHIP_IMG::[collisionwith~]} */
            if (do_bitmaps_overlap(MINE2_BMP, me->x, me->y, bmp, x, y)) {
                static struct {
                    QMState const *target;
                    QActionHandler act[2];
                } const tatbl_ = { /* transition-action table */
                    &Mine2_unused_s, /* target state */
                    {
                        Q_ACTION_CAST(&Mine2_used_x), /* exit */
                        Q_ACTION_CAST(0) /* zero terminator */
                    }
                };
                static MineEvt const mine1_hit = {
                    { HIT_MINE_SIG, 0U, 0U }, /* the QEvt base instance */
                    2U  /* type of the mine (2 for Mine type-2) */
                };
                 QACTIVE_POST(AO_Ship, (QEvt *)&mine1_hit, me);
                 /* go straight to 'disabled' and let the Ship do
                 * the exploding */
                status_ = QM_TRAN(&tatbl_);
            }
            else {
                status_ = QM_UNHANDLED();
            }
            break;
        }
        /* ${AOs::Mine2::SM::used::planted::MISSILE_IMG} */
        case MISSILE_IMG_SIG: {
            uint8_t x   = Q_EVT_CAST(ObjectImageEvt)->x;
            uint8_t y   = Q_EVT_CAST(ObjectImageEvt)->y;
            uint8_t bmp = Q_EVT_CAST(ObjectImageEvt)->bmp;
            /* ${AOs::Mine2::SM::used::planted::MISSILE_IMG::[collisionwith~]} */
            if (do_bitmaps_overlap(MINE2_MISSILE_BMP, me->x, me->y, bmp, x, y)) {
                static struct {
                    QMState const *target;
                    QActionHandler act[2];
                } const tatbl_ = { /* transition-action table */
                    &Mine2_exploding_s, /* target state */
                    {
                        Q_ACTION_CAST(&Mine2_exploding_e), /* entry */
                        Q_ACTION_CAST(0) /* zero terminator */
                    }
                };
                /* NOTE: Mine type-2 is nastier than Mine type-1.
                * The type-2 mine can hit the Ship with any of its
                * "tentacles". However, it can be destroyed by the
                * Missile only by hitting its center, defined as
                * a smaller bitmap MINE2_MISSILE_BMP.
                */
                static ScoreEvt const mine2_destroyed = {
                    { DESTROYED_MINE_SIG, 0U, 0U },  /* the QEvt base instance */
                    45U  /* score for destroying Mine type-2 */
                };
                QACTIVE_POST(AO_Missile, (QEvt *)&mine2_destroyed, me);
                status_ = QM_TRAN(&tatbl_);
            }
            else {
                status_ = QM_UNHANDLED();
            }
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
예제 #30
0
파일: table.cpp 프로젝트: alisonjoe/qpcpp
//${AOs::Table::SM::active::serving} .........................................
QP::QState Table::serving(Table * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // ${AOs::Table::SM::active::serving}
        case Q_ENTRY_SIG: {
            for (uint8_t n = 0U; n < N_PHILO; ++n) { // give permissions to eat...
                if (me->m_isHungry[n]
                    && (me->m_fork[LEFT(n)] == FREE)
                    && (me->m_fork[n] == FREE))
                {
                    me->m_fork[LEFT(n)] = USED;
                    me->m_fork[n] = USED;
                    TableEvt *te = Q_NEW(TableEvt, EAT_SIG);
                    te->philoNum = n;
                    AO_Philo[n]->POST(te, me);
                    me->m_isHungry[n] = false;
                    BSP::displayPhilStat(n, EATING);
                }
            }
            status_ = Q_HANDLED();
            break;
        }
        // ${AOs::Table::SM::active::serving::HUNGRY}
        case HUNGRY_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // phil ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!me->m_isHungry[n]));

            BSP::displayPhilStat(n, HUNGRY);
            uint8_t m = LEFT(n);
            // ${AOs::Table::SM::active::serving::HUNGRY::[bothfree]}
            if ((me->m_fork[m] == FREE) && (me->m_fork[n] == FREE)) {
                me->m_fork[m] = USED;
                me->m_fork[n] = USED;
                TableEvt *pe = Q_NEW(TableEvt, EAT_SIG);
                pe->philoNum = n;
                QP::QF::PUBLISH(pe, me);
                BSP::displayPhilStat(n, EATING);
                status_ = Q_HANDLED();
            }
            // ${AOs::Table::SM::active::serving::HUNGRY::[else]}
            else {
                me->m_isHungry[n] = true;
                status_ = Q_HANDLED();
            }
            break;
        }
        // ${AOs::Table::SM::active::serving::DONE}
        case DONE_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // phil ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!me->m_isHungry[n]));

            BSP::displayPhilStat(n, THINKING);
            uint8_t m = LEFT(n);
            // both forks of Phil[n] must be used
            Q_ASSERT((me->m_fork[n] == USED) && (me->m_fork[m] == USED));

            me->m_fork[m] = FREE;
            me->m_fork[n] = FREE;
            m = RIGHT(n); // check the right neighbor

            if (me->m_isHungry[m] && (me->m_fork[m] == FREE)) {
                me->m_fork[n] = USED;
                me->m_fork[m] = USED;
                me->m_isHungry[m] = false;
                TableEvt *pe = Q_NEW(TableEvt, EAT_SIG);
                pe->philoNum = m;
                QP::QF::PUBLISH(pe, me);
                BSP::displayPhilStat(m, EATING);
            }
            m = LEFT(n); // check the left neighbor
            n = LEFT(m); // left fork of the left neighbor
            if (me->m_isHungry[m] && (me->m_fork[n] == FREE)) {
                me->m_fork[m] = USED;
                me->m_fork[n] = USED;
                me->m_isHungry[m] = false;
                TableEvt *pe = Q_NEW(TableEvt, EAT_SIG);
                pe->philoNum = m;
                QP::QF::PUBLISH(pe, me);
                BSP::displayPhilStat(m, EATING);
            }
            status_ = Q_HANDLED();
            break;
        }
        // ${AOs::Table::SM::active::serving::EAT}
        case EAT_SIG: {
            Q_ERROR();
            status_ = Q_HANDLED();
            break;
        }
        // ${AOs::Table::SM::active::serving::PAUSE}
        case PAUSE_SIG: {
            status_ = Q_TRAN(&paused);
            break;
        }
        default: {
            status_ = Q_SUPER(&active);
            break;
        }
    }
    return status_;
}