QP/C  6.9.3
Real-Time Embedded Framework
QActive Struct Reference

#include <qf.h>

Inheritance diagram for QActive:
Inheritance graph
Collaboration diagram for QActive:
Collaboration graph

Public Member Functions

#define QACTIVE_START(me_, prio_, qSto_, qLen_, stkSto_, stkLen_, par_)
#define QACTIVE_POST(me_, e_, sender_)
#define QACTIVE_POST_X(me_, e_, margin_, sender_)
#define QACTIVE_POST_LIFO(me_, e_)
- Public Member Functions inherited from QHsm
#define QHSM_INIT(me_, par_, qs_id_)
#define QHSM_DISPATCH(me_, e_, qs_id_)    ((*(me_)->vptr->dispatch)((me_), (e_), (qs_id_)))
#define QHsm_state(me_)   (Q_STATE_CAST(Q_HSM_UPCAST(me_)->state.fun))
#define QHsm_childState(me_, parent_)    QHsm_childState_(Q_HSM_UPCAST(me_), Q_STATE_CAST(parent_))
bool QHsm_isIn (QHsm *const me, QStateHandler const state)

Data Fields

QHsm super
uint8_t prio
- Data Fields inherited from QHsm
struct QHsmVtable const * vptr
union QHsmAttr state
union QHsmAttr temp

Protected Member Functions

void QActive_ctor (QActive *const me, QStateHandler initial)
void QActive_stop (QActive *const me)
void QActive_subscribe (QActive const *const me, enum_t const sig)
void QActive_unsubscribe (QActive const *const me, enum_t const sig)
void QActive_unsubscribeAll (QActive const *const me)
bool QActive_defer (QActive const *const me, QEQueue *const eq, QEvt const *const e)
bool QActive_recall (QActive *const me, QEQueue *const eq)
uint_fast16_t QActive_flushDeferred (QActive const *const me, QEQueue *const eq)
void QActive_setAttr (QActive *const me, uint32_t attr1, void const *attr2)
- Protected Member Functions inherited from QHsm
void QHsm_ctor (QHsm *const me, QStateHandler initial)
QState QHsm_top (void const *const me, QEvt const *const e)

Detailed Description

Active Object base class (based on QHsm implementation)

Active objects in QP are encapsulated state machines (each embedding an event queue and a thread) that communicate with one another asynchronously by sending and receiving events. Within an active object, events are processed sequentially in a run-to-completion (RTC) fashion, while QF encapsulates all the details of thread-safe event exchange and queuing.

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.
The following example illustrates how to derive an active object from QActive. Please note that the QActive member super is defined as the first member of the derived struct (see Object Orientation).
typedef struct {
QActive super; /* inherits QActive */
QTimeEvt timeEvt; /* to timeout thining or eating */
uint8_t num; /* this philosopher's number */
} Philo;
unsigned char uint8_t
Definition: 16bit/stdint.h:29
Definition: qf.h:116
QHsm super
Definition: qf.h:117
Definition: qf.h:480

Definition at line 116 of file qf.h.

Member Function Documentation

◆ QActive_ctor()

void QActive_ctor ( QActive *const  me,
QStateHandler  initial 

protected "constructor" of an QActive active object

Definition at line 66 of file qf_qact.c.

◆ QActive_stop()

void QActive_stop ( QActive *const  me)

Stops execution of an active object and removes it from the framework's supervision.

QActive_stop() must be called only from the AO that is about to stop its execution. By that time, any pointers or references to the AO are considered invalid (dangling) and it becomes illegal for the rest of the application to post events to the AO.

Definition at line 164 of file qutest.c.

◆ QActive_subscribe()

void QActive_subscribe ( QActive const *const  me,
enum_t const  sig 

Subscribes for delivery of signal sig to the active object me.

Definition at line 207 of file qf_ps.c.

◆ QActive_unsubscribe()

void QActive_unsubscribe ( QActive const *const  me,
enum_t const  sig 

Un-subscribes from the delivery of signal sig to the AO me.

Definition at line 255 of file qf_ps.c.

◆ QActive_unsubscribeAll()

void QActive_unsubscribeAll ( QActive const *const  me)

Un-subscribes from the delivery of all signals to the AO me.

Definition at line 304 of file qf_ps.c.

◆ QActive_defer()

bool QActive_defer ( QActive const *const  me,
QEQueue *const  eq,
QEvt const *const  e 

Defer an event e to a given event queue eq.

Definition at line 78 of file qf_defer.c.

◆ QActive_recall()

bool QActive_recall ( QActive *const  me,
QEQueue *const  eq 

Recall a deferred event from a given event queue eq.

Definition at line 119 of file qf_defer.c.

◆ QActive_flushDeferred()

uint_fast16_t QActive_flushDeferred ( QActive const *const  me,
QEQueue *const  eq 

Flush the specified deferred queue eq.

Definition at line 188 of file qf_defer.c.

◆ QActive_setAttr()

void QActive_setAttr ( QActive *const  me,
uint32_t  attr1,
void const *  attr2 

Generic setting of additional attributes (useful in QP ports)

Field Documentation

◆ super

QHsm super

inherits QHsm

Definition at line 117 of file qf.h.

◆ prio

uint8_t prio

QF priority (1..QF_MAX_ACTIVE) of this active object.

Definition at line 164 of file qf.h.

The documentation for this struct was generated from the following file: