QP/C
Functions
qfsm_ini.c File Reference

QFsm_init() implementation. More...

#include "qep_pkg.h"
#include "qassert.h"

Go to the source code of this file.

Functions

void QFsm_init (QFsm *me, QEvent const *e)
 Performs the second step of FSM initialization by triggering the top-most initial transition.

Detailed Description

QFsm_init() implementation.

Definition in file qfsm_ini.c.


Function Documentation

void QFsm_init ( QFsm me,
QEvent const *  e 
)

Performs the second step of FSM initialization by triggering the top-most initial transition.

Parameters:
mepointer the state machine structure derived from QFsm
econstant pointer the QEvent or a structure derived from QEvent
Note:
Must be called only ONCE after the "constructor" QFsm_ctor().

The following example illustrates how to initialize a FSM, and dispatch events to it:

#include "qep.h"                                  /* QEP/C public interface */
#include "qbomb.h"                           /* QBomb FSM derived from QFsm */

static QBomb l_qbomb;                           /* an instance of QBomb FSM */

int main() {
    QBombInitEvt ie;                  /* initialization event for QBomb FSM */

    QBomb_ctor(&l_qbomb);   /* QBomb FSM "constructor" invokes QFsm_ctor_() */

    /* set the initialization event ie */

    QFsm_init((QFsm *)&l_qbomb, &ie);         /* trigger initial transition */

    for (;;) {                                                /* event loop */
        QEvent e;
        . . .
        /* wait for the next event and assign it to the event object e */
        . . .
        QFsm_dispatch((QFsm *)&l_qbomb, &e);       /* dispatch e to l_qbomb */
    }
    return 0;
}

Definition at line 40 of file qfsm_ini.c.

References Q_ALLEGE, Q_ENTRY_SIG, Q_RET_TRAN, Q_STATE_CAST, QEP_TRIG_, QS_BEGIN_, QS_CRIT_STAT_, QS_END_, QS_FUN_, QS_OBJ_, QS_QEP_INIT_TRAN, QS_QEP_STATE_INIT, QS_smObj_, and QS_TIME_.