Beispiel #1
0
/*..........................................................................*/
void QFsm_init_(QFsm * const me, QEvt const * const e) {
    QS_CRIT_STAT_

    Q_REQUIRE((me->vptr != (QMsmVtbl const *)0)    /* ctor must be executed */
              && (me->temp.fun != Q_STATE_CAST(0)) /* ctor must be executed */
              && (me->state.fun == Q_STATE_CAST(0)));/*init tran. NOT taken */

    QS_BEGIN_(QS_QEP_STATE_INIT, QS_priv_.smObjFilter, me)
        QS_OBJ_(me);                           /* this state machine object */
        QS_FUN_(Q_STATE_CAST(0));   /* source state (not defined for a FSM) */
        QS_FUN_(me->temp.fun);              /* the target of the transition */
    QS_END_()

                                 /* execute the top-most initial transition */
    Q_ALLEGE((*me->temp.fun)(me, e) == (QState)Q_RET_TRAN);/* must be taken */

    (void)QEP_TRIG_(me->temp.fun, Q_ENTRY_SIG);         /* enter the target */
    me->state.fun = me->temp.fun;            /* record the new active state */

    QS_BEGIN_(QS_QEP_INIT_TRAN, QS_priv_.smObjFilter, me)
        QS_TIME_();                                           /* time stamp */
        QS_OBJ_(me);                           /* this state machine object */
        QS_FUN_(me->state.fun);                     /* the new active state */
    QS_END_()
}
Beispiel #2
0
/* @(/1/8) .................................................................*/
void Philo_ctor(void) {
    QMActive_ctor(&AO_Philo0.super, Q_STATE_CAST(&Philo_initial));
    QMActive_ctor(&AO_Philo1.super, Q_STATE_CAST(&Philo_initial));
    QMActive_ctor(&AO_Philo2.super, Q_STATE_CAST(&Philo_initial));
    QMActive_ctor(&AO_Philo3.super, Q_STATE_CAST(&Philo_initial));
    QMActive_ctor(&AO_Philo4.super, Q_STATE_CAST(&Philo_initial));
    BSP_randomSeed(123U);
}
Beispiel #3
0
/*..........................................................................*/
void QHsm_init(QHsm * const me, QEvt const * const e) {
    QStateHandler t = me->state.fun;
    QS_CRIT_STAT_

    Q_REQUIRE((me->vptr != (QMsmVtbl const *)0)    /* ctor must be executed */
              && (me->temp.fun != Q_STATE_CAST(0)) /* ctor must be executed */
              && (t == Q_STATE_CAST(&QHsm_top))); /*initial tran. NOT taken */

                           /* the top-most initial transition must be taken */
    Q_ALLEGE((*me->temp.fun)(me, e) == (QState)Q_RET_TRAN);

    do {                                        /* drill into the target... */
        QStateHandler path[QEP_MAX_NEST_DEPTH_];
        int_t ip = (int_t)0;                 /* transition entry path index */

        QS_BEGIN_(QS_QEP_STATE_INIT, QS_priv_.smObjFilter, me)
            QS_OBJ_(me);                       /* this state machine object */
            QS_FUN_(t);                                 /* the source state */
            QS_FUN_(me->temp.fun);  /* the target of the initial transition */
        QS_END_()

        path[0] = me->temp.fun;
        (void)QEP_TRIG_(me->temp.fun, QEP_EMPTY_SIG_);
        while (me->temp.fun != t) {
            ++ip;
            path[ip] = me->temp.fun;
            (void)QEP_TRIG_(me->temp.fun, QEP_EMPTY_SIG_);
        }
        me->temp.fun = path[0];
                                            /* entry path must not overflow */
        Q_ASSERT(ip < (int_t)QEP_MAX_NEST_DEPTH_);

        do {        /* retrace the entry path in reverse (desired) order... */
            QEP_ENTER_(path[ip]);                         /* enter path[ip] */
            --ip;
        } while (ip >= (int_t)0);

        t = path[0];                /* current state becomes the new source */
    } while (QEP_TRIG_(t, Q_INIT_SIG) == (QState)Q_RET_TRAN);

    QS_BEGIN_(QS_QEP_INIT_TRAN, QS_priv_.smObjFilter, me)
        QS_TIME_();                                           /* time stamp */
        QS_OBJ_(me);                           /* this state machine object */
        QS_FUN_(t);                                 /* the new active state */
    QS_END_()

    me->state.fun = t;                   /* change the current active state */
    me->temp.fun  = t;                  /* mark the configuration as stable */
}
Beispiel #4
0
/*${SMs::ToastOven::SM} ....................................................*/
static QState ToastOven_initial(ToastOven * const me, QEvt const * const e) {
    /* ${SMs::ToastOven::SM::initial} */
    (void)e; /* avoid compiler warning */
    /* state history attributes */
    me->his_doorClosed = Q_STATE_CAST(&ToastOven_off);
    return Q_TRAN(&ToastOven_doorClosed);
}
Beispiel #5
0
//****************************************************************************
//! constructor of a "naked" thread
QXThread::QXThread(QXThreadHandler const handler, uint_fast8_t const tickRate)
  : QMActive(Q_STATE_CAST(handler)),
    m_timeEvt(this, static_cast<enum_t>(QXK_DELAY_SIG),
                    static_cast<uint8_t>(tickRate))
{
    m_state.act = Q_ACTION_CAST(0); // mark as naked thread
}
Beispiel #6
0
/*${SMs::ToastOven::SM} ....................................................*/
static QState ToastOven_initial(ToastOven * const me) {
    /*${SMs::ToastOven::SM::initial} */
    /* state history attributes */
    /* state history attributes */
    me->hist_doorClosed = Q_STATE_CAST(&ToastOven_off);
    return Q_TRAN(&ToastOven_doorClosed);
}
Beispiel #7
0
/*******************************************************************************
 * Code
 ******************************************************************************/
