QP/C  6.9.3
Real-Time Embedded Framework
qf_actq.c File Reference

QActive native queue operations (based on QEQueue) More...

#include "qf_port.h"
#include "qf_pkg.h"
#include "qassert.h"
#include "qs_port.h"
#include "qs_pkg.h"
Include dependency graph for qf_actq.c:

Go to the source code of this file.

Macros

#define QTICKER_CAST_(me_)   ((QActive *)(me_))
 

Functions

bool QActive_post_ (QActive *const me, QEvt const *const e, uint_fast16_t const margin, void const *const sender)
 
void QActive_postLIFO_ (QActive *const me, QEvt const *const e)
 
QEvt const * QActive_get_ (QActive *const me)
 
uint_fast16_t QF_getQueueMin (uint_fast8_t const prio)
 
static void QTicker_init_ (QHsm *const me, void const *par, uint_fast8_t const qs_id)
 
static void QTicker_dispatch_ (QHsm *const me, QEvt const *const e, uint_fast8_t const qs_id)
 
static bool QTicker_post_ (QActive *const me, QEvt const *const e, uint_fast16_t const margin, void const *const sender)
 
static void QTicker_postLIFO_ (QActive *const me, QEvt const *const e)
 
void QTicker_ctor (QTicker *const me, uint_fast8_t tickRate)
 

Detailed Description

QActive native queue operations (based on QEQueue)

Note
this source file is only included in the application build when the native QF active object queue is used (instead of a message queue of an RTOS).

Definition in file qf_actq.c.

Macro Definition Documentation

◆ QTICKER_CAST_

#define QTICKER_CAST_ (   me_)    ((QActive *)(me_))

Perform downcast to QTicker pointer.

Description
This macro encapsulates the downcast to (QTicker *), which is used in QTicker_init_() and QTicker_dispatch_(). Such casts can trigger PC-Lint-Plus "note 9087: cast from pointer to object type to pointer to different object type [MISRA 2012 Rule 11.3, required]". This macro helps to encapsulate this deviation.

Definition at line 434 of file qf_actq.c.

Function Documentation

◆ QActive_post_()

bool QActive_post_ ( QActive *const  me,
QEvt const *const  e,
uint_fast16_t const  margin,
void const *const  sender 
)
Description
Direct event posting is the simplest asynchronous communication method available in QF.
Parameters
[in,out]mepointer (see Object Orientation)
[in]epointer to the event to be posted
[in]marginnumber of required free slots in the queue after posting the event. The special value QF_NO_MARGIN means that this function will assert if posting fails.
[in]senderpointer to a sender object (used only for QS tracing)
Returns
'true' (success) if the posting succeeded (with the provided margin) and 'false' (failure) when the posting fails.
Attention
This function should be called only via the macro QACTIVE_POST() or QACTIVE_POST_X().
Note
The QF_NO_MARGIN value of the margin parameter is special and denotes situation when the post() operation is assumed to succeed (event delivery guarantee). An assertion fires, when the event cannot be delivered in this case.
Usage
extern QActive *AO_Table;
QState Philoso_hungry(Philo * const me, QEvt const * const e) {
QState status;
switch (e->sig) {
case Q_ENTRY_SIG: {
TableEvt *pe = Q_NEW(TableEvt, HUNGRY_SIG); /* dynamic alloc */
pe->philNum = me->num;
QACTIVE_POST(AO_Table, &pe->super, me); /* direct posting */
status = Q_HANDLED();
break;
}
. . .
default: {
status = Q_SUPER(&QHsm_top);
break;
}
}
return status;
}
#define Q_HANDLED()
Definition: qep.h:578
uint_fast8_t QState
Definition: qep.h:204
#define Q_SUPER(super_)
Definition: qep.h:572
@ Q_ENTRY_SIG
Definition: qep.h:714
#define Q_NEW(evtT_, sig_)
Definition: qf.h:757
Definition: qf.h:116
#define QACTIVE_POST(me_, e_, sender_)
Definition: qf.h:251
Definition: qep.h:151
QSignal sig
Definition: qep.h:152
QState QHsm_top(void const *const me, QEvt const *const e)
Definition: qep_hsm.c:250
See also
QActive_post_(), QActive_postLIFO()
Precondition
event pointer must be valid

Definition at line 92 of file qf_actq.c.

◆ QActive_postLIFO_()

void QActive_postLIFO_ ( QActive *const  me,
QEvt const *const  e 
)
Description
posts an event to the event queue of the active object me using the Last-In-First-Out (LIFO) policy.
Note
The LIFO policy should be used only for self-posting and with caution, because it alters order of events in the queue.
Parameters
[in]mepointer (see Object Orientation)
[in]epointer to the event to post to the queue
Attention
This function should be called only via the macro QACTIVE_POST_LIFO().
See also
QActive_post_(), QACTIVE_POST(), QACTIVE_POST_X()

Definition at line 235 of file qf_actq.c.

◆ QActive_get_()

QEvt const* QActive_get_ ( QActive *const  me)
Description
The behavior of this function depends on the kernel/OS used in the QF port. For built-in kernels (QV or QK) the function can be called only when the queue is not empty, so it doesn't block. For a blocking kernel/OS the function can block and wait for delivery of an event.
Parameters
[in,out]mepointer (see Object Orientation)
Returns
a pointer to the received event. The returned pointer is guaranteed to be valid (can't be NULL).
Note
This function is used internally by a QF port to extract events from the event queue of an active object. This function depends on the event queue implementation and is sometimes customized in the QF port (file qf_port.h). Depending on the definition of the macro QACTIVE_EQUEUE_WAIT_(), the function might block the calling thread when no events are available.

Definition at line 326 of file qf_actq.c.

◆ QF_getQueueMin()

uint_fast16_t QF_getQueueMin ( uint_fast8_t const  prio)
Description
Queries the minimum of free ever present in the given event queue of an active object with priority prio, since the active object was started.
Note
This function is available only when the native QF event queue implementation is used. Requesting the queue minimum of an unused priority level raises an assertion in the QF. (A priority level becomes used in QF after the call to the QF_add_() function.)
Parameters
[in]prioPriority of the active object, whose queue is queried
Returns
the minimum of free ever present in the given event queue of an active object with priority prio, since the active object was started.

Definition at line 392 of file qf_actq.c.

◆ QTicker_init_()

static void QTicker_init_ ( QHsm *const  me,
void const *  par,
uint_fast8_t const  qs_id 
)
static

Definition at line 458 of file qf_actq.c.

◆ QTicker_dispatch_()

static void QTicker_dispatch_ ( QHsm *const  me,
QEvt const *const  e,
uint_fast8_t const  qs_id 
)
static

Definition at line 473 of file qf_actq.c.

◆ QTicker_post_()

static bool QTicker_post_ ( QActive *const  me,
QEvt const *const  e,
uint_fast16_t const  margin,
void const *const  sender 
)
static

virtual function to asynchronously post (FIFO) an event to an AO

Definition at line 501 of file qf_actq.c.

◆ QTicker_postLIFO_()

static void QTicker_postLIFO_ ( QActive *const  me,
QEvt const *const  e 
)
static

Definition at line 538 of file qf_actq.c.

◆ QTicker_ctor()

void QTicker_ctor ( QTicker *const  me,
uint_fast8_t  tickRate 
)

"constructor" of QTicker

Definition at line 438 of file qf_actq.c.