46#ifndef QF_EVENT_SIZ_SIZE
48 #define QF_EVENT_SIZ_SIZE 2U
53 #define QF_MAX_EPOOL 3U
56#ifndef QF_MAX_TICK_RATE
59 #define QF_MAX_TICK_RATE 1U
60#elif (QF_MAX_TICK_RATE > 15U)
61 #error "QF_MAX_TICK_RATE exceeds the maximum of 15U"
64#ifndef QF_TIMEEVT_CTR_SIZE
67 #define QF_TIMEEVT_CTR_SIZE 2U
73#if (QF_EVENT_SIZ_SIZE == 1U)
75#elif (QF_EVENT_SIZ_SIZE == 2U)
83#elif (QF_EVENT_SIZ_SIZE == 4U)
86 #error "QF_EVENT_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U"
90#if (QF_TIMEEVT_CTR_SIZE == 1U)
92#elif (QF_TIMEEVT_CTR_SIZE == 2U)
103#elif (QF_TIMEEVT_CTR_SIZE == 4U)
106 #error "QF_TIMEEVT_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U"
156#ifdef QF_OS_OBJECT_TYPE
179 std::uint8_t m_dynPrio;
209 virtual void start(std::uint_fast8_t
const prio,
210 QEvt const * *
const qSto, std::uint_fast16_t
const qLen,
211 void *
const stkSto, std::uint_fast16_t
const stkSize,
212 void const *
const par);
215 virtual void start(std::uint_fast8_t
const prio,
216 QEvt const * *
const qSto, std::uint_fast16_t
const qLen,
217 void *
const stkSto, std::uint_fast16_t
const stkSize)
219 this->
start(prio, qSto, qLen, stkSto, stkSize,
nullptr);
269 std::uint_fast16_t
const margin)
noexcept;
271 virtual bool post_(
QEvt const *
const e, std::uint_fast16_t
const margin,
272 void const *
const sender)
noexcept;
435 std::uint_fast8_t
getPrio(
void)
const noexcept {
436 return static_cast<std::uint_fast8_t
>(
m_prio);
441 m_prio =
static_cast<std::uint8_t
>(prio);
445 void setAttr(std::uint32_t attr1,
void const *attr2 =
nullptr);
447#ifdef QF_OS_OBJECT_TYPE
480 QEvt
const *
get_(
void)
noexcept;
485 virtual bool postFromISR_(QEvt
const *
const e,
486 std::uint_fast16_t
const margin,
void *par,
487 void const *
const sender)
noexcept;
489 virtual bool postFromISR_(QEvt
const *
const e,
490 std::uint_fast16_t
const margin,
void *par)
noexcept;
538 void init(
void const *
const e,
539 std::uint_fast8_t
const qs_id)
override;
540 void init(std::uint_fast8_t
const qs_id)
override;
542 std::uint_fast8_t
const qs_id)
override;
642 std::uint_fast8_t
const tickRate = 0U)
noexcept;
693 bool disarm(
void)
noexcept;
809 static void init(
void);
843 enum_t const maxSignal)
noexcept;
876 static void poolInit(
void *
const poolSto,
877 std::uint_fast32_t
const poolSize,
878 std::uint_fast16_t
const evtSize)
noexcept;
920 static void stop(
void);
924 static void tickX_(std::uint_fast8_t
const tickRate)
noexcept;
945 void const *
const sender,
946 std::uint_fast8_t
const qs_id)
noexcept;
969 static void tickX_(std::uint_fast8_t
const tickRate,
970 void const *
const sender)
noexcept;
1004 static std::uint_fast16_t
getPoolMin(std::uint_fast8_t
const poolId)
1027 static std::uint_fast16_t
getQueueMin(std::uint_fast8_t
const prio)
1058 static QEvt *
newX_(std::uint_fast16_t
const evtSize,
1059 std::uint_fast16_t
const margin,
1060 enum_t const sig)
noexcept;
1086 static void gc(
QEvt const *
const e)
noexcept;
1104 QEvt const *
const evtRef)
noexcept;
1173 static void bzero(
void *
const start,
1174 std::uint_fast16_t
const len)
noexcept;
1179 static void publishFromISR_(
QEvt const *e,
void *par,
1180 void const *sender)
noexcept;
1181 static void tickXfromISR_(std::uint_fast8_t
const tickRate,
void *par,
1182 void const *
const sender)
noexcept;
1184 static void publishFromISR_(
QEvt const *e,
void *par)
noexcept;
1185 static void tickXfromISR_(std::uint_fast8_t
const tickRate,
1186 void *par)
noexcept;
1189 static QEvt *newXfromISR_(std::uint_fast16_t
const evtSize,
1190 std::uint_fast16_t
const margin,
1191 enum_t const sig)
noexcept;
1192 static void gcFromISR(
QEvt const *e)
noexcept;
1231 explicit QTicker(std::uint_fast8_t
const tickRate)
noexcept;
1233 void init(
void const *
const e,
1234 std::uint_fast8_t
const qs_id)
noexcept override;
1235 void init(std::uint_fast8_t
const qs_id)
noexcept override;
1237 std::uint_fast8_t
const qs_id)
noexcept override;
1243 std::uint_fast16_t
const margin)
noexcept override;
1245 bool post_(
QEvt const *
const e, std::uint_fast16_t
const margin,
1246 void const *
const sender)
noexcept override;
1254#ifndef QF_CRIT_EXIT_NOP
1265 #define QF_CRIT_EXIT_NOP() (static_cast<void>(0))
1272 #define Q_NEW(evtT_, sig_, ...) \
1273 (new(QP::QF::newX_(sizeof(evtT_), QP::QF_NO_MARGIN, 0)) \
1274 evtT_((sig_), ##__VA_ARGS__))
1276 #define Q_NEW_X(e_, evtT_, margin_, sig_, ...) do { \
1277 (e_) = static_cast<evtT_ *>( \
1278 QP::QF::newX_(sizeof(evtT_), (margin_), 0)); \
1279 if ((e_) != nullptr) { \
1280 new((e_)) evtT_((sig_), ##__VA_ARGS__); \
1307 #define Q_NEW(evtT_, sig_) (static_cast<evtT_ *>( \
1308 QP::QF::newX_(sizeof(evtT_), QP::QF_NO_MARGIN, (sig_))))
1336 #define Q_NEW_X(e_, evtT_, margin_, sig_) \
1337 ((e_) = static_cast<evtT_ *>(QP::QF::newX_( \
1338 sizeof(evtT_), (margin_), (sig_))))
1361#define Q_NEW_REF(evtRef_, evtT_) \
1362 ((evtRef_) = static_cast<evtT_ const *>(QP::QF::newRef_(e, (evtRef_))))
1379#define Q_DELETE_REF(evtRef_) do { \
1380 QP::QF::deleteRef_((evtRef_)); \
1411 #define TICK_X(tickRate_, sender_) tickX_((tickRate_), (sender_))
1435 #define PUBLISH(e_, sender_) \
1436 publish_((e_), (sender_), (sender_)->getPrio())
1459 #define POST(e_, sender_) post_((e_), QP::QF_NO_MARGIN, (sender_))
1494 #define POST_X(e_, margin_, sender_) \
1495 post_((e_), (margin_), (sender_))
1499 #define PUBLISH(e_, dummy_) publish_((e_))
1500 #define POST(e_, dummy_) post_((e_), QP::QF_NO_MARGIN)
1501 #define POST_X(e_, margin_, dummy_) post_((e_), (margin_))
1502 #define TICK_X(tickRate_, dummy_) tickX_((tickRate_))
1508#define TICK(sender_) TICK_X(0U, (sender_))
Dummy Active Object class for testing (inherits QP::QActive)
QActive active object class (based on QP::QHsm implementation strategy)
std::uint8_t m_prio
QF priority (1..QF_MAX_ACTIVE) of this active object.
void setAttr(std::uint32_t attr1, void const *attr2=nullptr)
Generic setting of additional attributes (useful in QP ports)
virtual void postLIFO(QEvt const *const e) noexcept
Posts an event directly to the event queue of the active object using the Last-In-First-Out (LIFO) po...
virtual void start(std::uint_fast8_t const prio, QEvt const **const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize)
Overloaded start function (no initialization event)
bool defer(QEQueue *const eq, QEvt const *const e) const noexcept
Defer an event to a given separate event queue.
virtual bool post_(QEvt const *const e, std::uint_fast16_t const margin, void const *const sender) noexcept
void unsubscribeAll(void) const noexcept
Unsubscribes from the delivery of all signals to the active object.
void subscribe(enum_t const sig) const noexcept
Subscribes for delivery of signal sig to the active object.
std::uint_fast8_t getPrio(void) const noexcept
Get the priority of the active object.
bool recall(QEQueue *const eq) noexcept
Recall a deferred event from a given event queue.
void stop(void)
Stops execution of an active object and removes it from the framework's supervision.
virtual void start(std::uint_fast8_t const prio, QEvt const **const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize, void const *const par)
Starts execution of an active object and registers the object with the framework.
std::uint_fast16_t flushDeferred(QEQueue *const eq) const noexcept
Flush the specified deferred queue 'eq'.
void unsubscribe(enum_t const sig) const noexcept
Unsubscribes from the delivery of signal sig to the active object.
QEvt const * get_(void) noexcept
Get an event from the event queue of an active object.
void setPrio(std::uint_fast8_t const prio)
Set the priority of the active object.
Native QF Event Queue class.
QF real-time active object framework.
static std::uint_fast16_t getPoolMin(std::uint_fast8_t const poolId) noexcept
This function returns the minimum of free entries of the given event pool.
static void onStartup(void)
Startup QF callback.
static void psInit(QSubscrList *const subscrSto, enum_t const maxSignal) noexcept
Publish-subscribe initialization.
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 of an active object (indic...
static void init(void)
QF initialization.
static void onCleanup(void)
Cleanup QF callback.
static void thread_(QActive *act)
Thread routine for executing an active object act.
static bool noTimeEvtsActiveX(std::uint_fast8_t const tickRate) noexcept
Returns true if all time events are inactive and false any time event is active.
static int_t run(void)
Transfers control to QF to run the application.
static QTimeEvt timeEvtHead_[QF_MAX_TICK_RATE]
heads of linked lists of time events, one for every clock tick rate
static void gc(QEvt const *const e) noexcept
Recycle a dynamic event.
static void deleteRef_(QEvt const *const evtRef) noexcept
Internal QF implementation of deleting event reference.
static QEvt * newX_(std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, enum_t const sig) noexcept
Internal QF implementation of creating new dynamic mutable event.
static void bzero(void *const start, std::uint_fast16_t const len) noexcept
Clear a specified region of memory to zero.
static void add_(QActive *const a) noexcept
Register an active object to be managed by the framework.
static void stop(void)
Function invoked by the application layer to stop the QF application and return control to the OS/Ker...
static QActive * active_[QF_MAX_ACTIVE+1U]
Internal array of registered active objects.
static std::uint_fast16_t poolGetMaxBlockSize(void) noexcept
Obtain the block size of any registered event pools.
static void remove_(QActive *const a) noexcept
Remove the active object from the framework.
static void poolInit(void *const poolSto, std::uint_fast32_t const poolSize, std::uint_fast16_t const evtSize) noexcept
Event pool initialization for dynamic allocation of events.
static QEvt const * newRef_(QEvt const *const e, QEvt const *const evtRef) noexcept
Internal QF implementation of creating new event reference.
static void tickX_(std::uint_fast8_t const tickRate, void const *const sender) noexcept
Processes all armed time events at every clock tick.
static char const * getVersion(void) noexcept
get the current QF version number string of the form X.Y.Z
static void publish_(QEvt const *const e, void const *const sender, std::uint_fast8_t const qs_id) noexcept
Publish event to all subscribers of a given signal e->sig
Hierarchical State Machine base class.
QStateHandler childState(QStateHandler const parent) noexcept
Obtain the current active child state of a given parent.
QHsmAttr m_state
current active state (state-variable)
QStateHandler state(void) const noexcept
Obtain the current state (state handler function)
bool isIn(QStateHandler const s) noexcept
Tests if a given state is part of the current active state configuration.
QMActive active object (based on QP::QMsm implementation)
QStateHandler getStateHandler() noexcept override
Get the current state handler of the QMsm.
void dispatch(QEvt const *const e, std::uint_fast8_t const qs_id) override
Dispatches an event to QHsm.
QMState const * childStateObj(QMState const *const parent) const noexcept
Obtain the current active child state of a given parent (read only)
void init(void const *const e, std::uint_fast8_t const qs_id) override
executes the top-most initial transition in QP::QHsm
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)
"Ticker" Active Object class (inherits QP::QActive)
void init(void const *const e, std::uint_fast8_t const qs_id) noexcept override
executes the top-most initial transition in QP::QHsm
void postLIFO(QEvt const *const e) noexcept override
Posts an event directly to the event queue of the active object using the Last-In-First-Out (LIFO) po...
bool post_(QEvt const *const e, std::uint_fast16_t const margin, void const *const sender) noexcept override
void dispatch(QEvt const *const e, std::uint_fast8_t const qs_id) noexcept override
Dispatches an event to QHsm.
Time Event class (inherits QP:QEvt)
QTimeEvtCtr currCtr(void) const noexcept
Get the current value of the down-counter of a time event.
QActive * toActive(void) noexcept
encapsulate the cast the m_act attribute to QActive*
QTimeEvtCtr volatile m_ctr
the internal down-counter of the time event
QTimeEvt * toTimeEvt(void) noexcept
encapsulate the cast the m_act attribute to QTimeEvt*
QTimeEvtCtr m_interval
the interval for the periodic time event (zero for the one-shot time event)
QTimeEvt(void) noexcept
private default constructor only for friends
QTimeEvt *volatile m_next
link to the next time event in the list
QTimeEvt(QTimeEvt const &)=delete
private copy constructor to disallow copying of QTimeEvts
void armX(QTimeEvtCtr const nTicks, QTimeEvtCtr const interval=0U) noexcept
Arm a time event (one shot or periodic) for event posting.
bool disarm(void) noexcept
Disarm a time event.
bool wasDisarmed(void) noexcept
Check the "was disarmed" status of a time event.
bool rearm(QTimeEvtCtr const nTicks) noexcept
Rearm a time event.
QTimeEvt & operator=(QTimeEvt const &)=delete
private assignment operator to disallow assigning of QTimeEvts
void *volatile m_act
the active object that receives the time events
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::uint_fast16_t const QF_NO_MARGIN
special value of margin that causes asserting failure in case event allocation or event posting fails
QMState const * obj
pointer to QMState object
constexpr char const versionStr[]
the current QP version number string based on QP_VERSION_STR
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to state-handler function.
std::uint16_t QEvtSize
The data type to store the block-size defined based on the macro #QF_EVENT_SIZ_SIZE.
std::uint32_t QTimeEvtCtr
State object for the QP::QMsm class (QM 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()
platform-independent priority sets of 8 or 64 elements.
void QXK_activate_(void)
QXK activator activates the next active object.
#define QF_OS_OBJECT_TYPE
Priority Set of up to 64 elements.