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

#include <qf.h>

Inheritance diagram for QTimeEvt:
Inheritance graph
Collaboration diagram for QTimeEvt:
Collaboration graph

Public Member Functions

void QTimeEvt_ctorX (QTimeEvt *const me, QActive *const act, enum_t const sig, uint_fast8_t tickRate)
void QTimeEvt_armX (QTimeEvt *const me, QTimeEvtCtr const nTicks, QTimeEvtCtr const interval)
bool QTimeEvt_rearm (QTimeEvt *const me, QTimeEvtCtr const nTicks)
bool QTimeEvt_disarm (QTimeEvt *const me)
bool QTimeEvt_wasDisarmed (QTimeEvt *const me)
QTimeEvtCtr QTimeEvt_currCtr (QTimeEvt const *const me)

Data Fields

QEvt super
struct QTimeEvt *volatile next
void *volatile act
QTimeEvtCtr volatile ctr
QTimeEvtCtr interval
- Data Fields inherited from QEvt
QSignal sig
uint8_t poolId_
uint8_t volatile refCtr_

Detailed Description

Time Event class

Time events are special QF events equipped with the notion of time passage. The basic usage model of the time events is as follows. An active object allocates one or more QTimeEvt objects (provides the storage for them). When the active object needs to arrange for a timeout, it arms one of its time events to fire either just once (one-shot) or periodically. Each time event times out independently from the others, so a QF application can make multiple parallel timeout requests (from the same or different active objects). When QF detects that the appropriate moment has arrived, it inserts the time event directly into the recipient's event queue. The recipient then processes the time event just like any other event.

Time events, as any other QF events derive from the QEvt base structure. Typically, you will use a time event as-is, but you can also further derive more specialized time events from it by adding some more data members and/or specialized functions that operate on the specialized time events.

Internally, the armed time events are organized into linked lists–one list for every supported ticking rate. These linked lists are scanned in every invocation of the QF_tickX_() function. Only armed (timing out) time events are in the list, so only armed time events consume CPU cycles.

See also
QTimeEvt for the description of the data members
Object Orientation
QF manages the time events in the function QF_tickX_(), which must be called periodically, from the clock tick ISR or from the special QTicker active object.
Even though QTimeEvt is a subclass of QEvt, QTimeEvt instances can NOT be allocated dynamically from event pools. In other words, it is illegal to allocate QTimeEvt instances with the Q_NEW() or Q_NEW_X() macros.

Definition at line 480 of file qf.h.

Member Function Documentation

◆ QTimeEvt_ctorX()

void QTimeEvt_ctorX ( QTimeEvt *const  me,
QActive *const  act,
enum_t const  sig,
uint_fast8_t  tickRate 

The extended "constructor" to initialize a Time Event.

Definition at line 238 of file qf_time.c.

◆ QTimeEvt_armX()

void QTimeEvt_armX ( QTimeEvt *const  me,
QTimeEvtCtr const  nTicks,
QTimeEvtCtr const  interval 

Arm a time event (one shot or periodic) for direct event posting.

Definition at line 297 of file qf_time.c.

◆ QTimeEvt_rearm()

bool QTimeEvt_rearm ( QTimeEvt *const  me,
QTimeEvtCtr const  nTicks 

Rearm a time event.

Definition at line 436 of file qf_time.c.

◆ QTimeEvt_disarm()

bool QTimeEvt_disarm ( QTimeEvt *const  me)

Disarm a time event.

Definition at line 374 of file qf_time.c.

◆ QTimeEvt_wasDisarmed()

bool QTimeEvt_wasDisarmed ( QTimeEvt *const  me)

Check the "was disarmed" status of a time event.

Definition at line 519 of file qf_time.c.

◆ QTimeEvt_currCtr()

QTimeEvtCtr QTimeEvt_currCtr ( QTimeEvt const *const  me)

Get the current value of the down-counter of a time event.

Definition at line 541 of file qf_time.c.

Field Documentation

◆ super

QEvt super

Definition at line 481 of file qf.h.

◆ next

struct QTimeEvt* volatile next

link to the next time event in the list

Definition at line 484 of file qf.h.

◆ act

void* volatile act

the active object that receives the time events

Definition at line 487 of file qf.h.

◆ ctr

QTimeEvtCtr volatile ctr

the internal down-counter of the time event.

The down-counter is decremented by 1 in every QF_tickX_() invocation. The time event fires (gets posted or published) when the down-counter reaches zero.

Definition at line 496 of file qf.h.

◆ interval

QTimeEvtCtr interval

the interval for periodic time event (zero for one-shot time event)

The value of the interval is re-loaded to the internal down-counter when the time event expires, so that the time event keeps timing out periodically.

Definition at line 505 of file qf.h.

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