QP/C++ 6.9.3
QMActive Class Reference

QMActive active object (based on QP::QMsm implementation) More...

#include <qf.hpp>

Inheritance diagram for QMActive:
Inheritance graph
Collaboration diagram for QMActive:
Collaboration graph

Public Member Functions

void init (void const *const e, std::uint_fast8_t const qs_id) override
 executes the top-most initial transition in QP::QHsm More...
 
void init (std::uint_fast8_t const qs_id) override
 overloaded init(qs_id) More...
 
void dispatch (QEvt const *const e, std::uint_fast8_t const qs_id) override
 Dispatches an event to QHsm. More...
 
QStateHandler getStateHandler () noexcept override
 Get the current state handler of the QMsm. More...
 
bool isInState (QMState const *const st) const noexcept
 Tests if a given state is part of the active state configuration. More...
 
QMState const * stateObj (void) const noexcept
 Return the current active state object (read only) More...
 
QMState const * childStateObj (QMState const *const parent) const noexcept
 Obtain the current active child state of a given parent (read only) More...
 
- Public Member Functions inherited from QActive
virtual void start (std::uint_fast8_t const prio, QEvt const **const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize, void const *const par)
 Starts execution of an active object and registers the object with the framework. More...
 
virtual void start (std::uint_fast8_t const prio, QEvt const **const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize)
 Overloaded start function (no initialization event) More...
 
void stop (void)
 Stops execution of an active object and removes it from the framework's supervision. More...
 
virtual bool post_ (QEvt const *const e, std::uint_fast16_t const margin, void const *const sender) noexcept
 
virtual void postLIFO (QEvt const *const e) noexcept
 Posts an event directly to the event queue of the active object using the Last-In-First-Out (LIFO) policy. More...
 
void unsubscribeAll (void) const noexcept
 Un-subscribes from the delivery of all signals to the active object. More...
 
void subscribe (enum_t const sig) const noexcept
 Subscribes for delivery of signal sig to the active object. More...
 
void unsubscribe (enum_t const sig) const noexcept
 Un-subscribes from the delivery of signal sig to the active object. More...
 
bool defer (QEQueue *const eq, QEvt const *const e) const noexcept
 Defer an event to a given separate event queue. More...
 
bool recall (QEQueue *const eq) noexcept
 Recall a deferred event from a given event queue. More...
 
std::uint_fast16_t flushDeferred (QEQueue *const eq) const noexcept
 Flush the specified deferred queue 'eq'. More...
 
std::uint_fast8_t getPrio (void) const noexcept
 Get the priority of the active object. More...
 
void setPrio (std::uint_fast8_t const prio)
 Set the priority of the active object. More...
 
void setAttr (std::uint32_t attr1, void const *attr2=nullptr)
 Generic setting of additional attributes (useful in QP ports) More...
 
QEvt const * get_ (void) noexcept
 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) noexcept
 Tests if a given state is part of the current active state configuration. More...
 
QStateHandler state (void) const noexcept
 Obtain the current state (state handler function) More...
 
QStateHandler childState (QStateHandler const parent) noexcept
 Obtain the current active child state of a given parent. More...
 

Protected Member Functions

 QMActive (QStateHandler const initial) noexcept
 protected constructor (abstract class) More...
 
- Protected Member Functions inherited from QActive
 QActive (QStateHandler const initial) noexcept
 protected constructor (abstract class) More...
 
- Protected Member Functions inherited from QHsm
 QHsm (QStateHandler const initial) noexcept
 Protected constructor of QHsm. More...
 
QState tran (QStateHandler const target) noexcept
 Helper function to specify a state transition. More...
 
QState tran_hist (QStateHandler const hist) noexcept
 Helper function to specify a transition to history. More...
 
QState super (QStateHandler const superstate) noexcept
 Helper function to specify the superstate of a given state. More...
 
QState qm_tran (void const *const tatbl) noexcept
 Helper function to specify a regular state transition in a QM state-handler. More...
 
