51 #include "qs_dummy.hpp"
59Q_DEFINE_THIS_MODULE(
"qep_hsm")
62static
QP::QEvt const l_reservedEvt_[4] {
72#define QHSM_RESERVED_EVT_(state_, sig_) \
73 ((*(state_))(this, &l_reservedEvt_[(sig_)]))
76#define QS_STATE_ENTRY_(state_, qsId_) \
79 QS_BEGIN_PRE_(QS_QEP_STATE_ENTRY, (qsId_)) \
81 QS_FUN_PRE_(state_); \
87#define QS_STATE_EXIT_(state_, qsId_) \
90 QS_BEGIN_PRE_(QS_QEP_STATE_EXIT, (qsId_)) \
92 QS_FUN_PRE_(state_); \
102#if (QP_VERSION < 730U) || (QP_VERSION != ((QP_RELEASE^4294967295U) % 0x3E8U))
103#error qpcpp version 7.3.0 or higher required
123 m_temp.fun = initial;
128 void const *
const e,
129 std::uint_fast8_t
const qsId)
136 if ((QS::priv_.flags & 0x01U) == 0U) {
137 QS::priv_.flags |= 0x01U;
178 std::int_fast8_t ip = 0;
201 QS_STATE_ENTRY_(path[ip], qsId);
250 QEvt const *
const e,
251 std::uint_fast8_t
const qsId)
316 for (; (t != s) && (limit > 0); t =
m_temp.
fun) {
319 QS_STATE_EXIT_(t, qsId);
321 static_cast<void>(QHSM_RESERVED_EVT_(t,
Q_EMPTY_SIG));
329 std::int_fast8_t ip =
hsm_tran(path, qsId);
338 QS_FUN_PRE_(path[0]);
346 for (; ip >= 0; --ip) {
351 QS_STATE_ENTRY_(path[ip], qsId);
397 QS_STATE_ENTRY_(path[ip], qsId);
456 ==
static_cast<std::uintptr_t
>(~m_temp.uint));
459 bool inState =
false;
463 std::int_fast8_t limit = MAX_NEST_DEPTH_ + 1;
465 for (; (r != Q_RET_IGNORED) && (limit > 0); --limit) {
471 r = QHSM_RESERVED_EVT_(s, Q_EMPTY_SIG);
481 m_temp.uint = ~m_state.uint;
490 bool isFound =
false;
497 if (m_temp.fun == parent) {
503 r = QHSM_RESERVED_EVT_(m_temp.fun, Q_EMPTY_SIG);
505 }
while (r != Q_RET_IGNORED);
508 m_temp.uint = ~m_state.uint;
522 std::uint_fast8_t
const qsId)
528 std::int_fast8_t ip = -1;
537 QS_STATE_EXIT_(s, qsId);
543 static_cast<void>(QHSM_RESERVED_EVT_(t,
Q_EMPTY_SIG));
553 static_cast<void>(QHSM_RESERVED_EVT_(s,
Q_EMPTY_SIG));
559 QS_STATE_EXIT_(s, qsId);
568 QS_STATE_EXIT_(s, qsId);
574 std::int_fast8_t iq = 0;
607 QS_STATE_EXIT_(s, qsId);
636 QS_STATE_EXIT_(t, qsId);
Abstract State Machine class (state machine interface)
@ Q_RET_HANDLED
event handled (internal transition)
@ Q_RET_IGNORED
event silently ignored (bubbled up to top)
@ Q_RET_UNHANDLED
event unhandled due to a guard
@ Q_RET_TRAN
regular transition
@ Q_RET_TRAN_HIST
transition to history of a given state
@ Q_RET_SUPER
event passed to superstate to handle
static QState top(void *const me, QEvt const *const e) noexcept
@ Q_EXIT_SIG
signal for exit actions
@ Q_INIT_SIG
signal for nested initial transitions
@ Q_ENTRY_SIG
signal for entry actions
@ Q_EMPTY_SIG
signal to execute the default case
static bool verify_(QEvt const *const e) noexcept
static constexpr std::int_fast8_t MAX_NEST_DEPTH_
QStateHandler childState(QStateHandler const parent) noexcept
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
bool isIn(QStateHandler const state) noexcept override
std::int_fast8_t hsm_tran(QStateHandler(&path)[MAX_NEST_DEPTH_], std::uint_fast8_t const qsId)
void init(void const *const e, std::uint_fast8_t const qsId) override
QHsm(QStateHandler const initial) noexcept
QState(*)(void *const me, QEvt const *const e) QStateHandler
@ QS_QEP_DISPATCH
an event was dispatched (begin of RTC step)
@ QS_QEP_TRAN_HIST
a tran to history was taken
@ QS_QEP_IGNORED
an event was ignored (silently discarded)
@ QS_QEP_UNHANDLED
an event was un-handled due to a guard
@ QS_QEP_STATE_INIT
an initial transition was taken in a state
@ QS_QEP_TRAN
a regular transition was taken
@ QS_QEP_INIT_TRAN
the top-most initial transition was taken
@ QS_QEP_INTERN_TRAN
an internal transition was taken
#define Q_EVT_CAST(subclass_)
#define Q_UNUSED_PAR(par_)
#define Q_STATE_CAST(handler_)
Internal (package scope) QP/C++ interface.
#define QS_FUN_DICTIONARY(fun_)
QS/C++ package-scope interface.
QS/C++ port to a 32-bit CPU, generic C++ compiler.
QP Functional Safety (FuSa) Subsystem.
#define Q_ASSERT_INCRIT(id_, expr_)
#define Q_ENSURE_INCRIT(id_, expr_)
#define Q_REQUIRE_INCRIT(id_, expr_)