38#define QP_VERSION 701U
43#define QP_VERSION_STR "7.0.1"
46#define QP_RELEASE 0x7C7E85E2U
57 #define Q_SIGNAL_SIZE 2U
97#define Q_EVT_CAST(class_) (static_cast<class_ const *>(e))
107#define Q_UINT2PTR_CAST(type_, uint_) (reinterpret_cast<type_ *>(uint_))
115#define QEVT_INITIALIZER(sig_) { static_cast<QP::QSignal>(sig_), 0U, 0U }
124#if (Q_SIGNAL_SIZE == 1U)
126#elif (Q_SIGNAL_SIZE == 2U)
137#elif (Q_SIGNAL_SIZE == 4U)
140 #error "Q_SIGNAL_SIZE defined incorrectly, expected 1U, 2U, or 4U"
172 enum StaticEvt : std::uint8_t { STATIC_EVT };
173 constexpr QEvt(
QSignal const s, StaticEvt ) noexcept
181 virtual ~QEvt() noexcept {}
193 friend class QActive;
194 friend class QMActive;
195 friend class QTimeEvt;
196 friend class QEQueue;
197 friend class QTicker;
198 friend class QXThread;
209struct QMTranActTable;
266 virtual ~QHsm() noexcept {}
282 virtual void init(
void const *
const e,
283 std::uint_fast8_t
const qs_id);
286 virtual void init(std::uint_fast8_t
const qs_id) {
287 init(
nullptr, qs_id);
307 std::uint_fast8_t
const qs_id);
361 static QState top(
void *
const me,
QEvt const *
const e)
noexcept;
453 void const *
const tatbl)
noexcept
477 void const *
const tatbl)
noexcept
546 std::uint_fast8_t
const qs_id);
596 void init(
void const *
const e,
597 std::uint_fast8_t
const qs_id)
override;
610 void init(std::uint_fast8_t
const qs_id)
override;
625 std::uint_fast8_t
const qs_id)
override;
728 std::uint_fast8_t
const qs_id);
743 std::uint_fast8_t
const qs_id);
759 std::uint_fast8_t
const qs_id);
805#define Q_STATE_DECL(state_) \
806 QP::QState state_ ## _h(QP::QEvt const * const e); \
807 static QP::QState state_(void * const me, QP::QEvt const * const e)
811#define Q_STATE_DEF(subclass_, state_) \
812 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) {\
813 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
814 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)
817#define Q_HANDLED() (Q_RET_HANDLED)
821#define Q_UNHANDLED() (Q_RET_UNHANDLED)
828#define Q_STATE_CAST(handler_) \
829 (reinterpret_cast<QP::QStateHandler>(handler_))
836#define Q_ACTION_CAST(act_) (reinterpret_cast<QP::QActionHandler>(act_))
840#define Q_ACTION_NULL (nullptr)
847#define QM_STATE_DECL(state_) \
848 QP::QState state_ ## _h(QP::QEvt const * const e); \
849 static QP::QState state_(void * const me, QP::QEvt const * const e); \
850 static QP::QMState const state_ ## _s
854#define QM_SM_STATE_DECL(subm_, state_) \
855 QP::QState state_ ## _h(QP::QEvt const * const e); \
856 static QP::QState state_(void * const me, QP::QEvt const * const e); \
857 static SM_ ## subm_ const state_ ## _s
861#define QM_ACTION_DECL(action_) \
862 QP::QState action_ ## _h(void); \
863 static QP::QState action_(void * const me)
867#define QM_STATE_DEF(subclass_, state_) \
868 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) {\
869 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
870 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)
874#define QM_ACTION_DEF(subclass_, action_) \
875 QP::QState subclass_::action_(void * const me) { \
876 return static_cast<subclass_ *>(me)->action_ ## _h(); } \
877 QP::QState subclass_::action_ ## _h(void)
880#define QM_HANDLED() (Q_RET_HANDLED)
884#define QM_UNHANDLED() (Q_RET_UNHANDLED)
887#define QM_SUPER() (Q_RET_SUPER)
891#define QM_STATE_NULL (nullptr)
Dummy Active Object class for testing (inherits QP::QActive)
QActive active object class (based on QP::QHsm implementation strategy)
QF real-time active object framework.
Dummy HSM class for testing (inherits QP::QHsm)
Hierarchical State Machine base class.
static constexpr QState Q_RET_SUPER_SUB
event passed to submachine superstate
QState qm_tran_init(void const *const tatbl) noexcept
Helper function to specify an initial state transition in a QM state-handler.
QState qm_tran_hist(QMState const *const hist, void const *const tatbl) noexcept
Helper function to specifiy a transition to history in a QM state-handler.
static constexpr QState Q_RET_HANDLED
event handled (internal transition)
static constexpr QState Q_RET_SUPER
event passed to the superstate to handle
QState tran_hist(QStateHandler const hist) noexcept
Helper function to specify a transition to history.
static constexpr QState Q_RET_UNHANDLED
event unhandled due to a guard evaluating to 'false'
QState qm_entry(QMState const *const s) noexcept
Helper function to specify a state entry in a QM state-handler.
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
@ Q_ENTRY_SIG
signal for entry actions
QState tran(QStateHandler const target) noexcept
Helper function to specify a state transition.
QState qm_tran_xp(QActionHandler const xp, void const *const tatbl) noexcept
Helper function to specify a transition to an exit point from a submachine state in a QM state-handle...
static QState top(void *const me, QEvt const *const e) noexcept
The top-state handler.
virtual void init(std::uint_fast8_t const qs_id)
overloaded init(qs_id)
virtual QStateHandler getStateHandler() noexcept
Get the current state handler of the HSM.
QState qm_tran_ep(void const *const tatbl) noexcept
Helper function to specify a transition to an entry point to a submachine state in a QM state-handler...
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_EP
entry-point transition into a submachine
QState qm_super_sub(QMState const *const s) noexcept
Helper function to call in a QM state-handler when it passes the event to the host submachine state t...
static constexpr QState Q_RET_TRAN_INIT
initial transition taken
static constexpr QState Q_RET_NULL
return value without any effect
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 QState Q_RET_EXIT
state exit action executed
static constexpr std::int_fast8_t MAX_NEST_DEPTH_
maximum nesting depth of states in HSM
QState qm_exit(QMState const *const s) noexcept
Helper function to specify a state exit in a QM state-handler.
QStateHandler state(void) const noexcept
Obtain the current state (state handler function)
QState super(QStateHandler const superstate) noexcept
Helper function to specify the superstate of a given state.
QState qm_tran(void const *const tatbl) noexcept
Helper function to specify a regular state transition in a QM state-handler.
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.
static constexpr QState Q_RET_TRAN_XP
exit-point transition out of a submachine
std::int_fast8_t hsm_tran(QStateHandler(&path)[MAX_NEST_DEPTH_], std::uint_fast8_t const qs_id)
Helper function to take a transition in QP::QHsm.
static constexpr QState Q_RET_ENTRY
state entry action executed
QState qm_sm_exit(QMState const *const s) noexcept
Helper function to specify a submachine exit in a QM state-handler.
QHsm(QStateHandler const initial) noexcept
Protected constructor of QHsm.
QMActive active object (based on QP::QMsm implementation)
QM State Machine implementation strategy.
void exitToTranSource_(QMState const *s, QMState const *const ts, std::uint_fast8_t const qs_id)
Internal helper function to exit current state to transition source.
bool isIn(QStateHandler const s) noexcept=delete
disallow inherited isIn() function in QP::QMsm and subclasses
static QMState const msm_top_s
the top state object for the QMsm
QStateHandler getStateHandler() noexcept override
Get the current state handler of the QMsm.
QStateHandler state(void) const noexcept=delete
disallow inhertited state() function in QP::QMsm and subclasses
static QState top(void *const me, QEvt const *const e) noexcept=delete
disallow inherited top() function in QP::QMsm and subclasses
QState execTatbl_(QMTranActTable const *const tatbl, std::uint_fast8_t const qs_id)
Internal helper function to execute a transition-action table.
void dispatch(QEvt const *const e, std::uint_fast8_t const qs_id) override
Dispatches an event to a MSM.
static constexpr std::int_fast8_t MAX_ENTRY_DEPTH_
maximum depth of implemented entry levels for transitions to history
QMState const * childStateObj(QMState const *const parent) const noexcept
Obtain the current active child state of a given parent (read only)
QStateHandler childState(QStateHandler const parent) noexcept=delete
disallow inhertited childState() function in QP::QMsm and subclasses
QState enterHistory_(QMState const *const hist, std::uint_fast8_t const qs_id)
Internal helper function to enter state history.
void init(void const *const e, std::uint_fast8_t const qs_id) override
Performs the second step of SM initialization by triggering the top-most initial transition.
QMState const * stateObj(void) const noexcept
Return the current active state object (read only)
bool isInState(QMState const *const st) const noexcept
Tests if a given state is part of the active state configuration.
QS software tracing facilities for output (QS-TX)
QXK preemptive, dual-mode (blocking/non-blocking) real-time kernel.
Priority Ceiling Mutex the QXK preemptive kernel.
Counting Semaphore of the QXK preemptive kernel.
Extended (blocking) thread of the QXK preemptive kernel.
namespace associated with the QP/C++ framework
std::uint8_t QF_EVT_POOL_ID_(QEvt const *const e) noexcept
return the Pool-ID of an event e
std::uint_fast8_t QState
Type returned from state-handler functions.
void QF_EVT_REF_CTR_DEC_(QEvt const *const e) noexcept
decrement the refCtr_ of an event e
void(*)(QXThread *const me) QXThreadHandler
Pointer to a thread-handler function.
QActionHandler const act[1]
std::uint8_t QF_EVT_REF_CTR_(QEvt const *const e) noexcept
return the Reference Conter of an event e
QMState const * obj
pointer to QMState object
QMTranActTable const * tatbl
transition-action table
constexpr char const versionStr[]
the current QP version number string based on QP_VERSION_STR
QActionHandler const entryAction
entry action handler function
QMState const * superstate
superstate of this state
QState(*)(void *const me) QActionHandler
Pointer to an action-handler function.
constexpr enum_t Q_USER_SIG
Offset or the user signals.
QActionHandler const initAction
init action handler function
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to state-handler function.
QActionHandler const exitAction
exit action handler function
QStateHandler const stateHandler
state handler function
QXThreadHandler thr
pointer to an thread-handler function
QStateHandler fun
pointer to a state handler function
std::uint16_t QSignal
QSignal represents the signal of an event.
void QF_EVT_REF_CTR_INC_(QEvt const *const e) noexcept
increment the refCtr_ of an event e
QActionHandler act
pointer to an action-handler function
State object for the QP::QMsm class (QM State Machine).
Transition-Action Table for the QP::QMsm State Machine.
Attribute of for the QHsm class (Hierarchical State Machine)
int enum_t
alias for enumerations used for event signals
int int_t
alias for line numbers in assertions and return from QF::run()
float float32_t
alias for 32-bit IEEE 754 floating point numbers
#define QP_VERSION_STR
The current QP version number string of the form XX.Y.Z, where XX is a 2-digit major version number,...
double float64_t
alias for 64-bit IEEE 754 floating point numbers
QSignal sig
signal of the event instance
std::uint8_t volatile refCtr_
reference counter
std::uint8_t poolId_
pool ID (0 for static event)