40Q_DEFINE_THIS_MODULE(
"qep_hsm")
44#define QHSM_MAX_NEST_DEPTH_ ((size_t)6U)
49static QEvt const l_resEvt_[4] = {
65#define QS_STATE_ACT_(rec_, state_) \
67 QS_BEGIN_PRE((rec_), qsId) \
74#define QS_TOP_INIT_(rec_, trg_) \
76 QS_BEGIN_PRE((rec_), qsId) \
84#define QS_TRAN_SEG_(rec_, src_, trg_) \
86 QS_BEGIN_PRE((rec_), qsId) \
94#define QS_TRAN_ACT_(rec_, state_) \
96 QS_BEGIN_PRE((rec_), qsId) \
104#define QS_TRAN0_(rec_, trg_) \
106 QS_BEGIN_PRE((rec_), qsId) \
108 QS_SIG_PRE(e->sig); \
115#define QS_TRAN_END_(rec_, src_, trg_) \
117 QS_BEGIN_PRE((rec_), qsId) \
119 QS_SIG_PRE(e->sig); \
127#define QS_STATE_ACT_(rec_, state_) ((void)0)
128#define QS_TOP_INIT_(rec_, trg_) ((void)0)
129#define QS_TRAN_SEG_(rec_, src_, trg_) ((void)0)
130#define QS_TRAN_ACT_(rec_, state_) ((void)0)
131#define QS_TRAN0_(rec_, trg_) ((void)0)
132#define QS_TRAN_END_(rec_, src_, trg_) ((void)0)
149 me->super.
vptr = &vtable;
151 me->super.
temp.fun = initial;
160 return Q_RET_IGNORED;
166 void const *
const e,
167 uint_fast8_t
const qsId)
176 if ((
QS_priv_.flags & 0x01U) == 0U) {
218 path[ip] = me->
temp.fun;
223 }
while (me->
temp.fun != s);
230 me->
state.fun = path[0];
242 QEvt const *
const e,
243 uint_fast8_t
const qsId)
259 uintptr_t
const state_dis = me->
temp.uint;
270 size_t ip = QHSM_MAX_NEST_DEPTH_;
281 if (r == Q_RET_UNHANDLED) {
287 }
while (r == Q_RET_SUPER);
293 if (r == Q_RET_IGNORED) {
296 else if (r == Q_RET_HANDLED) {
299 else if ((r == Q_RET_TRAN) || (r == Q_RET_TRAN_HIST)) {
304 if (r == Q_RET_TRAN_HIST) {
309 path[0] = me->
temp.fun;
312 for (
size_t iq = QHSM_MAX_NEST_DEPTH_ - 1U; iq > ip; --iq) {
314 if ((*path[iq])(me, &l_resEvt_[
Q_EXIT_SIG]) == Q_RET_HANDLED) {
330 me->
state.fun = path[0];
347 uint_fast8_t
const qsId)
361 if ((*s)(me, &l_resEvt_[
Q_EXIT_SIG]) == Q_RET_HANDLED) {
385 if (me->temp.fun == t) {
387 if ((*s)(me, &l_resEvt_[
Q_EXIT_SIG]) == Q_RET_HANDLED) {
392 else if (me->temp.fun == path[0]) {
394 if ((*s)(me, &l_resEvt_[
Q_EXIT_SIG]) == Q_RET_HANDLED) {
414 uint_fast8_t
const qsId)
422 me->
temp.fun = path[1];
433 path[ip] = me->
temp.fun;
438 if (me->
temp.fun == s) {
442 }
while (r == Q_RET_SUPER);
452 if ((*s)(me, &l_resEvt_[
Q_EXIT_SIG]) == Q_RET_HANDLED) {
471 if (r != Q_RET_HANDLED) {
476 if ((*s)(me, &l_resEvt_[
Q_EXIT_SIG]) == Q_RET_HANDLED) {
492 }
while (r != Q_RET_HANDLED);
504 uint_fast8_t
const qsId)
519 if ((*path[ip])(me, &l_resEvt_[
Q_ENTRY_SIG]) == Q_RET_HANDLED) {
528 while ((*t)(me, &l_resEvt_[
Q_INIT_SIG]) == Q_RET_TRAN) {
540 path[ip] = me->
temp.fun;
551 }
while (me->
temp.fun != t);
557 if ((*path[ip])(me, &l_resEvt_[
Q_ENTRY_SIG]) == Q_RET_HANDLED) {
575 bool inState =
false;
581 if (s == stateHndl) {
589 }
while (r == Q_RET_SUPER);
608 bool isFound =
false;
612 me->super.
temp.fun = child;
616 if (me->super.
temp.fun == parentHndl) {
622 child = me->super.
temp.fun;
626 }
while (r == Q_RET_SUPER);
637 return me->super.
state.fun;
645 return me->
state.fun;
Private attributes of the QS software tracing target-resident component (TX channel).
#define Q_UNUSED_PAR(par_)
Helper macro to mark unused parameters of functions.
#define Q_STATE_CAST(handler_)
Perform cast to QStateHandler.
#define Q_EXIT_SIG
Reserved signal sent to state handler to execute the exit case. \clearpage .
#define Q_EVT_CAST(class_)
Perform downcast of an event onto a subclass of QEvt class_.
#define Q_ENTRY_SIG
Reserved signal sent to state handler to execute the entry case. \clearpage .
#define Q_INIT_SIG
Reserved signal sent to state handler to execute the initial transition. \clearpage \clearpage .
#define Q_EMPTY_SIG
Reserved signal sent to state handler to execute the default case. \clearpage .
QState(*) QStateHandler(void *const me, QEvt const *const e)
Pointer to a state-handler function.
#define QEVT_INITIALIZER(sig_)
Initializer for QEvt instances (base class).
uint_fast8_t QState
Type returned from state-handler functions.
QP/C Framework in C internal (package-scope) interface.
#define QP_DIS_UPDATE(T_, org_)
Update Duplicate Inverse Storage integer variable.
#define QP_DIS_VERIFY(T_, org_, dis_)
Verify integer variable against its Duplicate Inverse Storage.
#define QS_CRIT_STAT
Internal QS macro for defining the critical section status \clearpage .
#define QS_FUN_DICTIONARY(fun_)
Produce function dictionary (typically for state-handler functions).
@ QS_QEP_STATE_INIT
an initial transition was taken in a state
@ QS_QEP_TRAN_HIST
a tran. to history was taken
@ QS_QEP_STATE_EXIT
a state was exited
@ QS_QEP_INIT_TRAN
the top-most initial transition was taken
@ QS_QEP_INTERN_TRAN
an internal transition was taken
@ QS_QEP_STATE_ENTRY
a state was entered
@ QS_QEP_UNHANDLED
an event was un-handled due to a guard
@ QS_QEP_TRAN
a regular transition was taken
@ QS_QEP_DISPATCH
an event was dispatched (begin of RTC step)
@ QS_QEP_IGNORED
an event was ignored (silently discarded)
#define QS_CRIT_EXIT()
Internal macro for exiting a critical section \clearpage .
#define QS_CRIT_ENTRY()
Internal macro for entering a critical section \clearpage .
QS (QP/Spy software tracing) internal (package-scope) interface. \clearpage .
QP Functional Safety (FuSa) Subsystem (fault detection).
#define Q_REQUIRE_LOCAL(id_, expr_)
Assertion for checking a precondition (local critical section).
#define Q_ERROR_LOCAL(id_)
Assertion with user-specified ID for a wrong path through the code (local critical section).
#define Q_ENSURE_LOCAL(id_, expr_)
Assertion for checking a postcondition (local critical section).
#define Q_ASSERT_LOCAL(id_, expr_)
General-purpose assertion with user-specified ID number (local critical section).
#define Q_INVARIANT_LOCAL(id_, expr_)
Assertion for checking a postcondition (local critical section).
Abstract State Machine class (state machine interface).
struct QAsmVtable const * vptr
Virtual pointer inherited by all QAsm subclasses (see also [SAS_QP_TECH_20]).
union QAsmAttr state
Current state (pointer to the current state-handler function).
union QAsmAttr temp
Temporary storage for target/act-table etc..
Virtual table for the QAsm class.
Hierarchical State Machine class (QHsm-style implementation strategy).
bool QHsm_isIn_(QAsm *const me, QStateHandler const stateHndl)
Check if a given state is part of the current active state configuration.
void QHsm_enter_target_(QAsm *const me, QStateHandler *const path, size_t const depth, uint_fast8_t const qsId)
Implementation of entry to the target state configuration.
QStateHandler QHsm_childState(QHsm *const me, QStateHandler const parentHndl)
Obtain the current active child state of a given parent in QHsm.
size_t QHsm_tran_simple_(QAsm *const me, QStateHandler *const path, uint_fast8_t const qsId)
Implementation of a simple state transition segment.
void QHsm_ctor(QHsm *const me, QStateHandler const initial)
Constructor of the QHsm base class.
QStateHandler QHsm_state(QHsm const *const me)
Obtain the current active state from a HSM (read only).
QStateHandler QHsm_getStateHandler_(QAsm const *const me)
Implementation of getting the state handler in an QHsm subclass.
void QHsm_dispatch_(QAsm *const me, QEvt const *const e, uint_fast8_t const qsId)
Implementation of dispatching events to a QHsm.
void QHsm_init_(QAsm *const me, void const *const e, uint_fast8_t const qsId)
Implementation of the top-most initial transition in QHsm.
size_t QHsm_tran_complex_(QAsm *const me, QStateHandler *const path, uint_fast8_t const qsId)
Implementation of a complex state transition segment.