QP/C++  5.9.8
QTicker Class Reference

Ticker Active Object class. More...

#include <qf.h>

Inheritance diagram for QTicker:
QActive QHsm

Public Member Functions

 QTicker (uint_fast8_t const tickRate)
 
virtual void init (QEvt const *const e)
 
virtual void init (void)
 Executes the top-most initial transition in QP::QHsm.
 
virtual void dispatch (QEvt const *const e)
 Dispatches an event to QHsm. More...
 
virtual bool post_ (QEvt const *const e, uint_fast16_t const margin, void const *const sender)
 
virtual void postLIFO (QEvt const *const e)
 Posts an event directly to the event queue of the active object using the Last-In-First-Out (LIFO) policy. More...
 
- Public Member Functions inherited from QActive
virtual void start (uint_fast8_t const prio, QEvt const *qSto[], uint_fast16_t const qLen, void *const stkSto, uint_fast16_t const stkSize, QEvt const *const ie)
 Starts execution of an active object and registers the object with the framework. More...
 
virtual void start (uint_fast8_t const prio, QEvt const *qSto[], uint_fast16_t const qLen, void *const stkSto, uint_fast16_t const stkSize)
 Overloaded start function (no initialization event)
 
void unsubscribeAll (void) const
 Un-subscribes from the delivery of all signals to the active object. More...
 
void stop (void)
 Stops execution of an active object and removes it from the framework's supervision. More...
 
void subscribe (enum_t const sig) const
 Subscribes for delivery of signal sig to the active object. More...
 
void unsubscribe (enum_t const sig) const
 Un-subscribes from the delivery of signal sig to the active object. More...
 
bool defer (QEQueue *const eq, QEvt const *const e) const
 Defer an event to a given separate event queue. More...
 
bool recall (QEQueue *const eq)
 Recall a deferred event from a given event queue. More...
 
uint_fast16_t flushDeferred (QEQueue *const eq) const
 Flush the specified deferred queue 'eq'. More...
 
uint_fast8_t getPrio (void) const
 Get the priority of the active object.
 
void setPrio (uint_fast8_t const prio)
 Set the priority of the active object.
 
QEvt const * get_ (void)
 Get an event from the event queue of an active object. More...
 
- Public Member Functions inherited from QHsm
virtual ~QHsm ()
 virtual destructor More...
 
bool isIn (QStateHandler const s)
 Tests if a given state is part of the current active state configuration. More...
 
QStateHandler state (void) const
 Obtain the current state (state handler function) More...
 
QStateHandler childState (QStateHandler const parent)
 Obtain the current active child state of a given parent. More...
 
QState tran_ (QStateHandler const target)
 internal helper function to record a state transition
 
QState tran_hist_ (QStateHandler const hist)
 internal helper function to record a transition to history
 
QState super_ (QStateHandler const superstate)
 internal helper function to record the superstate
 
QState qm_tran_ (QMTranActTable const *const tatbl)
 internal helper function to record a regular state transition
 
QState qm_tran_hist_ (QMState const *const hist, QMTranActTable const *const tatbl)
 Internal helper function to record a regular state transition.
 
QState qm_tran_init_ (QMTranActTable const *const tatbl)
 Internal helper function to record an initial state transition.
 
QState qm_tran_ep_ (QMTranActTable const *const tatbl)
 Internal helper function to record an transition to an entry point to a submachine state.
 
QState qm_tran_xp_ (QActionHandler const xp, QMTranActTable const *const tatbl)
 Internal helper function to record an transition to an exit point from a submachine state.
 
QState qm_entry_ (QMState const *const s)
 Internal helper function to record a state entry.
 
QState qm_exit_ (QMState const *const s)
 Internal helper function to record a state exit.
 
QState qm_super_sub_ (QMState const *const s)
 Internal helper function to call in a QM action-handler when it passes the event to the host submachine state to handle an event.
 

Additional Inherited Members

- Public Types inherited from QHsm
enum  ReservedHsmSignals { Q_ENTRY_SIG = 1, Q_EXIT_SIG, Q_INIT_SIG }
 
- Static Public Member Functions inherited from QHsm
static QState top (void *const me, QEvt const *const e)
 the top-state. More...
 
