QEP/C platform-independent public interface. More...
Go to the source code of this file.
Classes | |
class | QEvt |
Event class. More... | |
struct | QMState |
State object for the QMsm class (QM State Machine). More... | |
struct | QMTranActTable |
Transition-Action Table for the QMsm State Machine. More... | |
union | QHsmAttr |
Attribute of for the QHsm class (Hierarchical State Machine). More... | |
class | QHsm |
Hierarchical State Machine class. More... | |
struct | QHsmVtable |
Virtual table for the QHsm class. More... | |
class | QMsm |
QM state machine implementation strategy. More... | |
Macros | |
#define | QP_VERSION 722U |
#define | QP_VERSION_STR "7.2.2" |
#define | QP_RELEASE 0x76BAD85DU |
#define | Q_SIGNAL_SIZE 2U |
#define | QHSM_INIT(me_, par_, qs_id_) |
#define | QHSM_DISPATCH(me_, e_, qs_id_) ((*(me_)->vptr->dispatch)((me_), (e_), (qs_id_))) |
#define | Q_HSM_UPCAST(ptr_) ((QHsm *)(ptr_)) |
#define | Q_TRAN(target_) ((Q_HSM_UPCAST(me))->temp.fun = Q_STATE_CAST(target_), Q_RET_TRAN) |
#define | Q_TRAN_HIST(hist_) ((Q_HSM_UPCAST(me))->temp.fun = (hist_), Q_RET_TRAN_HIST) |
#define | Q_SUPER(super_) ((Q_HSM_UPCAST(me))->temp.fun = Q_STATE_CAST(super_), Q_RET_SUPER) |
#define | Q_HANDLED() (Q_RET_HANDLED) |
#define | Q_UNHANDLED() (Q_RET_UNHANDLED) |
#define | Q_ACTION_NULL ((QActionHandler)0) |
#define | Q_EVT_CAST(class_) ((class_ const *)(e)) |
#define | Q_STATE_CAST(handler_) ((QStateHandler)(handler_)) |
#define | Q_ACTION_CAST(action_) ((QActionHandler)(action_)) |
#define | Q_UNUSED_PAR(par_) ((void)(par_)) |
#define | Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U])) |
#define | Q_UINT2PTR_CAST(type_, uint_) ((type_ *)(uint_)) |
#define | QEVT_INITIALIZER(sig_) { (QSignal)(sig_), 0U, 0U } |
#define | QM_ENTRY(state_) ((Q_HSM_UPCAST(me))->temp.obj = (state_), Q_RET_ENTRY) |
#define | QM_EXIT(state_) ((Q_HSM_UPCAST(me))->temp.obj = (state_), Q_RET_EXIT) |
#define | QM_SM_EXIT(state_) ((Q_HSM_UPCAST(me))->temp.obj = (state_), Q_RET_EXIT) |
#define | QM_TRAN(tatbl_) |
#define | QM_TRAN_INIT(tatbl_) |
#define | QM_TRAN_HIST(history_, tatbl_) |
#define | QM_TRAN_EP(tatbl_) |
#define | QM_TRAN_XP(xp_, tatbl_) |
#define | QM_HANDLED() (Q_RET_HANDLED) |
#define | QM_UNHANDLED() (Q_RET_UNHANDLED) |
#define | QM_SUPER() (Q_RET_SUPER) |
#define | QM_SUPER_SUB(host_) ((Q_HSM_UPCAST(me))->temp.obj = (host_), Q_RET_SUPER_SUB) |
#define | QM_STATE_NULL ((QMState *)0) |
Typedefs | |
typedef int | int_t |
typedef int | enum_t |
typedef float | float32_t |
typedef double | float64_t |
typedef uint16_t | QSignal |
typedef enum QStateRet | QState |
typedef QState(* | QStateHandler) (void *const me, QEvt const *const e) |
typedef QState(* | QActionHandler) (void *const me) |
typedef void(* | QXThreadHandler) (struct QXThread *const me) |
Enumerations | |
enum | QStateRet { 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 } |
enum | QReservedSig { Q_EMPTY_SIG , Q_ENTRY_SIG , Q_EXIT_SIG , Q_INIT_SIG , Q_USER_SIG } |
Functions | |
int_fast8_t | QHsm_tran_ (QHsm *const me, QStateHandler *const path, uint_fast8_t const qs_id) |
Variables | |
char const | QP_versionStr [8] |
struct QMState |
This class groups together the attributes of a QMsm state, such as the parent state (state nesting), the associated state handler function and the exit action handler function. These attributes are used inside the QMsm_dispatch() and QMsm_init() functions.
Class Members | ||
---|---|---|
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 |
Class Members | ||
---|---|---|
QMState const * | target |
target of the transition |
QActionHandler const | act[1] |
array of actions |
#define QP_VERSION 722U |
The current QP version as an unsigned number
QP_VERSION is a decimal constant, where XX is a 1-digit or 2-digit major version number, Y is a 1-digit minor version number, and Z is a 1-digit release number.
#define QP_VERSION_STR "7.2.2" |
The current QP version as a zero terminated string literal.
QP_VERSION_STR is of the form "XX.Y.Z", where XX is a 1-or 2-digit major version number, Y is a 1-digit minor version number, and Z is a 1-digit release number.
#define QP_RELEASE 0x76BAD85DU |
#define Q_SIGNAL_SIZE 2U |
The size (in bytes) of the signal of an event. Valid values: 1U, 2U, or 4U; default 2U
This macro can be defined in the QEP port file (qep_port.h) to configure the QSignal type. When the macro is not defined, the default of 2 bytes is applied.
#define QHSM_INIT | ( | me_, | |
par_, | |||
qs_id_ | |||
) |
Virtual call to the top-most initial transition in a HSM.
[in,out] | me_ | current instance pointer (see oop) |
[in] | par_ | pointer the optional initialization parameter |
[in] | qs_id_ | QS local filter ID (used only when Q_SPY is defined) |
#define QHSM_DISPATCH | ( | me_, | |
e_, | |||
qs_id_ | |||
) | ((*(me_)->vptr->dispatch)((me_), (e_), (qs_id_))) |
Virtual call to dispatch an event to a HSM
Processes one event at a time in Run-to-Completion fashion.
[in,out] | me_ | current instance pointer (see oop) |
[in] | e_ | constant pointer the QEvt or a class derived from QEvt (see oop) |
[in] | qs_id_ | QS local filter ID (used only when Q_SPY is defined) |
#define Q_HSM_UPCAST | ( | ptr_ | ) | ((QHsm *)(ptr_)) |
Perform upcast from a subclass of QHsm to the base class QHsm
Upcasting from a subclass to superclass is a very frequent and safe operation in object-oriented programming and object-oriented languages (such as C++) perform such upcasting automatically. However, OOP is implemented in C just as a set of coding conventions (see oop), and the C compiler does not "know" that certain types are related by inheritance. Therefore for C, the upcast must be performed explicitly. Unfortunately, pointer casting violates the advisory MISRA-C 2012 Rule 11.3(req) "A cast shall not be performed between a pointer to object type and a pointer to a different object type". This macro encapsulates this deviation and provides a descriptive name for the reason of this cast.
#define Q_TRAN | ( | target_ | ) | ((Q_HSM_UPCAST(me))->temp.fun = Q_STATE_CAST(target_), Q_RET_TRAN) |
Perform upcast from a subclass of QHsm to the base class QHsm
Upcasting from a subclass to superclass is a very frequent and safe operation in object-oriented programming and object-oriented languages (such as C++) perform such upcasting automatically. However, OOP is implemented in C just as a set of coding conventions (see oop), and the C compiler does not "know" that certain types are related by inheritance. Therefore for C, the upcast must be performed explicitly. Unfortunately, pointer casting violates the advisory MISRA-C 2012 Rule 11.3(req) "A cast shall not be performed between a pointer to object type and a pointer to a different object type". This macro encapsulates this deviation and provides a descriptive name for the reason of this cast.
#define Q_TRAN_HIST | ( | hist_ | ) | ((Q_HSM_UPCAST(me))->temp.fun = (hist_), 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_), 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 | ( | ) | (Q_RET_HANDLED) |
Macro to call in a state-handler when it handles an event.
#define Q_UNHANDLED | ( | ) | (Q_RET_UNHANDLED) |
#define Q_ACTION_NULL ((QActionHandler)0) |
#define Q_EVT_CAST | ( | class_ | ) | ((class_ const *)(e)) |
Perform downcast of an event onto a subclass of QEvt class_
This macro encapsulates the downcast of QEvt pointers, which violates MISRA-C 2012 Rule 11.3(R) "A cast shall not be performed between a pointer to object type and a pointer to a different object type". This macro helps to localize this deviation.
class_ | a subclass of QEvt |
#define Q_STATE_CAST | ( | handler_ | ) | ((QStateHandler)(handler_)) |
Perform cast to QStateHandler.
This macro encapsulates the cast of a specific state handler function pointer to QStateHandler, which violates MISRA:C-2012 Rule 11.1(req) "Conversions shall not be performed between a pointer to function and any other type". This macro helps to localize this deviation.
#define Q_ACTION_CAST | ( | action_ | ) | ((QActionHandler)(action_)) |
Perform cast to QActionHandler.
This macro encapsulates the cast of a specific action handler function pointer to QActionHandler, which violates MISRA:C-2012 Rule 11.1(R) "Conversions shall not be performed between a pointer to function and any other type". This macro helps to localize this deviation.
#define Q_UNUSED_PAR | ( | par_ | ) | ((void)(par_)) |
#define Q_DIM | ( | array_ | ) | (sizeof(array_) / sizeof((array_)[0U])) |
#define Q_UINT2PTR_CAST | ( | type_, | |
uint_ | |||
) | ((type_ *)(uint_)) |
Perform cast from unsigned integer uint_
to pointer of type type_
This macro encapsulates the cast to (type_ *), which QP ports or application might use to access embedded hardware registers. Such uses can trigger PC-Lint "Note 923: cast from int to pointer" and this macro helps to encapsulate this deviation.
#define QEVT_INITIALIZER | ( | sig_ | ) | { (QSignal)(sig_), 0U, 0U } |
Initializer of static constant QEvt instances
This macro encapsulates the ugly casting of enumerated signals to QSignal and constants for QEvt.poolID and QEvt.refCtr_.
#define QM_ENTRY | ( | state_ | ) | ((Q_HSM_UPCAST(me))->temp.obj = (state_), Q_RET_ENTRY) |
#define QM_EXIT | ( | state_ | ) | ((Q_HSM_UPCAST(me))->temp.obj = (state_), Q_RET_EXIT) |
#define QM_SM_EXIT | ( | state_ | ) | ((Q_HSM_UPCAST(me))->temp.obj = (state_), 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 | ( | ) | (Q_RET_HANDLED) |
#define QM_UNHANDLED | ( | ) | (Q_RET_UNHANDLED) |
#define QM_SUPER | ( | ) | (Q_RET_SUPER) |
#define QM_SUPER_SUB | ( | host_ | ) | ((Q_HSM_UPCAST(me))->temp.obj = (host_), Q_RET_SUPER_SUB) |
#define QM_STATE_NULL ((QMState *)0) |
typedef int int_t |
typedef int enum_t |
typedef float float32_t |
alias for IEEE 754 32-bit floating point number, MISRA-C 2012 Dir 4.6(A)
typedef double float64_t |
alias for IEEE 754 64-bit floating point number, MISRA-C 2012 Dir 4.6(A)
typedef uint16_t QSignal |
QSignal represents the signal of an event
The relationship between an event and a signal is as follows. A signal in UML is the specification of an asynchronous stimulus that triggers reactions, and as such is an essential part of an event. (The signal conveys the type of the occurrence–what happened?) However, an event can also contain additional quantitative information about the occurrence in form of event parameters.
typedef QState(* QActionHandler) (void *const me) |
typedef void(* QXThreadHandler) (struct QXThread *const me) |
enum QStateRet |
All possible values returned from state/action handlers
enum QReservedSig |
Reserved signals by the HSM-style state machine implementation strategy.
int_fast8_t QHsm_tran_ | ( | QHsm *const | me, |
QStateHandler *const | path, | ||
uint_fast8_t const | qs_id | ||
) |
Helper function to execute transition sequence in a hierarchical state machine (HSM).
[in,out] | path | array of pointers to state-handler functions to execute the entry actions |
[in] | qs_id | QS-id of this state machine (for QS local filter) |
path
parameter.
|
extern |
the current QP version number string in ROM, based on QP_VERSION_STR