QP/C  6.9.3
Real-Time Embedded Framework
QHsm Struct Reference

#include <qep.h>

Inheritance diagram for QHsm:
Inheritance graph
Collaboration diagram for QHsm:
Collaboration graph

Public Member Functions

#define QHSM_INIT(me_, par_, qs_id_)
#define QHSM_DISPATCH(me_, e_, qs_id_)    ((*(me_)->vptr->dispatch)((me_), (e_), (qs_id_)))
#define QHsm_state(me_)   (Q_STATE_CAST(Q_HSM_UPCAST(me_)->state.fun))
#define QHsm_childState(me_, parent_)    QHsm_childState_(Q_HSM_UPCAST(me_), Q_STATE_CAST(parent_))
bool QHsm_isIn (QHsm *const me, QStateHandler const state)

Data Fields

struct QHsmVtable const * vptr
union QHsmAttr state
union QHsmAttr temp

Protected Member Functions

void QHsm_ctor (QHsm *const me, QStateHandler initial)
QState QHsm_top (void const *const me, QEvt const *const e)

Private Member Functions

QStateHandler QHsm_childState_ (QHsm *const me, QStateHandler const parent)

Detailed Description

Hierarchical State Machine class

QHsm represents a Hierarchical State Machine (HSM) with full support for hierarchical nesting of states, entry/exit actions, initial transitions, and transitions to history in any composite state. This class is designed for ease of manual coding of HSMs in C, but it is also supported by the QM modeling tool.
QHsm is also the base class for the QMsm state machine, which provides a superior efficiency, but requires the use of the QM modeling tool to generate code.
QHsm is not intended to be instantiated directly, but rather serves as the base structure for derivation of state machines in the application code.
The following example illustrates how to derive a state machine structure from QHsm. Please note that the QHsm member super is defined as the FIRST member of the derived struct.
typedef struct {
QHsm super; /* inhertits QHsm */
double operand1;
double operand2;
char display[DISP_WIDTH + 1];
uint8_t len;
uint8_t opKey;
} Calc;
unsigned char uint8_t
Definition: 16bit/stdint.h:29
Definition: qep.h:282

Definition at line 282 of file qep.h.

Member Function Documentation

◆ QHsm_isIn()

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.

Definition at line 602 of file qep_hsm.c.

◆ QHsm_ctor()

void QHsm_ctor ( QHsm *const  me,
QStateHandler  initial 

Protected "constructor" of QHsm

Definition at line 133 of file qep_hsm.c.

◆ QHsm_top()

QState QHsm_top ( void const *const  me,
QEvt const *const  e 

the top-state.

Definition at line 250 of file qep_hsm.c.

◆ QHsm_childState_()

QStateHandler QHsm_childState_ ( QHsm *const  me,
QStateHandler const  parent 

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

Definition at line 648 of file qep_hsm.c.

Field Documentation

◆ vptr

struct QHsmVtable const* vptr

virtual pointer

Definition at line 283 of file qep.h.

◆ state

union QHsmAttr state

current active state (state-variable)

Definition at line 283 of file qep.h.

◆ temp

union QHsmAttr temp

temporary: tran. chain, target state, etc.

Definition at line 283 of file qep.h.

The documentation for this struct was generated from the following file: