51 #define QEP_TRIG_(state_, sig_) \
52 ((*(state_))(this, &QEP_reservedEvt_[sig_]))
55 #define QEP_EXIT_(state_) do { \
56 if (QEP_TRIG_(state_, Q_EXIT_SIG) == Q_RET_HANDLED) { \
57 QS_BEGIN_PRE_(QS_QEP_STATE_EXIT, qs_id) \
59 QS_FUN_PRE_(state_); \
65 #define QEP_ENTER_(state_) do { \
66 if (QEP_TRIG_(state_, Q_ENTRY_SIG) == Q_RET_HANDLED) { \
67 QS_BEGIN_PRE_(QS_QEP_STATE_ENTRY, qs_id) \
69 QS_FUN_PRE_(state_); \
96 QEvt(0U, QEvt::STATIC_EVT),
97 QEvt(1U, QEvt::STATIC_EVT),
98 QEvt(2U, QEvt::STATIC_EVT),
99 QEvt(3U, QEvt::STATIC_EVT)
119 m_temp.fun = initial;
205 static_cast<void>(qs_id);
225 static_cast<void>(me);
226 static_cast<void>(e);
227 return Q_RET_IGNORED;
314 for (; ip >= 0; --ip) {
389 static_cast<void>(qs_id);
533 static_cast<void>(qs_id);
562 bool inState =
false;
602 bool isFound =
false;
624 static_cast<void>(isFound);
signed int int_fast8_t
fast at-least 8-bit signed int
unsigned int uint_fast8_t
fast at-least 8-bit unsigned int
static constexpr QState Q_RET_HANDLED
event handled (internal transition)
static constexpr QState Q_RET_SUPER
event passed to the superstate to handle
static constexpr QState Q_RET_UNHANDLED
event unhandled due to a guard evaluating to 'false'
virtual void dispatch(QEvt const *const e, std::uint_fast8_t const qs_id)
Dispatches an event to QHsm.
static constexpr QState Q_RET_IGNORED
event silently ignored (bubbled up to top)
@ Q_INIT_SIG
signal for nested initial transitions
@ Q_EXIT_SIG
signal for exit actions
static QState top(void *const me, QEvt const *const e) noexcept
the top-state.
virtual QStateHandler getStateHandler() noexcept
Get the current state handler of the HSM.
virtual ~QHsm()
virtual destructor
virtual void init(void const *const e, std::uint_fast8_t const qs_id)
executes the top-most initial transition in QP::QHsm
static constexpr QState Q_RET_TRAN
regular transition taken
QStateHandler childState(QStateHandler const parent) noexcept
Obtain the current active child state of a given parent.
QHsmAttr m_state
current active state (state-variable)
static constexpr std::int_fast8_t MAX_NEST_DEPTH_
< maximum nesting depth of states in HSM
bool isIn(QStateHandler const s) noexcept
Tests if a given state is part of the current active state configuration.
static constexpr QState Q_RET_TRAN_HIST
transition to history of a given state
QHsmAttr m_temp
temporary: transition chain, target state, etc.
std::int_fast8_t hsm_tran(QStateHandler(&path)[MAX_NEST_DEPTH_], std::uint_fast8_t const qs_id)
internal helper function to take a transition in QP::QHsm
QHsm(QStateHandler const initial) noexcept
Protected constructor of QHsm.
namespace associated with the QP/C++ framework
std::uint_fast8_t QState
Type returned from 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_UNHANDLED
an event was unhandled 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)
@ QEP_EMPTY_SIG_
empty signal for internal use only
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to state-handler function.
static QEvt const QEP_reservedEvt_[4]
QStateHandler fun
pointer to a state handler function
std::uint16_t QSignal
QSignal represents the signal of an event.
Customizable and memory-efficient assertions for embedded systems.
#define Q_DEFINE_THIS_MODULE(name_)
Define the user-specified module name for assertions in this file.
#define Q_ASSERT_ID(id_, test_)
General purpose assertion with user-specified assertion-id.
#define Q_ENSURE_ID(id_, test_)
Assertion for checking postconditions with user-specified assertion-id.
#define Q_REQUIRE_ID(id_, test_)
Assertion for checking preconditions with user-specified assertion-id.
#define Q_DIM(array_)
Helper macro to calculate static dimension of a 1-dim array_.
#define Q_STATE_CAST(handler_)
Macro to perform casting to QStateHandler.
#define Q_EVT_CAST(class_)
Perform downcast of an event onto a subclass of QEvt class_.
#define QEP_ENTER_(state_)
helper macro to trigger entry action in an HSM
#define QEP_EXIT_(state_)
helper macro to trigger exit action in an HSM
#define QEP_TRIG_(state_, sig_)
helper macro to trigger internal event in an HSM
QEP/C++ port, generic C++11 compiler.
#define QS_CRIT_STAT_
This is an internal macro for defining the critical section status type.
Dummy definitions of the QS macros that avoid code generation from the QS instrumentation.
#define QS_BEGIN_PRE_(rec_, qs_id_)
#define QS_OBJ_PRE_(obj_)
#define QS_FUN_PRE_(fun_)
#define QS_SIG_PRE_(sig_)
Internal (package scope) QS/C++ interface.
QS/C++ port to a 32-bit CPU, generic compiler.
QSignal sig
signal of the event instance