QP/C
Functions
qhsm_ini.c File Reference

QHsm_init() implementation. More...

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

Go to the source code of this file.

Functions

void QHsm_init (QHsm *me, QEvent const *e)
 Performs the second step of HSM initialization by triggering the top-most initial transition.

Detailed Description

QHsm_init() implementation.

Definition in file qhsm_ini.c.


Function Documentation

void QHsm_init ( QHsm me,
QEvent const *  e 
)

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

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

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

#include "qep.h"                                  /* QEP/C public interface */
#include "qcalc.h"                           /* QCalc HSM derived from QHsm */

static QCalc l_qcalc;                           /* an instance of QCalc HSM */

int main() {
    QCalc_ctor(&l_qcalc);   /* QCalc HSM "constructor" invokes QHsm_ctor_() */

    QHsm_init((QHsm *)&l_qcalc, (QEvent *)0); /* trigger initial transition */

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

Definition at line 40 of file qhsm_ini.c.

References Q_ALLEGE, Q_ASSERT, Q_INIT_SIG, Q_RET_TRAN, QEP_EMPTY_SIG_, QEP_ENTER_, QEP_MAX_NEST_DEPTH_, QEP_TRIG_, QHsm_top(), QS_BEGIN_, QS_CRIT_STAT_, QS_END_, QS_FUN_, QS_OBJ_, QS_QEP_INIT_TRAN, QS_QEP_STATE_INIT, QS_smObj_, and QS_TIME_.