QP/C  8.0.2
Real-Time Embedded Framework
Loading...
Searching...
No Matches
QHsm Class Reference

Hierarchical State Machine class (QHsm-style state machine implementation strategy) More...

#include "qp.h"

Inheritance diagram for QHsm:
QAsm

Public Member Functions

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

Static Public Member Functions

static QStateHandler QHsm_state (QHsm const *const me)
 

Protected Member Functions

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

Protected Attributes

QAsm super
 
- Protected Attributes inherited from QAsm
struct QAsmVtable const * vptr
 Virtual pointer inherited by all QAsm subclasses (see also Object Orientation)
 
union QAsmAttr state
 Current state (pointer to the current state-handler function)
 
union QAsmAttr temp
 Temporary storage for target/act-table etc.
 

Private Member Functions

void QHsm_init_ (QAsm *const me, void const *const e, uint_fast8_t const qsId)
 
void QHsm_dispatch_ (QAsm *const me, QEvt const *const e, uint_fast8_t const qsId)
 
bool QHsm_isIn_ (QAsm *const me, QStateHandler const state)
 
QStateHandler QHsm_getStateHandler_ (QAsm *const me)
 

Static Private Member Functions

static int_fast8_t QHsm_tran_simple_ (QAsm *const me, QStateHandler *const path, uint_fast8_t const qsId)
 
static int_fast8_t QHsm_tran_complex_ (QAsm *const me, QStateHandler *const path, uint_fast8_t const qsId)
 
static void QHsm_enter_target_ (QAsm *const me, QStateHandler *const path, int_fast8_t const depth, uint_fast8_t const qsId)
 

Additional Inherited Members

- Static Protected Member Functions inherited from QAsm
static void QAsm_ctor (QAsm *const me)
 

Detailed Description

Hierarchical State Machine class (QHsm-style state machine implementation strategy)

Details

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.

Note
QHsm is not intended to be instantiated directly, but rather serves as the abstract base class for derivation of state machines in the QP Application.
Backward Traceability
  • SRS_QP_SM_00: QP Framework shall provide support for hierarchical state machines both for Active Objects and for passive event-driven objects in the Application
  • SRS_QP_SM_10: QP Framework shall support multiple and interchangeable State Machine Implementation Strategies
  • SDS_QP_QEP: QEP Event Processor
  • SDS_QP_QHsm: QHsm State machine class.
Usage

The following example illustrates how to derive a state machine class from QHsm. Please note that the QHsm member super is defined as the FIRST member of the derived class.

typedef struct {
QHsm super; // <=== inherit QHsm
double operand1;
double operand2;
char display[DISP_WIDTH + 1];
uint8_t len;
uint8_t opKey;
} Calc;
void Calc_ctor(void) {
QHsm_ctor(&me->super, Q_STATE_CAST(&Calc_initial)); // ctor of the superclass
. . .
}
#define Q_STATE_CAST(handler_)
Perform cast to QStateHandler.
Definition qp.h:175
Hierarchical State Machine class (QHsm-style state machine implementation strategy)
Definition qp.h:254
QAsm super
Definition qp.h:255
void QHsm_ctor(QHsm *const me, QStateHandler const initial)
Definition qep_hsm.c:155

Definition at line 254 of file qp.h.

Member Function Documentation

◆ QHsm_ctor()

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

Definition at line 155 of file qep_hsm.c.

◆ QHsm_init_()

void QHsm_init_ ( QAsm *const me,
void const *const e,
uint_fast8_t const qsId )
private

Definition at line 174 of file qep_hsm.c.

◆ QHsm_dispatch_()

void QHsm_dispatch_ ( QAsm *const me,
QEvt const *const e,
uint_fast8_t const qsId )
private

Definition at line 244 of file qep_hsm.c.

◆ QHsm_isIn_()

bool QHsm_isIn_ ( QAsm *const me,
QStateHandler const state )
private

Definition at line 334 of file qep_hsm.c.

◆ QHsm_getStateHandler_()

QStateHandler QHsm_getStateHandler_ ( QAsm *const me)
private

Definition at line 357 of file qep_hsm.c.

◆ QHsm_top()

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

Definition at line 364 of file qep_hsm.c.

◆ QHsm_state()

static QStateHandler QHsm_state ( QHsm const *const me)
inlinestatic

Definition at line 289 of file qp.h.

◆ QHsm_childState()

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

Definition at line 374 of file qep_hsm.c.

◆ QHsm_tran_simple_()

static int_fast8_t QHsm_tran_simple_ ( QAsm *const me,
QStateHandler *const path,
uint_fast8_t const qsId )
staticprivate

Definition at line 405 of file qep_hsm.c.

◆ QHsm_tran_complex_()

static int_fast8_t QHsm_tran_complex_ ( QAsm *const me,
QStateHandler *const path,
uint_fast8_t const qsId )
staticprivate

Definition at line 468 of file qep_hsm.c.

◆ QHsm_enter_target_()

static void QHsm_enter_target_ ( QAsm *const me,
QStateHandler *const path,
int_fast8_t const depth,
uint_fast8_t const qsId )
staticprivate

Definition at line 557 of file qep_hsm.c.

Member Data Documentation

◆ super

QAsm super
protected

Definition at line 255 of file qp.h.


The documentation for this class was generated from the following files: