QP/C 6.9.1
QActive Struct Reference

Active Object base class (based on QHsm implementation) More...

#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_)
 Polymorphically start an active object. More...
 
#define QACTIVE_POST(me_, e_, sender_)
 Polymorphically posts an event to an active object (FIFO) with delivery guarantee. More...
 
#define QACTIVE_POST_X(me_, e_, margin_, sender_)
 Polymorphically posts an event to an active object (FIFO) without delivery guarantee. More...
 
#define QACTIVE_POST_LIFO(me_, e_)
 Polymorphically posts an event to an active object using the Last-In-First-Out (LIFO) policy. More...
 
- Public Member Functions inherited from QHsm
#define QHSM_INIT(me_, par_, qs_id_)
 Polymorphically executes the top-most initial transition in a HSM. More...
 
#define QHSM_DISPATCH(me_, e_, qs_id_)    ((*(me_)->vptr->dispatch)((me_), (e_), (qs_id_)))
 Polymorphically dispatches an event to a HSM. More...
 
#define QHsm_state(me_)   (Q_STATE_CAST(Q_HSM_UPCAST(me_)->state.fun))
 Obtain the current active state from a HSM (read only). More...
 
#define QHsm_childState(me_, parent_)    QHsm_childState_(Q_HSM_UPCAST(me_), Q_STATE_CAST(parent_))
 Obtain the current active child state of a given parent in QHsm. More...
 
bool QHsm_isIn (QHsm *const me, QStateHandler const state)
 Tests if a given state is part of the current active state configuration in QHsm subclasses. More...
 

Data Fields

QHsm super
 inherits QHsm More...
 
uint8_t prio
 QF priority (1..QF_MAX_ACTIVE) of this active object. More...
 
- Data Fields inherited from QHsm
struct QHsmVtable const * vptr
 virtual pointer More...
 
union QHsmAttr state
 current active state (state-variable) More...
 
union QHsmAttr temp
 temporary: tran. More...
 

Protected Member Functions

void QActive_ctor (QActive *const me, QStateHandler initial)
 protected "constructor" of an QActive active object More...
 
void QActive_stop (QActive *const me)
 Stops execution of an active object and removes it from the framework's supervision. More...
 
void QActive_subscribe (QActive const *const me, enum_t const sig)
 Subscribes for delivery of signal sig to the active object me. More...
 
void QActive_unsubscribe (QActive const *const me, enum_t const sig)
 Un-subscribes from the delivery of signal sig to the AO me. More...
 
void QActive_unsubscribeAll (QActive const *const me)
 Un-subscribes from the delivery of all signals to the AO me. More...
 
bool QActive_defer (QActive const *const me, QEQueue *const eq, QEvt const *const e)
 Defer an event e to a given event queue eq. More...
 
bool QActive_recall (QActive *const me, QEQueue *const eq)
 Recall a deferred event from a given event queue eq. More...
 
uint_fast16_t QActive_flushDeferred (QActive const *const me, QEQueue *const eq)
 Flush the specified deferred queue eq. More...
 
void QActive_setAttr (QActive *const me, uint32_t attr1, void const *attr2)
 Generic setting of additional attributes (useful in QP ports) More...
 
- Protected Member Functions inherited from QHsm
void QHsm_ctor (QHsm *const me, QStateHandler initial)
 Protected "constructor" of QHsm. More...
 
QState QHsm_top (void const *const me, QEvt const *const e)
 the top-state. More...
 

Detailed Description

Active Object base class (based on QHsm implementation)

Description
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.
Usage
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;

Definition at line 116 of file qf.h.

Member Function Documentation

◆ QActive_ctor()

void QActive_ctor ( QActive *const  me,
QStateHandler  initial 
)
protected

protected "constructor" of an QActive active object

Definition at line 66 of file qf_qact.c.

◆ QActive_stop()

void QActive_stop ( QActive *const  me)
protected

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

Attention
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 160 of file qutest.c.

◆ QActive_subscribe()

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

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

Definition at line 206 of file qf_ps.c.

◆ QActive_unsubscribe()

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

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

Definition at line 254 of file qf_ps.c.

◆ QActive_unsubscribeAll()

void QActive_unsubscribeAll ( QActive const *const  me)
protected

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

Definition at line 303 of file qf_ps.c.

◆ QActive_defer()

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

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 
)
protected

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 
)
protected

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 
)
protected

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:
uint8_t
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: 16bit/stdint.h:29
QTimeEvt
Time Event class.
Definition: qf.h:480
QActive
Active Object base class (based on QHsm implementation)
Definition: qf.h:116
QActive::super
QHsm super
inherits QHsm
Definition: qf.h:117