Hierarchical State Machine class (QHsm-style state machine implementation strategy) More...
#include "qp.h"
Public Member Functions | |
QStateHandler | QHsm_childState (QHsm *const me, QStateHandler const parent) |
Obtain the current active child state of a given parent in QMsm. | |
Static Public Member Functions | |
static QStateHandler | QHsm_state (QHsm const *const me) |
Obtain the current active state from a HSM (read only) | |
Public Attributes | |
QAsm | super |
Protected Member Functions | |
void | QHsm_ctor (QHsm *const me, QStateHandler const initial) |
Constructor of the QHsm base class. | |
Protected Member Functions inherited from QAsm | |
void | QAsm_ctor (QAsm *const me) |
Constructor of the QAsm base class. | |
QState | QHsm_top (QHsm const *const me, QEvt const *const e) |
Private Member Functions | |
void | QHsm_init_ (QAsm *const me, void const *const e, uint_fast8_t const qsId) |
Implementation of the top-most initial transition in QHsm. | |
void | QHsm_dispatch_ (QAsm *const me, QEvt const *const e, uint_fast8_t const qsId) |
Implementation of dispatching events to a QHsm. | |
QStateHandler | QHsm_getStateHandler_ (QAsm *const me) |
Implementation of getting the state handler in a QHsm subclass. | |
bool | QHsm_isIn_ (QAsm *const me, QStateHandler const state) |
Check if a given state is part of the current active state configuration. | |
int_fast8_t | QHsm_tran_ (QAsm *const me, QStateHandler *const path, uint_fast8_t const qsId) |
Additional Inherited Members | |
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. | |
Hierarchical State Machine class (QHsm-style state machine implementation strategy)
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.
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.
|
protected |
Constructor of the QHsm base class.
The constructor initializes the QHsm::state. The constructor is "protected" because it is only intended to be invoked from the subclasses of the abstract base class QAsm.
[in,out] | me | current instance pointer (see Object Orientation) |
[in] | initial | initial pseudostate of the instantiated state machine |
|
private |
Implementation of the top-most initial transition in QHsm.
Synchronously executes the top-most initial transition in a state machine.
[in,out] | me | current instance pointer (see Object Orientation) |
[in] | e | pointer to an extra parameter (might be NULL) |
[in] | qsId | QS-id of this state machine (for QS local filter) |
qep_msm:200
Implementation of dispatching events to a QHsm.
Synchronously dispatches an event for processing to a state machine. The processing of an event represents one run-to-completion (RTC) step.
[in,out] | me | current instance pointer (see Object Orientation) |
[in] | e | pointer to the event to be dispatched to the MSM |
[in] | qsId | QS-id of this state machine (for QS local filter) |
qep_msm:302
|
private |
Implementation of getting the state handler in a QHsm subclass.
[in,out] | me | current instance pointer (see Object Orientation) |
|
private |
Check if a given state is part of the current active state configuration.
Please note that for a HSM, to "be in a state" means also to be in a superstate of of the state.
[in] | me | current instance pointer (see Object Orientation) |
[in] | state | pointer to the state-handler function to be tested |
state
and 'false' otherwiseqep_hsm:602
|
inlinestatic |
Obtain the current active state from a HSM (read only)
[in] | me | current instance pointer (see Object Orientation) |
QStateHandler QHsm_childState | ( | QHsm *const | me, |
QStateHandler const | parent ) |
Obtain the current active child state of a given parent in QMsm.
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.
[in] | me | current instance pointer (see Object Orientation) |
[in] | parent | pointer to the state-handler |
parent
state-handler, 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.qep_msm:890
|
private |