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