static QState Q_HANDLED (void)
 internal helper function to specify the return of a state-handler when it handles the event.
 
static QState Q_UNHANDLED (void)
 internal helper function to specify the return of a state-handler function when it attempts to handle the event but a guard condition evaluates to false and there is no other explicit way of handling the event.
 
static QState QM_HANDLED (void)
 Internal helper function to call in a QM action-handler when it handles an event.
 
static QState QM_UNHANDLED (void)
 Macro to call in a QM action-handler when it does not handle an event due to a guard condition evaluating to false.
 
static QState QM_SUPER (void)
 Internal helper function to call in a QM action-handler when it passes the event to the superstate for processing.
 
- Public Attributes inherited from QActive
uint_fast8_t m_prio
 QF priority (1..QF_MAX_ACTIVE) of this active object.
 
- Protected Member Functions inherited from QActive
 QActive (QStateHandler const initial)
 protected constructor (abstract class)
 
- Protected Member Functions inherited from QHsm
 QHsm (QStateHandler const initial)
 Protected constructor of QHsm. More...
 

Detailed Description

Ticker Active Object class.

Description
The QTicker is an efficient active object specialized to process QF system clock tick at a specified tick frequency [0..QF_MAX_TICK_RATE]. Placing system clock tick processing in an active object allows you to remove the non-deterministic QF::TICK_X() processing from the interrupt level and move it into the thread-level, where you can prioritize it as low as you wish.

Definition at line 607 of file qf.h.

Member Function Documentation

◆ init()

void init ( QEvt const *const  e)
virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Description
Executes the top-most initial transition in a HSM.
Parameters
[in]epointer to the initialization event (might be NULL)
Note
Must be called exactly once before the QP::QHsm::dispatch().
Precondition
ctor must have been executed and initial tran NOT taken

Reimplemented from QHsm.

Definition at line 346 of file qf_actq.cpp.

◆ dispatch()

void dispatch ( QEvt const *const  e)
virtual

Dispatches an event to QHsm.

Description
Dispatches an event for processing to a hierarchical state machine (HSM). The processing of an event represents one run-to-completion (RTC) step.
Parameters
[in]epointer to the event to be dispatched to the HSM
Note
This state machine must be initialized by calling QP::QHsm::init() exactly once before calling QP::QHsm::dispatch().
Precondition
the current state must be initialized and the state configuration must be stable

Reimplemented from QHsm.

Definition at line 350 of file qf_actq.cpp.

◆ post_()

bool post_ ( QEvt const *const  e,
uint_fast16_t const  margin,
void const *const  sender 
)
virtual
Description
Direct event posting is the simplest asynchronous communication method available in QF.
Parameters
[in,out]epointer to the event to be posted
[in]marginnumber of required free slots in the queue after posting the event. The special value QP::QF_NO_MARGIN means that this function will assert if posting fails.
Returns
'true' (success) if the posting succeeded (with the provided margin) and 'false' (failure) when the posting fails.
Attention
Should be called only via the macro POST() or POST_X().
Note
The QP::QF_NO_MARGIN value of the margin argument 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;
QP::QState Philo::hungry(Philo * const me, QP::QEvt const * const e) {
QP::QState status;
switch (e->sig) {
case Q_ENTRY_SIG: {
TableEvt *pe = Q_NEW(TableEvt, HUNGRY_SIG);
pe->philoNum = PHILO_ID(me);
AO_Table->POST(pe, me);
status = Q_HANDLED();
break;
}
. . .
default: {
status = Q_SUPER(&QHsm::top);
break;
}
}
return status;
}
See also
QActive::postLIFO()
Precondition
event pointer must be valid
Note
assert if event cannot be posted and dropping events is not acceptable
Precondition
event pointer must be valid
Note
assert if event cannot be posted and dropping events is not acceptable

Reimplemented from QActive.

Definition at line 365 of file qf_actq.cpp.

◆ postLIFO()

void postLIFO ( QEvt const *const  e)
virtual

Posts an event directly to the event queue of the active object using the Last-In-First-Out (LIFO) policy.

Description
posts an event to the event queue of the active object 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]epointer to the event to post to the queue
See also
QActive::post_()

Reimplemented from QActive.

Definition at line 408 of file qf_actq.cpp.


The documentation for this class was generated from the following files: