QP/C 6.8.2
QMsm Struct Reference

QM State Machine implementation strategy. More...

#include <qep.h>

Inheritance diagram for QMsm:
Inheritance graph
Collaboration diagram for QMsm:
Collaboration graph

Public Member Functions

#define QMsm_stateObj(me_)   (Q_HSM_UPCAST(me_)->state.obj)
 Obtain the current active state from a MSM (read only) More...
 
#define QMsm_childStateObj(me_, parent_)   QMsm_childStateObj_(Q_HSM_UPCAST(me_), (parent_))
 Obtain the current active child state of a given parent in QMsm. More...
 
QMState const * QMsm_childStateObj_ (QMsm const *const me, QMState const *const parent)
 Helper function to obtain the current active child state of a parent. More...
 
bool QMsm_isInState (QMsm const *const me, QMState const *const state)
 Tests if a given state is part of the current active state configuration in a MSM. More...
 
- Public Member Functions inherited from QHsm
#define QHSM_INIT(me_, par_)
 Polymorphically executes the top-most initial transition in a HSM. More...
 
#define QHSM_DISPATCH(me_, e_)   ((*(me_)->vptr->dispatch)((me_), (e_)))
 Polymorphically dispatches an event to a HSM. More...
 
#define QHsm_state(me_)   (Q_STATE_CAST(Q_HSM_UPCAST(me_)->state.fun))
 Obtain the current active state from a HSM (read only). More...
 
#define QHsm_childState(me_, parent_)   QHsm_childState_(Q_HSM_UPCAST(me_), Q_STATE_CAST(parent_))
 Obtain the current active child state of a given parent in QHsm. More...
 
bool QHsm_isIn (QHsm *const me, QStateHandler const state)
 Tests if a given state is part of the current active state configuration in QHsm subclasses. More...
 

Data Fields

QHsm super
 inherits QHsm More...
 
- Data Fields inherited from QHsm
struct QHsmVtable const * vptr
 virtual pointer More...
 
union QHsmAttr state
 current active state (state-variable) More...
 
union QHsmAttr temp
 temporary: tran. More...
 

Protected Member Functions

void QMsm_ctor (QMsm *const me, QStateHandler initial)
 Constructor of QMsm. More...
 
- Protected Member Functions inherited from QHsm
void QHsm_ctor (QHsm *const me, QStateHandler initial)
 Protected "constructor" of QHsm. More...
 
QState QHsm_top (void const *const me, QEvt const *const e)
 the top-state. More...
 

Private Member Functions

void QMsm_init_ (QHsm *const me, void const *const e)
 Implementation of the top-most initial transition in QMsm. More...
 
void QMsm_dispatch_ (QHsm *const me, QEvt const *const e)
 Implementation of disparching events to QMsm. More...
 
static QState QMsm_execTatbl_ (QHsm *const me, struct QMTranActTable const *tatbl)
 helper function to execute a transition-action table. More...
 
static void QMsm_exitToTranSource_ (QHsm *const me, QMState const *cs, QMState const *ts)
 helper function to exit the current state up to the transition source More...
 
static QState QMsm_enterHistory_ (QHsm *const me, QMState const *const hist)
 helper function to execute a transition to history More...
 

Detailed Description

QM State Machine implementation strategy.

Description
QMsm (QM State Machine) provides a more efficient state machine implementation strategy than QHsm, but requires the use of the QM modeling tool, but are the fastest and need the least run-time support (the smallest event-processor taking up the least code space).
Note
QMsm is not intended to be instantiated directly, but rather serves as the base structure for derivation of state machines in the application code.
Usage
The following example illustrates how to derive a state machine structure from QMsm. Please note that the QMsm member 'super' is defined as the first member of the derived struct.
typedef struct {
QMsm super; /* inherits QMsm */
double operand1;
double operand2;
char display[DISP_WIDTH + 1];
uint8_t len;
uint8_t opKey;
} Calc;
See also
Object Orientation