QState qm_tran_hist (QMState const *const hist, void const *const tatbl) noexcept
 Helper function to specifiy a transition to history in a QM state-handler. More...
 
QState qm_tran_init (void const *const tatbl) noexcept
 Helper function to specify an initial state transition in a QM state-handler. More...
 
QState qm_tran_ep (void const *const tatbl) noexcept
 Helper function to specify a transition to an entry point to a submachine state in a QM state-handler. More...
 
QState qm_tran_xp (QActionHandler const xp, void const *const tatbl) noexcept
 Helper function to specify a transition to an exit point from a submachine state in a QM state-handler. More...
 
QState qm_entry (QMState const *const s) noexcept
 Helper function to specify a state entry in a QM state-handler. More...
 
QState qm_exit (QMState const *const s) noexcept
 Helper function to specify a state exit in a QM state-handler. More...
 
QState qm_sm_exit (QMState const *const s) noexcept
 Helper function to specify a submachine exit in a QM state-handler. More...
 
QState qm_super_sub (QMState const *const s) noexcept
 Helper function to call in a QM state-handler when it passes the event to the host submachine state to handle an event. More...
 

Private Member Functions

bool isIn (QStateHandler const s) noexcept
 operations inherited from QP::QHsm, but disallowed in QP::QMActive More...
 
QStateHandler state (void) const noexcept
 Obtain the current state (state handler function) More...
 
QStateHandler childState (QStateHandler const parent) noexcept
 Obtain the current active child state of a given parent. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from QHsm
static QState top (void *const me, QEvt const *const e) noexcept
 the top-state. More...
 
- Data Fields inherited from QActive
std::uint8_t m_prio
 QF priority (1..QF_MAX_ACTIVE) of this active object. More...
 
- Static Public Attributes inherited from QHsm
static constexpr QState Q_RET_SUPER {static_cast<QState>(0)}
 event passed to the superstate to handle More...
 
static constexpr QState Q_RET_SUPER_SUB {static_cast<QState>(1)}
 event passed to submachine superstate More...
 
static constexpr QState Q_RET_UNHANDLED {static_cast<QState>(2)}
 event unhandled due to a guard evaluating to 'false' More...
 
static constexpr QState Q_RET_HANDLED {static_cast<QState>(3)}
 event handled (internal transition) More...
 
static constexpr QState Q_RET_IGNORED {static_cast<QState>(4)}
 event silently ignored (bubbled up to top) More...
 
static constexpr QState Q_RET_ENTRY {static_cast<QState>(5)}
 state entry action executed More...
 
static constexpr QState Q_RET_EXIT {static_cast<QState>(6)}
 state exit action executed More...
 
static constexpr QState Q_RET_NULL {static_cast<QState>(7)}
 return value without any effect More...
 
static constexpr QState Q_RET_TRAN {static_cast<QState>(8)}
 regular transition taken More...
 
static constexpr QState Q_RET_TRAN_INIT {static_cast<QState>(9)}
 initial transition taken More...
 
static constexpr QState Q_RET_TRAN_EP {static_cast<QState>(10)}
 entry-point transition into a submachine More...
 
static constexpr QState Q_RET_TRAN_HIST {static_cast<QState>(11)}
 transition to history of a given state More...
 
static constexpr QState Q_RET_TRAN_XP {static_cast<QState>(12)}
 exit-point transition out of a submachine More...
 
- Protected Types inherited from QHsm
enum  ReservedHsmSignals : QSignal { Q_ENTRY_SIG = 1 , Q_EXIT_SIG , Q_INIT_SIG }
 

Detailed Description

QMActive active object (based on QP::QMsm implementation)

Description
QP::QMActive represents an active object that uses the QP::QMsm-style state machine implementation strategy. This strategy requires the use of the QM modeling tool to generate state machine code automatically, but the code is faster than in the QP::QHsm-style implementation strategy and needs less run-time support (smaller event-processor).
Note
QP::QMActive is not intended to be instantiated directly, but rather serves as the base class for derivation of active objects in the applications.
See also
QP::QActive
Usage
The following example illustrates how to derive an active object from QP::QMActive.
class Philo : public QMActive { // derives from QMActive
private:
uint8_t m_num; // number of this philosopher
QTimeEvt m_timeEvt; // to timeout thining or eating
public:
Philo::Philo() // constructor
: QMActive(&initial), // superclass' constructor
m_timeEvt(TIMEOUT_SIG, this, 0U)
{}
protected:
// NOTE: QMsm state machine code is not intended for manual
// coding but rather needs to be generated automatically by
// the QM modeling tool
QM_STATE_DECL(initial);
QM_STATE_DECL(thinking);
QM_STATE_DECL(hungry);
QM_STATE_DECL(eating);
};
unsigned char uint8_t
exact-width 8-bit unsigned int
Definition: 16bit/stdint.h:29
friend class QTimeEvt
Definition: qf.hpp:293
friend class QMActive
Definition: qep.hpp:471
#define QM_STATE_DECL(state_)
Macro to generate a declaration of a state-handler, state-caller and a state-object for a given state...
Definition: qep.hpp:662

Definition at line 330 of file qf.hpp.

Constructor & Destructor Documentation

◆ QMActive()

QMActive ( QStateHandler const  initial)
protectednoexcept

protected constructor (abstract class)

Definition at line 61 of file qf_qmact.cpp.

Member Function Documentation

◆ init() [1/2]

void init ( void const *const  e,
std::uint_fast8_t const  qs_id 
)
overridevirtual

executes the top-most initial transition in QP::QHsm

Description
Executes the top-most initial transition in a HSM.
Parameters
[in]epointer to an extra parameter (might be NULL)
[in]qs_idQS-id of this state machine (for QS local filter)
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 68 of file qf_qmact.cpp.

◆ init() [2/2]

void init ( std::uint_fast8_t const  qs_id)
overridevirtual

overloaded init(qs_id)

Reimplemented from QHsm.

Definition at line 73 of file qf_qmact.cpp.

◆ dispatch()

void dispatch ( QEvt const *const  e,
std::uint_fast8_t const  qs_id 
)
overridevirtual

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
[in]qs_idQS-id of this state machine (for QS local filter)
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 77 of file qf_qmact.cpp.

◆ getStateHandler()

QStateHandler getStateHandler ( )
overridevirtualnoexcept

Get the current state handler of the QMsm.

Reimplemented from QHsm.

Definition at line 94 of file qf_qmact.cpp.

◆ isInState()

bool isInState ( QMState const *const  st) const
noexcept

Tests if a given state is part of the active state configuration.

Definition at line 82 of file qf_qmact.cpp.

◆ stateObj()

QMState const* stateObj ( void  ) const
inlinenoexcept

Return the current active state object (read only)

Definition at line 348 of file qf.hpp.

◆ childStateObj()

QMState const * childStateObj ( QMState const *const  parent) const
noexcept

Obtain the current active child state of a given parent (read only)

Definition at line 86 of file qf_qmact.cpp.

◆ isIn()

bool isIn
privatenoexcept

operations inherited from QP::QHsm, but disallowed in QP::QMActive

Definition at line 292 of file qep_hsm.cpp.

◆ state()

QStateHandler state ( void  )
inlineprivatenoexcept

Obtain the current state (state handler function)

Note
used in the QM code generation

Definition at line 296 of file qep.hpp.

◆ childState()

QStateHandler childState
privatenoexcept

Obtain the current active child state of a given parent.

Note
used in the QM code generation
Description
Finds the child state of the given parent, such that this child state is an ancestor of the currently active state. The main purpose of this function is to support shallow history transitions in state machines derived from QHsm.
Parameters
[in]parentpointer to the state-handler function
Returns
the child of a given parent state, which is an ancestor of the currently active state
Note
this function is designed to be called during state transitions, so it does not necessarily start in a stable state configuration. However, the function establishes stable state configuration upon exit.
Postcondition
the child must be confirmed

Definition at line 302 of file qep_hsm.cpp.


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