Public QEP/C interface. More...
Go to the source code of this file.
Data Structures | |
struct | QEvt |
Event structure. More... | |
union | QHsmAttr |
Attribute of for the QHsm class (Hierarchical State Machine). More... | |
struct | QHsm |
struct | QMsmVtbl |
Virtual table for the QHsm class. More... | |
struct | QMState |
State object for the QMsm class (QM State Machine). More... | |
struct | QMTranActTable |
Transition-Action Table for the Meta State Machine. More... | |
Macros | |
#define | QP_VERSION 640U |
The current QP version as a decimal constant XYZ, where X is a 1-digit major version number, Y is a 1-digit minor version number, and Z is a 1-digit release number. More... | |
#define | QP_VERSION_STR "6.4.0" |
The current QP version number string of the form X.Y.Z, where X is a 1-digit major version number, Y is a 1-digit minor version number, and Z is a 1-digit release number. More... | |
#define | QP_RELEASE 0x8EA03F5FU |
Tamperproof current QP release (6.4.0) and date (2019-02-10) More... | |
#define | QEP_getVersion() (QP_versionStr) |
get the current QEP version number string of the form "X.Y.Z" More... | |
#define | Q_SIGNAL_SIZE 2 |
The size (in bytes) of the signal of an event. More... | |
#define | Q_HSM_UPCAST(ptr_) ((QHsm *)(ptr_)) |
Perform upcast from a subclass of QHsm to the base class QHsm. More... | |
#define | Q_EVT_CAST(class_) ((class_ const *)e) |
Perform downcast of an event onto a subclass of QEvt class_ . More... | |
#define | Q_UINT2PTR_CAST(type_, uint_) ((type_ *)(uint_)) |
Perform cast from unsigned integer uint_ to pointer of type type_ . More... | |
#define | Q_STATE_CAST(handler_) ((QStateHandler)(handler_)) |
Perform cast to QStateHandler. More... | |
#define | Q_ACTION_CAST(action_) ((QActionHandler)(action_)) |
Perform cast to QActionHandler. More... | |
#define | QHSM_INIT(me_, e_) |
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... | |
#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... | |
#define | Q_TRAN(target_) ((Q_HSM_UPCAST(me))->temp.fun = Q_STATE_CAST(target_), (QState)Q_RET_TRAN) |
Macro to call in a state-handler when it executes a regular or and initial transition. More... | |
#define | Q_TRAN_HIST(hist_) ((Q_HSM_UPCAST(me))->temp.fun = (hist_), (QState)Q_RET_TRAN_HIST) |
Macro to call in a state-handler when it executes a transition to history. More... | |
#define | Q_SUPER(super_) ((Q_HSM_UPCAST(me))->temp.fun = Q_STATE_CAST(super_), (QState)Q_RET_SUPER) |
Macro to call in a state-handler when it designates the superstate of a given state. More... | |
#define | Q_HANDLED() ((QState)Q_RET_HANDLED) |
Macro to call in a state-handler when it handles an event. More... | |
#define | Q_UNHANDLED() ((QState)Q_RET_UNHANDLED) |
Macro to call in a state-handler when it attempts to handle an event but a guard condition evaluates to 'false' and there is no other explicit way of handling the event. More... | |
#define | QM_ENTRY(state_) ((Q_HSM_UPCAST(me))->temp.obj = (state_), (QState)Q_RET_ENTRY) |
Macro to call in a QM action-handler when it executes an entry action. More... | |
#define | QM_EXIT(state_) ((Q_HSM_UPCAST(me))->temp.obj = (state_), (QState)Q_RET_EXIT) |
Macro to call in a QM action-handler when it executes an exit action. More... | |
#define | QM_SM_EXIT(state_) ((Q_HSM_UPCAST(me))->temp.obj = (state_), (QState)Q_RET_EXIT) |
Macro to call in a QM submachine exit-handler. More... | |
#define | QM_TRAN(tatbl_) |
Macro to call in a QM state-handler when it executes a regular transition. More... | |
#define | QM_TRAN_INIT(tatbl_) |
Macro to call in a QM state-handler when it executes an initial transition. More... | |
#define | QM_TRAN_HIST(history_, tatbl_) |
Macro to call in a QM state-handler when it executes a transition to history. More... | |
#define | QM_TRAN_EP(tatbl_) |
Macro to call in a QM state-handler when it executes a transition to the submachine via an entry point. More... | |
#define | QM_TRAN_XP(xp_, tatbl_) |
Macro to call in a QM state-handler when it executes a transition to exit point. More... | |
#define | QM_HANDLED() ((QState)Q_RET_HANDLED) |
Macro to call in a QM state-handler when it handled an event. More... | |
#define | QM_UNHANDLED() ((QState)Q_RET_UNHANDLED) |
Macro to call in a QM state-handler when when it attempts to handle an event but a guard condition evaluates to 'false' and there is no other explicit way of handling the event. More... | |
#define | QM_SUPER() ((QState)Q_RET_SUPER) |
Macro to call in a QM state-handler when it designates the superstate to handle an event. More... | |
#define | QM_SUPER_SUB(host_) ((Q_HSM_UPCAST(me))->temp.obj = (host_), (QState)Q_RET_SUPER_SUB) |
Macro to call in a QM submachine-handler when it designates the host state to handle an event. More... | |
Typedefs | |
typedef char | char_t |
typedef for character strings. More... | |
typedef int | int_t |
typedef for line numbers in assertions and return from QF_run() More... | |
typedef int | enum_t |
typedef for enumerations used for event signals More... | |
typedef float | float32_t |
IEEE 754 32-bit floating point number, MISRA-C 2004 rule 6.3(req) More... | |
typedef double | float64_t |
IEEE 754 64-bit floating point number, MISRA-C 2004 rule 6.3(req) More... | |
typedef uint16_t | QSignal |
QSignal represents the signal of an event. More... | |
typedef uint_fast8_t | QState |
typedef of the return type from a state/action-handler function. More... | |
typedef QState(* | QStateHandler) (void *const me, QEvt const *const e) |
Pointer to a state-handler function. More... | |
typedef QState(* | QActionHandler) (void *const me) |
Pointer to an action-handler function. More... | |
typedef QHsm | QMsm |
QM State Machine implementation strategy. More... | |
Enumerations | |
enum | { Q_RET_SUPER, Q_RET_SUPER_SUB, Q_RET_UNHANDLED, Q_RET_HANDLED, Q_RET_IGNORED, Q_RET_ENTRY, Q_RET_EXIT, Q_RET_NULL, Q_RET_TRAN, Q_RET_TRAN_INIT, Q_RET_TRAN_EP, Q_RET_TRAN_HIST, Q_RET_TRAN_XP } |
All possible values returned from state/action handlers. More... | |
enum | { Q_ENTRY_SIG = 1, Q_EXIT_SIG, Q_INIT_SIG, Q_USER_SIG } |
QEP reserved signals. More... | |
Functions | |
void | QHsm_ctor (QHsm *const me, QStateHandler initial) |
Protected "constructor" of QHsm. More... | |
void | QHsm_init_ (QHsm *const me, QEvt const *const e) |
Implementation of the top-most initial transition in QHsm subclass. More... | |
void | QHsm_dispatch_ (QHsm *const me, QEvt const *const e) |
Implementation of dispatching events to a QHsm subclass. More... | |
QStateHandler | QHsm_childState_ (QHsm *const me, QStateHandler const parent) |
Helper function to obtain the current active child state of a parent. 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... | |
QState | QHsm_top (void const *const me, QEvt const *const e) |
the top-state. More... | |
void | QMsm_ctor (QMsm *const me, QStateHandler initial) |
Protected "constructor" of QMsm. More... | |
void | QMsm_init_ (QMsm *const me, QEvt const *const e) |
Implementation of the top-most initial transition in QMsm. More... | |
void | QMsm_dispatch_ (QMsm *const me, QEvt const *const e) |
Implementation of disparching events to 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... | |
Variables | |
char_t const | QP_versionStr [6] |
the current QP version number string in ROM, based on QP_VERSION_STR More... | |
Public QEP/C interface.
Definition in file qep.h.
struct QEvt |
Event structure.
Data Fields | ||
---|---|---|
QSignal | sig | signal of the event instance |
uint8_t | poolId_ | pool ID (0 for static event) |
uint8_t volatile | refCtr_ | reference counter |
union QHsmAttr |
Attribute of for the QHsm class (Hierarchical State Machine).
Data Fields | ||
---|---|---|
QStateHandler | fun | pointer to a state-handler function |
QActionHandler | act | pointer to an action-handler function |
struct QMState const * | obj | pointer to QMState object |
struct QMTranActTable const * | tatbl | transition-action table |
struct QHsm |
Data Fields | ||
---|---|---|
struct QHsmVtbl const * | vptr | virtual pointer |
union QHsmAttr | state | current active state (state-variable) |
union QHsmAttr | temp |
temporary: tran. chain, target state, etc. |
struct QMState |
State object for the QMsm class (QM State Machine).
Data Fields | ||
---|---|---|
struct QMState const * | superstate | superstate of this state |
QStateHandler const | stateHandler | state handler function |
QActionHandler const | entryAction | entry action handler function |
QActionHandler const | exitAction | exit action handler function |
QActionHandler const | initAction | init action handler function |
struct QMTranActTable |
Data Fields | ||
---|---|---|
QMState const * | target | |
QActionHandler const | act[1] |
#define QP_VERSION 640U |
#define QP_VERSION_STR "6.4.0" |
#define QP_RELEASE 0x8EA03F5FU |
#define QEP_getVersion | ( | ) | (QP_versionStr) |
#define Q_SIGNAL_SIZE 2 |
#define Q_HSM_UPCAST | ( | ptr_ | ) | ((QHsm *)(ptr_)) |
Perform upcast from a subclass of QHsm to the base class QHsm.
#define Q_EVT_CAST | ( | class_ | ) | ((class_ const *)e) |
#define Q_UINT2PTR_CAST | ( | type_, | |
uint_ | |||
) | ((type_ *)(uint_)) |
Perform cast from unsigned integer uint_
to pointer of type type_
.
#define Q_STATE_CAST | ( | handler_ | ) | ((QStateHandler)(handler_)) |
Perform cast to QStateHandler.
#define Q_ACTION_CAST | ( | action_ | ) | ((QActionHandler)(action_)) |
Perform cast to QActionHandler.
#define QHSM_INIT | ( | me_, | |
e_ | |||
) |
Polymorphically executes the top-most initial transition in a HSM.
[in,out] | me_ | pointer (see Object Orientation) |
[in] | e_ | constant pointer the QEvt or a class derived from QEvt (see Object Orientation) |
#define QHSM_DISPATCH | ( | me_, | |
e_ | |||
) | ((*(me_)->vptr->dispatch)((me_), (e_))) |
Polymorphically dispatches an event to a HSM.
[in,out] | me_ | pointer (see Object Orientation) |
[in] | e_ | constant pointer the QEvt or a structure derived from QEvt (see Object Orientation) |
#define QHsm_state | ( | me_ | ) | (Q_STATE_CAST(Q_HSM_UPCAST(me_)->state.fun)) |
Obtain the current active state from a HSM (read only).
[in] | me_ | pointer (see Object Orientation) |
#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.
[in] | me_ | pointer (see Object Orientation) |
[in] | parent_ | pointer to the parent state-handler |
#define QMsm_stateObj | ( | me_ | ) | (Q_HSM_UPCAST(me_)->state.obj) |
Obtain the current active state from a MSM (read only)
[in] | me_ | pointer (see Object Orientation) |
#define QMsm_childStateObj | ( | me_, | |
parent_ | |||
) | QMsm_childStateObj_(Q_HSM_UPCAST(me_), (parent_)) |
Obtain the current active child state of a given parent in QMsm.
[in] | me_ | pointer (see Object Orientation) |
[in] | parent_ | pointer to the parent state-object |
#define Q_TRAN | ( | target_ | ) | ((Q_HSM_UPCAST(me))->temp.fun = Q_STATE_CAST(target_), (QState)Q_RET_TRAN) |
Macro to call in a state-handler when it executes a regular or and initial transition.
Applicable only to QHsm subclasses.
#define Q_TRAN_HIST | ( | hist_ | ) | ((Q_HSM_UPCAST(me))->temp.fun = (hist_), (QState)Q_RET_TRAN_HIST) |
Macro to call in a state-handler when it executes a transition to history.
Applicable only to HSMs.
#define Q_SUPER | ( | super_ | ) | ((Q_HSM_UPCAST(me))->temp.fun = Q_STATE_CAST(super_), (QState)Q_RET_SUPER) |
Macro to call in a state-handler when it designates the superstate of a given state.
Applicable only to QHsm subclasses.
#define Q_HANDLED | ( | ) | ((QState)Q_RET_HANDLED) |
#define Q_UNHANDLED | ( | ) | ((QState)Q_RET_UNHANDLED) |
#define QM_ENTRY | ( | state_ | ) | ((Q_HSM_UPCAST(me))->temp.obj = (state_), (QState)Q_RET_ENTRY) |
#define QM_EXIT | ( | state_ | ) | ((Q_HSM_UPCAST(me))->temp.obj = (state_), (QState)Q_RET_EXIT) |
#define QM_SM_EXIT | ( | state_ | ) | ((Q_HSM_UPCAST(me))->temp.obj = (state_), (QState)Q_RET_EXIT) |
#define QM_TRAN | ( | tatbl_ | ) |
Macro to call in a QM state-handler when it executes a regular transition.
Applicable only to QMsm subclasses.
#define QM_TRAN_INIT | ( | tatbl_ | ) |
Macro to call in a QM state-handler when it executes an initial transition.
Applicable only to QMsm subclasses.
#define QM_TRAN_HIST | ( | history_, | |
tatbl_ | |||
) |
Macro to call in a QM state-handler when it executes a transition to history.
Applicable only to QMsm subclasses.
#define QM_TRAN_EP | ( | tatbl_ | ) |
Macro to call in a QM state-handler when it executes a transition to the submachine via an entry point.
#define QM_TRAN_XP | ( | xp_, | |
tatbl_ | |||
) |
Macro to call in a QM state-handler when it executes a transition to exit point.
Applicable only to QMsm subclasses.
#define QM_HANDLED | ( | ) | ((QState)Q_RET_HANDLED) |
#define QM_UNHANDLED | ( | ) | ((QState)Q_RET_UNHANDLED) |
#define QM_SUPER | ( | ) | ((QState)Q_RET_SUPER) |
#define QM_SUPER_SUB | ( | host_ | ) | ((Q_HSM_UPCAST(me))->temp.obj = (host_), (QState)Q_RET_SUPER_SUB) |
typedef char char_t |
typedef int int_t |
typedef int enum_t |
typedef float float32_t |
IEEE 754 32-bit floating point number, MISRA-C 2004 rule 6.3(req)
typedef double float64_t |
IEEE 754 64-bit floating point number, MISRA-C 2004 rule 6.3(req)
QSignal represents the signal of an event.
typedef uint_fast8_t QState |
typedef QState(* QActionHandler) (void *const me) |
QM State Machine implementation strategy.
anonymous enum |
All possible values returned from state/action handlers.
anonymous enum |
void QHsm_ctor | ( | QHsm *const | me, |
QStateHandler | initial | ||
) |
Protected "constructor" of QHsm.
[in,out] | me | pointer (see Object Orientation) |
[in] | initial | pointer to the top-most initial state-handler function in the derived state machine |
Implementation of the top-most initial transition in QHsm subclass.
[in,out] | me | pointer (see Object Orientation) |
[in] | e | pointer to the initialization event (might be NULL) |
Implementation of dispatching events to a QHsm subclass.
[in,out] | me | pointer (see Object Orientation) |
[in] | e | pointer to the event to be dispatched to the HSM |
QStateHandler QHsm_childState_ | ( | QHsm *const | me, |
QStateHandler const | parent | ||
) |
Helper function to obtain the current active child state of a parent.
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 QHsm.[in] | me | pointer (see Object Orientation) |
[in] | parent | pointer to the state-handler function |
parent
state, which is an ancestor of the current active state. For the corner case when the currently active state is the given parent
state, function returns the parent
state.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.
[in] | me | pointer (see Object Orientation) |
[in] | state | pointer to the state-handler function to be tested |
state
and 'false' otherwise the top-state.
[in] | me | pointer (see Object Orientation) |
[in] | e | pointer to the event to be dispatched to the FSM |
void QMsm_ctor | ( | QMsm *const | me, |
QStateHandler | initial | ||
) |
Protected "constructor" of QMsm.
[in,out] | me | pointer (see Object Orientation) |
[in] | initial | the top-most initial transition for the MSM. |
Implementation of the top-most initial transition in QMsm.
[in,out] | me | pointer (see Object Orientation) |
[in] | e | pointer to the initialization event (might be NULL) |
Implementation of disparching events to QMsm.
[in,out] | me | pointer (see Object Orientation) |
[in] | e | pointer to the event to be dispatched to the MSM |
Helper function to obtain the current active child state of a parent.
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 | pointer (see Object Orientation) |
[in] | parent | pointer to the state-handler object |
parent
state, 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.Tests if a given state is part of the current active state configuration in a MSM.
[in] | me | pointer (see Object Orientation) |
[in] | state | pointer to the QMState object that corresponds to the tested state. |
state
and 'false' otherwise