Definition at line 407 of file qep.h.

Member Function Documentation

◆ QMsm_childStateObj_()

QMState const * QMsm_childStateObj_ ( QMsm const *const  me,
QMState const *const  parent 
)

Helper function to obtain the current active child state of a parent.

Definition at line 588 of file qep_msm.c.

◆ QMsm_isInState()

bool QMsm_isInState ( QMsm const *const  me,
QMState const *const  state 
)

Tests if a given state is part of the current active state configuration in a MSM.

Definition at line 557 of file qep_msm.c.

◆ QMsm_ctor()

void QMsm_ctor ( QMsm *const  me,
QStateHandler  initial 
)
protected

Constructor of QMsm.

Definition at line 119 of file qep_msm.c.

◆ QMsm_init_()

void QMsm_init_ ( QHsm *const  me,
void const *const  e 
)
private

Implementation of the top-most initial transition in QMsm.

Description
Executes the top-most initial transition in a MSM.
Parameters
[in,out]mepointer (see Object Orientation)
[in]epointer to an extra parameter (might be NULL)
Note
Must be called only ONCE after the QMsm_ctor().
Precondition
the virtual pointer must be initialized, the top-most initial transition must be initialized, and the initial transition must not be taken yet.

Definition at line 142 of file qep_msm.c.

◆ QMsm_dispatch_()

void QMsm_dispatch_ ( QHsm *const  me,
QEvt const *const  e 
)
private

Implementation of disparching events to QMsm.

Description
Dispatches an event for processing to a meta state machine (MSM). The processing of an event represents one run-to-completion (RTC) step.
Parameters
[in,out]mepointer (see Object Orientation)
[in]epointer to the event to be dispatched to the MSM
Note
This function should be called only via the virtual table (see QHSM_DISPATCH()) and should NOT be called directly in the applications.
Precondition
current state must be initialized

Definition at line 195 of file qep_msm.c.

◆ QMsm_execTatbl_()

static QState QMsm_execTatbl_ ( QHsm *const  me,
struct QMTranActTable const *  tatbl 
)
private

helper function to execute a transition-action table.

Description
Helper function to execute transition sequence in a transition-action table.
Parameters
[in,out]mepointer (see Object Orientation)
[in]tatblpointer to the transition-action table
Returns
status of the last action from the transition-action table.
Note
This function is for internal use inside the QEP event processor and should not be called directly from the applications.
Precondition
the transition-action table pointer must not be NULL

Definition at line 376 of file qep_msm.c.

◆ QMsm_exitToTranSource_()

static void QMsm_exitToTranSource_ ( QHsm *const  me,
QMState const *  cs,
QMState const *  ts 
)
private

helper function to exit the current state up to the transition source

Description
Static helper function to exit the current state configuration to the transition source, which in a hierarchical state machine might be a superstate of the current state.
Parameters
[in,out]mepointer (see Object Orientation)
[in]cspointer to the current state
[in]tspointer to the transition source state

Definition at line 451 of file qep_msm.c.

◆ QMsm_enterHistory_()

static QState QMsm_enterHistory_ ( QHsm *const  me,
QMState const *const  hist 
)
private

helper function to execute a transition to history

Description
Static helper function to execute the segment of transition to history after entering the composite state and
Parameters
[in,out]mepointer (see Object Orientation)
[in]histpointer to the history substate
Returns
Q_RET_TRAN_INIT, if an initial transition has been executed in the last entered state or Q_RET_NULL if no such transition was taken.

Definition at line 493 of file qep_msm.c.

Field Documentation

◆ super

QHsm super

inherits QHsm

Definition at line 408 of file qep.h.


The documentation for this struct was generated from the following files:
uint8_t
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: 16bit/stdint.h:29
QMsm::super
QHsm super
inherits QHsm
Definition: qep.h:408
QMsm
QM State Machine implementation strategy.
Definition: qep.h:407