QP/C++ 8.1.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.1.2"
34#define QP_VERSION 812U
35// <VER>=812 <DATE>=260105
36#define QP_RELEASE 0x64F71D43U
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
129#ifndef QEQUEUE_HPP_
130// NOTE must be consistent with "qequeue.hpp"
131using QEvtPtr = QEvt const *;
132#endif
133
134//----------------------------------------------------------------------------
135// QEP (hierarchical event processor) types
136
137using QState = std::uint_fast8_t;
138
139class QXThread; // forward declaration
140
141using QStateHandler = QState (*)(void * const me, QEvt const * const e);
142using QActionHandler = QState (*)(void * const me);
143using QXThreadHandler = void (*)(QXThread * const me);
144
152
156};
157
166
167constexpr QSignal Q_USER_SIG {4U};
168
169//----------------------------------------------------------------------------
170class QAsm {
171public:
174
175 // All possible values returned from state/action handlers...
176 // NOTE: The numerical order is important for algorithmic correctness.
177 static constexpr QState Q_RET_SUPER {0U};
178 static constexpr QState Q_RET_UNHANDLED {1U};
179 static constexpr QState Q_RET_HANDLED {2U};
180 static constexpr QState Q_RET_TRAN {3U};
181 static constexpr QState Q_RET_TRAN_HIST {4U};
182
183 // used in QHsm only...
184 static constexpr QState Q_RET_IGNORED {5U};
185
186 // used in QMsm only...
187 static constexpr QState Q_RET_ENTRY {6U};
188 static constexpr QState Q_RET_EXIT {7U};
189 static constexpr QState Q_RET_TRAN_INIT {8U};
190
191 // Reserved signals by the QP-framework (used in QHsm only)
192 static constexpr QSignal Q_EMPTY_SIG {0U};
193 static constexpr QSignal Q_ENTRY_SIG {1U};
194 static constexpr QSignal Q_EXIT_SIG {2U};
195 static constexpr QSignal Q_INIT_SIG {3U};
196
197 static constexpr QState Q_HANDLED() { // for coding QHsm state machines
198 return Q_RET_HANDLED; }
199 static constexpr QState Q_UNHANDLED() { // for coding QHsm state machines
200 return Q_RET_UNHANDLED; }
201 static constexpr QState QM_HANDLED() { // for coding QMsm state machines
202 return Q_RET_HANDLED; }
203 static constexpr QState QM_UNHANDLED() { // for coding QMsm state machines
204 return Q_RET_HANDLED; }
205 static constexpr QState QM_SUPER() { // for coding QMsm state machines
206 return Q_RET_SUPER; }
207 static constexpr QMState const *QM_STATE_NULL { nullptr };
208 static constexpr QActionHandler const Q_ACTION_NULL { nullptr };
209
210#ifdef Q_XTOR
211 virtual ~QAsm() = default;
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 // maximum depth of state nesting in a QHsm (including the top level)
318 // must be >= 3
319 static constexpr std::size_t MAX_NEST_DEPTH_ {6U};
320
321 std::size_t tran_simple_(
322 std::array<QStateHandler, MAX_NEST_DEPTH_> &path,
323 std::uint_fast8_t const qsId);
324
325 std::size_t tran_complex_(
326 std::array<QStateHandler, MAX_NEST_DEPTH_> &path,
327 std::uint_fast8_t const qsId);
328
330 std::array<QStateHandler, MAX_NEST_DEPTH_> &path,
331 std::size_t const depth,
332 std::uint_fast8_t const qsId);
333
334 // friends...
335 friend class QS;
336}; // class QHsm
337
338//----------------------------------------------------------------------------
339class QMsm : public QP::QAsm {
340protected:
341 explicit QMsm(QStateHandler const initial) noexcept;
342
343public:
344 using QAsm::init;
345 void init(
346 void const * const e,
347 std::uint_fast8_t const qsId) override;
349 QEvt const * const e,
350 std::uint_fast8_t const qsId) override;
351 bool isIn(QStateHandler const stateHndl) noexcept override;
352 QStateHandler getStateHandler() const noexcept override;
353
354 QMState const * childStateObj(QMState const * const parentHndl)
355 const noexcept;
356 static QMState const * topQMState() noexcept;
357
358private:
360 QMTranActTable const * const tatbl,
361 std::uint_fast8_t const qsId);
363 QMState const * const curr_state,
364 QMState const * const tran_source,
365 std::uint_fast8_t const qsId);
367 QMState const * const hist,
368 std::uint_fast8_t const qsId);
369
370 // friends...
371 friend class QS;
372}; // class QMsm
373
374} // namespace QP
375
376//============================================================================
377// QEP-macros
378
379#define Q_STATE_DECL(state_) \
380 QP::QState state_ ## _h(QP::QEvt const * const e); \
381 static QP::QState state_(void * const me, QP::QEvt const * const e)
382
383#define Q_STATE_DEF(subclass_, state_) \
384 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) { \
385 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
386 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)
387
388#define Q_EVT_CAST(subclass_) (static_cast<subclass_ const *>(e))
389#define Q_STATE_CAST(handler_) (reinterpret_cast<QP::QStateHandler>(handler_))
390
391#define QM_STATE_DECL(state_) \
392 QP::QState state_ ## _h(QP::QEvt const * const e); \
393 static QP::QState state_(void * const me, QP::QEvt const * const e); \
394 static QP::QMState const state_ ## _s
395
396#define QM_ACTION_DECL(action_) \
397 QP::QState action_ ## _h(); \
398 static QP::QState action_(void * const me)
399
400#define QM_STATE_DEF(subclass_, state_) \
401 QP::QState subclass_::state_(void * const me, QP::QEvt const * const e) {\
402 return static_cast<subclass_ *>(me)->state_ ## _h(e); } \
403 QP::QState subclass_::state_ ## _h(QP::QEvt const * const e)
404
405#define QM_ACTION_DEF(subclass_, action_) \
406 QP::QState subclass_::action_(void * const me) { \
407 return static_cast<subclass_ *>(me)->action_ ## _h(); } \
408 QP::QState subclass_::action_ ## _h()
409
410#ifdef Q_SPY
411 #define INIT(qsId_) init((qsId_))
412 #define DISPATCH(e_, qsId_) dispatch((e_), (qsId_))
413#else
414 #define INIT(dummy) init(0U)
415 #define DISPATCH(e_, dummy) dispatch((e_), 0U)
416#endif // ndef Q_SPY
417
418//============================================================================
419namespace QP {
420
421using QPrioSpec = std::uint16_t;
422
423class QEQueue; // forward declaration
424class QActive; // forward declaration
425
426#if (QF_TIMEEVT_CTR_SIZE == 1U)
427 using QTimeEvtCtr = std::uint8_t;
428#elif (QF_TIMEEVT_CTR_SIZE == 2U)
429 using QTimeEvtCtr = std::uint16_t;
430#elif (QF_TIMEEVT_CTR_SIZE == 4U)
431 using QTimeEvtCtr = std::uint32_t;
432#endif // (QF_TIMEEVT_CTR_SIZE == 4U)
433
434#if (QF_MAX_ACTIVE <= 8U)
435 using QPSetBits = std::uint8_t;
436#elif (8U < QF_MAX_ACTIVE) && (QF_MAX_ACTIVE <= 16U)
437 using QPSetBits = std::uint16_t;
438#elif (16 < QF_MAX_ACTIVE)
439 using QPSetBits = std::uint32_t;
440#endif // (16 < QF_MAX_ACTIVE)
441
442#ifndef QF_LOG2
443 std::uint_fast8_t QF_LOG2(QP::QPSetBits const bitmask) noexcept;
444#endif // ndef QF_LOG2
445
446//----------------------------------------------------------------------------
447class QPSet {
448private:
450#if (QF_MAX_ACTIVE > 32U)
452#endif
453
454public:
455 constexpr QPSet()
456 : m_bits0(0U)
457#if (QF_MAX_ACTIVE > 32U)
458 ,m_bits1(0U)
459#endif
460 {}
461
462 void setEmpty() noexcept;
463 bool isEmpty() const noexcept;
464 bool notEmpty() const noexcept;
465 bool hasElement(std::uint_fast8_t const n) const noexcept;
466 void insert(std::uint_fast8_t const n) noexcept;
467 void remove(std::uint_fast8_t const n) noexcept;
468 std::uint_fast8_t findMax() const noexcept;
469
470 // friends...
471 friend class QS;
472}; // class QPSet
473
474//----------------------------------------------------------------------------
476private:
478
479 // friends...
480 friend class QActive;
481 friend class QS;
482}; // class QSubscrList
483
484//----------------------------------------------------------------------------
485// declarations for friendship with the QActive class
486
487namespace QF {
488 void init();
489 void stop();
490 int_t run();
491
492 void onStartup();
493 void onCleanup();
494
495 constexpr std::uint_fast16_t NO_MARGIN {0xFFFFU};
496} // namespace QF
497
498//----------------------------------------------------------------------------
499class QActive : public QAsm {
500private:
501 std::uint8_t m_prio;
502 std::uint8_t m_pthre;
503
504#ifdef QACTIVE_THREAD_TYPE
506#endif
507
508#ifdef QACTIVE_OS_OBJ_TYPE
510#endif
511
512#ifdef QACTIVE_EQUEUE_TYPE
514#endif
515
516protected:
517 explicit QActive(QStateHandler const initial) noexcept;
518
519public:
520 using QAsm::init;
521 void init(
522 void const * const e,
523 std::uint_fast8_t const qsId) override;
524 void dispatch(
525 QEvt const * const e,
526 std::uint_fast8_t const qsId) override;
527 bool isIn(QStateHandler const stateHndl) noexcept override;
528 QStateHandler getStateHandler() const noexcept override;
529
530 QStateHandler childState(QStateHandler const parentHandler) noexcept;
532 std::uint32_t attr1,
533 void const * attr2 = nullptr);
534 void start(QPrioSpec const prioSpec,
535 QEvtPtr * const qSto, std::uint_fast16_t const qLen,
536 void * const stkSto, std::uint_fast16_t const stkSize,
537 void const * const par = nullptr);
538
539#ifdef QACTIVE_CAN_STOP
540 void stop();
541#endif // def QACTIVE_CAN_STOP
542 void register_() noexcept;
543 void unregister_() noexcept;
544 void post_(QEvt const * const e,
545 void const * const sender) noexcept
546 {
547 // delegate to postx_() with margin==QF::NO_MARGIN
548 static_cast<void>(postx_(e, QF::NO_MARGIN, sender));
549 }
550 bool postx_(QEvt const * const e,
551 std::uint_fast16_t const margin,
552 void const * const sender) noexcept;
553 void postLIFO(QEvt const * const e) noexcept;
554 QEvt const * get_() noexcept;
555 static std::uint16_t getQueueUse(
556 std::uint_fast8_t const prio) noexcept;
557 static std::uint16_t getQueueFree(
558 std::uint_fast8_t const prio) noexcept;
559 static std::uint16_t getQueueMin(
560 std::uint_fast8_t const prio) noexcept;
561 static void psInit(
562 QSubscrList * const subscrSto,
563 QSignal const maxSignal) noexcept;
564 static void publish_(
565 QEvt const * const e,
566 void const * const sender,
567 std::uint_fast8_t const qsId) noexcept;
568 void subscribe(QSignal const sig) const noexcept;
569 void unsubscribe(QSignal const sig) const noexcept;
570 void unsubscribeAll() const noexcept;
571 bool defer(
572 QEQueue * const eq,
573 QEvt const * const e) const noexcept;
574 bool recall(QEQueue * const eq) noexcept;
575 std::uint16_t flushDeferred(
576 QEQueue * const eq,
577 std::uint_fast16_t const num = 0xFFFFU) const noexcept;
578 std::uint8_t getPrio() const noexcept {
579 return m_prio; // public "getter" for the AO's prio
580 }
581 static void evtLoop_(QActive *act);
582 static QActive *fromRegistry(std::uint_fast8_t const prio);
583
584#ifdef QACTIVE_THREAD_TYPE
585 QACTIVE_THREAD_TYPE const & getThread() const & {
586 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
587 return m_thread;
588 }
590 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
591 = delete;
592 void setThread(QACTIVE_THREAD_TYPE const & thr) noexcept {
593 m_thread = thr; // public "setter", useful for MPU applications
594 }
595#endif // QACTIVE_THREAD_TYPE
596
597#ifdef QACTIVE_OS_OBJ_TYPE
599 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
600 return m_osObject;
601 }
603 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
604 = delete;
605#endif // QACTIVE_OS_OBJ_TYPE
606
607#ifdef QF_ISR_API
608 virtual bool postFromISR(
609 QEvt const * const e,
610 std::uint_fast16_t const margin,
611 void * par,
612 void const * const sender) noexcept;
613
614 static void publishFromISR(
615 QEvt const * e,
616 void * par,
617 void const * sender) noexcept;
618#endif // QF_ISR_API
619
620private:
621 void postFIFO_(
622 QEvt const * const e,
623 void const * const sender);
624 static void multicast_(
625 QPSet * const subscrSet,
626 QEvt const * const e,
627 void const * const sender);
628
629 // friends...
630 friend class QTimeEvt;
631 friend class QTicker;
632 friend class QXThread;
633 friend class QXMutex;
634 friend class QXSemaphore;
635 friend class QMActive;
636 friend class QActiveDummy;
637 friend class QK;
638 friend class QXK;
639 friend class QS;
640
641 friend void QF::init();
642 friend void QF::stop();
643 friend int_t QF::run();
644 friend void QF::onStartup();
645 friend void QF::onCleanup();
646
647}; // class QActive
648
649//----------------------------------------------------------------------------
650class QMActive : public QActive {
651protected:
652 explicit QMActive(QStateHandler const initial) noexcept;
653
654public:
655 using QActive::init;
656 void init(
657 void const * const e,
658 std::uint_fast8_t const qsId) override;
659 void dispatch(
660 QEvt const * const e,
661 std::uint_fast8_t const qsId) override;
662 bool isIn(QStateHandler const stateHndl) noexcept override;
663 QStateHandler getStateHandler() const noexcept override;
664
665 QMState const *childStateObj(QMState const * const parent) const noexcept;
666}; // class QMActive
667
668//----------------------------------------------------------------------------
669#if (QF_MAX_TICK_RATE > 0U)
670
671class QTimeEvt : public QEvt {
672private:
674 void * m_act;
677 std::uint8_t m_tickRate;
678 std::uint8_t m_flags;
679
680public:
681 QTimeEvt(
682 QActive * const act,
683 QSignal const sig,
684 std::uint_fast8_t const tickRate = 0U) noexcept;
685 void armX(
686 std::uint32_t const nTicks,
687 std::uint32_t const interval = 0U) noexcept;
688 bool disarm() noexcept;
689 bool rearm(std::uint32_t const nTicks) noexcept;
690 bool wasDisarmed() noexcept;
691 void const * getAct() const & {
692 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
693 return m_act;
694 }
695 void const * getAct() const &&
696 // ref-qualified reference (MISRA-C++:2023 Rule 6.8.4)
697 = delete;
698 QTimeEvtCtr getCtr() const noexcept {
699 return m_ctr; // public "getter" for the current time-evt count
700 }
701 QTimeEvtCtr getInterval() const noexcept {
702 return m_interval; // public "getter" for the time-evt interval
703 }
704 std::uint8_t getTickRate() const noexcept {
705 return m_tickRate; // public "getter" for the time-evt tick rate
706 }
707 static void tick(
708 std::uint_fast8_t const tickRate,
709 void const * const sender) noexcept;
710
711#ifdef Q_UTEST
712 static void tick1_(
713 std::uint_fast8_t const tickRate,
714 void const * const sender);
715#endif // def Q_UTEST
716
717#ifdef QF_ISR_API
718 static void tickFromISR(
719 std::uint_fast8_t const tickRate,
720 void * par,
721 void const * sender) noexcept;
722#endif // def QF_ISR_API
723 static bool noActive(std::uint_fast8_t const tickRate) noexcept;
724 QActive * toActive() noexcept {
725 // public "getter" for the AO associated with this time-evt
726 return static_cast<QActive *>(m_act);
727 }
728 QTimeEvt * toTimeEvt() noexcept {
729 // public "getter" for the AO associated with this time-evt
730 // NOTE: used for the special time-evts in QTimeEvt_head_[] array
731 return static_cast<QTimeEvt *>(m_act);
732 }
733 QTimeEvt() noexcept;
734
735private:
736 QTimeEvt *expire_(
737 QTimeEvt * const prev_link,
738 QActive const * const act,
739 std::uint_fast8_t const tickRate) noexcept;
740
741 // fiends...
742 friend class QXThread;
743 friend class QS;
744}; // class QTimeEvt
745
746//----------------------------------------------------------------------------
747class QTicker : public QActive {
748public:
749 explicit QTicker(std::uint8_t const tickRate) noexcept;
750 using QActive::init;
751 void init(
752 void const * const e,
753 std::uint_fast8_t const qsId) override;
754 void dispatch(
755 QEvt const * const e,
756 std::uint_fast8_t const qsId) override;
757 void trig_(void const * const sender) noexcept;
758}; // class QTicker
759
760#endif // (QF_MAX_TICK_RATE > 0U)
761
762//----------------------------------------------------------------------------
763namespace QF {
764
765//! @deprecated
766inline void psInit( QSubscrList * const subscrSto,
767 QSignal const maxSignal) noexcept
768{
769 // use QActive::psInit() instead of the deprecated QF::psInit()
770 QActive::psInit(subscrSto, maxSignal);
771}
772
773//! @deprecated
774inline void publish_(QEvt const * const e,
775 void const * const sender, std::uint_fast8_t const qsId) noexcept
776{
777 // use QTimeEvt::tick() instead of the deprecated QF::tick()
778 QActive::publish_(e, sender, qsId);
779}
780
781//! @deprecated
782inline std::uint_fast16_t getQueueMin(
783 std::uint_fast8_t const prio) noexcept
784{
785 // use QActive::getQueueMin() instead of the deprecated QF::getQueueMin()
786 return QActive::getQueueMin(prio);
787}
788
789#if (QF_MAX_TICK_RATE > 0U)
790//! @deprecated
791inline void tick(
792 std::uint_fast8_t const tickRate,
793 void const * const sender) noexcept
794{
795 // use QTimeEvt::tick() instead of the deprecated QF::tick()
796 QTimeEvt::tick(tickRate, sender);
797}
798#endif // (QF_MAX_TICK_RATE > 0U)
799
800//----------------------------------------------------------------------------
801// QF dynamic memory facilities
802void poolInit(
803 void * const poolSto,
804 std::uint_fast32_t const poolSize,
805 std::uint_fast16_t const evtSize) noexcept;
806
807std::uint16_t poolGetMaxBlockSize() noexcept;
808std::uint16_t getPoolUse(std::uint_fast8_t const poolNum) noexcept;
809std::uint16_t getPoolFree(std::uint_fast8_t const poolNum) noexcept;
810std::uint16_t getPoolMin(std::uint_fast8_t const poolNum) noexcept;
811QEvt * newX_(
812 std::uint_fast16_t const evtSize,
813 std::uint_fast16_t const margin,
814 QSignal const sig) noexcept;
815void gc(QEvt const * const e) noexcept;
816QEvt const * newRef_(
817 QEvt const * const e,
818 QEvt const * const evtRef) noexcept;
819
820void deleteRef_(QEvt const * const evtRef) noexcept;
821
822#ifndef QEVT_PAR_INIT
823 template<class evtT_>
824 inline evtT_ * q_new(QSignal const sig) {
825 // allocate a dynamic (mutable) event with NO_MARGIN
826 // NOTE: the returned event ptr is guaranteed NOT to be nullptr
827 return static_cast<evtT_*>(
828 QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, sig));
829 }
830 template<class evtT_>
831 inline evtT_ * q_new_x(std::uint_fast16_t const margin,
832 QSignal const sig)
833 {
834 // allocate a dynamic (mutable) event with a provided margin
835 // NOTE: the returned event ptr is MIGHT be nullptr
836 return static_cast<evtT_*>(QP::QF::newX_(sizeof(evtT_), margin, sig));
837 }
838#else
839 template<class evtT_, typename... Args>
840 inline evtT_ * q_new(QSignal const sig, Args... args) {
841 // allocate a dynamic (mutable) event with NO_MARGIN
842 // NOTE: the returned event ptr is guaranteed NOT to be nullptr
843 evtT_ *e = static_cast<evtT_*>(
844 QP::QF::newX_(sizeof(evtT_), QP::QF::NO_MARGIN, sig));
845 e->init(args...); // immediately initialize the event (RAII)
846 return e;
847 }
848 template<class evtT_, typename... Args>
849 inline evtT_ * q_new_x(std::uint_fast16_t const margin,
850 QSignal const sig, Args... args)
851 {
852 // allocate a dynamic (mutable) event with a provided margin
853 // NOTE: the event allocation is MIGHT fail
854 evtT_ *e =
855 static_cast<evtT_*>(QP::QF::newX_(sizeof(evtT_), margin, sig));
856 if (e != nullptr) { // was the allocation successfull?
857 e->init(args...); // immediately initialize the event (RAII)
858 }
859 // NOTE: the returned event ptr is MIGHT be nullptr
860 return e;
861 }
862#endif // QEVT_PAR_INIT
863
864template<class evtT_>
865inline void q_new_ref(
866 QP::QEvt const * const e,
867 evtT_ const *& evtRef)
868{
869 // set the const event reference (must NOT be nullptr)
870 evtRef = static_cast<evtT_ const *>(QP::QF::newRef_(e, evtRef));
871}
872
873template<class evtT_>
874inline void q_delete_ref(evtT_ const *& evtRef) {
875 QP::QF::deleteRef_(evtRef);
876 evtRef = nullptr; // invalidate the associated event reference
877}
878
879#ifdef QF_ISR_API
881 std::uint_fast16_t const evtSize,
882 std::uint_fast16_t const margin,
883 QSignal const sig) noexcept;
884void gcFromISR(QEvt const * e) noexcept;
885#endif // def QF_ISR_API
886
887} // namespace QF
888} // namespace QP
889
890//============================================================================
891extern "C" {
892
893//${QF-extern-C::QF_onContextSw} .............................................
894#ifdef QF_ON_CONTEXT_SW
896 QP::QActive * prev,
897 QP::QActive * next);
898#endif // def QF_ON_CONTEXT_SW
899
900} // extern "C"
901
902//----------------------------------------------------------------------------
903// QF base facilities
904
905#define Q_PRIO(prio_, pthre_) \
906 (static_cast<QP::QPrioSpec>((prio_) | (pthre_) << 8U))
907
908#ifndef QEVT_PAR_INIT
909 #define Q_NEW(evtT_, sig_) (QP::QF::q_new<evtT_>((sig_)))
910 #define Q_NEW_X(evtT_, margin_, sig_) \
911 (QP::QF::q_new_x<evtT_>((margin_), (sig_)))
912#else
913 #define Q_NEW(evtT_, sig_, ...) \
914 (QP::QF::q_new<evtT_>((sig_), __VA_ARGS__))
915 #define Q_NEW_X(evtT_, margin_, sig_, ...) \
916 (QP::QF::q_new_x<evtT_>((margin_), (sig_), __VA_ARGS__))
917#endif // QEVT_PAR_INIT
918
919#define Q_NEW_REF(evtRef_, evtT_) (QP::QF::q_new_ref<evtT_>(e, (evtRef_)))
920#define Q_DELETE_REF(evtRef_) do { \
921 QP::QF::deleteRef_((evtRef_)); \
922 (evtRef_) = nullptr; \
923} while (false)
924
925#ifdef Q_SPY
926 #define PUBLISH(e_, sender_) \
927 publish_((e_), (sender_), (sender_)->getPrio())
928 #define POST(e_, sender_) post_((e_), (sender_))
929 #define POST_X(e_, margin_, sender_) \
930 postx_((e_), (margin_), (sender_))
931 #define TICK_X(tickRate_, sender_) tick((tickRate_), (sender_))
932 #define TRIG(sender_) trig_((sender_))
933#else
934 #define PUBLISH(e_, dummy) publish_((e_), nullptr, 0U)
935 #define POST(e_, dummy) post_((e_), nullptr)
936 #define POST_X(e_, margin_, dummy) postx_((e_), (margin_), nullptr)
937 #define TICK_X(tickRate_, dummy) tick((tickRate_), nullptr)
938 #define TRIG(sender_) trig_(nullptr)
939#endif // ndef Q_SPY
940
941#define TICK(sender_) TICK_X(0U, (sender_))
942
943#ifndef QF_CRIT_EXIT_NOP
944 #define QF_CRIT_EXIT_NOP() (static_cast<void>(0))
945#endif // ndef QF_CRIT_EXIT_NOP
946
947#endif // QP_HPP_
Active object class (based on the QP::QHsm implementation strategy).
Definition qp.hpp:499
friend class QActiveDummy
Definition qp.hpp:636
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:505
static std::uint16_t getQueueMin(std::uint_fast8_t const prio) noexcept
Definition qf_actq.cpp:362
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:598
friend class QTicker
Definition qp.hpp:631
friend class QXMutex
Definition qp.hpp:633
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:639
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:544
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:255
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:634
QActive(QStateHandler const initial) noexcept
QActive constructor (abstract base class).
Definition qf_qact.cpp:55
std::uint8_t getPrio() const noexcept
Definition qp.hpp:578
QACTIVE_EQUEUE_TYPE m_eQueue
Port-dependent event-queue type (often QP::QEQueue).
Definition qp.hpp:513
QACTIVE_THREAD_TYPE const & getThread() const &&=delete
friend class QK
Definition qp.hpp:637
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:630
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:216
QACTIVE_OS_OBJ_TYPE const & getOsObject() const &&=delete
void setThread(QACTIVE_THREAD_TYPE const &thr) noexcept
Definition qp.hpp:592
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:502
QACTIVE_OS_OBJ_TYPE m_osObject
Port-dependent per-thread object.
Definition qp.hpp:509
std::uint8_t m_prio
QF-priority [1..QF_MAX_ACTIVE] of this AO.
Definition qp.hpp:501
friend class QMActive
Definition qp.hpp:635
friend class QXThread
Definition qp.hpp:632
QACTIVE_THREAD_TYPE const & getThread() const &
Definition qp.hpp:585
friend class QXK
Definition qp.hpp:638
Abstract State Machine class (state machine interface).
Definition qp.hpp:170
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:178
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:180
static constexpr QState QM_SUPER()
Definition qp.hpp:205
static constexpr QState Q_RET_ENTRY
Definition qp.hpp:187
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:173
static constexpr QState Q_RET_IGNORED
Definition qp.hpp:184
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:177
static constexpr QState Q_UNHANDLED()
Definition qp.hpp:199
virtual QStateHandler getStateHandler() const noexcept=0
Virtual method for getting the current state handler.
static constexpr QState Q_RET_TRAN_INIT
Definition qp.hpp:189
static constexpr QState Q_RET_TRAN_HIST
Definition qp.hpp:181
static constexpr QState Q_RET_EXIT
Definition qp.hpp:188
QMState const * stateObj() const noexcept
Definition qp.hpp:226
virtual ~QAsm()=default
Virtual destructor of the QP::QAsm abstract base class.
static constexpr QState Q_HANDLED()
Definition qp.hpp:197
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:203
static constexpr QSignal Q_INIT_SIG
Definition qp.hpp:195
static constexpr QActionHandler const Q_ACTION_NULL
Definition qp.hpp:208
QAsmAttr m_state
Current state (pointer to the current state-handler function).
Definition qp.hpp:172
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:193
static constexpr QSignal Q_EXIT_SIG
Definition qp.hpp:194
static constexpr QSignal Q_EMPTY_SIG
Definition qp.hpp:192
static constexpr QState Q_RET_HANDLED
Definition qp.hpp:179
static constexpr QMState const * QM_STATE_NULL
Definition qp.hpp:207
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:201
Native QF Event Queue.
Definition qequeue.hpp:55
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:335
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:225
static constexpr std::size_t MAX_NEST_DEPTH_
Definition qp.hpp:319
void enter_target_(std::array< QStateHandler, MAX_NEST_DEPTH_ > &path, std::size_t const depth, 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:150
std::size_t tran_simple_(std::array< QStateHandler, MAX_NEST_DEPTH_ > &path, std::uint_fast8_t const qsId)
QHsm(QStateHandler const initial) noexcept
Definition qep_hsm.cpp:142
bool isIn(QStateHandler const stateHndl) noexcept override
Check whether the HSM is in a given state.
Definition qep_hsm.cpp:549
std::size_t tran_complex_(std::array< QStateHandler, MAX_NEST_DEPTH_ > &path, std::uint_fast8_t const qsId)
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:371
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:447
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:471
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:451
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
constexpr QPSet()
Definition qp.hpp:455
QPSetBits m_bits0
Bitmask for elements 1..32.
Definition qp.hpp:449
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:475
QPSet m_set
The set of AOs that subscribed to a given event signal.
Definition qp.hpp:477
friend class QActive
Definition qp.hpp:480
friend class QS
Definition qp.hpp:481
void trig_(void const *const sender) noexcept
Asynchronously trigger the QTicker active object to perform tick processing.
Definition qf_actq.cpp:441
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:412
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:393
QTicker(std::uint8_t const tickRate) noexcept
Constructor of the QTicker Active Object class.
Definition qf_actq.cpp:385
Time Event class.
Definition qp.hpp:671
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:673
QTimeEvt * toTimeEvt() noexcept
Definition qp.hpp:728
friend class QS
Definition qp.hpp:743
bool disarm() noexcept
Disarm a time event.
Definition qf_time.cpp:148
std::uint8_t m_flags
Definition qp.hpp:678
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:701
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:674
QActive * toActive() noexcept
Definition qp.hpp:724
std::uint8_t m_tickRate
Definition qp.hpp:677
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:698
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:704
QTimeEvtCtr m_ctr
Down-counter of the time event.
Definition qp.hpp:675
QTimeEvtCtr m_interval
Interval for periodic time event (zero for one-shot time event).
Definition qp.hpp:676
void const * getAct() const &
Definition qp.hpp:691
bool wasDisarmed() noexcept
Check the "was disarmed" status of a time event.
Definition qf_time.cpp:261
friend class QXThread
Definition qp.hpp:742
eXtended (blocking) thread of the QXK preemptive kernel
Definition qxk.hpp:80
QF Active Object Framework namespace.
Definition qp.hpp:487
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
evtT_ * q_new_x(std::uint_fast16_t const margin, QSignal const sig, Args... args)
Definition qp.hpp:849
void tick(std::uint_fast8_t const tickRate, void const *const sender) noexcept
Definition qp.hpp:791
evtT_ * q_new(QSignal const sig, Args... args)
Definition qp.hpp:840
void psInit(QSubscrList *const subscrSto, QSignal const maxSignal) noexcept
Definition qp.hpp:766
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:495
void init()
QF initialization.
Definition qv.cpp:102
void q_new_ref(QP::QEvt const *const e, evtT_ const *&evtRef)
Create a new reference of the current event e.
Definition qp.hpp:865
std::uint16_t getPoolMin(std::uint_fast8_t const poolNum) noexcept
Obtain the minimum of free entries of the given event pool.
std::uint_fast16_t getQueueMin(std::uint_fast8_t const prio) noexcept
This function returns the minimum of free entries of the given event queue.
Definition qp.hpp:782
void q_delete_ref(evtT_ const *&evtRef)
Delete a new reference of the current event e.
Definition qp.hpp:874
int_t run()
Transfers control to QF to run the application.
Definition qv.cpp:115
void stop()
Invoked by the application layer to stop the QF framework and return control to the OS/Kernel (used i...
Definition qv.cpp:109
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:774
void onStartup()
Startup QF callback.
QP/C++ Framework namespace.
Definition qequeue.hpp:36
constexpr QSignal Q_USER_SIG
Definition qp.hpp:167
std::uint32_t QTimeEvtCtr
Data type to store the block-size defined based on the macro QF_TIMEEVT_CTR_SIZE.
Definition qp.hpp:431
QState(*)(void *const me) QActionHandler
Pointer to an action-handler function.
Definition qp.hpp:142
char const * version() noexcept
Definition qf_act.cpp:52
QEvt const * QEvtPtr
Pointer to const event instances passed around in QP/C++ Framework.
Definition qequeue.hpp:48
std::uint_fast8_t QState
Type returned from state-handler functions.
Definition qp.hpp:137
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function.
Definition qp.hpp:141
std::uint32_t QPSetBits
Bitmask for the internal representation of QPSet elements.
Definition qp.hpp:439
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:143
std::uint16_t QPrioSpec
Priority specification for Active Objects in QP.
Definition qp.hpp:421
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 QF_MAX_ACTIVE
Maximum # Active Objects in the system (1..64).
#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:145
QActionHandler const entryAction
Definition qp.hpp:148
QStateHandler const stateHandler
Definition qp.hpp:147
QActionHandler const exitAction
Definition qp.hpp:149
QMState const * superstate
Definition qp.hpp:146
QActionHandler const initAction
Definition qp.hpp:150
Transition-Action Table for the QP::QMsm State Machine.
Definition qp.hpp:153
QMState const * target
Definition qp.hpp:154
QActionHandler const act[1]
Definition qp.hpp:155
Attribute of for the QP::QAsm class (Abstract State Machine).
Definition qp.hpp:158
std::uintptr_t uint
Definition qp.hpp:164
QMState const * obj
Definition qp.hpp:162
QStateHandler fun
Definition qp.hpp:159
QMTranActTable const * tatbl
Definition qp.hpp:163
QXThreadHandler thr
Definition qp.hpp:161
QActionHandler act
Definition qp.hpp:160