Reference Manual For QP/C++ 8.1.6
Loading...
Searching...
No Matches
qp.hpp
Go to the documentation of this file.
1//============================================================================
2// QP/C++ Real-Time Event Framework (RTEF)
3//
4// Copyright (C) 2005-2026 Quantum Leaps, LLC. All rights reserved.
5//
6// Q u a n t u m L e a P s
7// ------------------------
8// Modern Embedded Software
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
11//
12// This software is dual-licensed under the terms of the open-source GNU
13// General Public License, version 3 or later (GPL-3.0-or-later), or,
14// alternatively, under the terms of one of the closed-source Quantum Leaps
15// commercial licenses.
16//
17// Redistributions in source code must retain this top-level comment block.
18//
19// NOTE:
20// The GPL does NOT permit distributing this code as part of proprietary
21// (closed-source) programs. For such use, please contact Quantum Leaps for
22// a commercial license, which is an alternative to the GPL designed
23// explicitly for closed-source distribution.
24//
25// Quantum Leaps contact information:
26// <www.state-machine.com/licensing>
27// <info@state-machine.com>
28//============================================================================
29#ifndef QP_HPP_
30#define QP_HPP_
31
32//============================================================================
33#define QP_VERSION_STR "8.1.6"
34#define QP_VERSION 816U
35// <VER>=816 <DATE>=261117
36#define QP_RELEASE 0x645CB1FFU
37
38//----------------------------------------------------------------------------
39// default configuration settings
40//! @cond INTERNAL
41
42#ifndef QF_MAX_ACTIVE
43#define QF_MAX_ACTIVE 32U
44#endif
45
46#if (QF_MAX_ACTIVE > 64U)
47#error QF_MAX_ACTIVE exceeds the maximum of 64U;
48#endif
49
50#ifndef QF_MAX_TICK_RATE
51#define QF_MAX_TICK_RATE 1U
52#endif
53
54#if (QF_MAX_TICK_RATE > 15U)
55#error QF_MAX_TICK_RATE exceeds the maximum of 15U;
56#endif
57
58#ifndef QF_MAX_EPOOL
59#define QF_MAX_EPOOL 3U
60#endif
61
62#if (QF_MAX_EPOOL > 15U)
63#error QF_MAX_EPOOL exceeds the maximum of 15U;
64#endif
65
66#ifndef QF_TIMEEVT_CTR_SIZE
67#define QF_TIMEEVT_CTR_SIZE 4U
68#endif
69
70#if (QF_TIMEEVT_CTR_SIZE != 2U) && (QF_TIMEEVT_CTR_SIZE != 4U)
71#error QF_TIMEEVT_CTR_SIZE defined incorrectly, expected 2U or 4U;
72#endif
73
74//! @endcond
75
76//----------------------------------------------------------------------------
77#include "qp_cfgchk.hpp" // QP configuration check (link-time)
78
79//----------------------------------------------------------------------------
80// global types/utilities
81
82using int_t = int;
83
84#define Q_UNUSED_PAR(par_) (static_cast<void>(par_))
85#define Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U]))
86#define Q_UINT2PTR_CAST(type_, uint_) (reinterpret_cast<type_ *>(uint_))
87
88//============================================================================
89namespace QP {
90
91char const *version() noexcept;
92
93using QSignal = std::uint16_t;
94
95//----------------------------------------------------------------------------
96class QEvt {
97public:
98 std::uint32_t sig : 16;
99 std::uint32_t poolNum_ : 8;
100 std::uint32_t refCtr_ : 8;
101 std::uint32_t filler_;
102
103 enum DynEvt: std::uint8_t { DYNAMIC };
104
105 explicit constexpr QEvt(QSignal const s) noexcept
106 : sig(s) // the provided event signal
107 ,poolNum_(0x00U) // no-pool event
108 ,refCtr_ (0xE0U) // special event "marker"
109 ,filler_ (0xE0E0E0E0U) // the "filler" ensures the same QEvt size
110 // as in SafeQP/C++
111 {}
112
113 QEvt() // disallow the default ctor
114 = delete;
115 void init() const = delete; // derived event classes must declare init()
116 void init(DynEvt const dummy) const noexcept {
117 Q_UNUSED_PAR(dummy);
118 // no event parameters to initialize
119 }
120}; // class QEvt
121
122#ifndef QEQUEUE_HPP_
123// NOTE must be consistent with "qequeue.hpp"
124struct QEvtPtr {
125 QEvt const *e;
126};
127#endif // QEQUEUE_HPP_
128
129//----------------------------------------------------------------------------
130// QEP (hierarchical event processor) types
131
132using QState = std::uint_fast8_t;
133
134class QXThread; // forward declaration
135
136using QStateHandler = QState (*)(void * const me, QEvt const * const e);
137using QActionHandler = QState (*)(void * const me);
138using QXThreadHandler = void (*)(QXThread * const me);
139
140struct QMState {
141 QMState const *superstate;
142 QStateHandler const stateHandler;
143 QActionHandler const entryAction;
144 QActionHandler const exitAction;
145 QActionHandler const initAction;
146};
147
149 QMState const *target;
150 std::array<QActionHandler, 1> act;
151};
152
153union QAsmAttr {
154 QStateHandler fun;
155 QActionHandler act;
156 QXThreadHandler thr;
157 QMState const *obj;
158 QMTranActTable const *tatbl;
159 std::uintptr_t uint;
160};
161
162constexpr QSignal Q_USER_SIG {4U};
163
164//----------------------------------------------------------------------------
165class QAsm {
166public:
169
170 // All possible values returned from state/action handlers...
171 // NOTE: The numerical order is important for algorithmic correctness.
172 static constexpr QState Q_RET_SUPER {0U};
173 static constexpr QState Q_RET_UNHANDLED {1U};
174 static constexpr QState Q_RET_HANDLED {2U};
175 static constexpr QState Q_RET_TRAN {3U};
176 static constexpr QState Q_RET_TRAN_HIST {4U};
177
178 // used in QHsm only...
179 static constexpr QState Q_RET_IGNORED {5U};
180
181 // used in QMsm only...
182 static constexpr QState Q_RET_ENTRY {6U};
183 static constexpr QState Q_RET_EXIT {7U};
184 static constexpr QState Q_RET_TRAN_INIT {8U};
185
186 // Reserved signals by the QP-framework (used in QHsm only)
187 static constexpr QSignal Q_EMPTY_SIG {0U};
188 static constexpr QSignal Q_ENTRY_SIG {1U};
189 static constexpr QSignal Q_EXIT_SIG {2U};
190 static constexpr QSignal Q_INIT_SIG {3U};
191
192 static constexpr QState Q_HANDLED() { // for coding QHsm state machines
193 return Q_RET_HANDLED; }
194 static constexpr QState Q_UNHANDLED() { // for coding QHsm state machines
195 return Q_RET_UNHANDLED; }
196 static constexpr QState QM_HANDLED() { // for coding QMsm state machines
197 return Q_RET_HANDLED; }
198 static constexpr QState QM_UNHANDLED() { // for coding QMsm state machines
199 return Q_RET_HANDLED; }
200 static constexpr QState QM_SUPER() { // for coding QMsm state machines
201 return Q_RET_SUPER; }
202 static constexpr QMState const *QM_STATE_NULL { nullptr };
203 static constexpr QActionHandler const Q_ACTION_NULL { nullptr };
204
205 // maximum supported nesting depth of a state machine (see code.dox)
206 static constexpr std::size_t MAX_NEST_DEPTH_ {5U};
207 static_assert(MAX_NEST_DEPTH_ >= 3U, "MAX_NEST_DEPTH_ must be >= 3");
208
209#ifdef Q_XTOR
210 virtual ~QAsm() = default;
211#endif // def Q_XTOR
212 virtual void init(
213 void const * const e,
214 std::uint_fast8_t const qsId) = 0;
215 virtual void init(std::uint_fast8_t const qsId);
216 virtual void dispatch(
217 QEvt const * const e,
218 std::uint_fast8_t const qsId) = 0;
219 virtual bool isIn(QStateHandler const stateHndl) = 0;
220 virtual QStateHandler getStateHandler() const noexcept = 0;
221
222 QStateHandler state() const noexcept {
223 return m_state.fun; // public "getter" for the state handler
224 }
225 QMState const * stateObj() const noexcept {
226 return m_state.obj; // public "getter" for the state object
227 }
228
229 static QState top(void * const me, QEvt const * const e) noexcept;
230
231protected:
232 explicit QAsm() noexcept;
233
234 QState tran(QStateHandler const target) noexcept {
235 // for coding QMsm state machines
236 m_temp.fun = target;
237 return Q_RET_TRAN;
238 }
239 QState tran_hist(QStateHandler const hist) noexcept {
240 // for coding QMsm state machines
241 m_temp.fun = hist;
242 return Q_RET_TRAN_HIST;
243 }
244 QState super(QStateHandler const superstate) noexcept {
245 // for coding QMsm state machines
246 m_temp.fun = superstate;
247 return Q_RET_SUPER;
248 }
249 QState qm_tran(void const * const tatbl) noexcept {
250 // for coding QMsm state machines
251 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
252 return Q_RET_TRAN;
253 }
254 QState qm_tran_init(void const * const tatbl) noexcept {
255 // for coding QMsm state machines
256 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
257 return Q_RET_TRAN_INIT;
258 }
260 QMState const * const hist,
261 void const * const tatbl) noexcept
262 { // for coding QMsm state machines
263 m_state.obj = hist; // store the history in state
264 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
265 return Q_RET_TRAN_HIST;
266 }
267
268 QState qm_entry(QMState const * const s) noexcept {
269 // for coding QMsm state machines
270 m_temp.obj = s;
271 return Q_RET_ENTRY;
272 }
273
274 QState qm_exit(QMState const * const s) noexcept {
275 // for coding QMsm state machines
276 m_temp.obj = s;
277 return Q_RET_EXIT;
278 }
279}; // class QAsm
280
281//----------------------------------------------------------------------------
282class QHsm : public QP::QAsm {
283protected:
284 explicit QHsm(QStateHandler const initial) noexcept;
285
286public:
287 using QAsm::init;
288 void init(
289 void const * const e,
290 std::uint_fast8_t const qsId) override;
291 void dispatch(
292 QEvt const * const e,
293 std::uint_fast8_t const qsId) override;
294 bool isIn(QStateHandler const stateHndl) noexcept override;
295 QStateHandler getStateHandler() const noexcept override;
296
297 QStateHandler childState(QStateHandler const parentHndl) noexcept;
298
299private:
300 // length of the path[] arrays (all nesting levels and the top state)
301 static constexpr std::size_t MAX_PATH_LEN_ {MAX_NEST_DEPTH_ + 1U};
302
303 std::size_t tran_simple_(
304 std::array<QStateHandler, MAX_PATH_LEN_> &path,
305 std::uint_fast8_t const qsId);
306
307 std::size_t tran_complex_(
308 std::array<QStateHandler, MAX_PATH_LEN_> &path,
309 std::uint_fast8_t const qsId);
310
312 std::array<QStateHandler, MAX_PATH_LEN_> &path,
313 std::size_t const depth,
314 std::uint_fast8_t const qsId);
315
316 // friends...
317 friend class QS;
318}; // class QHsm
319
320//----------------------------------------------------------------------------
321class QMsm : public QP::QAsm {
322protected:
323 explicit QMsm(QStateHandler const initial) noexcept;
324
325public:
326 using QAsm::init;
327 void init(
328 void const * const e,
329 std::uint_fast8_t const qsId) override;
331 QEvt const * const e,
332 std::uint_fast8_t const qsId) override;
333 bool isIn(QStateHandler const stateHndl) noexcept override;
334 QStateHandler getStateHandler() const noexcept override;
335
336 QMState const * childStateObj(QMState const * const parentHndl)
337 const noexcept;
338 static QMState const * topQMState() noexcept;
339
340private:
342 QMTranActTable const * const tatbl,
343 std::uint_fast8_t const qsId);
345 QMState const * const curr_state,
346 QMState const * const tran_source,
347 std::uint_fast8_t const qsId);
349 QMState const * const hist,
350 std::uint_fast8_t const qsId);
351
352 // friends...
353 friend class QS;
354}; // class QMsm
355
356} // namespace QP
357
358//============================================================================
359// QEP-macros
360
361#define Q_STATE_DECL(state_) \
362 QP::QState state_ ## _h(QP::QEvt const * const e); \
363 static QP::QState state_(void * const me, QP::QEvt const * const e)
364
365#define Q_STATE_DEF(subclass_, state_) \
366 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) { \
367 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
368 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)
369
370#define Q_EVT_CAST(subclass_) (static_cast<subclass_ const *>(e))
371#define Q_STATE_CAST(handler_) (reinterpret_cast<QP::QStateHandler>(handler_))
372
373#define QM_STATE_DECL(state_) \
374 QP::QState state_ ## _h(QP::QEvt const * const e); \
375 static QP::QState state_(void * const me, QP::QEvt const * const e); \
376 static QP::QMState const state_ ## _s
377
378#define QM_ACTION_DECL(action_) \
379 QP::QState action_ ## _h(); \
380 static QP::QState action_(void * const me)
381
382#define QM_STATE_DEF(subclass_, state_) \
383 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) {\
384 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
385 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)
386
387#define QM_ACTION_DEF(subclass_, action_) \
388 QP::QState subclass_::action_(void * const me) { \
389 return static_cast<subclass_ *>(me)->action_ ## _h(); } \
390 QP::QState subclass_::action_ ## _h()
391
392#ifdef Q_SPY
393 #define INIT(qsId_) init((qsId_))
394 #define DISPATCH(e_, qsId_) dispatch((e_), (qsId_))
395#else
396 #define INIT(dummy) init(0U)
397 #define DISPATCH(e_, dummy) dispatch((e_), 0U)
398#endif // ndef Q_SPY
399
400//============================================================================
401namespace QP {
402
403using QPrioSpec = std::uint16_t;
404
405class QEQueue; // forward declaration
406class QActive; // forward declaration
407
408#if (QF_TIMEEVT_CTR_SIZE == 2U)
409 using QTimeEvtCtr = std::uint16_t;
410#elif (QF_TIMEEVT_CTR_SIZE == 4U)
411 using QTimeEvtCtr = std::uint32_t;
412#endif // (QF_TIMEEVT_CTR_SIZE == 4U)
413
414#if (QF_MAX_ACTIVE <= 8U)
415 using QPSetBits = std::uint8_t;
416#elif (8U < QF_MAX_ACTIVE) && (QF_MAX_ACTIVE <= 16U)
417 using QPSetBits = std::uint16_t;
418#elif (16 < QF_MAX_ACTIVE)
419 using QPSetBits = std::uint32_t;
420#endif // (16 < QF_MAX_ACTIVE)
421
422#ifndef QF_LOG2
423 std::uint_fast8_t QF_LOG2(QP::QPSetBits const bitmask) noexcept;
424#endif // ndef QF_LOG2
425
426//----------------------------------------------------------------------------
427class QPSet {
428private:
430#if (QF_MAX_ACTIVE > 32U)
432#endif
433
434public:
435 constexpr QPSet()
436 : m_bits0(0U)
437#if (QF_MAX_ACTIVE > 32U)
438 ,m_bits1(0U)
439#endif
440 {}
441
442 void setEmpty() noexcept;
443 bool isEmpty() const noexcept;
444 bool notEmpty() const noexcept;
445 bool hasElement(std::uint_fast8_t const n) const noexcept;
446 void insert(std::uint_fast8_t const n) noexcept;
447 void remove(std::uint_fast8_t const n) noexcept;
448 std::uint_fast8_t findMax() const noexcept;
449
450 // friends...
451 friend class QS;
452}; // class QPSet
453
454//----------------------------------------------------------------------------
456private:
458
459 // friends...
460 friend class QActive;
461 friend class QS;
462}; // class QSubscrList
463
464//----------------------------------------------------------------------------
465// declarations for friendship with the QActive class
466
467namespace QF {
468 void QF_INIT_CFGCHK_(); // config.-specific name, see "qp_cfgchk.hpp"
469 inline void init() {
471 }
472 void stop();
473 int_t run();
474
475 void onStartup();
476 void onCleanup();
477
478 constexpr std::uint_fast16_t NO_MARGIN {0xFFFFU};
479} // namespace QF
480
481//----------------------------------------------------------------------------
482class QActive : public QAsm {
483private:
484 std::uint8_t m_prio;
485 std::uint8_t m_pthre;
486
487#ifdef QACTIVE_THREAD_TYPE
489#endif
490
491#ifdef QACTIVE_OS_OBJ_TYPE
493#endif
494
495#ifdef QACTIVE_EQUEUE_TYPE
497#endif
498
499protected:
500 explicit QActive(QStateHandler const initial) noexcept;
501
502public:
503 using QAsm::init;
504 void init(
505 void const * const e,
506 std::uint_fast8_t const qsId) override;
507 void dispatch(
508 QEvt const * const e,
509 std::uint_fast8_t const qsId) override;
510 bool isIn(QStateHandler const stateHndl) noexcept override;
511 QStateHandler getStateHandler() const noexcept override;
512
513 QStateHandler childState(QStateHandler const parentHandler) noexcept;
515 std::uint32_t attr1,
516 void const * attr2 = nullptr);
517 void start(QPrioSpec const prioSpec,
518 QEvtPtr * const qSto, std::uint_fast16_t const qLen,
519 void * const stkSto, std::uint_fast16_t const stkSize,
520 void const * const par = nullptr);
521
522#ifdef QACTIVE_CAN_STOP
523 void stop();
524#endif // def QACTIVE_CAN_STOP
525 void register_() noexcept;
526 void unregister_() noexcept;
527 void post_(QEvt const * const e,
528 void const * const sender) noexcept
529 {
530 // delegate to postx_() with margin==QF::NO_MARGIN
531 static_cast<void>(postx_(e, QF::NO_MARGIN, sender));
532 }
533 bool postx_(QEvt const * const e,
534 std::uint_fast16_t const margin,
535 void const * const sender) noexcept;
536 void postLIFO(QEvt const * const e) noexcept;
537 QEvt const * get_() noexcept;
538 static std::uint16_t getQueueUse(
539 std::uint_fast8_t const prio) noexcept;
540 static std::uint16_t getQueueFree(
541 std::uint_fast8_t const prio) noexcept;
542 static std::uint16_t getQueueMin(
543 std::uint_fast8_t const prio) noexcept;
544 static void psInit(
545 QSubscrList * const subscrSto,
546 QSignal const maxSignal) noexcept;
547 static void publish_(
548 QEvt const * const e,
549 void const * const sender,
550 std::uint_fast8_t const qsId) noexcept;
551 void subscribe(QSignal const sig) const noexcept;
552 void unsubscribe(QSignal const sig) const noexcept;
553 void unsubscribeAll() const noexcept;
554 bool defer(
555 QEQueue * const eq,
556 QEvt const * const e) const noexcept;
557 bool recall(QEQueue * const eq) noexcept;
558 std::uint16_t flushDeferred(
559 QEQueue * const eq,
560 std::uint_fast16_t const num = 0xFFFFU) const noexcept;
561 std::uint8_t getPrio() const noexcept {
562 return m_prio; // public "getter" for the AO's prio
563 }
564 static void evtLoop_(QActive *act);
565
566#ifdef QACTIVE_THREAD_TYPE
567 QACTIVE_THREAD_TYPE const & getThread() const & {
568 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
569 return m_thread;
570 }
571 QACTIVE_THREAD_TYPE const & getThread() const &&
572 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
573 = delete;
574 void setThread(QACTIVE_THREAD_TYPE const & thr) noexcept {
575 m_thread = thr; // public "setter", useful for MPU applications
576 }
577#endif // QACTIVE_THREAD_TYPE
578
579#ifdef QACTIVE_OS_OBJ_TYPE
580 QACTIVE_OS_OBJ_TYPE const & getOsObject() const & {
581 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
582 return m_osObject;
583 }
584 QACTIVE_OS_OBJ_TYPE const & getOsObject() const &&
585 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
586 = delete;
587#endif // QACTIVE_OS_OBJ_TYPE
588
589#ifdef QF_ISR_API
590 virtual bool postFromISR(
591 QEvt const * const e,
592 std::uint_fast16_t const margin,
593 void * const par,
594 void const * const sender) noexcept;
595
596 static void publishFromISR(
597 QEvt const * const e,
598 void * const par,
599 void const * const sender) noexcept;
600#endif // QF_ISR_API
601
602private:
603 void postFIFO_(
604 QEvt const * const e,
605 void const * const sender);
606 static void multicast_(
607 QPSet * const subscrSet,
608 QEvt const * const e,
609 void const * const sender);
610
611 // friends...
612 friend class QTimeEvt;
613 friend class QTicker;
614 friend class QXThread;
615 friend class QXMutex;
616 friend class QXSemaphore;
617 friend class QMActive;
618 friend class QActiveDummy;
619 friend class QK;
620 friend class QXK;
621 friend class QS;
622
623 friend void QF::QF_INIT_CFGCHK_();
624 friend void QF::stop();
625 friend int_t QF::run();
626 friend void QF::onStartup();
627 friend void QF::onCleanup();
628
629}; // class QActive
630
631//----------------------------------------------------------------------------
632class QMActive : public QActive {
633protected:
634 explicit QMActive(QStateHandler const initial) noexcept;
635
636public:
637 using QActive::init;
638 void init(
639 void const * const e,
640 std::uint_fast8_t const qsId) override;
641 void dispatch(
642 QEvt const * const e,
643 std::uint_fast8_t const qsId) override;
644 bool isIn(QStateHandler const stateHndl) noexcept override;
645 QStateHandler getStateHandler() const noexcept override;
646
647 QMState const *childStateObj(QMState const * const parent) const noexcept;
648}; // class QMActive
649
650//----------------------------------------------------------------------------
651#if (QF_MAX_TICK_RATE > 0U)
652
653class QTimeEvt : public QEvt {
654private:
656 void * m_act;
659 std::uint8_t m_tickRate;
660 std::uint8_t m_flags;
661
662public:
663 QTimeEvt(
664 QActive * const act,
665 QSignal const sig,
666 std::uint_fast8_t const tickRate = 0U) noexcept;
667 void armX(
668 std::uint32_t const nTicks,
669 std::uint32_t const interval = 0U) noexcept;
670 bool disarm() noexcept;
671 bool rearm(std::uint32_t const nTicks) noexcept;
672 bool wasDisarmed() noexcept;
673 void const * getAct() const & {
674 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
675 return m_act;
676 }
677 void const * getAct() const &&
678 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
679 = delete;
680 QTimeEvtCtr getCtr() const noexcept {
681 return m_ctr; // public "getter" for the current time-evt count
682 }
683 QTimeEvtCtr getInterval() const noexcept {
684 return m_interval; // public "getter" for the time-evt interval
685 }
686 std::uint8_t getTickRate() const noexcept {
687 return m_tickRate; // public "getter" for the time-evt tick rate
688 }
689 std::uint8_t getFlags() const noexcept {
690 return m_flags; // public "getter" for the time-evt flags
691 }
692 static void tick(
693 std::uint_fast8_t const tickRate,
694 void const * const sender) noexcept;
695
696#ifdef Q_UTEST
697 static void tick1_(
698 std::uint_fast8_t const tickRate,
699 void const * const sender);
700#endif // def Q_UTEST
701
702#ifdef QF_ISR_API
703 static void tickFromISR(
704 std::uint_fast8_t const tickRate,
705 void * const par,
706 void const * sender) noexcept;
707#endif // def QF_ISR_API
708 static bool noActive(std::uint_fast8_t const tickRate) noexcept;
709 QActive * toActive() noexcept {
710 // public "getter" for the AO associated with this time-evt
711 return static_cast<QActive *>(m_act);
712 }
713 QTimeEvt * toTimeEvt() noexcept {
714 // public "getter" for the AO associated with this time-evt
715 // NOTE: used for the special time-evts in QTimeEvt_head_[] array
716 return static_cast<QTimeEvt *>(m_act);
717 }
718 QTimeEvt() noexcept;
719
720private:
721 QTimeEvt *expire_(
722 QTimeEvt * const prev_link,
723 QActive const * const act,
724 std::uint_fast8_t const tickRate) noexcept;
725
726 // friends...
727 friend class QXThread;
728 friend class QS;
729}; // class QTimeEvt
730
731//----------------------------------------------------------------------------
732class QTicker : public QActive {
733public:
734 explicit QTicker(std::uint8_t const tickRate) noexcept;
735 using QActive::init;
736 void init(
737 void const * const e,
738 std::uint_fast8_t const qsId) override;
739 void dispatch(
740 QEvt const * const e,
741 std::uint_fast8_t const qsId) override;
742 void trig_(void const * const sender) noexcept;
743}; // class QTicker
744
745#endif // (QF_MAX_TICK_RATE > 0U)
746
747//----------------------------------------------------------------------------
748namespace QF {
749
750//! @deprecated
751inline void psInit( QSubscrList * const subscrSto,
752 QSignal const maxSignal) noexcept
753{
754 // use QActive::psInit() instead of the deprecated QF::psInit()
755 QActive::psInit(subscrSto, maxSignal);
756}
757
758//! @deprecated
759inline void publish_(QEvt const * const e,
760 void const * const sender, std::uint_fast8_t const qsId) noexcept
761{
762 // use QActive::publish_() instead of the deprecated QF::publish_()
763 QActive::publish_(e, sender, qsId);
764}
765
766//! @deprecated
767inline std::uint_fast16_t getQueueMin(
768 std::uint_fast8_t const prio) noexcept
769{
770 // use QActive::getQueueMin() instead of the deprecated QF::getQueueMin()
771 return QActive::getQueueMin(prio);
772}
773
774#if (QF_MAX_TICK_RATE > 0U)
775//! @deprecated
776inline void tick(
777 std::uint_fast8_t const tickRate,
778 void const * const sender) noexcept
779{
780 // use QTimeEvt::tick() instead of the deprecated QF::tick()
781 QTimeEvt::tick(tickRate, sender);
782}
783#endif // (QF_MAX_TICK_RATE > 0U)
784
785//----------------------------------------------------------------------------
786// QF base facilities
787QPrioSpec prioSpec(
788 std::uint8_t const prio,
789 std::uint8_t const pthre) noexcept;
790
791//----------------------------------------------------------------------------
792// QF dynamic memory facilities
793void poolInit(
794 void * const poolSto,
795 std::uint_fast32_t const poolSize,
796 std::uint_fast16_t const evtSize) noexcept;
797
798std::uint16_t poolGetMaxBlockSize() noexcept;
799std::uint16_t getPoolUse(std::uint_fast8_t const poolNum) noexcept;
800std::uint16_t getPoolFree(std::uint_fast8_t const poolNum) noexcept;
801std::uint16_t getPoolMin(std::uint_fast8_t const poolNum) noexcept;
802QEvt * newX_(
803 std::uint_fast16_t const evtSize,
804 std::uint_fast16_t const margin,
805 QSignal const sig) noexcept;
806void gc(QEvt const * const e) noexcept;
807QEvt const * newRef_(
808 QEvt const * const e,
809 QEvt const * const evtRef) noexcept;
810
811void deleteRef_(QEvt const * const evtRef) noexcept;
812
813#ifndef QEVT_PAR_INIT
814 template<class evtT_>
815 inline evtT_ * q_new(QSignal const sig) {
816 // allocate a dynamic (mutable) event with NO_MARGIN
817 // NOTE: the returned event ptr is guaranteed NOT to be nullptr
818 return static_cast<evtT_*>(
819 QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, sig));
820 }
821 template<class evtT_>
822 inline evtT_ * q_new_x(std::uint_fast16_t const margin,
823 QSignal const sig)
824 {
825 // allocate a dynamic (mutable) event with a provided margin
826 // NOTE: the returned event ptr might be nullptr
827 return static_cast<evtT_*>(QP::QF::newX_(sizeof(evtT_), margin, sig));
828 }
829#else
830 //! @cond INTERNAL
831 // compile-time helpers for q_new()/q_new_x()
832 template<class evtT_> struct isQEvt_ {
833 static constexpr bool value = false;
834 };
835 template<> struct isQEvt_<QEvt> {
836 static constexpr bool value = true;
837 };
838 template<typename... Args> struct isDynTag_ {
839 static constexpr bool value = false;
840 };
841 template<> struct isDynTag_<QEvt::DynEvt> {
842 static constexpr bool value = true;
843 };
844 //! @endcond
845
846 template<class evtT_, typename... Args>
847 inline evtT_ * q_new(QSignal const sig, Args... args) {
848 static_assert(isQEvt_<evtT_>::value || !isDynTag_<Args...>::value,
849 "QEvt::DYNAMIC is only for QP::QEvt; an event class with "
850 "parameters must declare its own init()");
851 // allocate a dynamic (mutable) event with NO_MARGIN
852 // NOTE: the returned event ptr is guaranteed NOT to be nullptr
853 evtT_ *e = static_cast<evtT_*>(
854 QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, sig));
855 e->init(args...); // immediately initialize the event (RAII)
856 return e;
857 }
858 template<class evtT_, typename... Args>
859 inline evtT_ * q_new_x(std::uint_fast16_t const margin,
860 QSignal const sig, Args... args)
861 {
862 static_assert(isQEvt_<evtT_>::value || !isDynTag_<Args...>::value,
863 "QEvt::DYNAMIC is only for QP::QEvt; an event class with "
864 "parameters must declare its own init()");
865 // allocate a dynamic (mutable) event with a provided margin
866 // NOTE: the event allocation might fail
867 evtT_ *e =
868 static_cast<evtT_*>(QP::QF::newX_(sizeof(evtT_), margin, sig));
869 if (e != nullptr) { // was the allocation successful?
870 e->init(args...); // immediately initialize the event (RAII)
871 }
872 // NOTE: the returned event ptr might be nullptr
873 return e;
874 }
875#endif // QEVT_PAR_INIT
876
877template<class evtT_>
878inline void q_new_ref(
879 QP::QEvt const * const e,
880 evtT_ const *& evtRef)
881{
882 // set the const event reference (must NOT be nullptr)
883 evtRef = static_cast<evtT_ const *>(QP::QF::newRef_(e, evtRef));
884}
885
886template<class evtT_>
887inline void q_delete_ref(evtT_ const *& evtRef) {
888 QP::QF::deleteRef_(evtRef);
889 evtRef = nullptr; // invalidate the associated event reference
890}
891
892#ifdef QF_ISR_API
893QEvt * newXfromISR_(
894 std::uint_fast16_t const evtSize,
895 std::uint_fast16_t const margin,
896 QSignal const sig) noexcept;
897void gcFromISR(QEvt const * e) noexcept;
898#endif // def QF_ISR_API
899
900} // namespace QF
901} // namespace QP
902
903//============================================================================
904
905#ifdef QF_ON_CONTEXT_SW
906extern "C" void QF_onContextSw(QP::QActive * prev, QP::QActive * next);
907#endif // QF_ON_CONTEXT_SW
908
909//----------------------------------------------------------------------------
910// QF base facilities
911
912#ifndef QEVT_PAR_INIT
913 #define Q_NEW(evtT_, sig_) (QP::QF::q_new<evtT_>((sig_)))
914 #define Q_NEW_X(evtT_, margin_, sig_) \
915 (QP::QF::q_new_x<evtT_>((margin_), (sig_)))
916#else
917 #define Q_NEW(evtT_, sig_, ...) \
918 (QP::QF::q_new<evtT_>((sig_), __VA_ARGS__))
919 #define Q_NEW_X(evtT_, margin_, sig_, ...) \
920 (QP::QF::q_new_x<evtT_>((margin_), (sig_), __VA_ARGS__))
921#endif // QEVT_PAR_INIT
922
923#define Q_NEW_REF(evtRef_, evtT_) (QP::QF::q_new_ref<evtT_>(e, (evtRef_)))
924#define Q_DELETE_REF(evtRef_) do { \
925 QP::QF::deleteRef_((evtRef_)); \
926 (evtRef_) = nullptr; \
927} while (false)
928
929#ifdef Q_SPY
930 #define PUBLISH(e_, sender_) \
931 publish_((e_), (sender_), (sender_)->getPrio())
932 #define POST(e_, sender_) post_((e_), (sender_))
933 #define POST_X(e_, margin_, sender_) \
934 postx_((e_), (margin_), (sender_))
935 #define TICK_X(tickRate_, sender_) tick((tickRate_), (sender_))
936 #define TRIG(sender_) trig_((sender_))
937#else
938 #define PUBLISH(e_, dummy) publish_((e_), nullptr, 0U)
939 #define POST(e_, dummy) post_((e_), nullptr)
940 #define POST_X(e_, margin_, dummy) postx_((e_), (margin_), nullptr)
941 #define TICK_X(tickRate_, dummy) tick((tickRate_), nullptr)
942 #define TRIG(sender_) trig_(nullptr)
943#endif // ndef Q_SPY
944
945#define TICK(sender_) TICK_X(0U, (sender_))
946
947#ifndef QF_CRIT_EXIT_NOP
948 #define QF_CRIT_EXIT_NOP() (static_cast<void>(0))
949#endif // ndef QF_CRIT_EXIT_NOP
950
951#endif // QP_HPP_
Active Object class (based on the QP::QHsm implementation strategy).
Definition qp.hpp:482
QACTIVE_THREAD_TYPE m_thread
Port-dependent representation of the thread of the active object.
Definition qp.hpp:488
static std::uint16_t getQueueMin(std::uint_fast8_t const prio) noexcept
Obtain the minimum of free entries of the given event queue since start.
Definition qf_actq.cpp:349
void unregister_() noexcept
Un-register the active object from the framework.
Definition qf_qact.cpp:129
void init(void const *const e, std::uint_fast8_t const qsId) override
Take the top-most initial transition in QActive (delegate to QP::QHsm).
Definition qf_qact.cpp:147
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)...
Definition qp.hpp:527
void register_() noexcept
Register this active object to be managed by the framework.
Definition qf_qact.cpp:78
void postFIFO_(QEvt const *const e, void const *const sender)
Internal helper function to insert event to QP::QEQueue queue.
Definition qf_actq.cpp:240
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.
Definition qf_ps.cpp:76
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)Forward Tracea...
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
Dispatch an event to QActive (delegate to QP::QHsm).
Definition qf_qact.cpp:155
bool isIn(QStateHandler const stateHndl) noexcept override
Is-in-state query in QActive (delegate to QP::QHsm).
Definition qf_qact.cpp:163
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)...
Definition qf_actq.cpp:49
QActive(QStateHandler const initial) noexcept
QActive constructor (abstract base class).
Definition qf_qact.cpp:65
QACTIVE_EQUEUE_TYPE m_eQueue
Port-dependent event-queue type (often QP::QEQueue).
Definition qp.hpp:496
QStateHandler childState(QStateHandler const parentHandler) noexcept
Obtain the current active child state of a given parent in QP::QActive (delegate to QP::QHsm).
Definition qf_qact.cpp:168
static void psInit(QSubscrList *const subscrSto, QSignal const maxSignal) noexcept
Initializes the publish-subscribe facility for the application.
Definition qf_ps.cpp:51
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.
Definition qv.cpp:173
QStateHandler getStateHandler() const noexcept override
Get current state-handler in QActive (delegate to QP::QHsm).
Definition qf_qact.cpp:173
std::uint8_t m_pthre
Preemption-threshold [1..QF_MAX_ACTIVE] of this AO.
Definition qp.hpp:485
QACTIVE_OS_OBJ_TYPE m_osObject
Port-dependent per-thread object.
Definition qp.hpp:492
virtual bool postFromISR(QEvt const *const e, std::uint_fast16_t const margin, void *const par, void const *const sender) noexcept
The "FromISR" variant used in the QP port to "FreeRTOS" \clearpage .
std::uint8_t m_prio
QF-priority [1..QF_MAX_ACTIVE] of this AO.
Definition qp.hpp:484
static void publishFromISR(QEvt const *const e, void *const par, void const *const sender) noexcept
The "FromISR" variant used in the QP port to "FreeRTOS" \clearpage \clearpage .
Abstract State Machine class (state machine interface).
Definition qp.hpp:165
QState qm_entry(QMState const *const s) noexcept
Internal helper function to execute state entry actions in QP::QMsm.
Definition qp.hpp:268
QAsm() noexcept
Constructor of the QP::QAsm base class.
Definition qf_act.cpp:79
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.
Definition qp.hpp:259
QStateHandler state() const noexcept
Obtain the current active state from a state machine (read only).
Definition qp.hpp:222
static constexpr QState Q_RET_UNHANDLED
Return value from a state handler: the event was not handled due to a guard condition (Q_UNHANDLED())...
Definition qp.hpp:173
QState qm_tran(void const *const tatbl) noexcept
Internal helper function to take a state transition in QP::QMsm.
Definition qp.hpp:249
static constexpr QState Q_RET_TRAN
Return value from a state handler: a regular state transition was taken (tran()) \clearpage .
Definition qp.hpp:175
static constexpr QState Q_RET_ENTRY
Return value from an entry action: the entry action was executed (used in QP::QMsm only) \clearpage ...
Definition qp.hpp:182
QState qm_exit(QMState const *const s) noexcept
Internal helper function to execute state exit actions in QP::QMsm.
Definition qp.hpp:274
QState tran_hist(QStateHandler const hist) noexcept
Internal helper function to take a state transition to history in sublclasses of QP::QAsm.
Definition qp.hpp:239
QState super(QStateHandler const superstate) noexcept
Internal helper function to indicate superstate of a given state in sublclasses of QP::QAsm.
Definition qp.hpp:244
QState qm_tran_init(void const *const tatbl) noexcept
Internal helper function to take an initial transition in QP::QMsm.
Definition qp.hpp:254
QAsmAttr m_temp
Temporary storage for target/act-table etc.
Definition qp.hpp:168
static constexpr QState Q_RET_IGNORED
Return value from a state handler: the event was ignored (used in QP::QHsm only) \clearpage .
Definition qp.hpp:179
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
Return value from a state handler: the event is passed to the superstate (super()).
Definition qp.hpp:172
virtual QStateHandler getStateHandler() const noexcept=0
Virtual method for getting the current state handler.
static constexpr QState Q_RET_TRAN_INIT
Return value from an initial transition: a nested initial transition was taken (used in QP::QMsm only...
Definition qp.hpp:184
static constexpr QState Q_RET_TRAN_HIST
Return value from a state handler: a transition to history was taken (tran_hist()) \clearpage .
Definition qp.hpp:176
static constexpr QState Q_RET_EXIT
Return value from an exit action: the exit action was executed (used in QP::QMsm only) \clearpage .
Definition qp.hpp:183
QMState const * stateObj() const noexcept
Obtain the current state from a MSM (read only).
Definition qp.hpp:225
static constexpr std::size_t MAX_NEST_DEPTH_
Maximum supported nesting depth of a state machine.
Definition qp.hpp:206
virtual ~QAsm()=default
Virtual destructor of the QP::QAsm abstract base class.
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.
Definition qp.hpp:234
static constexpr QSignal Q_INIT_SIG
Reserved signal sent to state handler to execute the initial transition (used in QP::QHsm only) \cle...
Definition qp.hpp:190
QAsmAttr m_state
Current state (pointer to the current state-handler function) \clearpage .
Definition qp.hpp:167
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
Reserved signal sent to state handler to execute the entry case (used in QP::QHsm only) \clearpage .
Definition qp.hpp:188
static constexpr QSignal Q_EXIT_SIG
Reserved signal sent to state handler to execute the exit case (used in QP::QHsm only) \clearpage .
Definition qp.hpp:189
static constexpr QSignal Q_EMPTY_SIG
Reserved signal sent to state handler to execute the default case (used in QP::QHsm only) \clearpage...
Definition qp.hpp:187
static constexpr QState Q_RET_HANDLED
Return value from a state handler: the event was handled (Q_HANDLED()) \clearpage .
Definition qp.hpp:174
static QState top(void *const me, QEvt const *const e) noexcept
Top state handler that ignores all events.
Definition qf_act.cpp:84
Native QF Event Queue.
Definition qequeue.hpp:56
Event class.
Definition qp.hpp:96
void init(DynEvt const dummy) const noexcept
Event initialization for dynamic events.
Definition qp.hpp:116
@ DYNAMIC
Dummy parameter for dynamic event initialization (see QP::QEvt::init(DynEvt)) \clearpage .
Definition qp.hpp:103
std::uint32_t poolNum_
Event pool number of this event.
Definition qp.hpp:99
constexpr QEvt(QSignal const s) noexcept
Event constexpr constructor applicable to immutable and mutable event instances.
Definition qp.hpp:105
std::uint32_t refCtr_
Event reference counter.
Definition qp.hpp:100
QEvt()=delete
Disallowed default event constructor (documented and traced together with all constructors of QP::QEv...
void init() const =delete
Deleted initialization without arguments: compile-time check for a missing init() in event classes de...
std::uint32_t filler_
Member of QP::QEvt to make it identical size in QP/C++ and SafeQP/C++.
Definition qp.hpp:101
std::uint32_t sig
Signal of the event (see Event Signal).
Definition qp.hpp:98
std::size_t tran_complex_(std::array< QStateHandler, MAX_PATH_LEN_ > &path, std::uint_fast8_t const qsId)
Implementation of a complex state transition segment.
void enter_target_(std::array< QStateHandler, MAX_PATH_LEN_ > &path, std::size_t const depth, std::uint_fast8_t const qsId)
Implementation of entry to the target state configuration.
std::size_t tran_simple_(std::array< QStateHandler, MAX_PATH_LEN_ > &path, std::uint_fast8_t const qsId)
Implementation of a simple state transition segment.
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual override to dispatch an event to QHsm.
Definition qep_hsm.cpp:225
QStateHandler childState(QStateHandler const parentHndl) noexcept
Obtain the current active child state of a given parent in QP::QHsm.
Definition qep_hsm.cpp:574
void init(void const *const e, std::uint_fast8_t const qsId) override
Virtual override to take the top-most initial transition in QHsm.
Definition qep_hsm.cpp:150
QHsm(QStateHandler const initial) noexcept
Constructor of the QP::QHsm base class.
Definition qep_hsm.cpp:142
bool isIn(QStateHandler const stateHndl) noexcept override
Check whether the HSM is in a given stateHndl.
Definition qep_hsm.cpp:544
QStateHandler getStateHandler() const noexcept override
Implementation of getting the state handler in an QP::QHsm subclass.
Definition qep_hsm.cpp:605
static constexpr std::size_t MAX_PATH_LEN_
Length of the entry-path arrays in QHsm state machines.
Definition qp.hpp:301
QMActive(QStateHandler const initial) noexcept
Constructor of QP::QMActive class.
Definition qf_qmact.cpp:48
QStateHandler getStateHandler() const noexcept override
Get current state-handler in QActive (delegate to QP::QMsm).
Definition qf_qmact.cpp:85
bool isIn(QStateHandler const stateHndl) noexcept override
Is-in-state query in QActive (delegate to QP::QMsm).
Definition qf_qmact.cpp:74
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Dispatch an event to QActive (delegate to QP::QMsm).
Definition qf_qmact.cpp:66
void init(void const *const e, std::uint_fast8_t const qsId) override
Take the top-most initial transition in QActive (delegate to QP::QMsm).
Definition qf_qmact.cpp:58
QMState const * childStateObj(QMState const *const parent) const noexcept
Obtain the current active child state of a given parent in QP::QMActive (delegate to QP::QMsm).
Definition qf_qmact.cpp:79
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 given current-state up to the given tran-source in QP::QMsm.
QState execTatbl_(QMTranActTable const *const tatbl, std::uint_fast8_t const qsId)
Execute a transition-action table in QP::QMsm.
static QMState const * topQMState() noexcept
return top-most state object in a QP::QMsm
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Implementation of dispatching events to a QP::QMsm.
QState enterHistory_(QMState const *const hist, std::uint_fast8_t const qsId)
Enter the history of a given state in QP::QMsm.
void init(void const *const e, std::uint_fast8_t const qsId) override
Implementation of the top-most initial transition in QP::QMsm.
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.
Definition qp.hpp:427
std::uint_fast8_t findMax() const noexcept
Find the maximum element in the (non-empty) priority-set.
Definition qf_qact.cpp:289
void remove(std::uint_fast8_t const n) noexcept
Remove element n from the priority-set (n = 1..QF_MAX_ACTIVE).
Definition qf_qact.cpp:272
QPSetBits m_bits1
Bitmask for elements 33..64 \clearpage .
Definition qp.hpp:431
bool notEmpty() const noexcept
Find out whether the priority-set is NOT empty.
Definition qf_qact.cpp:232
bool hasElement(std::uint_fast8_t const n) const noexcept
Find out whether the priority-set has element n.
Definition qf_qact.cpp:242
QPSetBits m_bits0
Bitmask for elements 1..32 \clearpage .
Definition qp.hpp:429
void setEmpty() noexcept
Make the priority set empty \clearpage .
Definition qf_qact.cpp:215
bool isEmpty() const noexcept
Find out whether the priority-set is empty.
Definition qf_qact.cpp:222
void insert(std::uint_fast8_t const n) noexcept
Insert element n into the priority-set (n = 1..QF_MAX_ACTIVE).
Definition qf_qact.cpp:255
Software tracing instrumentation target-resident component.
Definition qs.hpp:476
Subscriber List (for publish-subscribe).
Definition qp.hpp:455
QPSet m_set
The set of AOs that subscribed to a given event signal \clearpage .
Definition qp.hpp:457
void trig_(void const *const sender) noexcept
Asynchronously trigger the QTicker active object to perform tick processing.
Definition qf_actq.cpp:428
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Internal helper function to dispatch an event to QP::QTicker AO.
Definition qf_actq.cpp:399
void init(void const *const e, std::uint_fast8_t const qsId) override
Internal helper function to take the top-most initial transition in QTicker AO.
Definition qf_actq.cpp:380
QTicker(std::uint8_t const tickRate) noexcept
Constructor of the QTicker Active Object class.
Definition qf_actq.cpp:372
Time Event class.
Definition qp.hpp:653
static void tick(std::uint_fast8_t const tickRate, void const *const sender) noexcept
Processes all armed time events at every clock tick.
Definition qf_time.cpp:288
QTimeEvt * m_next
Link to the next time event in the list \clearpage .
Definition qp.hpp:655
QTimeEvt * toTimeEvt() noexcept
Get the list of newly armed time events from a head time event (as a pointer to QP::QTimeEvt).
Definition qp.hpp:713
bool disarm() noexcept
Disarm a time event.
Definition qf_time.cpp:151
QTimeEvt(QActive *const act, QSignal const sig, std::uint_fast8_t const tickRate=0U) noexcept
The "extended" constructor to initialize a Time Event.
Definition qf_time.cpp:54
static void tick1_(std::uint_fast8_t const tickRate, void const *const sender)
Processes one (the next upcoming) clock tick for QUTest.
static bool noActive(std::uint_fast8_t const tickRate) noexcept
Check if any time events are active at a given clock tick rate.
Definition qf_time.cpp:370
void * m_act
Active object that receives the time events \clearpage .
Definition qp.hpp:656
QActive * toActive() noexcept
Get the recipient Active Object of a time event (as a pointer to QP::QActive).
Definition qp.hpp:709
std::uint8_t getFlags() const noexcept
Get the internal status flags of a time event.
Definition qp.hpp:689
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).
Definition qf_time.cpp:80
QTimeEvtCtr getCtr() const noexcept
Get the current value of the down-counter of a time event.
Definition qp.hpp:680
bool rearm(std::uint32_t const nTicks) noexcept
Rearm a time event.
Definition qf_time.cpp:196
QTimeEvtCtr m_ctr
Down-counter of the time event.
Definition qp.hpp:657
QTimeEvtCtr m_interval
Interval for periodic time event (zero for one-shot time event).
Definition qp.hpp:658
bool wasDisarmed() noexcept
Check whether the timeout being processed is valid (not stale).
Definition qf_time.cpp:270
eXtended (blocking) thread of the QXK preemptive kernel
Definition qxk.hpp:80
QF Active Object Framework namespace.
Definition qp.hpp:467
void deleteRef_(QEvt const *const evtRef) noexcept
Internal QF implementation of deleting event reference.
Definition qf_dyn.cpp:364
void onCleanup()
Cleanup QF callback.
QEvt const * newRef_(QEvt const *const e, QEvt const *const evtRef) noexcept
Internal QF implementation of creating new event reference.
Definition qf_dyn.cpp:322
void gc(QEvt const *const e) noexcept
Recycle a mutable (dynamic) event.
Definition qf_dyn.cpp:267
QEvt * newX_(std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, QSignal const sig) noexcept
Internal QF implementation of creating new mutable (dynamic) event.
Definition qf_dyn.cpp:193
evtT_ * q_new_x(std::uint_fast16_t const margin, QSignal const sig, Args... args)
Function template to allocate a dynamic event without asserting successful allocation.
Definition qp.hpp:859
void tick(std::uint_fast8_t const tickRate, void const *const sender) noexcept
Definition qp.hpp:776
evtT_ * q_new(QSignal const sig, Args... args)
Function template to allocate a dynamic event and asserting successful allocation.
Definition qp.hpp:847
void psInit(QSubscrList *const subscrSto, QSignal const maxSignal) noexcept
Definition qp.hpp:751
void QF_INIT_CFGCHK_()
QF initialization with the configuration-specific name (QP configuration check).
Definition qv.cpp:64
std::uint16_t getPoolUse(std::uint_fast8_t const poolNum) noexcept
Obtain the number of used entries of the given event pool or of all event pools.
constexpr std::uint_fast16_t NO_MARGIN
Special value of margin that causes asserting failure in case event allocation or event posting fails...
Definition qp.hpp:478
void init()
QF initialization.
Definition qp.hpp:469
void q_new_ref(QP::QEvt const *const e, evtT_ const *&evtRef)
Create a new reference of the current event e.
Definition qp.hpp:878
std::uint16_t getPoolMin(std::uint_fast8_t const poolNum) noexcept
Obtain the minimum of free entries of the given event pool.
std::uint_fast16_t getQueueMin(std::uint_fast8_t const prio) noexcept
Definition qp.hpp:767
void q_delete_ref(evtT_ const *&evtRef)
Delete a new reference of the current event e.
Definition qp.hpp:887
int_t run()
Transfers control to QF to run the application.
Definition qv.cpp:70
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
Obtain the number of free entries of the given event pool.
void publish_(QEvt const *const e, void const *const sender, std::uint_fast8_t const qsId) noexcept
Definition qp.hpp:759
void onStartup()
Startup QF callback.
QP/C++ Framework namespace \clearpage .
Definition qequeue.hpp:36
std::uint32_t QTimeEvtCtr
Data type to store the time-event down-counter and interval defined based on the macro QF_TIMEEVT_CTR...
Definition qp.hpp:411
QState(*)(void *const me) QActionHandler
Pointer to an action-handler function \clearpage .
Definition qp.hpp:137
char const * version() noexcept
Version string of the Framework embedded in the binary image.
Definition qf_act.cpp:52
std::uint_fast8_t QF_LOG2(QP::QPSetBits const bitmask) noexcept
Generic (portable) integer log-base-2 of a QPSet bitmask.
Definition qf_qact.cpp:180
std::uint_fast8_t QState
Type returned from state-handler functions \clearpage .
Definition qp.hpp:132
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function \clearpage .
Definition qp.hpp:136
std::uint32_t QPSetBits
Bitmask for the internal representation of QPSet elements.
Definition qp.hpp:419
std::uint16_t QSignal
The signal of event QP::QEvt.
Definition qp.hpp:93
void(*)(QXThread *const me) QXThreadHandler
Pointer to an extended-thread handler function.
Definition qp.hpp:138
std::uint16_t QPrioSpec
Priority specification for Active Objects in QP.
Definition qp.hpp:403
int int_t
Alias for assertion-ID numbers in QP assertions and return from QP::QF::run().
Definition qp.hpp:82
#define Q_UNUSED_PAR(par_)
Helper macro to mark unused parameters of functions.
Definition qp.hpp:84
void QF_onContextSw(QP::QActive *prev, QP::QActive *next)
QF context switch callback used in built-in kernels.
QP/C++ configuration check (link-time detection of a configuration mismatch between the QP/C++ Framew...
#define QF_MAX_ACTIVE
Maximum # Active Objects in the system (1..64).
Definition qp_config.hpp:57
#define QACTIVE_OS_OBJ_TYPE
Port-specific QActive "OS-object" type.
Definition qp_port.hpp:159
#define QACTIVE_EQUEUE_TYPE
Port-specific QActive event queue type.
Definition qp_port.hpp:79
#define QACTIVE_THREAD_TYPE
Port-specific QActive thread type.
Definition qp_port.hpp:155
The data type to store in the event queue ring-buffer.
Definition qequeue.hpp:51
State object for the QP::QMsm class (QM State Machine).
Definition qp.hpp:140
Transition-Action Table for the QP::QMsm State Machine \clearpage .
Definition qp.hpp:148
Attribute of for the QP::QAsm class (Abstract State Machine).
Definition qp.hpp:153