QP/C 6.8.2
QHsm Struct Reference

Hierarchical State Machine class. More...

#include <qep.h>

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

Public Member Functions

#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

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 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

QStateHandler QHsm_childState_ (QHsm *const me, QStateHandler const parent)
 Helper function to obtain the current active child state of a parent. More...
 

Detailed Description

Hierarchical State Machine class.

Description
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.
Note
QHsm 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 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;

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 561 of file qep_hsm.c.

◆ QHsm_ctor()

void QHsm_ctor ( QHsm *const  me,
QStateHandler  initial 
)
protected

Protected "constructor" of QHsm.

Definition at line 128 of file qep_hsm.c.

◆ QHsm_top()

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

the top-state.

Definition at line 235 of file qep_hsm.c.

◆ QHsm_childState_()

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

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

Definition at line 607 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:
uint8_t
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: 16bit/stdint.h:29
QHsm
Hierarchical State Machine class.
Definition: qep.h:282