QP/C++ 8.1.1
Real-Time Event Framework
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 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 (GPL) or under the terms of one of the closed-
14// source Quantum Leaps commercial licenses.
15//
16// Redistributions in source code must retain this top-level comment block.
17// Plagiarizing this software to sidestep the license obligations is illegal.
18//
19// NOTE:
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.
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.2"
34#define QP_VERSION 812U
35// <VER>=812 <DATE>=251201
36#define QP_RELEASE 0x6A45C1C3U
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 > 4U)
71#error QF_TIMEEVT_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U;
72#endif
73
74#ifndef QF_EVENT_SIZ_SIZE
75#define QF_EVENT_SIZ_SIZE 2U
76#endif
77
78#if (QF_EVENT_SIZ_SIZE > 4U)
79#error QF_EVENT_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U;
80#endif
81
82//! @endcond
83
84//----------------------------------------------------------------------------
85// global types/utilities
86
87using int_t = int;
88
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_))
92
93//============================================================================
94namespace QP {
95
96char const *version() noexcept;
97
98using QSignal = std::uint16_t;
99
100//----------------------------------------------------------------------------
101class QEvt {
102public:
103 std::uint32_t sig : 16;
104 std::uint32_t poolNum_ : 8;
105 std::uint32_t refCtr_ : 8;
106 std::uint32_t filler_;
107
108 enum DynEvt: std::uint8_t { DYNAMIC };
109
110 explicit constexpr QEvt(QSignal const s) noexcept
111 : sig(s) // the provided event signal
112 ,poolNum_(0x00U) // no-pool event
113 ,refCtr_ (0xE0U) // special event "marker"
114 ,filler_ (0xE0E0E0E0U) // the "filler" ensures the same QEvt size
115 // as in SafeQP/C++
116 {}
117
118 QEvt() // disallow the default ctor
119 = delete;
120 void init() const noexcept {
121 // no event parameters to initialize
122 }
123 void init(DynEvt const dummy) const noexcept {
124 Q_UNUSED_PAR(dummy);
125 // no event parameters to initialize
126 }
127}; // class QEvt
128
129using QEvtPtr = QEvt const *;
130
131//----------------------------------------------------------------------------
132// QEP (hierarchical event processor) types
133
134using QState = std::uint_fast8_t;
135
136class QXThread; // forward declaration
137
138using QStateHandler = QState (*)(void * const me, QEvt const * const e);
139using QActionHandler = QState (*)(void * const me);
140using QXThreadHandler = void (*)(QXThread * const me);
141
149
153};
154
163
164constexpr QSignal Q_USER_SIG {4U};
165
166//----------------------------------------------------------------------------
167class QAsm {
168public:
171
172 // All possible values returned from state/action handlers...
173 // NOTE: The numerical order is important for algorithmic correctness.
174 static constexpr QState Q_RET_SUPER {0U};
175 static constexpr QState Q_RET_UNHANDLED {1U};
176 static constexpr QState Q_RET_HANDLED {2U};
177 static constexpr QState Q_RET_TRAN {3U};
178 static constexpr QState Q_RET_TRAN_HIST {4U};
179
180 // used in QHsm only...
181 static constexpr QState Q_RET_IGNORED {5U};
182
183 // used in QMsm only...
184 static constexpr QState Q_RET_ENTRY {6U};
185 static constexpr QState Q_RET_EXIT {7U};
186 static constexpr QState Q_RET_TRAN_INIT {8U};
187
188
189 // Reserved signals by the QP-framework (used in QHsm only)
190 static constexpr QSignal Q_EMPTY_SIG {0U};
191 static constexpr QSignal Q_ENTRY_SIG {1U};
192 static constexpr QSignal Q_EXIT_SIG {2U};
193 static constexpr QSignal Q_INIT_SIG {3U};
194
195 static constexpr QState Q_HANDLED() { // for coding QHsm state machines
196 return Q_RET_HANDLED; }
197 static constexpr QState Q_UNHANDLED() { // for coding QHsm state machines
198 return Q_RET_UNHANDLED; }
199 static constexpr QState QM_HANDLED() { // for coding QMsm state machines
200 return Q_RET_HANDLED; }
201 static constexpr QState QM_UNHANDLED() { // for coding QMsm state machines
202 return Q_RET_HANDLED; }
203 static constexpr QState QM_SUPER() { // for coding QMsm state machines
204 return Q_RET_SUPER; }
205 static constexpr QMState const *QM_STATE_NULL { nullptr };
206 static constexpr QActionHandler const Q_ACTION_NULL { nullptr };
207
208#ifdef Q_XTOR
209 virtual ~QAsm() noexcept {
210 // empty
211 }
212#endif // def Q_XTOR
213 virtual void init(
214 void const * const e,
215 std::uint_fast8_t const qsId) = 0;
216 virtual void init(std::uint_fast8_t const qsId);
217 virtual void dispatch(
218 QEvt const * const e,
219 std::uint_fast8_t const qsId) = 0;
220 virtual bool isIn(QStateHandler const stateHndl) = 0;
221 virtual QStateHandler getStateHandler() const noexcept = 0;
222
223 QStateHandler state() const noexcept {
224 return m_state.fun; // public "getter" for the state handler
225 }
226 QMState const * stateObj() const noexcept {
227 return m_state.obj; // public "getter" for the state object
228 }
229
230 static QState top(void * const me, QEvt const * const e) noexcept;
231
232protected:
233 explicit QAsm() noexcept;
234
235 QState tran(QStateHandler const target) noexcept {
236 // for coding QMsm state machines
237 m_temp.fun = target;
238 return Q_RET_TRAN;
239 }
240 QState tran_hist(QStateHandler const hist) noexcept {
241 // for coding QMsm state machines
242 m_temp.fun = hist;
243 return Q_RET_TRAN_HIST;
244 }
245 QState super(QStateHandler const superstate) noexcept {
246 // for coding QMsm state machines
247 m_temp.fun = superstate;
248 return Q_RET_SUPER;
249 }
250 QState qm_tran(void const * const tatbl) noexcept {
251 // for coding QMsm state machines
252 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
253 return Q_RET_TRAN;
254 }
255 QState qm_tran_init(void const * const tatbl) noexcept {
256 // for coding QMsm state machines
257 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
258 return Q_RET_TRAN_INIT;
259 }
261 QMState const * const hist,
262 void const * const tatbl) noexcept
263 { // for coding QMsm state machines
264 m_state.obj = hist; // store the history in state
265 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
266 return Q_RET_TRAN_HIST;
267 }
268
269#ifdef Q_SPY
270 QState qm_entry(QMState const * const s) noexcept {
271 // for coding QMsm state machines
272 m_temp.obj = s;
273 return Q_RET_ENTRY;
274 }
275#else
276 QState qm_entry(QMState const * const s) const noexcept {
277 // for coding QMsm state machines
278 static_cast<void>(s); // unused parameter
279 return Q_RET_ENTRY;
280 }
281#endif // Q_SPY
282
283#ifdef Q_SPY
284 QState qm_exit(QMState const * const s) noexcept {
285 // for coding QMsm state machines
286 m_temp.obj = s;
287 return Q_RET_EXIT;
288 }
289#else
290 QState qm_exit(QMState const * const s) const noexcept {
291 // for coding QMsm state machines
292 static_cast<void>(s); // unused parameter
293 return Q_RET_EXIT;
294 }
295#endif // Q_SPY
296}; // class QAsm
297
298//----------------------------------------------------------------------------
299class QHsm : public QP::QAsm {
300protected:
301 explicit QHsm(QStateHandler const initial) noexcept;
302
303public:
304 using QAsm::init;
305 void init(
306 void const * const e,
307 std::uint_fast8_t const qsId) override;
308 void dispatch(
309 QEvt const * const e,
310 std::uint_fast8_t const qsId) override;
311 bool isIn(QStateHandler const stateHndl) noexcept override;
312 QStateHandler getStateHandler() const noexcept override;
313
314 QStateHandler childState(QStateHandler const parentHndl) noexcept;
315
316private:
317 std::int_fast8_t tran_simple_(
318 QStateHandler * const path,
319 std::uint_fast8_t const qsId);
320
321 std::int_fast8_t tran_complex_(
322 QStateHandler * const path,
323 std::uint_fast8_t const qsId);
324
326 QStateHandler * const path,
327 std::int_fast8_t const depth,
328 std::uint_fast8_t const qsId);
329
330 // friends...
331 friend class QS;
332}; // class QHsm
333
334//----------------------------------------------------------------------------
335class QMsm : public QP::QAsm {
336protected:
337 explicit QMsm(QStateHandler const initial) noexcept;
338
339public:
340 using QAsm::init;
341 void init(
342 void const * const e,
343 std::uint_fast8_t const qsId) override;
345 QEvt const * const e,
346 std::uint_fast8_t const qsId) override;
347 bool isIn(QStateHandler const stateHndl) noexcept override;
348 QStateHandler getStateHandler() const noexcept override;
349
350 QMState const * childStateObj(QMState const * const parentHndl)
351 const noexcept;
352 static QMState const * topQMState() noexcept;
353
354private:
356 QMTranActTable const * const tatbl,
357 std::uint_fast8_t const qsId);
359 QMState const * const curr_state,
360 QMState const * const tran_source,
361 std::uint_fast8_t const qsId);
363 QMState const * const hist,
364 std::uint_fast8_t const qsId);
365
366 // friends...
367 friend class QS;
368}; // class QMsm
369
370} // namespace QP
371
372//============================================================================
373// QEP-macros
374
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)
378
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)
383
384#define Q_EVT_CAST(subclass_) (static_cast<subclass_ const *>(e))
385#define Q_STATE_CAST(handler_) (reinterpret_cast<QP::QStateHandler>(handler_))
386
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
391
392#define QM_ACTION_DECL(action_) \
393 QP::QState action_ ## _h(); \
394 static QP::QState action_(void * const me)
395
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)
400
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()
405
406#ifdef Q_SPY
407 #define INIT(qsId_) init((qsId_))
408 #define DISPATCH(e_, qsId_) dispatch((e_), (qsId_))
409#else
410 #define INIT(dummy) init(0U)
411 #define DISPATCH(e_, dummy) dispatch((e_), 0U)
412#endif // ndef Q_SPY
413
414//============================================================================
415namespace QP {
416
417using QPrioSpec = std::uint16_t;
418
419class QEQueue; // forward declaration
420class QActive; // forward declaration
421
422#if (QF_TIMEEVT_CTR_SIZE == 1U)
423 using QTimeEvtCtr = std::uint8_t;
424#elif (QF_TIMEEVT_CTR_SIZE == 2U)
425 using QTimeEvtCtr = std::uint16_t;
426#elif (QF_TIMEEVT_CTR_SIZE == 4U)
427 using QTimeEvtCtr = std::uint32_t;
428#endif // (QF_TIMEEVT_CTR_SIZE == 4U)
429
430#if (QF_MAX_ACTIVE <= 8U)
431 using QPSetBits = std::uint8_t;
432#elif (8U < QF_MAX_ACTIVE) && (QF_MAX_ACTIVE <= 16U)
433 using QPSetBits = std::uint16_t;
434#elif (16 < QF_MAX_ACTIVE)
435 using QPSetBits = std::uint32_t;
436#endif // (16 < QF_MAX_ACTIVE)
437
438#ifndef QF_LOG2
439 std::uint_fast8_t QF_LOG2(QP::QPSetBits const bitmask) noexcept;
440#endif // ndef QF_LOG2
441
442//----------------------------------------------------------------------------
443class QPSet {
444private:
446#if (QF_MAX_ACTIVE > 32U)
448#endif
449
450public:
451 void setEmpty() noexcept;
452 bool isEmpty() const noexcept;
453 bool notEmpty() const noexcept;
454 bool hasElement(std::uint_fast8_t const n) const noexcept;
455 void insert(std::uint_fast8_t const n) noexcept;
456 void remove(std::uint_fast8_t const n) noexcept;
457 std::uint_fast8_t findMax() const noexcept;
458
459 // friends...
460 friend class QS;
461}; // class QPSet
462
463//----------------------------------------------------------------------------
465private:
467
468 // friends...
469 friend class QActive;
470 friend class QS;
471}; // class QSubscrList
472
473//----------------------------------------------------------------------------
474// declarations for friendship with the QActive class
475
476namespace QF {
477 void init();
478 void stop();
479 int_t run();
480
481 void onStartup();
482 void onCleanup();
483
484 constexpr std::uint_fast16_t NO_MARGIN {0xFFFFU};
485} // namespace QF
486
487//----------------------------------------------------------------------------
488class QActive : public QAsm {
489private:
490 std::uint8_t m_prio;
491 std::uint8_t m_pthre;
492
493#ifdef QACTIVE_THREAD_TYPE
495#endif
496
497#ifdef QACTIVE_OS_OBJ_TYPE
499#endif
500
501#ifdef QACTIVE_EQUEUE_TYPE
503#endif
504
505protected:
506 explicit QActive(QStateHandler const initial) noexcept;
507
508public:
509 using QAsm::init;
510 void init(
511 void const * const e,
512 std::uint_fast8_t const qsId) override;
513 void dispatch(
514 QEvt const * const e,
515 std::uint_fast8_t const qsId) override;
516 bool isIn(QStateHandler const stateHndl) noexcept override;
517 QStateHandler getStateHandler() const noexcept override;
518
519 QStateHandler childState(QStateHandler const parentHandler) noexcept;
521 std::uint32_t attr1,
522 void const * attr2 = nullptr);
523 void start(QPrioSpec const prioSpec,
524 QEvtPtr * const qSto, std::uint_fast16_t const qLen,
525 void * const stkSto, std::uint_fast16_t const stkSize,
526 void const * const par = nullptr);
527
528#ifdef QACTIVE_CAN_STOP
529 void stop();
530#endif // def QACTIVE_CAN_STOP
531 void register_() noexcept;
532 void unregister_() noexcept;
533 void post_(QEvt const * const e,
534 void const * const sender) noexcept
535 {
536 // delegate to postx_() with margin==QF::NO_MARGIN
537 static_cast<void>(postx_(e, QF::NO_MARGIN, sender));
538 }
539 bool postx_(QEvt const * const e,
540 std::uint_fast16_t const margin,
541 void const * const sender) noexcept;
542 void postLIFO(QEvt const * const e) noexcept;
543 QEvt const * 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;
550 static void psInit(
551 QSubscrList * const subscrSto,
552 QSignal const maxSignal) noexcept;
553 static void publish_(
554 QEvt const * const e,
555 void const * const sender,
556 std::uint_fast8_t const qsId) noexcept;
557 void subscribe(QSignal const sig) const noexcept;
558 void unsubscribe(QSignal const sig) const noexcept;
559 void unsubscribeAll() const noexcept;
560 bool defer(
561 QEQueue * const eq,
562 QEvt const * const e) const noexcept;
563 bool recall(QEQueue * const eq) noexcept;
564 std::uint16_t flushDeferred(
565 QEQueue * const eq,
566 std::uint_fast16_t const num = 0xFFFFU) const noexcept;
567 std::uint8_t getPrio() const noexcept {
568 return m_prio; // public "getter" for the AO's prio
569 }
570 static void evtLoop_(QActive *act);
571 static QActive *fromRegistry(std::uint_fast8_t const prio);
572
573#ifdef QACTIVE_THREAD_TYPE
574 QACTIVE_THREAD_TYPE const & getThread() const & {
575 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
576 return m_thread;
577 }
579 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
580 = delete;
581 void setThread(QACTIVE_THREAD_TYPE const & thr) noexcept {
582 m_thread = thr; // public "setter", useful for MPU applications
583 }
584#endif // QACTIVE_THREAD_TYPE
585
586#ifdef QACTIVE_OS_OBJ_TYPE
588 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
589 return m_osObject;
590 }
592 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
593 = delete;
594#endif // QACTIVE_OS_OBJ_TYPE
595
596#ifdef QF_ISR_API
597 virtual bool postFromISR(
598 QEvt const * const e,
599 std::uint_fast16_t const margin,
600 void * par,
601 void const * const sender) noexcept;
602
603 static void publishFromISR(
604 QEvt const * e,
605 void * par,
606 void const * sender) noexcept;
607#endif // QF_ISR_API
608
609private:
610 void postFIFO_(
611 QEvt const * const e,
612 void const * const sender);
613 static void multicast_(
614 QPSet * const subscrSet,
615 QEvt const * const e,
616 void const * const sender);
617
618 // friends...
619 friend class QTimeEvt;
620 friend class QTicker;
621 friend class QXThread;
622 friend class QXMutex;
623 friend class QXSemaphore;
624 friend class QMActive;
625 friend class QActiveDummy;
626 friend class QK;
627 friend class QXK;
628 friend class QS;
629
630 friend void QF::init();
631 friend void QF::stop();
632 friend int_t QF::run();
633 friend void QF::onStartup();
634 friend void QF::onCleanup();
635
636}; // class QActive
637
638//----------------------------------------------------------------------------
639class QMActive : public QActive {
640protected:
641 explicit QMActive(QStateHandler const initial) noexcept;
642
643public:
644 using QActive::init;
645 void init(
646 void const * const e,
647 std::uint_fast8_t const qsId) override;
648 void dispatch(
649 QEvt const * const e,
650 std::uint_fast8_t const qsId) override;
651 bool isIn(QStateHandler const stateHndl) noexcept override;
652 QStateHandler getStateHandler() const noexcept override;
653
654 QMState const *childStateObj(QMState const * const parent) const noexcept;
655}; // class QMActive
656
657//----------------------------------------------------------------------------
658#if (QF_MAX_TICK_RATE > 0U)
659
660class QTimeEvt : public QEvt {
661private:
663 void * m_act;
666 std::uint8_t m_tickRate;
667 std::uint8_t m_flags;
668
669public:
670 QTimeEvt(
671 QActive * const act,
672 QSignal const sig,
673 std::uint_fast8_t const tickRate = 0U) noexcept;
674 void armX(
675 std::uint32_t const nTicks,
676 std::uint32_t const interval = 0U) noexcept;
677 bool disarm() noexcept;
678 bool rearm(std::uint32_t const nTicks) noexcept;
679 bool wasDisarmed() noexcept;
680 void const * getAct() const & {
681 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
682 return m_act;
683 }
684 void const * getAct() const &&
685 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
686 = delete;
687 QTimeEvtCtr getCtr() const noexcept {
688 return m_ctr; // public "getter" for the current time-evt count
689 }
690 QTimeEvtCtr getInterval() const noexcept {
691 return m_interval; // public "getter" for the time-evt interval
692 }
693 std::uint8_t getTickRate() const noexcept {
694 return m_tickRate; // public "getter" for the time-evt tick rate
695 }
696 static void tick(
697 std::uint_fast8_t const tickRate,
698 void const * const sender) noexcept;
699
700#ifdef Q_UTEST
701 static void tick1_(
702 std::uint_fast8_t const tickRate,
703 void const * const sender);
704#endif // def Q_UTEST
705
706#ifdef QF_ISR_API
707 static void tickFromISR(
708 std::uint_fast8_t const tickRate,
709 void * par,
710 void const * sender) noexcept;
711#endif // def QF_ISR_API
712 static bool noActive(std::uint_fast8_t const tickRate) noexcept;
713 QActive * toActive() noexcept {
714 // public "getter" for the AO associated with this time-evt
715 return static_cast<QActive *>(m_act);
716 }
717 QTimeEvt * toTimeEvt() noexcept {
718 // public "getter" for the AO associated with this time-evt
719 // NOTE: used for the special time-evts in QTimeEvt_head_[] array
720 return static_cast<QTimeEvt *>(m_act);
721 }
722 QTimeEvt() noexcept;
723
724private:
725 QTimeEvt *expire_(
726 QTimeEvt * const prev_link,
727 QActive const * const act,
728 std::uint_fast8_t const tickRate) noexcept;
729
730 // fiends...
731 friend class QXThread;
732 friend class QS;
733}; // class QTimeEvt
734
735//----------------------------------------------------------------------------
736class QTicker : public QActive {
737public:
738 explicit QTicker(std::uint8_t const tickRate) noexcept;
739 using QActive::init;
740 void init(
741 void const * const e,
742 std::uint_fast8_t const qsId) override;
743 void dispatch(
744 QEvt const * const e,
745 std::uint_fast8_t const qsId) override;
746 void trig_(void const * const sender) noexcept;
747}; // class QTicker
748
749#endif // (QF_MAX_TICK_RATE > 0U)
750
751//----------------------------------------------------------------------------
752namespace QF {
753
754//! @deprecated
755inline void psInit( QSubscrList * const subscrSto,
756 QSignal const maxSignal) noexcept
757{
758 // use QActive::psInit() instead of the deprecated QF::psInit()
759 QActive::psInit(subscrSto, maxSignal);
760}
761
762//! @deprecated
763inline void publish_(QEvt const * const e,
764 void const * const sender, std::uint_fast8_t const qsId) noexcept
765{
766 // use QTimeEvt::tick() instead of the deprecated QF::tick()
767 QActive::publish_(e, sender, qsId);
768}
769
770//! @deprecated
771static inline std::uint_fast16_t getQueueMin(
772 std::uint_fast8_t const prio) noexcept
773{
774 // use QActive::getQueueMin() instead of the deprecated QF::getQueueMin()
775 return QActive::getQueueMin(prio);
776}
777
778#if (QF_MAX_TICK_RATE > 0U)
779//! @deprecated
780inline void tick(
781 std::uint_fast8_t const tickRate,
782 void const * const sender) noexcept
783{
784 // use QTimeEvt::tick() instead of the deprecated QF::tick()
785 QTimeEvt::tick(tickRate, sender);
786}
787#endif // (QF_MAX_TICK_RATE > 0U)
788
789//----------------------------------------------------------------------------
790// QF dynamic memory facilities
791void poolInit(
792 void * const poolSto,
793 std::uint_fast32_t const poolSize,
794 std::uint_fast16_t const evtSize) noexcept;
795
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;
800QEvt * newX_(
801 std::uint_fast16_t const evtSize,
802 std::uint_fast16_t const margin,
803 QSignal const sig) noexcept;
804void gc(QEvt const * const e) noexcept;
805QEvt const * newRef_(
806 QEvt const * const e,
807 QEvt const * const evtRef) noexcept;
808
809void deleteRef_(QEvt const * const evtRef) noexcept;
810
811#ifndef QEVT_PAR_INIT
812 template<class evtT_>
813 inline evtT_ * q_new(QSignal const sig) {
814 // allocate a dynamic (mutable) event with NO_MARGIN
815 // NOTE: the returned event ptr is guaranteed NOT to be nullptr
816 return static_cast<evtT_*>(
817 QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, sig));
818 }
819 template<class evtT_>
820 inline evtT_ * q_new_x(std::uint_fast16_t const margin,
821 QSignal const sig)
822 {
823 // allocate a dynamic (mutable) event with a provided margin
824 // NOTE: the returned event ptr is MIGHT be nullptr
825 return static_cast<evtT_*>(QP::QF::newX_(sizeof(evtT_), margin, sig));
826 }
827#else
828 template<class evtT_, typename... Args>
829 inline evtT_ * q_new(QSignal const sig, Args... 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_*>(
833 QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, sig));
834 e->init(args...); // immediately initialize the event (RAII)
835 return e;
836 }
837 template<class evtT_, typename... Args>
838 inline evtT_ * q_new_x(std::uint_fast16_t const margin,
839 QSignal const sig, Args... args)
840 {
841 // allocate a dynamic (mutable) event with a provided margin
842 // NOTE: the event allocation is MIGHT fail
843 evtT_ *e =
844 static_cast<evtT_*>(QP::QF::newX_(sizeof(evtT_), margin, sig));
845 if (e != nullptr) { // was the allocation successfull?
846 e->init(args...); // immediately initialize the event (RAII)
847 }
848 // NOTE: the returned event ptr is MIGHT be nullptr
849 return e;
850 }
851#endif // QEVT_PAR_INIT
852
853template<class evtT_>
854inline void q_new_ref(
855 QP::QEvt const * const e,
856 evtT_ const *& evtRef)
857{
858 // set the const event reference (must NOT be nullptr)
859 evtRef = static_cast<evtT_ const *>(QP::QF::newRef_(e, evtRef));
860}
861
862template<class evtT_>
863inline void q_delete_ref(evtT_ const *& evtRef) {
864 QP::QF::deleteRef_(evtRef);
865 evtRef = nullptr; // invalidate the associated event reference
866}
867
868#ifdef QF_ISR_API
870 std::uint_fast16_t const evtSize,
871 std::uint_fast16_t const margin,
872 QSignal const sig) noexcept;
873void gcFromISR(QEvt const * e) noexcept;
874#endif // def QF_ISR_API
875
876} // namespace QF
877} // namespace QP
878
879//============================================================================
880extern "C" {
881
882//${QF-extern-C::QF_onContextSw} .............................................
883#ifdef QF_ON_CONTEXT_SW
885 QP::QActive * prev,
886 QP::QActive * next);
887#endif // def QF_ON_CONTEXT_SW
888
889} // extern "C"
890
891//----------------------------------------------------------------------------
892// QF base facilities
893
894#define Q_PRIO(prio_, pthre_) \
895 (static_cast<QP::QPrioSpec>((prio_) | (pthre_) << 8U))
896
897#ifndef QEVT_PAR_INIT
898 #define Q_NEW(evtT_, sig_) (QP::QF::q_new<evtT_>((sig_)))
899 #define Q_NEW_X(evtT_, margin_, sig_) \
900 (QP::QF::q_new_x<evtT_>((margin_), (sig_)))
901#else
902 #define Q_NEW(evtT_, sig_, ...) \
903 (QP::QF::q_new<evtT_>((sig_), __VA_ARGS__))
904 #define Q_NEW_X(evtT_, margin_, sig_, ...) \
905 (QP::QF::q_new_x<evtT_>((margin_), (sig_), __VA_ARGS__))
906#endif // QEVT_PAR_INIT
907
908#define Q_NEW_REF(evtRef_, evtT_) (QP::QF::q_new_ref<evtT_>(e, (evtRef_)))
909#define Q_DELETE_REF(evtRef_) do { \
910 QP::QF::deleteRef_((evtRef_)); \
911 (evtRef_) = nullptr; \
912} while (false)
913
914#ifdef Q_SPY
915 #define PUBLISH(e_, sender_) \
916 publish_((e_), (sender_), (sender_)->getPrio())
917 #define POST(e_, sender_) post_((e_), (sender_))
918 #define POST_X(e_, margin_, sender_) \
919 postx_((e_), (margin_), (sender_))
920 #define TICK_X(tickRate_, sender_) tick((tickRate_), (sender_))
921 #define TRIG(sender_) trig_((sender_))
922#else
923 #define PUBLISH(e_, dummy) publish_((e_), nullptr, 0U)
924 #define POST(e_, dummy) post_((e_), nullptr)
925 #define POST_X(e_, margin_, dummy) postx_((e_), (margin_), nullptr)
926 #define TICK_X(tickRate_, dummy) tick((tickRate_), nullptr)
927 #define TRIG(sender_) trig_(nullptr)
928#endif // ndef Q_SPY
929
930#define TICK(sender_) TICK_X(0U, (sender_))
931
932#ifndef QF_CRIT_EXIT_NOP
933 #define QF_CRIT_EXIT_NOP() (static_cast<void>(0))
934#endif // ndef QF_CRIT_EXIT_NOP
935
936#endif // QP_HPP_
Active object class (based on the QP::QHsm implementation strategy).
Definition qp.hpp:488
friend class QActiveDummy
Definition qp.hpp:625
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.
Definition qp.hpp:494
static std::uint16_t getQueueMin(std::uint_fast8_t const prio) noexcept
Definition qf_actq.cpp:368
void unregister_() noexcept
Un-register the active object from the framework.
Definition qf_qact.cpp:116
QACTIVE_OS_OBJ_TYPE const & getOsObject() const &
Definition qp.hpp:587
friend class QTicker
Definition qp.hpp:620
friend class QXMutex
Definition qp.hpp:622
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.
Definition qf_qact.cpp:134
friend class QS
Definition qp.hpp:628
static void multicast_(QPSet *const subscrSet, QEvt const *const e, void const *const sender)
Definition qf_ps.cpp:127
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:533
void register_() noexcept
Register this active object to be managed by the framework.
Definition qf_qact.cpp:68
void postFIFO_(QEvt const *const e, void const *const sender)
Definition qf_actq.cpp:261
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.
Definition qf_ps.cpp:71
void stop()
Stops execution of an active object and removes it from the framework's supervision.
Definition qutest.cpp:278
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.
Definition qf_qact.cpp:142
bool isIn(QStateHandler const stateHndl) noexcept override
Virtual function to check whether the state machine is in a given state.
Definition qf_qact.cpp:150
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
static QActive * fromRegistry(std::uint_fast8_t const prio)
Definition qf_qact.cpp:160
friend class QXSemaphore
Definition qp.hpp:623
QActive(QStateHandler const initial) noexcept
QActive constructor (abstract base class).
Definition qf_qact.cpp:55
std::uint8_t getPrio() const noexcept
Definition qp.hpp:567
QACTIVE_EQUEUE_TYPE m_eQueue
Port-dependent event-queue type (often QP::QEQueue).
Definition qp.hpp:502
QACTIVE_THREAD_TYPE const & getThread() const &&=delete
friend class QK
Definition qp.hpp:626
QStateHandler childState(QStateHandler const parentHandler) noexcept
Definition qf_qact.cpp:155
static void psInit(QSubscrList *const subscrSto, QSignal const maxSignal) noexcept
Publish event to all subscribers of a given signal e->sig.
Definition qf_ps.cpp:51
friend class QTimeEvt
Definition qp.hpp:619
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:212
QACTIVE_OS_OBJ_TYPE const & getOsObject() const &&=delete
void setThread(QACTIVE_THREAD_TYPE const &thr) noexcept
Definition qp.hpp:581
QStateHandler getStateHandler() const noexcept override
Virtual method for getting the current state handler.
Definition qf_qact.cpp:165
std::uint8_t m_pthre
Preemption-threshold [1..QF_MAX_ACTIVE] of this AO.
Definition qp.hpp:491
QACTIVE_OS_OBJ_TYPE m_osObject
Port-dependent per-thread object.
Definition qp.hpp:498
std::uint8_t m_prio
QF-priority [1..QF_MAX_ACTIVE] of this AO.
Definition qp.hpp:490
friend class QMActive
Definition qp.hpp:624
friend class QXThread
Definition qp.hpp:621
QACTIVE_THREAD_TYPE const & getThread() const &
Definition qp.hpp:574
friend class QXK
Definition qp.hpp:627
Abstract State Machine class (state machine interface).
Definition qp.hpp:167
QState qm_entry(QMState const *const s) noexcept
Internal helper function to execute state entry actions in QP::QMsm.
Definition qp.hpp:270
QAsm() noexcept
Constructor of the QP::QAsm base class.
Definition qf_act.cpp:75
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:260
QStateHandler state() const noexcept
Definition qp.hpp:223
static constexpr QState Q_RET_UNHANDLED
Definition qp.hpp:175
QState qm_tran(void const *const tatbl) noexcept
Internal helper function to take a state transition in QP::QMsm.
Definition qp.hpp:250
static constexpr QState Q_RET_TRAN
Definition qp.hpp:177
static constexpr QState QM_SUPER()
Definition qp.hpp:203
static constexpr QState Q_RET_ENTRY
Definition qp.hpp:184
QState qm_exit(QMState const *const s) noexcept
Internal helper function to execute state exit actions in QP::QMsm.
Definition qp.hpp:284
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:240
QState super(QStateHandler const superstate) noexcept
Internal helper function to indicate superstate of a given state in sublclasses of QP::QAsm.
Definition qp.hpp:245
QState qm_tran_init(void const *const tatbl) noexcept
Definition qp.hpp:255
QAsmAttr m_temp
Temporary storage for target/act-table etc.
Definition qp.hpp:170
static constexpr QState Q_RET_IGNORED
Definition qp.hpp:181
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
Definition qp.hpp:174
static constexpr QState Q_UNHANDLED()
Definition qp.hpp:197
virtual QStateHandler getStateHandler() const noexcept=0
Virtual method for getting the current state handler.
static constexpr QState Q_RET_TRAN_INIT
Definition qp.hpp:186
static constexpr QState Q_RET_TRAN_HIST
Definition qp.hpp:178
static constexpr QState Q_RET_EXIT
Definition qp.hpp:185
QMState const * stateObj() const noexcept
Definition qp.hpp:226
static constexpr QState Q_HANDLED()
Definition qp.hpp:195
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:235
static constexpr QState QM_UNHANDLED()
Definition qp.hpp:201
virtual ~QAsm() noexcept
Virtual destructor of the QP::QAsm abstract base class.
Definition qp.hpp:209
static constexpr QSignal Q_INIT_SIG
Definition qp.hpp:193
static constexpr QActionHandler const Q_ACTION_NULL
Definition qp.hpp:206
QAsmAttr m_state
Current state (pointer to the current state-handler function).
Definition qp.hpp:169
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
Definition qp.hpp:191
static constexpr QSignal Q_EXIT_SIG
Definition qp.hpp:192
static constexpr QSignal Q_EMPTY_SIG
Definition qp.hpp:190
static constexpr QState Q_RET_HANDLED
Definition qp.hpp:176
static constexpr QMState const * QM_STATE_NULL
Definition qp.hpp:205
static QState top(void *const me, QEvt const *const e) noexcept
Top state handler that ignores all events.
Definition qf_act.cpp:80
static constexpr QState QM_HANDLED()
Definition qp.hpp:199
Native QF Event Queue.
Definition qequeue.hpp:53
Event class.
Definition qp.hpp:101
void init(DynEvt const dummy) const noexcept
Event initialization for dynamic events (overload).
Definition qp.hpp:123
@ DYNAMIC
Dummy parameter for dynamic event initialization (see QEvt::QEvt(DynEvt)).
Definition qp.hpp:108
void init() const noexcept
Event initialization for dynamic events.
Definition qp.hpp:120
std::uint32_t poolNum_
Event pool number of this event.
Definition qp.hpp:104
constexpr QEvt(QSignal const s) noexcept
Event constexpr constructor applicable to immutable and mutable event instances.
Definition qp.hpp:110
std::uint32_t refCtr_
Event reference counter.
Definition qp.hpp:105
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++.
Definition qp.hpp:106
std::uint32_t sig
Signal of the event (see Event Signal).
Definition qp.hpp:103
friend class QS
Definition qp.hpp:331
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.
Definition qep_hsm.cpp:230
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.
Definition qep_hsm.cpp:579
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.
Definition qep_hsm.cpp:154
QHsm(QStateHandler const initial) noexcept
Definition qep_hsm.cpp:146
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.
Definition qep_hsm.cpp:549
QStateHandler getStateHandler() const noexcept override
Virtual method for getting the current state handler.
Definition qep_hsm.cpp:610
QMActive(QStateHandler const initial) noexcept
Constructor of QP::QMActive class.
Definition qf_qmact.cpp:48
QStateHandler getStateHandler() const noexcept override
Virtual method for getting the current state handler.
Definition qf_qmact.cpp:85
bool isIn(QStateHandler const stateHndl) noexcept override
Virtual function to check whether the state machine is in a given state.
Definition qf_qmact.cpp:74
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
Definition qf_qmact.cpp:66
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.
Definition qf_qmact.cpp:58
QMState const * childStateObj(QMState const *const parent) const noexcept
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 current state up to the explicit transition source.
friend class QS
Definition qp.hpp:367
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.
Definition qp.hpp:443
std::uint_fast8_t findMax() const noexcept
Find the maximum element in the set.
Definition qf_qact.cpp:273
friend class QS
Definition qp.hpp:460
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:259
QPSetBits m_bits1
Bitmask for elements 33..64.
Definition qp.hpp:447
bool notEmpty() const noexcept
Find out whether the priority-set is NOT empty.
Definition qf_qact.cpp:224
bool hasElement(std::uint_fast8_t const n) const noexcept
Find out whether the priority-set has element n.
Definition qf_qact.cpp:234
QPSetBits m_bits0
Bitmask for elements 1..32.
Definition qp.hpp:445
void setEmpty() noexcept
Make the priority set empty.
Definition qf_qact.cpp:207
bool isEmpty() const noexcept
Find out whether the priority-set is empty.
Definition qf_qact.cpp:214
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:245
Subscriber List (for publish-subscribe).
Definition qp.hpp:464
QPSet m_set
The set of AOs that subscribed to a given event signal.
Definition qp.hpp:466
friend class QActive
Definition qp.hpp:469
friend class QS
Definition qp.hpp:470
void trig_(void const *const sender) noexcept
Asynchronously trigger the QTicker active object to perform tick processing.
Definition qf_actq.cpp:447
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
Definition qf_actq.cpp:418
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.
Definition qf_actq.cpp:399
QTicker(std::uint8_t const tickRate) noexcept
Constructor of the QTicker Active Object class.
Definition qf_actq.cpp:391
Time Event class.
Definition qp.hpp:660
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.
Definition qf_time.cpp:276
QTimeEvt * m_next
Link to the next time event in the list.
Definition qp.hpp:662
QTimeEvt * toTimeEvt() noexcept
Definition qp.hpp:717
friend class QS
Definition qp.hpp:732
bool disarm() noexcept
Disarm a time event.
Definition qf_time.cpp:148
std::uint8_t m_flags
Definition qp.hpp:667
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
QTimeEvtCtr getInterval() const noexcept
Definition qp.hpp:690
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:360
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.
Definition qp.hpp:663
QActive * toActive() noexcept
Definition qp.hpp:713
std::uint8_t m_tickRate
Definition qp.hpp:666
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:687
bool rearm(std::uint32_t const nTicks) noexcept
Rearm a time event.
Definition qf_time.cpp:191
std::uint8_t getTickRate() const noexcept
Definition qp.hpp:693
QTimeEvtCtr m_ctr
Down-counter of the time event.
Definition qp.hpp:664
QTimeEvtCtr m_interval
Interval for periodic time event (zero for one-shot time event).
Definition qp.hpp:665
void const * getAct() const &
Definition qp.hpp:680
bool wasDisarmed() noexcept
Check the "was disarmed" status of a time event.
Definition qf_time.cpp:261
friend class QXThread
Definition qp.hpp:731
eXtended (blocking) thread of the QXK preemptive kernel
Definition qxk.hpp:79
QF Active Object Framework namespace.
Definition qp.hpp:476
void deleteRef_(QEvt const *const evtRef) noexcept
Definition qf_dyn.cpp:378
void onCleanup()
Cleanup QF callback.
QEvt const * newRef_(QEvt const *const e, QEvt const *const evtRef) noexcept
Definition qf_dyn.cpp:336
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.
Definition qf_dyn.cpp:276
QEvt * newX_(std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, QSignal const sig) noexcept
Definition qf_dyn.cpp:197
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.
Definition qp.hpp:771
evtT_ * q_new_x(std::uint_fast16_t const margin, QSignal const sig, Args... args)
Definition qp.hpp:838
void tick(std::uint_fast8_t const tickRate, void const *const sender) noexcept
Definition qp.hpp:780
evtT_ * q_new(QSignal const sig, Args... args)
Definition qp.hpp:829
void psInit(QSubscrList *const subscrSto, QSignal const maxSignal) noexcept
Definition qp.hpp:755
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...
Definition qp.hpp:484
void init()
QF initialization.
Definition qv.cpp:96
void q_new_ref(QP::QEvt const *const e, evtT_ const *&evtRef)
Create a new reference of the current event e.
Definition qp.hpp:854
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.
Definition qp.hpp:863
int_t run()
Transfers control to QF to run the application.
Definition qv.cpp:109
void stop()
Invoked by the application layer to stop the QF framework and return control to the OS/Kernel (used i...
Definition qv.cpp:103
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
Definition qp.hpp:763
void onStartup()
Startup QF callback.
QP/C++ Framework namespace.
Definition qequeue.hpp:36
constexpr QSignal Q_USER_SIG
Definition qp.hpp:164
std::uint32_t QTimeEvtCtr
Data type to store the block-size defined based on the macro QF_TIMEEVT_CTR_SIZE.
Definition qp.hpp:427
QState(*)(void *const me) QActionHandler
Pointer to an action-handler function.
Definition qp.hpp:139
char const * version() noexcept
Definition qf_act.cpp:52
QEvt const * QEvtPtr
Pointer to const event instances passed around in QP/C++ Framework.
Definition qp.hpp:129
std::uint_fast8_t QState
Type returned from state-handler functions.
Definition qp.hpp:134
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function.
Definition qp.hpp:138
std::uint32_t QPSetBits
Bitmask for the internal representation of QPSet elements.
Definition qp.hpp:435
std::uint16_t QSignal
The signal of event QP::QEvt.
Definition qp.hpp:98
void(*)(QXThread *const me) QXThreadHandler
Pointer to an extended-thread handler function.
Definition qp.hpp:140
std::uint16_t QPrioSpec
Priority specification for Active Objects in QP.
Definition qp.hpp:417
int int_t
Alias for assertion-ID numbers in QP assertions and return from QP::QF::run().
Definition qp.hpp:87
#define Q_UNUSED_PAR(par_)
Helper macro to mark unused parameters of functions.
Definition qp.hpp:89
void QF_onContextSw(QP::QActive *prev, QP::QActive *next)
#define QACTIVE_OS_OBJ_TYPE
Port-specific QActive "OS-object" type.
Definition qp_port.hpp:41
#define QACTIVE_EQUEUE_TYPE
Port-specific QActive event queue type.
Definition qp_port.hpp:34
#define QACTIVE_THREAD_TYPE
Port-specific QActive thread type.
Definition qp_port.hpp:48
#define QF_LOG2(bitmask_)
Port-specific integer log-base-2 of a 32-bit bitmask.
Definition qp_port.hpp:141
State object for the QP::QMsm class (QM State Machine).
Definition qp.hpp:142
QActionHandler const entryAction
Definition qp.hpp:145
QStateHandler const stateHandler
Definition qp.hpp:144
QActionHandler const exitAction
Definition qp.hpp:146
QMState const * superstate
Definition qp.hpp:143
QActionHandler const initAction
Definition qp.hpp:147
Transition-Action Table for the QP::QMsm State Machine.
Definition qp.hpp:150
QMState const * target
Definition qp.hpp:151
QActionHandler const act[1]
Definition qp.hpp:152
Attribute of for the QP::QAsm class (Abstract State Machine).
Definition qp.hpp:155
std::uintptr_t uint
Definition qp.hpp:161
QMState const * obj
Definition qp.hpp:159
QStateHandler fun
Definition qp.hpp:156
QMTranActTable const * tatbl
Definition qp.hpp:160
QXThreadHandler thr
Definition qp.hpp:158
QActionHandler act
Definition qp.hpp:157