void LEDSEQ_Creator(uint16_t led)
{
    LedSeq * const me = &AO_LedSeq;
    me->led = led;

    QActive_ctor(&me->super, Q_STATE_CAST(&LEDSEQ_Init));
}
Beispiel #8
0
/*${AOs::USBTask_ctor} .....................................................*/
void USBTask_ctor(void) {
    USBTask* me = &l_usbtask;

    QActive_ctor( &me->super, Q_STATE_CAST( &USBTask_initial ));
    //QTimeEvt_ctor( &me->blinkEvt, BLINK_SIG );
    //QTimeEvt_ctor( &me->rollEvt, ROLL_SIG );
}
Beispiel #9
0
Datei: cli.c Projekt: ageamiu/cdb
/*${AOs::CLI_ctor} .........................................................*/
void CLI_ctor(void) {
    CLI* me = &l_cli;

    QActive_ctor( &me->super, Q_STATE_CAST( &CLI_initial ));
    QTimeEvt_ctor( &me->blinkEvt, BLINK_SIG );
    QTimeEvt_ctor( &me->rollEvt, ROLL_SIG );
}
Beispiel #10
0
/* @(/2/12) ................................................................*/
QMsm * Mine2_ctor(uint8_t id) {
    Mine2 *me;
    Q_REQUIRE(id < GAME_MINES_MAX);
    me = &l_mine2[id];
    /* superclass' ctor */
    QMsm_ctor(&me->super, Q_STATE_CAST(&Mine2_initial));
    return (QMsm *)me;
}
Beispiel #11
0
//${AOs::Table} ..............................................................
//${AOs::Table::Table} .......................................................
Table::Table()
  : QActive(Q_STATE_CAST(&Table::initial))
{
    for (uint8_t n = 0U; n < N_PHILO; ++n) {
        m_fork[n] = FREE;
        m_isHungry[n] = false;
    }
}
Beispiel #12
0
// Philo definition ----------------------------------------------------------
// @(/3/0) ...................................................................
// @(/3/0/1) .................................................................
Philo::Philo() 
  : QActive(Q_STATE_CAST(&Philo::initial)),
    m_timeEvt(this,
     TIMEOUT_SIG,
    0U)
{
    // empty
}
Beispiel #13
0
void Calc_ctor(Calc * const me) {
    /* superclass' ctor */
    QMsm_ctor(&me->super, Q_STATE_CAST(&Calc_initial));

    me->operand1 = 0.0;
    me->operand2 = 0.0;
    me->len      = 0U;
    me->opKey    = 0U;
}
Beispiel #14
0
/*${AOs::Philo_ctor} .......................................................*/
void Philo_ctor(void) {
    uint8_t n;
    Philo *me;
    for (n = 0U; n < N_PHILO; ++n) {
        me = &l_philo[n];
        QMActive_ctor(&me->super, Q_STATE_CAST(&Philo_initial));
        QTimeEvt_ctorX(&me->timeEvt, &me->super, TIMEOUT_SIG, 0U);
    }
}
Beispiel #15
0
/* @(/1/21) ................................................................*/
void QGprs_ctor(void) {
    QGprs *me = &l_Gprs;
    QActive_ctor(&me->super, Q_STATE_CAST(&QGprs_initial));
    QTimeEvt_ctor(&me->m_Timer, Q_TIMEOUT_SIG);
    QTimeEvt_ctor(&me->m_LEDTimer, GPRS_LED_TIMEOUT_SIG);
    QTimeEvt_ctor(&me->m_retrieveTimer, GPRS_RETRIEVE_TIMEOUT_SIG);
    QTimeEvt_ctor(&me->m_PingTimer, GPRS_PING_TIMEOUT_SIG);
    QTimeEvt_ctor(&me->m_retrieveTimer, GPRS_RETRIEVE_TIMEOUT_SIG);
}
Beispiel #16
0
/*..........................................................................*/
void QFsm_ctor(QFsm * const me, QStateHandler initial) {
    static QMsmVtbl const vtbl = {                    /* QFsm virtual table */
        &QFsm_init_,
        &QFsm_dispatch_
    };
    /* do not call the QMsm_ctor() here, see NOTE01 */
    me->vptr = &vtbl;            /* hook the vptr to the QFsm virtual table */
    me->state.fun = Q_STATE_CAST(0);
    me->temp.fun  = initial;
}
Beispiel #17
0
/*..........................................................................*/
void QHsm_ctor(QHsm * const me, QStateHandler initial) {
    static QMsmVtbl const vtbl = {                    /* QHsm virtual table */
        &QHsm_init,
        &QHsm_dispatch
    };
    /* do not call the QMsm_ctor() here, see NOTE01 */
    me->vptr  = &vtbl;
    me->state.fun = Q_STATE_CAST(&QHsm_top);
    me->temp.fun  = initial;
}
Beispiel #18
0
Q_DEFINE_THIS_FILE

// Alarm component --------------------
//$skip${QP_VERSION} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// Check for the minimum required QP version
#if (QP_VERSION < 650U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
#error qpcpp version 6.5.0 or higher required
#endif
//$endskip${QP_VERSION} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//$define${Components::Alarm} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//${Components::Alarm} .......................................................
//${Components::Alarm::Alarm} ................................................
Alarm::Alarm()
 : QHsm(Q_STATE_CAST(&Alarm::initial))
{}
Beispiel #19
0
/**
* @description
* Executes the top-most initial transition in a MSM.
*
* @param[in,out] me pointer (see @ref oop)
* @param[in]     e  pointer to the initialization event (might be NULL)
*
* @note Must be called only ONCE after the QMsm_ctor().
*/
void QMsm_init_(QMsm * const me, QEvt const * const e) {
    QState r;
    QS_CRIT_STAT_

    /** @pre the virtual pointer must be initialized, the top-most initial
    * transition must be initialized, and the initial transition must not
    * be taken yet.
    */
    Q_REQUIRE_ID(200, (me->vptr != (QMsmVtbl const *)0)
                      && (me->temp.fun != Q_STATE_CAST(0))
                      && (me->state.obj == &l_msm_top_s));

    r = (*me->temp.fun)(me, e); /* the action of the top-most initial tran. */

    /* the top-most initial transition must be taken */
    Q_ASSERT_ID(210, r == (QState)Q_RET_TRAN_INIT);

    QS_BEGIN_(QS_QEP_STATE_INIT, QS_priv_.smObjFilter, me)
        QS_OBJ_(me); /* this state machine object */
        QS_FUN_(me->state.obj->stateHandler);        /* source state handler*/
        QS_FUN_(me->temp.tatbl->target->stateHandler);/*target state handler*/
    QS_END_()

    /* set state to the last tran. target */
    me->state.obj = me->temp.tatbl->target;

    /* drill down into the state hierarchy with initial transitions... */
    do {
        r = QMsm_execTatbl_(me, me->temp.tatbl); /* execute the tran. table */
    } while (r >= (QState)Q_RET_TRAN_INIT);

    QS_BEGIN_(QS_QEP_INIT_TRAN, QS_priv_.smObjFilter, me)
        QS_TIME_();                           /* time stamp */
        QS_OBJ_(me);                          /* this state machine object */
        QS_FUN_(me->state.obj->stateHandler); /* the new current state */
    QS_END_()
}
Beispiel #20
0
/* @(/1/38) ................................................................*/
void QIR_ctor(void) {
    QIR *me = &l_QIR;
    QActive_ctor(&me->super, Q_STATE_CAST(&QIR_initial));

    //QTimeEvt_ctor(&me->m_Timer, Q_TIMEOUT_SIG);
}
Beispiel #21
0
/*--------------------------------------------------------------------------*/
void Cruncher_ctor(void) {
    QActive_ctor(&AO_Cruncher.super, Q_STATE_CAST(&Cruncher_initial));
}
Beispiel #22
0
/* @(/1/37) ................................................................*/
void QPrinter_ctor(void) {
    QPrinter *me = &l_QPrinter;
    QActive_ctor(&me->super, Q_STATE_CAST(&QPrinter_initial));
}
Beispiel #23
0
/*${SMs::ToastOven_ctor} ...................................................*/
void ToastOven_ctor(void) {
    ToastOven *me = &l_oven;
    QHsm_ctor(&me->super, Q_STATE_CAST(&ToastOven_initial));
}
//...................................................................
QHsm::QHsm(QPseudoState initial) 
   : myState(&QHsm::top), mySource(Q_STATE_CAST(initial))
{}
//...................................................................
void QHsm::dispatch(QEvent const *e) {
  for (mySource = myState; mySource;
       mySource = Q_STATE_CAST((this->*mySource)(e))) 
  {}
}
Beispiel #26
0
 Mine1()
   : QMsm(Q_STATE_CAST(&Mine1::initial))
 {}
Beispiel #27
0
            me->m_x = Q_EVT_CAST(ObjectPosEvt)->x;
            me->m_y = Q_EVT_CAST(ObjectPosEvt)->y;
            status_ = QM_TRAN(&planted_s, &QP::QMsm::s_emptyAction_[0]);
            break;
        }
        default: {
            status_ = QM_SUPER();
            break;
        }
    }
    return status_;
}
// @(/2/3/4/2) ...............................................................
QP::QMState const Mine1::used_s = {
    static_cast<QP::QMState const *>(0),
    Q_STATE_CAST(&Mine1::used),
    Q_ACTION_CAST(&Mine1::used_x)
};
QP::QState Mine1::used_x(Mine1 * const me) {
    // tell the Tunnel that this mine is becoming disabled
    MineEvt *mev = Q_NEW(MineEvt, MINE_DISABLED_SIG);
    mev->id = MINE_ID(me);
    AO_Tunnel->POST(mev, me);
    return QM_EXIT(&used_s);
}
QP::QState Mine1::used(Mine1 * const me, QP::QEvt const * const e) {
    QP::QState status_;
    switch (e->sig) {
        // @(/2/3/4/2/0)
        case MINE_RECYCLE_SIG: {
            static QP::QActionHandler const act_[] = {
Beispiel #28
0
/*${AOs::Blinky_ctor} ......................................................*/
static void Blinky_ctor(void) {
    Blinky * const me = &AO_Blinky;
    QActive_ctor(&me->super, Q_STATE_CAST(&Blinky_initial));
}
Beispiel #29
0
/* @(/2/9) .................................................................*/
void Ship_ctor(void) {
    Ship *me = &l_ship;
    QMActive_ctor(&me->super, Q_STATE_CAST(&Ship_initial));
    me->x = GAME_SHIP_X;
    me->y = GAME_SHIP_Y;
}
Beispiel #30
0
    QMActive super;

/* private: */
    uint8_t x;
    uint8_t y;
    uint8_t exp_ctr;
    uint16_t score;
} Ship;

/* protected: */
static QState Ship_initial(Ship * const me, QEvt const * const e);
static QState Ship_active  (Ship * const me, QEvt const * const e);
static QState Ship_active_i(Ship * const me);
static QMState const Ship_active_s = {
    (QMState const *)0,
    Q_STATE_CAST(&Ship_active),
    Q_ACTION_CAST(0)
};
static QState Ship_parked  (Ship * const me, QEvt const * const e);
static QMState const Ship_parked_s = {
    &Ship_active_s,
    Q_STATE_CAST(&Ship_parked),
    Q_ACTION_CAST(0)
};
static QState Ship_flying  (Ship * const me, QEvt const * const e);
static QState Ship_flying_e(Ship * const me);
static QMState const Ship_flying_s = {
    &Ship_active_s,
    Q_STATE_CAST(&Ship_flying),
    Q_ACTION_CAST(0)
};