QP/C++  8.0.2
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.0.3"
34#define QP_VERSION 803U
35// <VER>=803 <DATE>=250317
36#define QP_RELEASE 0x6ACCA50CU
37
38//============================================================================
39// default configuration settings
40//! @cond INTERNAL
41
42#ifndef Q_SIGNAL_SIZE
43#define Q_SIGNAL_SIZE 2U
44#endif
45
46#ifndef QF_MAX_ACTIVE
47#define QF_MAX_ACTIVE 32U
48#endif
49
50#if (QF_MAX_ACTIVE > 64U)
51#error QF_MAX_ACTIVE exceeds the maximum of 64U;
52#endif
53
54#ifndef QF_MAX_TICK_RATE
55#define QF_MAX_TICK_RATE 1U
56#endif
57
58#if (QF_MAX_TICK_RATE > 15U)
59#error QF_MAX_TICK_RATE exceeds the maximum of 15U;
60#endif
61
62#ifndef QF_MAX_EPOOL
63#define QF_MAX_EPOOL 3U
64#endif
65
66#if (QF_MAX_EPOOL > 15U)
67#error QF_MAX_EPOOL exceeds the maximum of 15U;
68#endif
69
70#ifndef QF_TIMEEVT_CTR_SIZE
71#define QF_TIMEEVT_CTR_SIZE 4U
72#endif
73
74#if (QF_TIMEEVT_CTR_SIZE > 4U)
75#error QF_TIMEEVT_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U;
76#endif
77
78#ifndef QF_EVENT_SIZ_SIZE
79#define QF_EVENT_SIZ_SIZE 2U
80#endif
81
82#if (QF_EVENT_SIZ_SIZE > 4U)
83#error QF_EVENT_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U;
84#endif
85
86//! @endcond
87
88//============================================================================
89// global types/utilities
90
91using int_t = int;
92
93using enum_t = int;
94using float32_t = float;
95using float64_t = double;
96
97#define Q_UNUSED_PAR(par_) (static_cast<void>(par_))
98#define Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U]))
99#define Q_UINT2PTR_CAST(type_, uint_) (reinterpret_cast<type_ *>(uint_))
100
101//============================================================================
102
103namespace QP {
104
105extern char const versionStr[24];
106
107// QSignal type
108#if (Q_SIGNAL_SIZE == 1U)
109 using QSignal = std::uint8_t;
110#elif (Q_SIGNAL_SIZE == 2U)
111 using QSignal = std::uint16_t;
112#elif (Q_SIGNAL_SIZE == 4U)
113 using QSignal = std::uint32_t;
114#endif
115
116//============================================================================
117
118class QEvt {
119public:
121 std::uint8_t poolNum_;
122 std::uint8_t volatile refCtr_;
123
124public:
125 enum DynEvt: std::uint8_t { DYNAMIC };
126
127public:
128 explicit constexpr QEvt(QSignal const s) noexcept
129 : sig(s),
130 poolNum_(0x00U),
131 refCtr_(0xE0U)
132 {}
133
134 QEvt() = delete;
135 void init() noexcept {
136 // no event parameters to initialize
137 }
138 void init(DynEvt const dummy) noexcept {
139 Q_UNUSED_PAR(dummy);
140 // no event parameters to initialize
141 }
142}; // class QEvt
143
144using QEvtPtr = QEvt const *;
145
146//============================================================================
147// QEP (hierarchical event processor) types
148
149using QState = std::uint_fast8_t;
150
151class QXThread; // forward declaration
152
153using QStateHandler = QState (*)(void * const me, QEvt const * const e);
154using QActionHandler = QState (*)(void * const me);
155using QXThreadHandler = void (*)(QXThread * const me);
156
164
168};
169
177
178constexpr enum_t Q_USER_SIG {4};
179
180//============================================================================
181class QAsm {
182public:
185
186public:
187 // All possible return values from state-handlers
188 // NOTE: The ordering is important for algorithmic correctness.
189 static constexpr QState Q_RET_SUPER {0U};
190 static constexpr QState Q_RET_UNHANDLED {1U};
191
192 // handled and do not need to "bubble up"
193 static constexpr QState Q_RET_HANDLED {2U};
194 static constexpr QState Q_RET_IGNORED {3U};
195
196 // entry/exit
197 static constexpr QState Q_RET_ENTRY {4U};
198 static constexpr QState Q_RET_EXIT {5U};
199
200 // no side effects
201 static constexpr QState Q_RET_NULL {6U};
202
203 // transitions need to execute transition-action table in QP::QMsm
204 static constexpr QState Q_RET_TRAN {7U};
205 static constexpr QState Q_RET_TRAN_INIT {8U};
206
207 // transitions that additionally clobber QHsm.m_state
208 static constexpr QState Q_RET_TRAN_HIST {9U};
209
210 // Reserved signals by the QP-framework
211 static constexpr QSignal Q_EMPTY_SIG {0U};
212 static constexpr QSignal Q_ENTRY_SIG {1U};
213 static constexpr QSignal Q_EXIT_SIG {2U};
214 static constexpr QSignal Q_INIT_SIG {3U};
215
216protected:
217 explicit QAsm() noexcept
218 : m_state(),
219 m_temp ()
220 {}
221
222public:
223
224#ifdef Q_XTOR
225 virtual ~QAsm() noexcept {
226 // empty
227 }
228#endif // def Q_XTOR
229 virtual void init(
230 void const * const e,
231 std::uint_fast8_t const qsId) = 0;
232 virtual void init(std::uint_fast8_t const qsId) {
233 this->init(nullptr, qsId);
234 }
235 virtual void dispatch(
236 QEvt const * const e,
237 std::uint_fast8_t const qsId) = 0;
238 virtual bool isIn(QStateHandler const stateHndl) noexcept {
239 Q_UNUSED_PAR(stateHndl);
240 return false;
241 }
242 QStateHandler state() const noexcept {
243 return m_state.fun;
244 }
245 QMState const * stateObj() const noexcept {
246 return m_state.obj;
247 }
248
249#ifdef Q_SPY
250 virtual QStateHandler getStateHandler() noexcept {
251 return m_state.fun;
252 }
253#endif // def Q_SPY
254
255 static QState top(
256 void * const me,
257 QEvt const * const e) noexcept
258 {
259 static_cast<void>(me);
260 static_cast<void>(e);
261 return Q_RET_IGNORED; // the top state ignores all events
262 }
263
264protected:
265 QState tran(QStateHandler const target) noexcept {
266 m_temp.fun = target;
267 return Q_RET_TRAN;
268 }
269 QState tran_hist(QStateHandler const hist) noexcept {
270 m_temp.fun = hist;
271 return Q_RET_TRAN_HIST;
272 }
273 QState super(QStateHandler const superstate) noexcept {
274 m_temp.fun = superstate;
275 return Q_RET_SUPER;
276 }
277 QState qm_tran(void const * const tatbl) noexcept {
278 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
279 return Q_RET_TRAN;
280 }
281 QState qm_tran_init(void const * const tatbl) noexcept {
282 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
283 return Q_RET_TRAN_INIT;
284 }
286 QMState const * const hist,
287 void const * const tatbl) noexcept
288 {
289 m_state.obj = hist;
290 m_temp.tatbl = static_cast<QP::QMTranActTable const *>(tatbl);
291 return Q_RET_TRAN_HIST;
292 }
293
294#ifdef Q_SPY
295 QState qm_entry(QMState const * const s) noexcept {
296 m_temp.obj = s;
297 return Q_RET_ENTRY;
298 }
299#endif // def Q_SPY
300
301#ifndef Q_SPY
302 QState qm_entry(QMState const * const s) noexcept {
303 static_cast<void>(s); // unused parameter
304 return Q_RET_ENTRY;
305 }
306#endif // ndef Q_SPY
307
308#ifdef Q_SPY
309 QState qm_exit(QMState const * const s) noexcept {
310 m_temp.obj = s;
311 return Q_RET_EXIT;
312 }
313#endif // def Q_SPY
314
315#ifndef Q_SPY
316 QState qm_exit(QMState const * const s) noexcept {
317 static_cast<void>(s); // unused parameter
318 return Q_RET_EXIT;
319 }
320#endif // ndef Q_SPY
321}; // class QAsm
322
323//============================================================================
324class QHsm : public QP::QAsm {
325protected:
326 explicit QHsm(QStateHandler const initial) noexcept;
327
328public:
329 void init(
330 void const * const e,
331 std::uint_fast8_t const qsId) override;
332 void init(std::uint_fast8_t const qsId) override {
333 this->init(nullptr, qsId);
334 }
335 void dispatch(
336 QEvt const * const e,
337 std::uint_fast8_t const qsId) override;
338 bool isIn(QStateHandler const stateHndl) noexcept override;
339 QStateHandler childState(QStateHandler const parentHndl) noexcept;
340
341#ifdef Q_SPY
342 QStateHandler getStateHandler() noexcept override {
343 return m_state.fun;
344 }
345#endif // def Q_SPY
346
347private:
348 std::int_fast8_t tran_simple_(
349 QStateHandler * const path,
350 std::uint_fast8_t const qsId);
351
352 std::int_fast8_t tran_complex_(
353 QStateHandler * const path,
354 std::uint_fast8_t const qsId);
355
357 QStateHandler * const path,
358 std::int_fast8_t const depth,
359 std::uint_fast8_t const qsId);
360}; // class QHsm
361
362//============================================================================
363class QMsm : public QP::QAsm {
364protected:
365 explicit QMsm(QStateHandler const initial) noexcept;
366
367public:
368 void init(
369 void const * const e,
370 std::uint_fast8_t const qsId) override;
371 void init(std::uint_fast8_t const qsId) override {
372 this->init(nullptr, qsId);
373 }
375 QEvt const * const e,
376 std::uint_fast8_t const qsId) override;
377
378#ifdef Q_SPY
379 QStateHandler getStateHandler() noexcept override {
380 return m_state.obj->stateHandler;
381 }
382#endif // def Q_SPY
383 bool isIn(QStateHandler const stateHndl) noexcept override;
384 QMState const * childStateObj(QMState const * const parentHndl)
385 const noexcept;
386
387private:
389 QMTranActTable const * const tatbl,
390 std::uint_fast8_t const qsId);
392 QMState const * const cs,
393 QMState const * const ts,
394 std::uint_fast8_t const qsId);
396 QMState const * const hist,
397 std::uint_fast8_t const qsId);
398
399public:
400 QMState const * topQMState() const noexcept;
401}; // class QMsm
402
403} // namespace QP
404
405//============================================================================
406// QEP-macros
407
408#define Q_STATE_DECL(state_) \
409 QP::QState state_ ## _h(QP::QEvt const * const e); \
410 static QP::QState state_(void * const me, QP::QEvt const * const e)
411
412#define Q_STATE_DEF(subclass_, state_) \
413 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) { \
414 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
415 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)
416
417#define Q_HANDLED() (Q_RET_HANDLED)
418#define Q_UNHANDLED() (Q_RET_UNHANDLED)
419
420#define Q_EVT_CAST(subclass_) (static_cast<subclass_ const *>(e))
421#define Q_STATE_CAST(handler_) (reinterpret_cast<QP::QStateHandler>(handler_))
422
423#define QM_STATE_DECL(state_) \
424 QP::QState state_ ## _h(QP::QEvt const * const e); \
425 static QP::QState state_(void * const me, QP::QEvt const * const e); \
426 static QP::QMState const state_ ## _s
427
428#define QM_ACTION_DECL(action_) \
429 QP::QState action_ ## _h(); \
430 static QP::QState action_(void * const me)
431
432#define QM_STATE_DEF(subclass_, state_) \
433 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) {\
434 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
435 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)
436
437#define QM_ACTION_DEF(subclass_, action_) \
438 QP::QState subclass_::action_(void * const me) { \
439 return static_cast<subclass_ *>(me)->action_ ## _h(); } \
440 QP::QState subclass_::action_ ## _h()
441
442#define QM_HANDLED() (Q_RET_HANDLED)
443#define QM_UNHANDLED() (Q_RET_HANDLED)
444#define QM_SUPER() (Q_RET_SUPER)
445#define QM_STATE_NULL (nullptr)
446#define Q_ACTION_NULL (nullptr)
447
448#ifdef Q_SPY
449 #define INIT(qsId_) init((qsId_))
450 #define DISPATCH(e_, qsId_) dispatch((e_), (qsId_))
451#else
452 #define INIT(dummy) init(0U)
453 #define DISPATCH(e_, dummy) dispatch((e_), 0U)
454#endif // ndef Q_SPY
455
456//============================================================================
457namespace QP {
458
459using QPrioSpec = std::uint16_t;
460
461#if (QF_TIMEEVT_CTR_SIZE == 1U)
462 using QTimeEvtCtr = std::uint8_t;
463#elif (QF_TIMEEVT_CTR_SIZE == 2U)
464 using QTimeEvtCtr = std::uint16_t;
465#elif (QF_TIMEEVT_CTR_SIZE == 4U)
466 using QTimeEvtCtr = std::uint32_t;
467#endif // (QF_TIMEEVT_CTR_SIZE == 4U)
468
469#if (QF_MAX_ACTIVE <= 8U)
470 using QPSetBits = std::uint8_t;
471#elif (8U < QF_MAX_ACTIVE) && (QF_MAX_ACTIVE <= 16U)
472 using QPSetBits = std::uint16_t;
473#elif (16 < QF_MAX_ACTIVE)
474 using QPSetBits = std::uint32_t;
475#endif // (16 < QF_MAX_ACTIVE)
476
477#ifndef QF_LOG2
478 std::uint_fast8_t QF_LOG2(QP::QPSetBits const bitmask) noexcept;
479#endif // ndef QF_LOG2
480
481//============================================================================
482class QPSet {
483private:
484 QPSetBits m_bits[((QF_MAX_ACTIVE + (8U*sizeof(QPSetBits))) - 1U)/(8U*sizeof(QPSetBits))];
485
486public:
487 void setEmpty() noexcept {
488 m_bits[0] = 0U;
489#if (QF_MAX_ACTIVE > 32)
490 m_bits[1] = 0U;
491#endif
492 }
493 bool isEmpty() const noexcept {
494#if (QF_MAX_ACTIVE <= 32U)
495 return (m_bits[0] == 0U);
496#else
497 return (m_bits[0] == 0U) ? (m_bits[1] == 0U) : false;
498#endif
499 }
500 bool notEmpty() const noexcept {
501#if (QF_MAX_ACTIVE <= 32U)
502 return (m_bits[0] != 0U);
503#else
504 return (m_bits[0] != 0U) ? true : (m_bits[1] != 0U);
505#endif
506 }
507 bool hasElement(std::uint_fast8_t const n) const noexcept {
508#if (QF_MAX_ACTIVE <= 32U)
509 return (m_bits[0] & (static_cast<QPSetBits>(1U) << (n - 1U))) != 0U;
510#else
511 return (n <= 32U)
512 ? ((m_bits[0] & (static_cast<QPSetBits>(1U) << (n - 1U))) != 0U)
513 : ((m_bits[1] & (static_cast<QPSetBits>(1U) << (n - 33U))) != 0U);
514#endif
515 }
516 void insert(std::uint_fast8_t const n) noexcept {
517#if (QF_MAX_ACTIVE <= 32U)
518 m_bits[0] = (m_bits[0] | (static_cast<QPSetBits>(1U) << (n - 1U)));
519#else
520 if (n <= 32U) {
521 m_bits[0] = (m_bits[0] | (static_cast<QPSetBits>(1U) << (n - 1U)));
522 }
523 else {
524 m_bits[1] = (m_bits[1] | (static_cast<QPSetBits>(1U) << (n - 33U)));
525 }
526#endif
527 }
528 void remove(std::uint_fast8_t const n) noexcept {
529#if (QF_MAX_ACTIVE <= 32U)
530 m_bits[0] = (m_bits[0] & static_cast<QPSetBits>(~(1U << (n - 1U))));
531#else
532 if (n <= 32U) {
533 (m_bits[0] = (m_bits[0] & ~(static_cast<QPSetBits>(1U) << (n - 1U))));
534 }
535 else {
536 (m_bits[1] = (m_bits[1] & ~(static_cast<QPSetBits>(1U) << (n - 33U))));
537 }
538#endif
539 }
540 std::uint_fast8_t findMax() const noexcept {
541#if (QF_MAX_ACTIVE <= 32U)
542 return QF_LOG2(m_bits[0]);
543#else
544 return (m_bits[1] != 0U)
545 ? (QF_LOG2(m_bits[1]) + 32U)
546 : (QF_LOG2(m_bits[0]));
547#endif
548 }
549
550}; // class QPSet
551
552//============================================================================
554private:
556
557 // friends...
558 friend class QActive;
559}; // class QSubscrList
560
561//============================================================================
562class QEQueue; // forward declaration
563
564
565//============================================================================
566class QActive : public QP::QAsm {
567private:
568 std::uint8_t m_prio;
569 std::uint8_t m_pthre;
570
571#ifdef QACTIVE_THREAD_TYPE
573#endif // def QACTIVE_THREAD_TYPE
574
575#ifdef QACTIVE_OS_OBJ_TYPE
577#endif // def QACTIVE_OS_OBJ_TYPE
578
579#ifdef QACTIVE_EQUEUE_TYPE
581#endif // def QACTIVE_EQUEUE_TYPE
582
583public:
587
588 // friends...
589 friend class QTimeEvt;
590 friend class QTicker;
591 friend class QXThread;
592 friend class QXMutex;
593 friend class QXSemaphore;
594 friend class QActiveDummy;
595 friend class GuiQActive;
596 friend class GuiQMActive;
597 friend void schedLock();
598
599protected:
600 explicit QActive(QStateHandler const initial) noexcept
601 : QAsm(),
602 m_prio(0U),
603 m_pthre(0U)
604 {
605 m_state.fun = Q_STATE_CAST(&top);
606 m_temp.fun = initial;
607 }
608
609public:
610 void init(
611 void const * const e,
612 std::uint_fast8_t const qsId) override
613 {
614 reinterpret_cast<QHsm *>(this)->QHsm::init(e, qsId);
615 }
616 void init(std::uint_fast8_t const qsId) override {
617 this->init(nullptr, qsId);
618 }
620 QEvt const * const e,
621 std::uint_fast8_t const qsId) override
622 {
623 reinterpret_cast<QHsm *>(this)->QHsm::dispatch(e, qsId);
624 }
625 bool isIn(QStateHandler const stateHndl) noexcept override {
626 return reinterpret_cast<QHsm *>(this)->QHsm::isIn(stateHndl);
627 }
628 QStateHandler childState(QStateHandler const parentHandler) noexcept {
629 return reinterpret_cast<QHsm *>(this)->QHsm::childState(parentHandler);
630 }
632 std::uint32_t attr1,
633 void const * attr2 = nullptr);
634 void start(
635 QPrioSpec const prioSpec,
636 QEvtPtr * const qSto,
637 std::uint_fast16_t const qLen,
638 void * const stkSto,
639 std::uint_fast16_t const stkSize,
640 void const * const par);
641 void start(
642 QPrioSpec const prioSpec,
643 QEvtPtr * const qSto,
644 std::uint_fast16_t const qLen,
645 void * const stkSto,
646 std::uint_fast16_t const stkSize)
647 {
648 this->start(prioSpec, qSto, qLen, stkSto, stkSize, nullptr);
649 }
650
651#ifdef QACTIVE_CAN_STOP
652 void stop();
653#endif // def QACTIVE_CAN_STOP
654 void register_() noexcept;
655 void unregister_() noexcept;
656 bool post_(
657 QEvt const * const e,
658 std::uint_fast16_t const margin,
659 void const * const sender) noexcept;
660 void postLIFO(QEvt const * const e) noexcept;
661 QEvt const * get_() noexcept;
662 static std::uint_fast16_t getQueueMin(std::uint_fast8_t const prio) noexcept;
663 static void psInit(
664 QSubscrList * const subscrSto,
665 enum_t const maxSignal) noexcept;
666 static void publish_(
667 QEvt const * const e,
668 void const * const sender,
669 std::uint_fast8_t const qsId) noexcept;
670 void subscribe(enum_t const sig) const noexcept;
671 void unsubscribe(enum_t const sig) const noexcept;
672 void unsubscribeAll() const noexcept;
673 bool defer(
674 QEQueue * const eq,
675 QEvt const * const e) const noexcept;
676 bool recall(QEQueue * const eq) noexcept;
677 std::uint_fast16_t flushDeferred(
678 QEQueue * const eq,
679 std::uint_fast16_t const num = 0xFFFFU) const noexcept;
680 std::uint_fast8_t getPrio() const noexcept {
681 return static_cast<std::uint_fast8_t>(m_prio);
682 }
683 void setPrio(QPrioSpec const prio) noexcept {
684 m_prio = static_cast<std::uint8_t>(prio & 0xFFU);
685 m_pthre = static_cast<std::uint8_t>(prio >> 8U);
686 }
687 std::uint_fast8_t getPThre() const noexcept {
688 return static_cast<std::uint_fast8_t>(m_pthre);
689 }
690
691#ifdef QACTIVE_EQUEUE_TYPE
692 QACTIVE_EQUEUE_TYPE const & getEQueue() const noexcept {
693 return m_eQueue;
694 }
695#endif // def QACTIVE_EQUEUE_TYPE
696
697#ifdef QACTIVE_OS_OBJ_TYPE
698 QACTIVE_OS_OBJ_TYPE const & getOsObject() const noexcept {
699 return m_osObject;
700 }
701#endif // def QACTIVE_OS_OBJ_TYPE
702
703#ifdef QACTIVE_THREAD_TYPE
704 QACTIVE_THREAD_TYPE const & getThread() const noexcept {
705 return m_thread;
706 }
707#endif // def QACTIVE_THREAD_TYPE
708
709#ifdef QACTIVE_THREAD_TYPE
710 void setThread(QACTIVE_THREAD_TYPE const & thr) {
711 m_thread = thr;
712 }
713#endif // def QACTIVE_THREAD_TYPE
714 static void evtLoop_(QActive * act);
715
716#ifdef QF_ISR_API
717 virtual bool postFromISR(
718 QEvt const * const e,
719 std::uint_fast16_t const margin,
720 void * par,
721 void const * const sender) noexcept;
722#endif // def QF_ISR_API
723
724#ifdef QF_ISR_API
725 static void publishFromISR(
726 QEvt const * e,
727 void * par,
728 void const * sender) noexcept;
729#endif // def QF_ISR_API
730
731private:
732 void postFIFO_(
733 QEvt const * const e,
734 void const * const sender);
735}; // class QActive
736
737//============================================================================
738class QMActive : public QP::QActive {
739protected:
740 explicit QMActive(QStateHandler const initial) noexcept;
741
742public:
743 void init(
744 void const * const e,
745 std::uint_fast8_t const qsId) override
746 {
747 reinterpret_cast<QMsm *>(this)->QMsm::init(e, qsId);
748 }
749 void init(std::uint_fast8_t const qsId) override {
750 this->init(nullptr, qsId);
751 }
753 QEvt const * const e,
754 std::uint_fast8_t const qsId) override
755 {
756 reinterpret_cast<QMsm *>(this)->QMsm::dispatch(e, qsId);
757 }
758 bool isIn(QStateHandler const stateHndl) noexcept override {
759 return reinterpret_cast<QMsm *>(this)->QMsm::isIn(stateHndl);
760 }
761
762#ifdef Q_SPY
763 QStateHandler getStateHandler() noexcept override {
764 return reinterpret_cast<QMsm *>(this)->QMsm::getStateHandler();
765 }
766#endif // def Q_SPY
767 QMState const * childStateObj(QMState const * const parent) const noexcept {
768 return reinterpret_cast<QMsm const *>(this)
769 ->QMsm::childStateObj(parent);
770 }
771}; // class QMActive
772
773
774//============================================================================
775class QTimeEvt : public QP::QEvt {
776private:
777 QTimeEvt * volatile m_next;
778 void * m_act;
781 std::uint8_t m_tickRate;
782 std::uint8_t m_flags;
783
784public:
786
787private:
788 friend class QXThread;
789
790public:
791 QTimeEvt(
792 QActive * const act,
793 QSignal const sig,
794 std::uint_fast8_t const tickRate = 0U) noexcept;
795 void armX(
796 std::uint32_t const nTicks,
797 std::uint32_t const interval = 0U) noexcept;
798 bool disarm() noexcept;
799 bool rearm(std::uint32_t const nTicks) noexcept;
800 bool wasDisarmed() noexcept;
801 void const * getAct() const noexcept {
802 return m_act;
803 }
804 QTimeEvtCtr getCtr() const noexcept {
805 return m_ctr;
806 }
807 QTimeEvtCtr getInterval() const noexcept {
808 return m_interval;
809 }
810 std::uint8_t getTickRate() const noexcept {
811 return m_tickRate;
812 }
813 static void tick(
814 std::uint_fast8_t const tickRate,
815 void const * const sender) noexcept;
816
817#ifdef Q_UTEST
818 static void tick1_(
819 std::uint_fast8_t const tickRate,
820 void const * const sender);
821#endif // def Q_UTEST
822
823#ifdef QF_ISR_API
824 static void tickFromISR(
825 std::uint_fast8_t const tickRate,
826 void * par,
827 void const * sender) noexcept;
828#endif // def QF_ISR_API
829 static bool noActive(std::uint_fast8_t const tickRate) noexcept;
830 QActive * toActive() noexcept {
831 return static_cast<QActive *>(m_act);
832 }
833 QTimeEvt * toTimeEvt() noexcept {
834 return static_cast<QTimeEvt *>(m_act);
835 }
836
837private:
838 QTimeEvt() noexcept;
839 QTimeEvt(QTimeEvt const & other) = delete;
840 QTimeEvt & operator=(QTimeEvt const & other) = delete;
842 QTimeEvt * const prev_link,
843 QActive const * const act,
844 std::uint_fast8_t const tickRate) noexcept;
845}; // class QTimeEvt
846
847//============================================================================
848class QTicker : public QP::QActive {
849public:
850 explicit QTicker(std::uint_fast8_t const tickRate) noexcept;
851 void init(
852 void const * const e,
853 std::uint_fast8_t const qsId) override;
854 void init(std::uint_fast8_t const qsId) override {
855 this->init(nullptr, qsId);
856 }
857 void dispatch(
858 QEvt const * const e,
859 std::uint_fast8_t const qsId) override;
860 void trig_(void const * const sender) noexcept;
861}; // class QTicker
862
863//============================================================================
864namespace QF {
865
866void init();
867void stop();
868
869int_t run();
870
873
874//! @deprecated
875inline void psInit(
876 QSubscrList * const subscrSto,
877 enum_t const maxSignal) noexcept
878{
879 QActive::psInit(subscrSto, maxSignal);
880}
881
882//! @deprecated
883inline void publish_(
884 QEvt const * const e,
885 void const * const sender,
886 std::uint_fast8_t const qsId) noexcept
887{
888 QActive::publish_(e, sender, qsId);
889}
890
891//! @deprecated
892inline void tick(
893 std::uint_fast8_t const tickRate,
894 void const * const sender) noexcept
895{
896 QTimeEvt::tick(tickRate, sender);
897}
898
899//! @deprecated
900inline std::uint_fast16_t getQueueMin(std::uint_fast8_t const prio) noexcept {
901 return QActive::getQueueMin(prio);
902}
903
904constexpr std::uint_fast16_t NO_MARGIN {0xFFFFU};
905
906//============================================================================
907// QF dynamic memory facilities
908void poolInit(
909 void * const poolSto,
910 std::uint_fast32_t const poolSize,
911 std::uint_fast16_t const evtSize) noexcept;
912
913std::uint_fast16_t poolGetMaxBlockSize() noexcept;
914std::uint_fast16_t getPoolMin(std::uint_fast8_t const poolNum) noexcept;
915QEvt * newX_(
916 std::uint_fast16_t const evtSize,
917 std::uint_fast16_t const margin,
918 enum_t const sig) noexcept;
919void gc(QEvt const * const e) noexcept;
920QEvt const * newRef_(
921 QEvt const * const e,
922 QEvt const * const evtRef) noexcept;
923
924void deleteRef_(QEvt const * const evtRef) noexcept;
925
926#ifndef QEVT_PAR_INIT
927 template<class evtT_>
928 inline evtT_ * q_new(enum_t const sig) {
929 return static_cast<evtT_*>(
930 QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, sig));
931 }
932 template<class evtT_>
933 inline evtT_ * q_new_x(
934 std::uint_fast16_t const margin,
935 enum_t const sig)
936 {
937 return static_cast<evtT_*>(QP::QF::newX_(sizeof(evtT_), margin, sig));
938 }
939#else
940 template<class evtT_, typename... Args>
941 inline evtT_ * q_new(
942 enum_t const sig,
943 Args... args)
944 {
945 evtT_ *e = static_cast<evtT_*>(
946 QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, sig));
947 e->init(args...); // e cannot be nullptr
948 return e;
949 }
950 template<class evtT_, typename... Args>
951 inline evtT_ * q_new_x(
952 std::uint_fast16_t const margin,
953 enum_t const sig,
954 Args... args)
955 {
956 evtT_ *e = static_cast<evtT_*>(QP::QF::newX_(sizeof(evtT_), margin, sig));
957 if (e != nullptr) {
958 e->init(args...);
959 }
960 return e;
961 }
962#endif // def QEVT_PAR_INIT
963
964template<class evtT_>
965inline void q_new_ref(
966 QP::QEvt const * const e,
967 evtT_ const *& evtRef)
968{
969 evtRef = static_cast<evtT_ const *>(QP::QF::newRef_(e, evtRef));
970}
971
972template<class evtT_>
973inline void q_delete_ref(evtT_ const *& evtRef) {
974 QP::QF::deleteRef_(evtRef);
975 evtRef = nullptr;
976}
977
978#ifdef QF_ISR_API
980 std::uint_fast16_t const evtSize,
981 std::uint_fast16_t const margin,
982 enum_t const sig) noexcept;
983void gcFromISR(QEvt const * e) noexcept;
984#endif // def QF_ISR_API
985
986} // namespace QF
987} // namespace QP
988
989//============================================================================
990extern "C" {
991
992//${QF-extern-C::QF_onContextSw} .............................................
993#ifdef QF_ON_CONTEXT_SW
995 QP::QActive * prev,
996 QP::QActive * next);
997#endif // def QF_ON_CONTEXT_SW
998} // extern "C"
999
1000//============================================================================
1001// QF base facilities
1002
1003#define Q_PRIO(prio_, pthre_) \
1004 (static_cast<QP::QPrioSpec>((prio_) | (pthre_) << 8U))
1005
1006#ifndef QEVT_PAR_INIT
1007 #define Q_NEW(evtT_, sig_) (QP::QF::q_new<evtT_>((sig_)))
1008 #define Q_NEW_X(evtT_, margin_, sig_) (QP::QF::q_new_x<evtT_>((margin_), (sig_)))
1009#else
1010 #define Q_NEW(evtT_, sig_, ...) (QP::QF::q_new<evtT_>((sig_), __VA_ARGS__))
1011 #define Q_NEW_X(evtT_, margin_, sig_, ...) (QP::QF::q_new_x<evtT_>((margin_), (sig_), __VA_ARGS__))
1012#endif // QEVT_PAR_INIT
1013
1014#define Q_NEW_REF(evtRef_, evtT_) (QP::QF::q_new_ref<evtT_>(e, (evtRef_)))
1015#define Q_DELETE_REF(evtRef_) do { \
1016 QP::QF::deleteRef_((evtRef_)); \
1017 (evtRef_) = nullptr; \
1018} while (false)
1019
1020#ifdef Q_SPY
1021 #define PUBLISH(e_, sender_) \
1022 publish_((e_), (sender_), (sender_)->getPrio())
1023 #define POST(e_, sender_) post_((e_), QP::QF::NO_MARGIN, (sender_))
1024 #define POST_X(e_, margin_, sender_) \
1025 post_((e_), (margin_), (sender_))
1026 #define TICK_X(tickRate_, sender_) tick((tickRate_), (sender_))
1027 #define TRIG(sender_) trig_((sender_))
1028#else
1029 #define PUBLISH(e_, dummy) publish_((e_), nullptr, 0U)
1030 #define POST(e_, dummy) post_((e_), QP::QF::NO_MARGIN, nullptr)
1031 #define POST_X(e_, margin_, dummy) post_((e_), (margin_), nullptr)
1032 #define TICK_X(tickRate_, dummy) tick((tickRate_), nullptr)
1033 #define TRIG(sender_) trig_(nullptr)
1034#endif // ndef Q_SPY
1035
1036#define TICK(sender_) TICK_X(0U, (sender_))
1037
1038#ifndef QF_CRIT_EXIT_NOP
1039 #define QF_CRIT_EXIT_NOP() (static_cast<void>(0))
1040#endif // ndef QF_CRIT_EXIT_NOP
1041
1042//============================================================================
1043// memory protection facilities
1044
1045#ifdef QF_MEM_ISOLATE
1046 #error Memory isolation not supported in this QP edition, need SafeQP
1047#endif // def QF_MEM_ISOLATE
1048
1049#endif // QP_HPP_
Active object class (based on the QHsm implementation strategy)
Definition qp.hpp:566
friend class QActiveDummy
Definition qp.hpp:594
QACTIVE_OS_OBJ_TYPE const & getOsObject() const noexcept
Definition qp.hpp:698
virtual bool postFromISR(QEvt const *const e, std::uint_fast16_t const margin, void *par, void const *const sender) noexcept
QACTIVE_THREAD_TYPE m_thread
Definition qp.hpp:572
void unregister_() noexcept
Definition qf_qact.cpp:93
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)
Definition qv.cpp:216
void subscribe(enum_t const sig) const noexcept
Definition qf_ps.cpp:157
friend class QTicker
Definition qp.hpp:590
friend class QXMutex
Definition qp.hpp:592
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 qp.hpp:610
friend class GuiQMActive
Definition qp.hpp:596
static QActive * registry_[QF_MAX_ACTIVE+1U]
Definition qp.hpp:584
bool defer(QEQueue *const eq, QEvt const *const e) const noexcept
Definition qf_defer.cpp:48
void setThread(QACTIVE_THREAD_TYPE const &thr)
Definition qp.hpp:710
static QSubscrList * subscrList_
Definition qp.hpp:585
void register_() noexcept
Definition qf_qact.cpp:48
std::uint_fast8_t getPThre() const noexcept
Definition qp.hpp:687
QACTIVE_THREAD_TYPE const & getThread() const noexcept
Definition qp.hpp:704
void unsubscribe(enum_t const sig) const noexcept
Definition qf_ps.cpp:181
void postFIFO_(QEvt const *const e, void const *const sender)
Definition qf_actq.cpp:270
static void publishFromISR(QEvt const *e, void *par, void const *sender) noexcept
static void publish_(QEvt const *const e, void const *const sender, std::uint_fast8_t const qsId) noexcept
Definition qf_ps.cpp:65
friend class GuiQActive
Definition qp.hpp:595
static void evtLoop_(QActive *act)
void setAttr(std::uint32_t attr1, void const *attr2=nullptr)
static void psInit(QSubscrList *const subscrSto, enum_t const maxSignal) noexcept
Definition qf_ps.cpp:51
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
Definition qp.hpp:619
static enum_t maxPubSignal_
Definition qp.hpp:586
bool post_(QEvt const *const e, std::uint_fast16_t const margin, void const *const sender) noexcept
Definition qf_actq.cpp:49
bool isIn(QStateHandler const stateHndl) noexcept override
Virtual function to check whether the state machine is in a given state.
Definition qp.hpp:625
void init(std::uint_fast8_t const qsId) override
Virtual function to take the top-most initial transition in the state machine (overloaded).
Definition qp.hpp:616
void setPrio(QPrioSpec const prio) noexcept
Definition qp.hpp:683
friend class QXSemaphore
Definition qp.hpp:593
QActive(QStateHandler const initial) noexcept
Definition qp.hpp:600
QACTIVE_EQUEUE_TYPE m_eQueue
Definition qp.hpp:580
QEvt const * get_() noexcept
Definition qf_actq.cpp:208
friend void schedLock()
QStateHandler childState(QStateHandler const parentHandler) noexcept
Definition qp.hpp:628
void postLIFO(QEvt const *const e) noexcept
Definition qf_actq.cpp:133
bool recall(QEQueue *const eq) noexcept
Definition qf_defer.cpp:69
friend class QTimeEvt
Definition qp.hpp:589
std::uint_fast16_t flushDeferred(QEQueue *const eq, std::uint_fast16_t const num=0xFFFFU) const noexcept
Definition qf_defer.cpp:121
std::uint8_t m_pthre
Definition qp.hpp:569
std::uint_fast8_t getPrio() const noexcept
Definition qp.hpp:680
QACTIVE_EQUEUE_TYPE const & getEQueue() const noexcept
Definition qp.hpp:692
QACTIVE_OS_OBJ_TYPE m_osObject
Definition qp.hpp:576
std::uint8_t m_prio
Definition qp.hpp:568
void unsubscribeAll() const noexcept
Definition qf_ps.cpp:205
static std::uint_fast16_t getQueueMin(std::uint_fast8_t const prio) noexcept
Definition qf_actq.cpp:333
void start(QPrioSpec const prioSpec, QEvtPtr *const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize)
Definition qp.hpp:641
friend class QXThread
Definition qp.hpp:591
Abstract State Machine class (state machine interface)
Definition qp.hpp:181
virtual void init(std::uint_fast8_t const qsId)
Virtual function to take the top-most initial transition in the state machine (overloaded).
Definition qp.hpp:232
QState qm_entry(QMState const *const s) noexcept
Internal helper function to execute state entry actions in QP::QMsm.
Definition qp.hpp:295
QAsm() noexcept
Constructor of the QP::QAsm base class.
Definition qp.hpp:217
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:285
QStateHandler state() const noexcept
Definition qp.hpp:242
static constexpr QState Q_RET_UNHANDLED
Definition qp.hpp:190
QState qm_tran(void const *const tatbl) noexcept
Internal helper function to take a state transition in QP::QMsm.
Definition qp.hpp:277
static constexpr QState Q_RET_TRAN
Definition qp.hpp:204
static constexpr QState Q_RET_ENTRY
Definition qp.hpp:197
QState qm_exit(QMState const *const s) noexcept
Internal helper function to execute state exit actions in QP::QMsm.
Definition qp.hpp:309
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:269
QState super(QStateHandler const superstate) noexcept
Internal helper function to indicate superstate of a given state in sublclasses of QP::QAsm.
Definition qp.hpp:273
QState qm_tran_init(void const *const tatbl) noexcept
Definition qp.hpp:281
static constexpr QState Q_RET_NULL
Definition qp.hpp:201
QAsmAttr m_temp
Temporary storage for target/act-table etc.
Definition qp.hpp:184
static constexpr QState Q_RET_IGNORED
Definition qp.hpp:194
static constexpr QState Q_RET_SUPER
Definition qp.hpp:189
static QState top(void *const me, QEvt const *const e) noexcept
Top state handler that ignores all events.
Definition qp.hpp:255
static constexpr QState Q_RET_TRAN_INIT
Definition qp.hpp:205
static constexpr QState Q_RET_TRAN_HIST
Definition qp.hpp:208
virtual QStateHandler getStateHandler() noexcept
Virtual method for getting the state handler.
Definition qp.hpp:250
static constexpr QState Q_RET_EXIT
Definition qp.hpp:198
QMState const * stateObj() const noexcept
Definition qp.hpp:245
virtual bool isIn(QStateHandler const stateHndl) noexcept
Virtual function to check whether the state machine is in a given state.
Definition qp.hpp:238
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:265
virtual ~QAsm() noexcept
Virtual destructor of the QP::QAsm abstract base class.
Definition qp.hpp:225
static constexpr QSignal Q_INIT_SIG
Definition qp.hpp:214
QAsmAttr m_state
Current state (pointer to the current state-handler function)
Definition qp.hpp:183
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:212
static constexpr QSignal Q_EXIT_SIG
Definition qp.hpp:213
static constexpr QSignal Q_EMPTY_SIG
Definition qp.hpp:211
static constexpr QState Q_RET_HANDLED
Definition qp.hpp:193
Native QP event queue.
Definition qequeue.hpp:53
Event class.
Definition qp.hpp:118
QSignal sig
Signal of the event (see Event Signal)
Definition qp.hpp:120
@ DYNAMIC
Definition qp.hpp:125
std::uint8_t poolNum_
Event pool number of this event.
Definition qp.hpp:121
std::uint8_t volatile refCtr_
Event reference counter.
Definition qp.hpp:122
constexpr QEvt(QSignal const s) noexcept
Event constexpr constructor applicable to immutable and mutable event instances.
Definition qp.hpp:128
void init(DynEvt const dummy) noexcept
Definition qp.hpp:138
void init() noexcept
Definition qp.hpp:135
QEvt()=delete
Hierarchical State Machine class (QHsm-style state machine implementation strategy)
Definition qp.hpp:324
QStateHandler getStateHandler() noexcept override
Definition qp.hpp:342
std::int_fast8_t tran_complex_(QStateHandler *const path, std::uint_fast8_t const qsId)
void init(std::uint_fast8_t const qsId) override
Virtual function to take the top-most initial transition in the state machine (overloaded).
Definition qp.hpp:332
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:222
std::int_fast8_t tran_simple_(QStateHandler *const path, std::uint_fast8_t const qsId)
QStateHandler childState(QStateHandler const parentHndl) noexcept
Definition qep_hsm.cpp:328
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
Definition qep_hsm.cpp:310
QMActive(QStateHandler const initial) noexcept
Constructor of QP::QMActive class.
Definition qf_qmact.cpp:48
bool isIn(QStateHandler const stateHndl) noexcept override
Virtual function to check whether the state machine is in a given state.
Definition qp.hpp:758
QStateHandler getStateHandler() noexcept override
Virtual method for getting the state handler.
Definition qp.hpp:763
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
Definition qp.hpp:752
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 qp.hpp:743
QMState const * childStateObj(QMState const *const parent) const noexcept
Definition qp.hpp:767
void init(std::uint_fast8_t const qsId) override
Virtual function to take the top-most initial transition in the state machine (overloaded).
Definition qp.hpp:749
Hierarchical State Machine class (QMsm-style state machine implementation strategy)
Definition qp.hpp:363
QMState const * childStateObj(QMState const *const parentHndl) const noexcept
QState execTatbl_(QMTranActTable const *const tatbl, std::uint_fast8_t const qsId)
void init(std::uint_fast8_t const qsId) override
Virtual function to take the top-most initial transition in the state machine (overloaded).
Definition qp.hpp:371
void dispatch(QEvt const *const e, std::uint_fast8_t const qsId) override
Virtual function to dispatch an event to the state machine.
void exitToTranSource_(QMState const *const cs, QMState const *const ts, std::uint_fast8_t const qsId)
QState enterHistory_(QMState const *const hist, std::uint_fast8_t const qsId)
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
QMsm(QStateHandler const initial) noexcept
QMState const * topQMState() const noexcept
QStateHandler getStateHandler() noexcept override
Obtain the current active state from a MSM (read only)
Definition qp.hpp:379
Set of Active Objects of up to QF_MAX_ACTIVE elements.
Definition qp.hpp:482
std::uint_fast8_t findMax() const noexcept
Definition qp.hpp:540
void remove(std::uint_fast8_t const n) noexcept
Definition qp.hpp:528
bool notEmpty() const noexcept
Definition qp.hpp:500
bool hasElement(std::uint_fast8_t const n) const noexcept
Definition qp.hpp:507
QPSetBits m_bits[((QF_MAX_ACTIVE+(8U *sizeof(QPSetBits))) - 1U)/(8U *sizeof(QPSetBits))]
Definition qp.hpp:484
void setEmpty() noexcept
Definition qp.hpp:487
bool isEmpty() const noexcept
Definition qp.hpp:493
void insert(std::uint_fast8_t const n) noexcept
Definition qp.hpp:516
Subscriber List (for publish-subscribe)
Definition qp.hpp:553
QPSet m_set
Definition qp.hpp:555
friend class QActive
Definition qp.hpp:558
void init(std::uint_fast8_t const qsId) override
Virtual function to take the top-most initial transition in the state machine (overloaded).
Definition qp.hpp:854
QTicker(std::uint_fast8_t const tickRate) noexcept
Definition qf_actq.cpp:347
static void tick(std::uint_fast8_t const tickRate, void const *const sender) noexcept
Definition qf_time.cpp:258
QTimeEvt * toTimeEvt() noexcept
Definition qp.hpp:833
void const * getAct() const noexcept
Definition qp.hpp:801
static QTimeEvt timeEvtHead_[QF_MAX_TICK_RATE]
Definition qp.hpp:785
bool disarm() noexcept
Definition qf_time.cpp:136
std::uint8_t m_flags
Definition qp.hpp:782
QTimeEvt() noexcept
Definition qf_time.cpp:367
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:50
static void tick1_(std::uint_fast8_t const tickRate, void const *const sender)
QTimeEvtCtr getInterval() const noexcept
Definition qp.hpp:807
static bool noActive(std::uint_fast8_t const tickRate) noexcept
Definition qf_time.cpp:347
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:778
QTimeEvt *volatile m_next
Link to the next time event in the list.
Definition qp.hpp:777
QActive * toActive() noexcept
Definition qp.hpp:830
std::uint8_t m_tickRate
Definition qp.hpp:781
void armX(std::uint32_t const nTicks, std::uint32_t const interval=0U) noexcept
Definition qf_time.cpp:72
QTimeEvtCtr getCtr() const noexcept
Definition qp.hpp:804
bool rearm(std::uint32_t const nTicks) noexcept
Definition qf_time.cpp:179
std::uint8_t getTickRate() const noexcept
Definition qp.hpp:810
QTimeEvtCtr volatile m_ctr
Down-counter of the time event.
Definition qp.hpp:779
QTimeEvt * expire_(QTimeEvt *const prev_link, QActive const *const act, std::uint_fast8_t const tickRate) noexcept
Definition qf_time.cpp:378
QTimeEvtCtr m_interval
Interval for periodic time event (zero for one-shot time event)
Definition qp.hpp:780
bool wasDisarmed() noexcept
Definition qf_time.cpp:245
friend class QXThread
Definition qp.hpp:788
eXtended (blocking) thread of the QXK preemptive kernel
QF Active Object Framework namespace.
void deleteRef_(QEvt const *const evtRef) noexcept
Definition qf_dyn.cpp:278
void onCleanup()
void psInit(QSubscrList *const subscrSto, enum_t const maxSignal) noexcept
Definition qp.hpp:875
QEvt const * newRef_(QEvt const *const e, QEvt const *const evtRef) noexcept
Definition qf_dyn.cpp:243
evtT_ * q_new(enum_t const sig, Args... args)
Definition qp.hpp:941
void tick(std::uint_fast8_t const tickRate, void const *const sender) noexcept
Definition qp.hpp:892
evtT_ * q_new_x(std::uint_fast16_t const margin, enum_t const sig, Args... args)
Definition qp.hpp:951
void gcFromISR(QEvt const *e) noexcept
constexpr std::uint_fast16_t NO_MARGIN
Definition qp.hpp:904
void q_new_ref(QP::QEvt const *const e, evtT_ const *&evtRef)
Definition qp.hpp:965
std::uint_fast16_t getQueueMin(std::uint_fast8_t const prio) noexcept
Definition qp.hpp:900
QEvt * newXfromISR_(std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, enum_t const sig) noexcept
void q_delete_ref(evtT_ const *&evtRef)
Definition qp.hpp:973
QEvt * newX_(std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, enum_t const sig) noexcept
Definition qf_dyn.cpp:115
void publish_(QEvt const *const e, void const *const sender, std::uint_fast8_t const qsId) noexcept
Definition qp.hpp:883
void onStartup()
QP/C++ framework.
constexpr enum_t Q_USER_SIG
Definition qp.hpp:178
std::uint32_t QTimeEvtCtr
Data type to store the block-size defined based on the macro QF_TIMEEVT_CTR_SIZE.
Definition qp.hpp:466
char const versionStr[24]
Definition qf_act.cpp:48
QState(*)(void *const me) QActionHandler
Pointer to an action-handler function.
Definition qp.hpp:154
std::uint_fast8_t QF_LOG2(QP::QPSetBits const bitmask) noexcept
Definition qf_act.cpp:71
QEvt const * QEvtPtr
Pointer to const event instances passed around in QP Framework.
Definition qp.hpp:144
std::uint_fast8_t QState
Type returned from state-handler functions.
Definition qp.hpp:149
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function.
Definition qp.hpp:153
std::uint32_t QPSetBits
Definition qp.hpp:474
std::uint16_t QSignal
The signal of event QP::QEvt.
Definition qp.hpp:111
void(*)(QXThread *const me) QXThreadHandler
Pointer to an extended-thread handler function.
Definition qp.hpp:155
std::uint16_t QPrioSpec
Priority specification for Active Objects in QP.
Definition qp.hpp:459
int enum_t
Definition qp.hpp:93
int int_t
Alias for assertion-ID numbers in QP assertions and return from QP::QF::run()
Definition qp.hpp:91
float float32_t
Alias for IEEE 754 32-bit floating point number.
Definition qp.hpp:94
#define Q_UNUSED_PAR(par_)
Helper macro to clearly mark unused parameters of functions.
Definition qp.hpp:97
double float64_t
Alias for IEEE 754 64-bit floating point number.
Definition qp.hpp:95
#define Q_STATE_CAST(handler_)
Definition qp.hpp:421
void QF_onContextSw(QP::QActive *prev, QP::QActive *next)
#define QF_MAX_TICK_RATE
Maximum # clock tick rates in the system (0..15)
#define QF_MAX_ACTIVE
Maximum # Active Objects in the system (1..64)
#define QACTIVE_OS_OBJ_TYPE
QP::QActive "OS-object" type used in various QP/C++ ports.
Definition qp_port.hpp:29
#define QACTIVE_EQUEUE_TYPE
QP::QActive event queue type used in various QP/C++ ports.
Definition qp_port.hpp:26
#define QACTIVE_THREAD_TYPE
QP::QActive "thread" type used in various QP/C++ ports.
Definition qp_port.hpp:32
State object for the QP::QMsm class (QM State Machine)
Definition qp.hpp:157
QActionHandler const entryAction
Definition qp.hpp:160
QStateHandler const stateHandler
Definition qp.hpp:159
QActionHandler const exitAction
Definition qp.hpp:161
QMState const * superstate
Definition qp.hpp:158
QActionHandler const initAction
Definition qp.hpp:162
Transition-Action Table for the QP::QMsm State Machine.
Definition qp.hpp:165
QMState const * target
Definition qp.hpp:166
QActionHandler const act[1]
Definition qp.hpp:167
Attribute of for the QP::QAsm class (Abstract State Machine)
Definition qp.hpp:170
QMState const * obj
Definition qp.hpp:174
QStateHandler fun
Definition qp.hpp:171
QMTranActTable const * tatbl
Definition qp.hpp:175
QXThreadHandler thr
Definition qp.hpp:173
QActionHandler act
Definition qp.hpp:172