QP/C 6.9.0
qep_msm.c File Reference

QMsm implementation More...

#include "qep_port.h"
#include "qassert.h"
#include "qs_port.h"
#include "qs_pkg.h"
Include dependency graph for qep_msm.c:

Go to the source code of this file.

Macros

#define QEP_ACT_PTR_INC_(act_)   (++(act_))
 Internal QEP macro to increment the given action table act_. More...
 

Enumerations

enum  { QMSM_MAX_ENTRY_DEPTH_ = 4 }
 internal QEP constants More...
 

Functions

void QMsm_ctor (QMsm *const me, QStateHandler initial)
 
bool QMsm_isInState (QMsm const *const me, QMState const *const state)
 
QMState const * QMsm_childStateObj_ (QMsm const *const me, QMState const *const parent)
 

Variables

static struct QMState const l_msm_top_s
 

Detailed Description

QMsm implementation

Definition in file qep_msm.c.

Macro Definition Documentation

◆ QEP_ACT_PTR_INC_

#define QEP_ACT_PTR_INC_ (   act_)    (++(act_))

Internal QEP macro to increment the given action table act_.

Note
Incrementing a pointer violates the MISRA-C 2004 Rule 17.4(req), pointer arithmetic other than array indexing. Encapsulating this violation in a macro allows to selectively suppress this specific deviation.

Definition at line 75 of file qep_msm.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

internal QEP constants

Enumerator
QMSM_MAX_ENTRY_DEPTH_ 

maximum depth of entry levels in a MSM for transition to history.

Definition at line 54 of file qep_msm.c.

Function Documentation

◆ QMsm_ctor()

void QMsm_ctor ( QMsm *const  me,
QStateHandler  initial 
)
Description
Performs the first step of QMsm initialization by assigning the initial pseudostate to the currently active state of the state machine.
Parameters
[in,out]mepointer (see Object Orientation)
[in]initialthe top-most initial transition for the MSM.
Note
Must be called only ONCE before QHSM_INIT().
QMsm inherits QHsm, so by the Object Orientation convention it should call the constructor of the superclass, i.e., QHsm_ctor(). However, this would pull in the QHsmVtable, which in turn will pull in the code for QHsm_init_() and QHsm_dispatch_() implemetations. To avoid this code size penalty, in case QHsm is not used in a given project, the QMsm_ctor() performs direct intitialization of the Vtable, which avoids pulling in the code for QMsm.
Usage
The following example illustrates how to invoke QMsm_ctor() in the "constructor" of a derived state machine:
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;
}

Definition at line 119 of file qep_msm.c.

◆ QMsm_isInState()

bool QMsm_isInState ( QMsm const *const  me,
QMState const *const  state 
)
Description
Tests if a state machine derived from QMsm is-in a given state.
Note
For a MSM, to "be-in" a state means also to "be-in" a superstate of of the state.
Parameters
[in]mepointer (see Object Orientation)
[in]statepointer to the QMState object that corresponds to the tested state.
Returns
'true' if the MSM "is in" the state and 'false' otherwise

Definition at line 557 of file qep_msm.c.

◆ QMsm_childStateObj_()

QMState const* QMsm_childStateObj_ ( QMsm const *const  me,
QMState const *const  parent 
)
Description
Finds the child state of the given parent, such that this child state is an ancestor of the currently active state. The main purpose of this function is to support shallow history transitions in state machines derived from QMsm.
Parameters
[in]mepointer (see Object Orientation)
[in]parentpointer to the state-handler object
Returns
the child of a given parent state, which is an ancestor of the currently active state. For the corner case when the currently active state is the given parent state, function returns the parent state.
See also
QMsm_childStateObj()
Postcondition
the child must be found

Definition at line 588 of file qep_msm.c.

Variable Documentation

◆ l_msm_top_s

struct QMState const l_msm_top_s
static
Initial value:
= {
(struct QMState *)0,
}

Definition at line 1 of file qep_msm.c.

QMState
State object for the QMsm class (QM State Machine).
Definition: qep.h:423
Q_ACTION_CAST
#define Q_ACTION_CAST(action_)
Perform cast to QActionHandler.
Definition: qep.h:237
Q_STATE_CAST
#define Q_STATE_CAST(handler_)
Perform cast to QStateHandler.
Definition: qep.h:228
QMsm::QMsm_ctor
void QMsm_ctor(QMsm *const me, QStateHandler initial)
Constructor of QMsm.
Definition: qep_msm.c:119