37 #include "qs_dummy.hpp"
43Q_DEFINE_THIS_MODULE(
"qep_hsm")
47static constexpr std::int_fast8_t QHSM_MAX_NEST_DEPTH_ {6};
52static constexpr std::array<QP::QEvt, 4> l_resEvt_ {
70#define QS_STATE_ACT_(rec_, state_) \
72 QS_BEGIN_PRE((rec_), qsId) \
79#define QS_TOP_INIT_(rec_, trg_) \
81 QS_BEGIN_PRE((rec_), qsId) \
89#define QS_TRAN_SEG_(rec_, src_, trg_) \
91 QS_BEGIN_PRE((rec_), qsId) \
99#define QS_TRAN_ACT_(rec_, state_) \
101 QS_BEGIN_PRE((rec_), qsId) \
102 QS_SIG_PRE(e->sig); \
104 QS_FUN_PRE(state_); \
109#define QS_TRAN0_(rec_, trg_) \
111 QS_BEGIN_PRE((rec_), qsId) \
113 QS_SIG_PRE(e->sig); \
120#define QS_TRAN_END_(rec_, src_, trg_) \
122 QS_BEGIN_PRE((rec_), qsId) \
124 QS_SIG_PRE(e->sig); \
132#define QS_STATE_ACT_(rec_, state_) (static_cast<void>(0))
133#define QS_TOP_INIT_(rec_, trg_) (static_cast<void>(0))
134#define QS_TRAN_SEG_(rec_, src_, trg_) (static_cast<void>(0))
135#define QS_TRAN_ACT_(rec_, state_) (static_cast<void>(0))
136#define QS_TRAN0_(rec_, trg_) (static_cast<void>(0))
137#define QS_TRAN_END_(rec_, src_, trg_) (static_cast<void>(0))
155 void const *
const e,
156 std::uint_fast8_t
const qsId)
165 if ((QS::priv_.flags & 0x01U) == 0U) {
166 QS::priv_.flags |= 0x01U;
197 std::array <QStateHandler, QHSM_MAX_NEST_DEPTH_> path;
199 std::int_fast8_t ip = -1;
213 }
while (
m_temp.fun != s);
231 QEvt const *
const e,
232 std::uint_fast8_t
const qsId)
253 std::array <QStateHandler, QHSM_MAX_NEST_DEPTH_> path;
256 std::int_fast8_t ip = QHSM_MAX_NEST_DEPTH_;
295 for (std::int_fast8_t iq = QHSM_MAX_NEST_DEPTH_ - 1; iq > ip; --iq) {
329 std::uint_fast8_t
const qsId)
337 std::int_fast8_t ip = 0;
364 static_cast<void>((*s)(
this, &l_resEvt_[
Q_EMPTY_SIG]));
374 else if (
m_temp.fun == path[0]) {
396 std::uint_fast8_t
const qsId)
405 std::int_fast8_t iq = 0;
410 std::int_fast8_t ip = 0;
432 static_cast<void>((*s)(
this, &l_resEvt_[
Q_EXIT_SIG]));
445 for (; iq >= 0; --iq) {
461 static_cast<void>((*s)(
this, &l_resEvt_[
Q_EMPTY_SIG]));
466 for (; iq >= 0; --iq) {
484 std::int_fast8_t
const depth,
485 std::uint_fast8_t
const qsId)
492 std::int_fast8_t ip = depth;
494 for (; ip >= 0; --ip) {
528 }
while (
m_temp.fun != t);
531 for (; ip >= 0; --ip) {
548 bool inState =
false;
554 if (s == stateHndl) {
578 bool isFound =
false;
586 if (
m_temp.fun == parentHndl) {
QAsm() noexcept
Constructor of the QP::QAsm base class.
static constexpr QState Q_RET_UNHANDLED
static constexpr QState Q_RET_TRAN
QAsmAttr m_temp
Temporary storage for target/act-table etc.
static constexpr QState Q_RET_IGNORED
static constexpr QState Q_RET_SUPER
static constexpr QState Q_RET_TRAN_HIST
static constexpr QSignal Q_INIT_SIG
QAsmAttr m_state
Current state (pointer to the current state-handler function).
static constexpr QSignal Q_ENTRY_SIG
static constexpr QSignal Q_EXIT_SIG
static constexpr QSignal Q_EMPTY_SIG
static constexpr QState Q_RET_HANDLED
static QState top(void *const me, QEvt const *const e) noexcept
Top state handler that ignores all events.
std::int_fast8_t tran_complex_(QStateHandler *const path, std::uint_fast8_t const qsId)
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
std::int_fast8_t tran_simple_(QStateHandler *const path, std::uint_fast8_t const qsId)
QStateHandler childState(QStateHandler const parentHndl) noexcept
Obtain the current active child state of a given parent in QP::QMsm.
void init(void const *const e, std::uint_fast8_t const qsId) override
Virtual function to take the top-most initial transition in the state machine.
QHsm(QStateHandler const initial) noexcept
void enter_target_(QStateHandler *const path, std::int_fast8_t const depth, std::uint_fast8_t const qsId)
bool isIn(QStateHandler const stateHndl) noexcept override
Check whether the HSM is in a given state.
QStateHandler getStateHandler() const noexcept override
Virtual method for getting the current state handler.
QP/C++ Framework namespace.
@ QS_QEP_DISPATCH
an event was dispatched (begin of RTC step)
@ QS_QEP_STATE_ENTRY
a state was entered
@ QS_QEP_STATE_EXIT
a state was exited
@ 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
static T_ dis_update(T_ const org)
Internal function template to calculate the Duplicate Inverse Storage (DIS).
static bool dis_verify(T_ const org, T_ const dis)
Internal function template to verify the Duplicate Inverse Storage (DIS).
std::uint_fast8_t QState
Type returned from state-handler functions.
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function.
std::uint16_t QSignal
The signal of event QP::QEvt.
#define Q_EVT_CAST(subclass_)
Perform downcast of an event onto a subclass of QP::QEvt class_.
#define Q_UNUSED_PAR(par_)
Helper macro to clearly mark unused parameters of functions.
#define Q_STATE_CAST(handler_)
Perform cast to QP::QStateHandler.
QP Framework in C++ internal (package-scope) interface
#define QS_CRIT_STAT
Internal QS macro for defining the critical section status.
#define QS_FUN_DICTIONARY(fun_)
Produce function dictionary (typically for state-handler functions).
#define QS_CRIT_EXIT()
Internal macro for exiting a critical section.
#define QS_CRIT_ENTRY()
Internal macro for entering a critical section.
QS (QP/Spy software tracing) internal (package-scope) interface.
QP Functional Safety (FuSa) Subsystem.
#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).
#define Q_INVARIANT_INCRIT(id_, expr_)
Assertion for checking a postcondition (in critical section).