|
void | init (void const *const e, std::uint_fast8_t const qsId) override |
|
void | init (std::uint_fast8_t const qsId) override |
|
void | dispatch (QEvt const *const e, std::uint_fast8_t const qsId) override |
|
bool | isIn (QStateHandler const state) noexcept override |
|
QStateHandler | childState (QStateHandler const parent) noexcept |
|
void | setAttr (std::uint32_t attr1, void const *attr2=nullptr) |
|
void | start (QPrioSpec const prioSpec, QEvt const **const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize, void const *const par) |
|
void | start (QPrioSpec const prioSpec, QEvt const **const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize) |
|
void | stop () |
|
void | register_ () noexcept |
|
void | unregister_ () noexcept |
|
bool | post_ (QEvt const *const e, std::uint_fast16_t const margin, void const *const sender) noexcept |
|
void | postLIFO (QEvt const *const e) noexcept |
|
QEvt const * | get_ () noexcept |
|
void | subscribe (enum_t const sig) const noexcept |
|
void | unsubscribe (enum_t const sig) const noexcept |
|
void | unsubscribeAll () const noexcept |
|
bool | defer (QEQueue *const eq, QEvt const *const e) const noexcept |
|
bool | recall (QEQueue *const eq) noexcept |
|
std::uint_fast16_t | flushDeferred (QEQueue *const eq, std::uint_fast16_t const num=0xFFFFU) const noexcept |
|
std::uint_fast8_t | getPrio () const noexcept |
|
void | setPrio (QPrioSpec const prio) noexcept |
|
std::uint_fast8_t | getPThre () const noexcept |
|
QACTIVE_EQUEUE_TYPE const & | getEQueue () const noexcept |
|
QACTIVE_OS_OBJ_TYPE const & | getOsObject () const noexcept |
|
QACTIVE_THREAD_TYPE const & | getThread () const noexcept |
|
void | setThread (QACTIVE_THREAD_TYPE const &thr) |
|
virtual bool | postFromISR (QEvt const *const e, std::uint_fast16_t const margin, void *par, void const *const sender) noexcept |
|
virtual | ~QAsm () noexcept |
|
QStateHandler | state () const noexcept |
|
QMState const * | stateObj () const noexcept |
|
virtual QStateHandler | getStateHandler () noexcept |
|
Active object class (based on the QHsm implementation strategy)
- Details
Active objects are encapsulated tasks (each containing an event queue and a state machine) that communicate with one another asynchronously by sending and receiving events. Within an active object, events are processed in a run-to-completion (RTC) fashion, while QF encapsulates all the details of thread-safe event exchange and queuing.
QP::QActive represents an active object that uses the QHsm-style implementation strategy for state machines. This strategy is tailored to manual coding, but it is also supported by the QM modeling tool. The resulting code is slower than in the QMsm-style implementation strategy.
- Note
- QP::QActive is not intended to be instantiated directly, but rather serves as the abstract base class for derivation of active objects in the applications.
- See also
- QP::QMActive
- Backward Traceability
- Usage
The following example illustrates how to derive an active object from QP::QActive.
private:
std::uint8_t m_id;
public:
static Philo inst[N_PHILO];
public:
Philo();
protected:
};
Active object class (based on the QHsm implementation strategy)
#define Q_STATE_DECL(state_)
Definition at line 719 of file qp.hpp.
void QP::QActive::init |
( |
void const *const | e, |
|
|
std::uint_fast8_t const | qsId ) |
|
inlineoverridevirtual |
Virtual function to take the top-most initial transition in the state machine.
- Details
Synchronously executes the top-most initial transition in a state machine (must be overridden in the subclasses).
- Parameters
-
[in] | e | pointer to an initialization parameter (might be nullptr) |
[in] | qsId | QS-id of this state machine (for QS local filter) |
- Precondition
qep_asm:200
- the virtual pointer must be initialized,
- the top-most initial transition must be initialized,
- the initial transition must not be taken yet.
Implements QP::QAsm.
Reimplemented in QP::QActiveDummy, QP::QMActive, QP::QTicker, and QP::QXThread.
Definition at line 776 of file qp.hpp.
void QP::QActive::init |
( |
std::uint_fast8_t const | qsId | ) |
|
|
inlineoverridevirtual |
Virtual function to take the top-most initial transition in the state machine (overloaded).
- Details
Synchronously executes the top-most initial transition in a state machine. This overloaded version takes no initialization parameter.
- Parameters
-
[in] | qsId | QS-id of this state machine (for QS local filter) |
Reimplemented from QP::QAsm.
Reimplemented in QP::QMActive, QP::QTicker, and QP::QXThread.
Definition at line 782 of file qp.hpp.
void QP::QActive::dispatch |
( |
QEvt const *const | e, |
|
|
std::uint_fast8_t const | qsId ) |
|
inlineoverridevirtual |
Virtual function to dispatch an event to the state machine.
- Details
Synchronously dispatches an event for processing to a state machine (must be overridden in the subclasses). The processing of an event represents one run-to-completion (RTC) step.
- Parameters
-
[in] | e | pointer to the event to be dispatched to the MSM |
[in] | qsId | QS-id of this state machine (for QS local filter) |
- Precondition
qep_asm:302
- current state must be initialized
- check the internal integrity (Software Self-Monitoring (SSM))
Implements QP::QAsm.
Reimplemented in QP::QActiveDummy, QP::QMActive, QP::QTicker, and QP::QXThread.
Definition at line 785 of file qp.hpp.
|
inlineoverridevirtualnoexcept |
Virtual function to check whether the state machine is in a given state.
- Details
Tests if a given state is part of the current active state configuration. Please note that in a hierarchical state machine, to "be in a state" means also to be in a superstate of of the state.
- Parameters
-
[in] | state | pointer to the state-handler function to be checked |
- Returns
- 'true' if the state machine "is in" the
state
and 'false' otherwise
- Attention
- This function must be called only on a state machine that is in the "stable state configuration". Among others, this means that the state machine cannot call it in the middle of its own transition.
- Backward Traceability
Reimplemented from QP::QAsm.
Reimplemented in QP::QMActive.
Definition at line 791 of file qp.hpp.
Publish event to all subscribers of a given signal e->sig
- Details
This function posts (using the FIFO policy) the event e
to all active objects that have subscribed to the signal e
->sig, which is called multicasting. The multicasting performed in this function is very efficient based on reference-counting inside the published event ("zero-copy" event multicasting). This function is designed to be callable from any part of the system, including ISRs, device drivers, and active objects.
- Note
- To avoid any unexpected re-ordering of events posted into AO queues, the event multicasting is performed with scheduler locked. However, the scheduler is locked only up to the priority level of the highest-priority subscriber, so any AOs of even higher priority, which did not subscribe to this event are not affected.
Definition at line 83 of file qf_ps.cpp.
void QP::QActive::publish_ |
( |
QEvt const *const | e, |
|
|
void const *const | sender, |
|
|
std::uint_fast8_t const | qsId ) |
|
staticnoexcept |
Publish event to all subscribers of a given signal e->sig
- Details
This function posts (using the FIFO policy) the event e
to all active objects that have subscribed to the signal e
->sig, which is called multicasting. The multicasting performed in this function is very efficient based on reference-counting inside the published event ("zero-copy" event multicasting). This function is designed to be callable from any part of the system, including ISRs, device drivers, and active objects.
- Precondition
qf_ps:200
- the published signal must be within the configured range
- Precondition
qf_ps:202
- check the integrity of the subscriber set (QP FuSa Subsystem)
- Note
- To avoid any unexpected re-ordering of events posted into AO queues, the event multicasting is performed with scheduler locked. However, the scheduler is locked only up to the priority level of the highest-priority subscriber, so any AOs of even higher priority, which did not subscribe to this event are not affected.
- Attention
- This operation is typically used via macro PUBLISH(). This is because the last parameter
qsId
might be defined/provided only in the Spy build configuration (see Q_SPY). The macro ignores the qsId
parameter outside the Spy configuration, so the same code builds correctly in all configurations.
- Usage
switch (e->sig) {
. . .
m_timeEvt.disarm();
QP::QActive::PUBLISH(pe, this);
break;
}
. . .
}
return status_;
}
@ Q_EXIT_SIG
signal for exit actions
#define Q_STATE_DEF(subclass_, state_)
Definition at line 106 of file qf_ps.cpp.
bool QP::QActive::defer |
( |
QEQueue *const | eq, |
|
|
QEvt const *const | e ) const |
|
noexcept |
Defer an event to a given separate event queue
- Details
This function is part of the event deferral support. An active object uses this function to defer an event e
to the QF-supported native event queue eq
. QF correctly accounts for another outstanding reference to the event and will not recycle the event at the end of the RTC step. Later, the active object might recall one event at a time from the event queue.
- Parameters
-
[in] | eq | pointer to a "raw" thread-safe queue to recall an event from. |
[in] | e | pointer to the event to be deferred |
- Returns
- 'true' (success) when the event could be deferred and 'false' (failure) if event deferral failed due to overflowing the queue.
Definition at line 69 of file qf_defer.cpp.