1//============================================================================ 2// QP/C++ Real-Time Event Framework (RTEF) 4// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved. 6// Q u a n t u m L e a P s 7// ------------------------ 8// Modern Embedded Software 10// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial 12// This software is dual-licensed under the terms of the open-source GNU 13// General Public License (GPL) or under the terms of one of the closed- 14// source Quantum Leaps commercial licenses. 16// Redistributions in source code must retain this top-level comment block. 17// Plagiarizing this software to sidestep the license obligations is illegal. 20// The GPL does NOT permit the incorporation of this code into proprietary 21// programs. Please contact Quantum Leaps for commercial licensing options, 22// which expressly supersede the GPL and are designed explicitly for 23// closed-source distribution. 25// Quantum Leaps contact information: 26// <www.state-machine.com/licensing> 27// <info@state-machine.com> 28//============================================================================ 32//============================================================================ 33#define QP_VERSION_STR "8.1.2" 34#define QP_VERSION 812U 35// <VER>=812 <DATE>=251201 36#define QP_RELEASE 0x6A45C1C3U 38//---------------------------------------------------------------------------- 39// default configuration settings 43#define QF_MAX_ACTIVE 32U 46#if (QF_MAX_ACTIVE > 64U) 47#error QF_MAX_ACTIVE exceeds the maximum of 64U; 50#ifndef QF_MAX_TICK_RATE 51#define QF_MAX_TICK_RATE 1U 54#if (QF_MAX_TICK_RATE > 15U) 55#error QF_MAX_TICK_RATE exceeds the maximum of 15U; 59#define QF_MAX_EPOOL 3U 62#if (QF_MAX_EPOOL > 15U) 63#error QF_MAX_EPOOL exceeds the maximum of 15U; 66#ifndef QF_TIMEEVT_CTR_SIZE 67#define QF_TIMEEVT_CTR_SIZE 4U 70#if (QF_TIMEEVT_CTR_SIZE > 4U) 71#error QF_TIMEEVT_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U; 74#ifndef QF_EVENT_SIZ_SIZE 75#define QF_EVENT_SIZ_SIZE 2U 78#if (QF_EVENT_SIZ_SIZE > 4U) 79#error QF_EVENT_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U; 84//---------------------------------------------------------------------------- 85// global types/utilities 89#define Q_UNUSED_PAR(par_) (static_cast<void>(par_)) 90#define Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U])) 91#define Q_UINT2PTR_CAST(type_, uint_) (reinterpret_cast<type_ *>(uint_)) 93//============================================================================ 100//---------------------------------------------------------------------------- 111 :
sig(s)
// the provided event signal 113 ,
refCtr_ (0xE0U)
// special event "marker" 114 ,
filler_ (0xE0E0E0E0U)
// the "filler" ensures the same QEvt size 118QEvt()
// disallow the default ctor 121// no event parameters to initialize 125// no event parameters to initialize 131//---------------------------------------------------------------------------- 132// QEP (hierarchical event processor) types 166//---------------------------------------------------------------------------- 172// All possible values returned from state/action handlers... 173// NOTE: The numerical order is important for algorithmic correctness. 180// used in QHsm only... 183// used in QMsm only... 189// Reserved signals by the QP-framework (used in QHsm only) 215 std::uint_fast8_t
const qsId) = 0;
216virtualvoidinit(std::uint_fast8_t
const qsId);
219 std::uint_fast8_t
const qsId) = 0;
224returnm_state.fun;
// public "getter" for the state handler 227returnm_state.obj;
// public "getter" for the state object 233explicitQAsm() noexcept;
236// for coding QMsm state machines 241// for coding QMsm state machines 246// for coding QMsm state machines 251// for coding QMsm state machines 256// for coding QMsm state machines 262voidconst *
const tatbl)
noexcept 263 {
// for coding QMsm state machines 264m_state.obj = hist;
// store the history in state 271// for coding QMsm state machines 277// for coding QMsm state machines 278static_cast<void>(s);
// unused parameter 285// for coding QMsm state machines 291// for coding QMsm state machines 292static_cast<void>(s);
// unused parameter 298//---------------------------------------------------------------------------- 307 std::uint_fast8_t
const qsId)
override;
310 std::uint_fast8_t
const qsId)
override;
319 std::uint_fast8_t
const qsId);
323 std::uint_fast8_t
const qsId);
327 std::int_fast8_t
const depth,
328 std::uint_fast8_t
const qsId);
334//---------------------------------------------------------------------------- 343 std::uint_fast8_t
const qsId)
override;
346 std::uint_fast8_t
const qsId)
override;
357 std::uint_fast8_t const qsId);
359QMState const * const curr_state,
360QMState const * const tran_source,
361 std::uint_fast8_t const qsId);
364 std::uint_fast8_t const qsId);
372//============================================================================ 375#define Q_STATE_DECL(state_) \ 376 QP::QState state_ ## _h(QP::QEvt const * const e); \ 377 static QP::QState state_(void * const me, QP::QEvt const * const e) 379#define Q_STATE_DEF(subclass_, state_) \ 380 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) { \ 381 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \ 382 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e) 384#define Q_EVT_CAST(subclass_) (static_cast<subclass_ const *>(e)) 385#define Q_STATE_CAST(handler_) (reinterpret_cast<QP::QStateHandler>(handler_)) 387#define QM_STATE_DECL(state_) \ 388 QP::QState state_ ## _h(QP::QEvt const * const e); \ 389 static QP::QState state_(void * const me, QP::QEvt const * const e); \ 390 static QP::QMState const state_ ## _s 392#define QM_ACTION_DECL(action_) \ 393 QP::QState action_ ## _h(); \ 394 static QP::QState action_(void * const me) 396#define QM_STATE_DEF(subclass_, state_) \ 397 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) {\ 398 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \ 399 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e) 401#define QM_ACTION_DEF(subclass_, action_) \ 402 QP::QState subclass_::action_(void * const me) { \ 403 return static_cast<subclass_ *>(me)->action_ ## _h(); } \ 404 QP::QState subclass_::action_ ## _h() 407 #define INIT(qsId_) init((qsId_)) 408 #define DISPATCH(e_, qsId_) dispatch((e_), (qsId_)) 410 #define INIT(dummy) init(0U) 411 #define DISPATCH(e_, dummy) dispatch((e_), 0U) 414//============================================================================ 419classQEQueue;
// forward declaration 420classQActive;
// forward declaration 422#if (QF_TIMEEVT_CTR_SIZE == 1U) 424#elif (QF_TIMEEVT_CTR_SIZE == 2U) 426#elif (QF_TIMEEVT_CTR_SIZE == 4U) 428#endif// (QF_TIMEEVT_CTR_SIZE == 4U) 430#if (QF_MAX_ACTIVE <= 8U) 432#elif (8U < QF_MAX_ACTIVE) && (QF_MAX_ACTIVE <= 16U) 434#elif (16 < QF_MAX_ACTIVE) 436#endif// (16 < QF_MAX_ACTIVE) 442//---------------------------------------------------------------------------- 446#if (QF_MAX_ACTIVE > 32U) 454boolhasElement(std::uint_fast8_t const n) const noexcept;
455voidinsert(std::uint_fast8_t const n) noexcept;
456voidremove(std::uint_fast8_t const n) noexcept;
457 std::uint_fast8_t
findMax() const noexcept;
463//---------------------------------------------------------------------------- 471};
// class QSubscrList 473//---------------------------------------------------------------------------- 474// declarations for friendship with the QActive class 487//---------------------------------------------------------------------------- 493#ifdef QACTIVE_THREAD_TYPE 497#ifdef QACTIVE_OS_OBJ_TYPE 501#ifdef QACTIVE_EQUEUE_TYPE 512 std::uint_fast8_t
const qsId)
override;
515 std::uint_fast8_t
const qsId)
override;
522void const * attr2 =
nullptr);
524QEvtPtr * const qSto, std::uint_fast16_t const qLen,
525void * const stkSto, std::uint_fast16_t const stkSize,
526void const * const par =
nullptr);
528#ifdef QACTIVE_CAN_STOP 530#endif// def QACTIVE_CAN_STOP 534void const * const sender) noexcept
536// delegate to postx_() with margin==QF::NO_MARGIN 539bool postx_(
QEvtconst *
const e,
540 std::uint_fast16_t
const margin,
541voidconst *
const sender)
noexcept;
542void postLIFO(
QEvtconst *
const e)
noexcept;
543QEvtconst * get_() noexcept;
544 static std::uint16_t getQueueUse(
545 std::uint_fast8_t const prio) noexcept;
546 static std::uint16_t getQueueFree(
547 std::uint_fast8_t const prio) noexcept;
548 static std::uint16_t getQueueMin(
549 std::uint_fast8_t const prio) noexcept;
552QSignal const maxSignal) noexcept;
555void const * const sender,
556 std::uint_fast8_t const qsId) noexcept;
557void subscribe(
QSignal const sig) const noexcept;
558void unsubscribe(
QSignal const sig) const noexcept;
559void unsubscribeAll() const noexcept;
562QEvt const * const e) const noexcept;
563bool recall(
QEQueue * const eq) noexcept;
564 std::uint16_t flushDeferred(
566 std::uint_fast16_t const num = 0xFFFFU) const noexcept;
567 constexpr std::uint8_t
getPrio() const noexcept {
568returnm_prio;
// public "getter" for the AO's prio 573#ifdef QACTIVE_THREAD_TYPE 575// ref-qualified reference (MISRA-C++:2023 Rule 6.8.4) 579// ref-qualified reference (MISRA-C++:2023 Rule 6.8.4) 582m_thread = thr;
// public "setter", useful for MPU applications 584#endif// QACTIVE_THREAD_TYPE 586#ifdef QACTIVE_OS_OBJ_TYPE 588// ref-qualified reference (MISRA-C++:2023 Rule 6.8.4) 592// ref-qualified reference (MISRA-C++:2023 Rule 6.8.4) 594#endif// QACTIVE_OS_OBJ_TYPE 599 std::uint_fast16_t
const margin,
601voidconst *
const sender)
noexcept;
606voidconst * sender)
noexcept;
612voidconst *
const sender);
614QPSet *
const subscrSet,
616voidconst *
const sender);
638//---------------------------------------------------------------------------- 647 std::uint_fast8_t
const qsId)
override;
650 std::uint_fast8_t
const qsId)
override;
657//---------------------------------------------------------------------------- 658#if (QF_MAX_TICK_RATE > 0U) 673 std::uint_fast8_t
const tickRate = 0U)
noexcept;
675 std::uint32_t
const nTicks,
676 std::uint32_t
const interval = 0U)
noexcept;
678boolrearm(std::uint32_t const nTicks) noexcept;
681// ref-qualified reference (MISRA-C++:2023 Rule 6.8.4) 685// ref-qualified reference (MISRA-C++:2023 Rule 6.8.4) 688returnm_ctr;
// public "getter" for the current time-evt count 691returnm_interval;
// public "getter" for the time-evt interval 694returnm_tickRate;
// public "getter" for the time-evt tick rate 697 std::uint_fast8_t
const tickRate,
698voidconst *
const sender)
noexcept;
702 std::uint_fast8_t
const tickRate,
703voidconst *
const sender);
708 std::uint_fast8_t
const tickRate,
710voidconst * sender)
noexcept;
711#endif// def QF_ISR_API 712staticboolnoActive(std::uint_fast8_t
const tickRate)
noexcept;
714// public "getter" for the AO associated with this time-evt 718// public "getter" for the AO associated with this time-evt 719// NOTE: used for the special time-evts in QTimeEvt_head_[] array 728 std::uint_fast8_t const tickRate) noexcept;
735//---------------------------------------------------------------------------- 738explicitQTicker(std::uint8_t
const tickRate)
noexcept;
742 std::uint_fast8_t
const qsId)
override;
745 std::uint_fast8_t
const qsId)
override;
746voidtrig_(
voidconst *
const sender)
noexcept;
749#endif// (QF_MAX_TICK_RATE > 0U) 751//---------------------------------------------------------------------------- 758// use QActive::psInit() instead of the deprecated QF::psInit() 764voidconst *
const sender, std::uint_fast8_t
const qsId)
noexcept 766// use QTimeEvt::tick() instead of the deprecated QF::tick() 772 std::uint_fast8_t
const prio)
noexcept 774// use QActive::getQueueMin() instead of the deprecated QF::getQueueMin() 778#if (QF_MAX_TICK_RATE > 0U) 781 std::uint_fast8_t
const tickRate,
782voidconst *
const sender)
noexcept 784// use QTimeEvt::tick() instead of the deprecated QF::tick() 787#endif// (QF_MAX_TICK_RATE > 0U) 789//---------------------------------------------------------------------------- 790// QF dynamic memory facilities 793 std::uint_fast32_t
const poolSize,
794 std::uint_fast16_t
const evtSize)
noexcept;
796std::uint16_t poolGetMaxBlockSize() noexcept;
797std::uint16_t
getPoolUse(std::uint_fast8_t const poolNum) noexcept;
798std::uint16_t
getPoolFree(std::uint_fast8_t const poolNum) noexcept;
799std::uint16_t
getPoolMin(std::uint_fast8_t const poolNum) noexcept;
801 std::uint_fast16_t const evtSize,
802 std::uint_fast16_t const margin,
804voidgc(
QEvt const * const e) noexcept;
807QEvt const * const evtRef) noexcept;
814// allocate a dynamic (mutable) event with NO_MARGIN 815// NOTE: the returned event ptr is guaranteed NOT to be nullptr 816returnstatic_cast<evtT_*
>(
820inline evtT_ * q_new_x(std::uint_fast16_t
const margin,
823// allocate a dynamic (mutable) event with a provided margin 824// NOTE: the returned event ptr is MIGHT be nullptr 825returnstatic_cast<evtT_*
>(
QP::QF::newX_(
sizeof(evtT_), margin, sig));
828template<
classevtT_,
typename... Args>
830// allocate a dynamic (mutable) event with NO_MARGIN 831// NOTE: the returned event ptr is guaranteed NOT to be nullptr 832 evtT_ *e =
static_cast<evtT_*
>(
834 e->init(args...);
// immediately initialize the event (RAII) 837template<
classevtT_,
typename... Args>
838inline evtT_ *
q_new_x(std::uint_fast16_t
const margin,
841// allocate a dynamic (mutable) event with a provided margin 842// NOTE: the event allocation is MIGHT fail 844static_cast<evtT_*
>(
QP::QF::newX_(
sizeof(evtT_), margin, sig));
845if (e !=
nullptr) {
// was the allocation successfull? 846 e->init(args...);
// immediately initialize the event (RAII) 848// NOTE: the returned event ptr is MIGHT be nullptr 851#endif// QEVT_PAR_INIT 856 evtT_
const *& evtRef)
858// set the const event reference (must NOT be nullptr) 865 evtRef =
nullptr;
// invalidate the associated event reference 870 std::uint_fast16_t
const evtSize,
871 std::uint_fast16_t
const margin,
874#endif// def QF_ISR_API 879//============================================================================ 882//${QF-extern-C::QF_onContextSw} ............................................. 883#ifdef QF_ON_CONTEXT_SW 887#endif// def QF_ON_CONTEXT_SW 890//---------------------------------------------------------------------------- 893#define Q_PRIO(prio_, pthre_) \ 894 (static_cast<QP::QPrioSpec>((prio_) | (pthre_) << 8U)) 897 #define Q_NEW(evtT_, sig_) (QP::QF::q_new<evtT_>((sig_))) 898 #define Q_NEW_X(evtT_, margin_, sig_) \ 899 (QP::QF::q_new_x<evtT_>((margin_), (sig_))) 901 #define Q_NEW(evtT_, sig_, ...) \ 902 (QP::QF::q_new<evtT_>((sig_), __VA_ARGS__)) 903 #define Q_NEW_X(evtT_, margin_, sig_, ...) \ 904 (QP::QF::q_new_x<evtT_>((margin_), (sig_), __VA_ARGS__)) 905#endif// QEVT_PAR_INIT 907#define Q_NEW_REF(evtRef_, evtT_) (QP::QF::q_new_ref<evtT_>(e, (evtRef_))) 908#define Q_DELETE_REF(evtRef_) do { \ 909 QP::QF::deleteRef_((evtRef_)); \ 910 (evtRef_) = nullptr; \ 914 #define PUBLISH(e_, sender_) \ 915 publish_((e_), (sender_), (sender_)->getPrio()) 916 #define POST(e_, sender_) post_((e_), (sender_)) 917 #define POST_X(e_, margin_, sender_) \ 918 postx_((e_), (margin_), (sender_)) 919 #define TICK_X(tickRate_, sender_) tick((tickRate_), (sender_)) 920 #define TRIG(sender_) trig_((sender_)) 922 #define PUBLISH(e_, dummy) publish_((e_), nullptr, 0U) 923 #define POST(e_, dummy) post_((e_), nullptr) 924 #define POST_X(e_, margin_, dummy) postx_((e_), (margin_), nullptr) 925 #define TICK_X(tickRate_, dummy) tick((tickRate_), nullptr) 926 #define TRIG(sender_) trig_(nullptr) 929#define TICK(sender_) TICK_X(0U, (sender_)) 931#ifndef QF_CRIT_EXIT_NOP 932 #define QF_CRIT_EXIT_NOP() (static_cast<void>(0)) 933#endif// ndef QF_CRIT_EXIT_NOP 935//---------------------------------------------------------------------------- 936// memory protection facilities 939 #error Memory isolation not supported in this QP edition, need SafeQP 940#endif// def QF_MEM_ISOLATE Active object class (based on the QP::QHsm implementation strategy).
friend class QActiveDummy
virtual bool postFromISR(QEvt const *const e, std::uint_fast16_t const margin, void *par, void const *const sender) noexcept
The "FromISR" variant used in the QP port to "FreeRTOS".
QACTIVE_THREAD_TYPE m_thread
Port-dependent representation of the thread of the active object.
static std::uint16_t getQueueMin(std::uint_fast8_t const prio) noexcept
void unregister_() noexcept
Un-register the active object from the framework.
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.
static void multicast_(QPSet *const subscrSet, QEvt const *const e, void const *const sender)
void post_(QEvt const *const e, void const *const sender) noexcept
Posts an event e directly to the event queue of the active object using the First-In-First-Out (FIFO)...
void register_() noexcept
Register this active object to be managed by the framework.
void postFIFO_(QEvt const *const e, void const *const sender)
static void publishFromISR(QEvt const *e, void *par, void const *sender) noexcept
The "FromISR" variant used in the QP port to "FreeRTOS".
static void publish_(QEvt const *const e, void const *const sender, std::uint_fast8_t const qsId) noexcept
Publish event to all subscribers of a given signal e->sig.
void stop()
Stops execution of an active object and removes it from the framework's supervision.
static void evtLoop_(QActive *act)
Event loop thread routine for executing an active object act (defined some in QP ports).
void setAttr(std::uint32_t attr1, void const *attr2=nullptr)
Generic setting of additional attributes (defined in some QP ports).
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
constexpr QACTIVE_OS_OBJ_TYPE const & getOsObject() const &
constexpr std::uint8_t getPrio() const noexcept
bool isIn(QStateHandler const stateHndl) noexcept override
Virtual function to check whether the state machine is in a given state.
bool postx_(QEvt const *const e, std::uint_fast16_t const margin, void const *const sender) noexcept
Posts an event e directly to the event queue of the active object using the First-In-First-Out (FIFO)...
static QActive * fromRegistry(std::uint_fast8_t const prio)
QActive(QStateHandler const initial) noexcept
QActive constructor (abstract base class).
QACTIVE_EQUEUE_TYPE m_eQueue
Port-dependent event-queue type (often QP::QEQueue).
QACTIVE_THREAD_TYPE const & getThread() const &&=delete
QStateHandler childState(QStateHandler const parentHandler) noexcept
constexpr QACTIVE_THREAD_TYPE const & getThread() const &
static void psInit(QSubscrList *const subscrSto, QSignal const maxSignal) noexcept
Publish event to all subscribers of a given signal e->sig.
void start(QPrioSpec const prioSpec, QEvtPtr *const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize, void const *const par=nullptr)
Starts execution of an active object and registers the object with the framework.
QACTIVE_OS_OBJ_TYPE const & getOsObject() const &&=delete
void setThread(QACTIVE_THREAD_TYPE const &thr) noexcept
QStateHandler getStateHandler() const noexcept override
Virtual method for getting the current state handler.
std::uint8_t m_pthre
Preemption-threshold [1..QF_MAX_ACTIVE] of this AO.
QACTIVE_OS_OBJ_TYPE m_osObject
Port-dependent per-thread object.
std::uint8_t m_prio
QF-priority [1..QF_MAX_ACTIVE] of this AO.
Abstract State Machine class (state machine interface).
QState qm_entry(QMState const *const s) noexcept
Internal helper function to execute state entry actions in QP::QMsm.
QAsm() noexcept
Constructor of the QP::QAsm base class.
QState qm_tran_hist(QMState const *const hist, void const *const tatbl) noexcept
Internal helper function to take a state transition to history in QP::QMsm.
QStateHandler state() const noexcept
static constexpr QState Q_RET_UNHANDLED
QState qm_tran(void const *const tatbl) noexcept
Internal helper function to take a state transition in QP::QMsm.
static constexpr QState Q_RET_TRAN
static constexpr QState QM_SUPER()
static constexpr QState Q_RET_ENTRY
QState qm_exit(QMState const *const s) noexcept
Internal helper function to execute state exit actions in QP::QMsm.
QState tran_hist(QStateHandler const hist) noexcept
Internal helper function to take a state transition to history in sublclasses of QP::QAsm.
QState super(QStateHandler const superstate) noexcept
Internal helper function to indicate superstate of a given state in sublclasses of QP::QAsm.
QState qm_tran_init(void const *const tatbl) noexcept
QAsmAttr m_temp
Temporary storage for target/act-table etc.
static constexpr QState Q_RET_IGNORED
virtual bool isIn(QStateHandler const stateHndl)=0
Virtual function to check whether the state machine is in a given state.
static constexpr QState Q_RET_SUPER
static constexpr QState Q_UNHANDLED()
virtual QStateHandler getStateHandler() const noexcept=0
Virtual method for getting the current state handler.
static constexpr QState Q_RET_TRAN_INIT
static constexpr QState Q_RET_TRAN_HIST
static constexpr QState Q_RET_EXIT
QMState const * stateObj() const noexcept
static constexpr QState Q_HANDLED()
virtual void init(void const *const e, std::uint_fast8_t const qsId)=0
Virtual function to take the top-most initial transition in the state machine.
QState tran(QStateHandler const target) noexcept
Internal helper function to take a state transition in sublclasses of QP::QAsm.
static constexpr QState QM_UNHANDLED()
virtual ~QAsm() noexcept
Virtual destructor of the QP::QAsm abstract base class.
static constexpr QSignal Q_INIT_SIG
static constexpr QActionHandler const Q_ACTION_NULL
QAsmAttr m_state
Current state (pointer to the current state-handler function).
virtual void dispatch(QEvt const *const e, std::uint_fast8_t const qsId)=0
Virtual function to dispatch an event to the state machine.
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 constexpr QMState const * QM_STATE_NULL
static QState top(void *const me, QEvt const *const e) noexcept
Top state handler that ignores all events.
static constexpr QState QM_HANDLED()
void init(DynEvt const dummy) const noexcept
Event initialization for dynamic events (overload).
@ DYNAMIC
Dummy parameter for dynamic event initialization (see QEvt::QEvt(DynEvt)).
void init() const noexcept
Event initialization for dynamic events.
std::uint32_t poolNum_
Event pool number of this event.
constexpr QEvt(QSignal const s) noexcept
Event constexpr constructor applicable to immutable and mutable event instances.
std::uint32_t refCtr_
Event reference counter.
QEvt()=delete
Disallowed default event constructor.
std::uint32_t filler_
Member of QP::QEvt to make it identical size in QP/C++ and SafeQP/C++.
std::uint32_t sig
Signal of the event (see Event Signal).
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.
QMActive(QStateHandler const initial) noexcept
Constructor of QP::QMActive class.
QStateHandler getStateHandler() const noexcept override
Virtual method for getting the current state handler.
bool isIn(QStateHandler const stateHndl) noexcept override
Virtual function to check whether the state machine is in a given state.
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
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.
QMState const * childStateObj(QMState const *const parent) const noexcept
QMState const * childStateObj(QMState const *const parentHndl) const noexcept
Obtain the current active child state of a given parent in QP::QMsm.
void exitToTranSource_(QMState const *const curr_state, QMState const *const tran_source, std::uint_fast8_t const qsId)
Exit the current state up to the explicit transition source.
QState execTatbl_(QMTranActTable const *const tatbl, std::uint_fast8_t const qsId)
Execute transition-action table.
static QMState const * topQMState() noexcept
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
QState enterHistory_(QMState const *const hist, std::uint_fast8_t const qsId)
Enter history of a composite state.
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.
bool isIn(QStateHandler const stateHndl) noexcept override
Tests if a given state is part of the current active state configuration.
QMsm(QStateHandler const initial) noexcept
Constructor of QP::QMsm.
QStateHandler getStateHandler() const noexcept override
Obtain the current active state from a MSM (read only).
Set of Active Objects of up to QF_MAX_ACTIVE elements.
std::uint_fast8_t findMax() const noexcept
Find the maximum element in the set.
void remove(std::uint_fast8_t const n) noexcept
Remove element n from the priority-set (n = 1..QF_MAX_ACTIVE).
QPSetBits m_bits1
Bitmask for elements 33..64.
bool notEmpty() const noexcept
Find out whether the priority-set is NOT empty.
bool hasElement(std::uint_fast8_t const n) const noexcept
Find out whether the priority-set has element n.
QPSetBits m_bits0
Bitmask for elements 1..32.
void setEmpty() noexcept
Make the priority set empty.
bool isEmpty() const noexcept
Find out whether the priority-set is empty.
void insert(std::uint_fast8_t const n) noexcept
Insert element n into the priority-set (n = 1..QF_MAX_ACTIVE).
Subscriber List (for publish-subscribe).
QPSet m_set
The set of AOs that subscribed to a given event signal.
void trig_(void const *const sender) noexcept
Asynchronously trigger the QTicker active object to perform tick processing.
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
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.
QTicker(std::uint8_t const tickRate) noexcept
Constructor of the QTicker Active Object class.
void const * getAct() const &&=delete
static void tick(std::uint_fast8_t const tickRate, void const *const sender) noexcept
Processes all armed time events at every clock tick.
QTimeEvt * m_next
Link to the next time event in the list.
QTimeEvt * toTimeEvt() noexcept
bool disarm() noexcept
Disarm a time event.
QTimeEvt(QActive *const act, QSignal const sig, std::uint_fast8_t const tickRate=0U) noexcept
The "extended" constructor to initialize a Time Event.
QTimeEvtCtr getInterval() const noexcept
static bool noActive(std::uint_fast8_t const tickRate) noexcept
Check if any time events are active at a given clock tick rate.
static void tickFromISR(std::uint_fast8_t const tickRate, void *par, void const *sender) noexcept
void * m_act
Active object that receives the time events.
QActive * toActive() noexcept
void armX(std::uint32_t const nTicks, std::uint32_t const interval=0U) noexcept
Arm a time event (extended version for one shot or periodic time event).
QTimeEvtCtr getCtr() const noexcept
Get the current value of the down-counter of a time event.
bool rearm(std::uint32_t const nTicks) noexcept
Rearm a time event.
std::uint8_t getTickRate() const noexcept
QTimeEvtCtr m_ctr
Down-counter of the time event.
QTimeEvtCtr m_interval
Interval for periodic time event (zero for one-shot time event).
void const * getAct() const &
bool wasDisarmed() noexcept
Check the "was disarmed" status of a time event.
eXtended (blocking) thread of the QXK preemptive kernel
QF Active Object Framework namespace.
void deleteRef_(QEvt const *const evtRef) noexcept
void onCleanup()
Cleanup QF callback.
QEvt const * newRef_(QEvt const *const e, QEvt const *const evtRef) noexcept
QEvt * newXfromISR_(std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, QSignal const sig) noexcept
void gc(QEvt const *const e) noexcept
Recycle a mutable (mutable) event.
QEvt * newX_(std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, QSignal const sig) noexcept
static std::uint_fast16_t getQueueMin(std::uint_fast8_t const prio) noexcept
This function returns the minimum of free entries of the given event queue.
evtT_ * q_new_x(std::uint_fast16_t const margin, QSignal const sig, Args... args)
void tick(std::uint_fast8_t const tickRate, void const *const sender) noexcept
evtT_ * q_new(QSignal const sig, Args... args)
void psInit(QSubscrList *const subscrSto, QSignal const maxSignal) noexcept
void gcFromISR(QEvt const *e) noexcept
std::uint16_t getPoolUse(std::uint_fast8_t const poolNum) noexcept
constexpr std::uint_fast16_t NO_MARGIN
Special value of margin that causes asserting failure in case event allocation or event posting fails...
void init()
QF initialization.
void q_new_ref(QP::QEvt const *const e, evtT_ const *&evtRef)
Create a new reference of the current event e.
std::uint16_t getPoolMin(std::uint_fast8_t const poolNum) noexcept
Obtain the minimum of free entries of the given event pool.
void q_delete_ref(evtT_ const *&evtRef)
Delete a new reference of the current event e.
int_t run()
Transfers control to QF to run the application.
void stop()
Invoked by the application layer to stop the QF framework and return control to the OS/Kernel (used i...
std::uint16_t getPoolFree(std::uint_fast8_t const poolNum) noexcept
void publish_(QEvt const *const e, void const *const sender, std::uint_fast8_t const qsId) noexcept
void onStartup()
Startup QF callback.
QP/C++ Framework namespace.
constexpr QSignal Q_USER_SIG
std::uint32_t QTimeEvtCtr
Data type to store the block-size defined based on the macro QF_TIMEEVT_CTR_SIZE.
QState(*)(void *const me) QActionHandler
Pointer to an action-handler function.
char const * version() noexcept
std::uint_fast8_t QF_LOG2(QP::QPSetBits const bitmask) noexcept
QEvt const * QEvtPtr
Pointer to const event instances passed around in QP/C++ Framework.
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::uint32_t QPSetBits
Bitmask for the internal representation of QPSet elements.
std::uint16_t QSignal
The signal of event QP::QEvt.
void(*)(QXThread *const me) QXThreadHandler
Pointer to an extended-thread handler function.
std::uint16_t QPrioSpec
Priority specification for Active Objects in QP.
int int_t
Alias for assertion-ID numbers in QP assertions and return from QP::QF::run().
#define Q_UNUSED_PAR(par_)
Helper macro to clearly mark unused parameters of functions.
void QF_onContextSw(QP::QActive *prev, QP::QActive *next)
#define QACTIVE_OS_OBJ_TYPE
QP::QActive "OS-object" type used in various QP/C++ ports.
#define QACTIVE_EQUEUE_TYPE
QP::QActive event queue type used in various QP/C++ ports.
#define QACTIVE_THREAD_TYPE
QP::QActive "thread" type used in various QP/C++ ports.
State object for the QP::QMsm class (QM State Machine).
QActionHandler const entryAction
QStateHandler const stateHandler
QActionHandler const exitAction
QMState const * superstate
QActionHandler const initAction
Transition-Action Table for the QP::QMsm State Machine.
QActionHandler const act[1]
Attribute of for the QP::QAsm class (Abstract State Machine).
QMTranActTable const * tatbl