40Q_DEFINE_THIS_MODULE(
"qep_hsm")
44#define QHSM_MAX_NEST_DEPTH_ 6
46static QEvt const l_reservedEvt_[4] = {
57#define QHSM_RESERVED_EVT_(state_, sig_) \
58 ((*(state_))(me, &l_reservedEvt_[(sig_)]))
62#define QS_STATE_ACT_(rec_, state_) \
64 QS_BEGIN_PRE((rec_), qsId) \
71#define QS_TOP_INIT_(rec_, trg_) \
73 QS_BEGIN_PRE((rec_), qsId) \
81#define QS_TRAN_SEG_(rec_, src_, trg_) \
83 QS_BEGIN_PRE((rec_), qsId) \
91#define QS_TRAN_ACT_(rec_, state_) \
93 QS_BEGIN_PRE((rec_), qsId) \
101#define QS_TRAN0_(rec_, trg_) \
103 QS_BEGIN_PRE((rec_), qsId) \
105 QS_SIG_PRE(e->sig); \
112#define QS_TRAN_END_(rec_, src_, trg_) \
114 QS_BEGIN_PRE((rec_), qsId) \
116 QS_SIG_PRE(e->sig); \
124#define QS_STATE_ACT_(rec_, state_) ((void)0)
125#define QS_TOP_INIT_(rec_, trg_) ((void)0)
126#define QS_TRAN_SEG_(rec_, src_, trg_) ((void)0)
127#define QS_TRAN_ACT_(rec_, state_) ((void)0)
128#define QS_TRAN0_(rec_, trg_) ((void)0)
129#define QS_TRAN_END_(rec_, src_, trg_) ((void)0)
135static int_fast8_t QHsm_tran_simple_(
138 uint_fast8_t
const qsId);
141static int_fast8_t QHsm_tran_complex_(
144 uint_fast8_t
const qsId);
147static void QHsm_enter_target_(
150 int_fast8_t
const depth,
151 uint_fast8_t
const qsId);
176 void const *
const e,
177 uint_fast8_t
const qsId)
185 if ((QS_priv_.flags & 0x01U) == 0U) {
186 QS_priv_.flags |= 0x01U;
213 QS_TRAN_SEG_(QS_QEP_STATE_INIT, t, me->
temp.
fun);
234 QS_TOP_INIT_(QS_QEP_INIT_TRAN, t);
246 QEvt const *
const e,
247 uint_fast8_t
const qsId)
263 QS_TRAN0_(QS_QEP_DISPATCH, s);
271 for (; ip > 0; --ip) {
276 QS_TRAN_ACT_(QS_QEP_UNHANDLED, s);
290 QS_TRAN_SEG_(QS_QEP_TRAN_HIST, s, me->
temp.
fun);
303 QS_STATE_ACT_(QS_QEP_STATE_EXIT, t);
318 QS_TRAN_END_(QS_QEP_TRAN, s, t);
322 QS_TRAN0_(QS_QEP_INTERN_TRAN, s);
325 QS_TRAN0_(QS_QEP_IGNORED, me->
state.
fun);
338 bool inState =
false;
365 QEvt const *
const e)
378 bool isFound =
false;
408 uint_fast8_t
const qsId)
423 QS_STATE_ACT_(QS_QEP_STATE_EXIT, s);
445 QS_STATE_ACT_(QS_QEP_STATE_EXIT, s);
450 else if (me->
temp.
fun == path[0]) {
453 QS_STATE_ACT_(QS_QEP_STATE_EXIT, s);
471 uint_fast8_t
const qsId)
510 QS_STATE_ACT_(QS_QEP_STATE_EXIT, s);
535 QS_STATE_ACT_(QS_QEP_STATE_EXIT, t);
560 int_fast8_t
const depth,
561 uint_fast8_t
const qsId)
573 int_fast8_t ip = depth;
576 for (; ip >= 0; --ip) {
581 QS_STATE_ACT_(QS_QEP_STATE_ENTRY, path[ip]);
590 QS_TRAN_SEG_(QS_QEP_STATE_INIT, t, me->
temp.
fun);
617 QS_STATE_ACT_(QS_QEP_STATE_ENTRY, path[ip]);
#define QHSM_MAX_NEST_DEPTH_
#define Q_UNUSED_PAR(par_)
Helper macro to clearly 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)
QState(* QStateHandler)(void *const me, QEvt const *const e)
Pointer to a state-handler function.
#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)
#define Q_INIT_SIG
reserved signal sent to state handler to execute the initial transition)
#define Q_EMPTY_SIG
reserved signal sent to state handler to execute the default case)
#define QEVT_INITIALIZER(sig_)
Initializer for immutable (constant) QEvt instances.
uint_fast8_t QState
Type returned from state-handler functions.
#define QS_FUN_DICTIONARY(fun_)
#define Q_ASSERT_INCRIT(id_, expr_)
#define Q_INVARIANT_INCRIT(id_, expr_)
#define Q_REQUIRE_INCRIT(id_, expr_)
Abstract State Machine class (state machine interface)
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.
Virtual table for the QAsm class.
Hierarchical State Machine class (QHsm-style state machine implementation strategy)
QState QHsm_top(QHsm const *const me, QEvt const *const e)
static void QHsm_enter_target_(QAsm *const me, QStateHandler *const path, int_fast8_t const depth, uint_fast8_t const qsId)
static int_fast8_t QHsm_tran_simple_(QAsm *const me, QStateHandler *const path, uint_fast8_t const qsId)
QStateHandler QHsm_getStateHandler_(QAsm *const me)
void QHsm_ctor(QHsm *const me, QStateHandler const initial)
void QHsm_dispatch_(QAsm *const me, QEvt const *const e, uint_fast8_t const qsId)
bool QHsm_isIn_(QAsm *const me, QStateHandler const state)
void QHsm_init_(QAsm *const me, void const *const e, uint_fast8_t const qsId)
static int_fast8_t QHsm_tran_complex_(QAsm *const me, QStateHandler *const path, uint_fast8_t const qsId)
QStateHandler QHsm_childState(QHsm *const me, QStateHandler const parent)