QP/C++  7.4.0-rc.3
Real-Time Embedded Framework
Loading...
Searching...
No Matches
QP::QAsm Class Referenceabstract

Abstract State Machine class (state machine interface) More...

#include "qp.hpp"

Inheritance diagram for QP::QAsm:
QP::QActive QP::QHsm QP::QHsmDummy QP::QMsm QP::QActiveDummy QP::QMActive QP::QTicker QP::QXThread

Public Types

enum  QStateRet : QState {
  Q_RET_SUPER , Q_RET_SUPER_SUB , Q_RET_UNHANDLED , Q_RET_HANDLED ,
  Q_RET_IGNORED , Q_RET_ENTRY , Q_RET_EXIT , Q_RET_NULL ,
  Q_RET_TRAN , Q_RET_TRAN_INIT , Q_RET_TRAN_EP , Q_RET_TRAN_HIST ,
  Q_RET_TRAN_XP
}
 
enum  ReservedSig : QSignal { Q_EMPTY_SIG , Q_ENTRY_SIG , Q_EXIT_SIG , Q_INIT_SIG }
 Reserved signals by the QP-framework. More...
 

Public Member Functions

virtual ~QAsm () noexcept
 
virtual void init (void const *const e, std::uint_fast8_t const qsId)=0
 
virtual void init (std::uint_fast8_t const qsId)
 
virtual void dispatch (QEvt const *const e, std::uint_fast8_t const qsId)=0
 
virtual bool isIn (QStateHandler const state) noexcept
 
QStateHandler state () const noexcept
 
QMState const * stateObj () const noexcept
 
virtual QStateHandler getStateHandler () noexcept
 

Static Public Member Functions

static QState top (void *const me, QEvt const *const e) noexcept
 

Protected Member Functions

 QAsm () noexcept
 
QState tran (QStateHandler const target) noexcept
 
QState tran_hist (QStateHandler const hist) noexcept
 
QState super (QStateHandler const superstate) noexcept
 
QState qm_tran (void const *const tatbl) noexcept
 
QState qm_tran_init (void const *const tatbl) noexcept
 
QState qm_tran_hist (QMState const *const hist, void const *const tatbl) noexcept
 
QState qm_tran_ep (void const *const tatbl) noexcept
 
QState qm_tran_xp (QActionHandler const xp, void const *const tatbl) noexcept
 
QState qm_entry (QMState const *const s) noexcept
 
QState qm_exit (QMState const *const s) noexcept
 
QState qm_sm_exit (QMState const *const s) noexcept
 
QState qm_super_sub (QMState const *const s) noexcept
 

Protected Attributes

QAsmAttr m_state
 
QAsmAttr m_temp
 

Detailed Description

Abstract State Machine class (state machine interface)

Backward Traceability

Definition at line 218 of file qp.hpp.

Member Enumeration Documentation

◆ QStateRet

All possible return values from state-handlers

Note
The order is important for algorithmic correctness.
Enumerator
Q_RET_SUPER 

event passed to superstate to handle

Q_RET_SUPER_SUB 

event passed to submachine superstate

Q_RET_UNHANDLED 

event unhandled due to a guard

Q_RET_HANDLED 

event handled (internal transition)

Q_RET_IGNORED 

event silently ignored (bubbled up to top)

Q_RET_ENTRY 

state entry action executed

Q_RET_EXIT 

state exit action executed

Q_RET_NULL 

return value without any effect

Q_RET_TRAN 

regular transition

Q_RET_TRAN_INIT 

initial transition in a state or submachine

Q_RET_TRAN_EP 

entry-point transition into a submachine

Q_RET_TRAN_HIST 

transition to history of a given state

Q_RET_TRAN_XP 

exit-point transition out of a submachine

Definition at line 228 of file qp.hpp.

◆ ReservedSig

Reserved signals by the QP-framework.

Enumerator
Q_EMPTY_SIG 

signal to execute the default case

Q_ENTRY_SIG 

signal for entry actions

Q_EXIT_SIG 

signal for exit actions

Q_INIT_SIG 

signal for nested initial transitions

Definition at line 256 of file qp.hpp.

Constructor & Destructor Documentation

◆ QAsm()

QP::QAsm::QAsm ( )
inlineexplicitprotectednoexcept

Protected default constructor of QP::QAsm.

Definition at line 264 of file qp.hpp.

◆ ~QAsm()

virtual QP::QAsm::~QAsm ( )
inlinevirtualnoexcept

Virtual destructor of the QP::QAsm abstract base class.

Note
This virtual destructor is not provided by default and is provided only when the macro Q_XTOR is defined. This is because a presence of virtual destructor(s) seems to pull in the delete operator from the C++ library. This, in turn, might be problematic for deeply embedded systems that work without the heap and any other libraries.

Definition at line 272 of file qp.hpp.

Member Function Documentation

◆ init() [1/2]

virtual void QP::QAsm::init ( void const *const e,
std::uint_fast8_t const qsId )
pure virtual

Virtual function to take the top-most initial transition in the state machine.

Details

Synchronously executes the top-most initial transition in a state machine (must be overridden in the subclasses).

Parameters
[in]epointer to an initialization parameter (might be nullptr)
[in]qsIdQS-id of this state machine (for QS local filter)
Precondition qep_asm:200
  • the virtual pointer must be initialized,
  • the top-most initial transition must be initialized,
  • the initial transition must not be taken yet.

Implemented in QP::QActive, QP::QActiveDummy, QP::QHsm, QP::QHsmDummy, QP::QMActive, QP::QMsm, QP::QTicker, and QP::QXThread.

◆ init() [2/2]

virtual void QP::QAsm::init ( std::uint_fast8_t const qsId)
inlinevirtual

Virtual function to take the top-most initial transition in the state machine (overloaded).

Details

Synchronously executes the top-most initial transition in a state machine. This overloaded version takes no initialization parameter.

Parameters
[in]qsIdQS-id of this state machine (for QS local filter)

Reimplemented in QP::QActive, QP::QHsm, QP::QMActive, QP::QMsm, QP::QTicker, and QP::QXThread.

Definition at line 279 of file qp.hpp.

◆ dispatch()

virtual void QP::QAsm::dispatch ( QEvt const *const e,
std::uint_fast8_t const qsId )
pure virtual

Virtual function to dispatch an event to the state machine.

Details

Synchronously dispatches an event for processing to a state machine (must be overridden in the subclasses). The processing of an event represents one run-to-completion (RTC) step.

Parameters
[in]epointer to the event to be dispatched to the MSM
[in]qsIdQS-id of this state machine (for QS local filter)
Precondition qep_asm:302
  • current state must be initialized
  • check the internal integrity (Software Self-Monitoring (SSM))

Implemented in QP::QActive, QP::QActiveDummy, QP::QHsm, QP::QHsmDummy, QP::QMActive, QP::QMsm, QP::QTicker, and QP::QXThread.

◆ isIn()

virtual bool QP::QAsm::isIn ( QP::QStateHandler const state)
inlinevirtualnoexcept

Virtual function to check whether the state machine is in a given state.

Details

Tests if a given state is part of the current active state configuration. Please note that in a hierarchical state machine, to "be in a state" means also to be in a superstate of of the state.

Parameters
[in]statepointer to the state-handler function to be checked
Returns
'true' if the state machine "is in" the state and 'false' otherwise
Attention
This function must be called only on a state machine that is in the "stable state configuration". Among others, this means that the state machine cannot call it in the middle of its own transition.
Backward Traceability

Reimplemented in QP::QActive, QP::QHsm, QP::QMActive, and QP::QMsm.

Definition at line 285 of file qp.hpp.

◆ state()

QStateHandler QP::QAsm::state ( ) const
inlinenoexcept

Definition at line 289 of file qp.hpp.

◆ stateObj()

QMState const * QP::QAsm::stateObj ( ) const
inlinenoexcept

Definition at line 292 of file qp.hpp.

◆ getStateHandler()

virtual QStateHandler QP::QAsm::getStateHandler ( )
inlinevirtualnoexcept

Get the current state (handler) in the state machine

Reimplemented in QP::QHsm, QP::QMActive, and QP::QMsm.

Definition at line 297 of file qp.hpp.

◆ top()

static QState QP::QAsm::top ( void *const me,
QEvt const *const e )
inlinestaticnoexcept

Top state handler that ignores all events.

Definition at line 301 of file qp.hpp.

◆ tran()

QState QP::QAsm::tran ( QStateHandler const target)
inlineprotectednoexcept

Internal helper function to take a state transition in QP::QHsm

Definition at line 311 of file qp.hpp.

◆ tran_hist()

QState QP::QAsm::tran_hist ( QStateHandler const hist)
inlineprotectednoexcept

Internal helper function to take a state transition to history in QP::QHsm

Definition at line 315 of file qp.hpp.

◆ super()

QState QP::QAsm::super ( QStateHandler const superstate)
inlineprotectednoexcept

Internal helper function to indicate superstate of a given state

Definition at line 319 of file qp.hpp.

◆ qm_tran()

QState QP::QAsm::qm_tran ( void const *const tatbl)
inlineprotectednoexcept

Internal helper function to take a state transition in QP::QMsm

Definition at line 323 of file qp.hpp.

◆ qm_tran_init()

QState QP::QAsm::qm_tran_init ( void const *const tatbl)
inlineprotectednoexcept

Internal helper function to take an initial transition in QP::QMsm

Definition at line 327 of file qp.hpp.

◆ qm_tran_hist()

QState QP::QAsm::qm_tran_hist ( QMState const *const hist,
void const *const tatbl )
inlineprotectednoexcept

Internal helper function to take a state transition to history in QP::QMsm

Definition at line 331 of file qp.hpp.

◆ qm_tran_ep()

QState QP::QAsm::qm_tran_ep ( void const *const tatbl)
inlineprotectednoexcept

Internal helper function to take a transition to an entry point in QP::QMsm

Definition at line 339 of file qp.hpp.

◆ qm_tran_xp()

QState QP::QAsm::qm_tran_xp ( QActionHandler const xp,
void const *const tatbl )
inlineprotectednoexcept

Internal helper function to take a transition from an exit point in QP::QMsm

Definition at line 343 of file qp.hpp.

◆ qm_entry()

QState QP::QAsm::qm_entry ( QMState const *const s)
inlineprotectednoexcept

Internal helper function to execute state entry actions in QP::QMsm

Definition at line 353 of file qp.hpp.

◆ qm_exit()

QState QP::QAsm::qm_exit ( QMState const *const s)
inlineprotectednoexcept

Internal helper function to execute state exit actions in QP::QMsm

Definition at line 367 of file qp.hpp.

◆ qm_sm_exit()

QState QP::QAsm::qm_sm_exit ( QMState const *const s)
inlineprotectednoexcept

Internal helper function to execute state exit in a submachine in QP::QMsm

Backward Traceability
  • SAS_QP_QAsm

Definition at line 379 of file qp.hpp.

◆ qm_super_sub()

QState QP::QAsm::qm_super_sub ( QMState const *const s)
inlineprotectednoexcept

Definition at line 383 of file qp.hpp.

Member Data Documentation

◆ m_state

QAsmAttr QP::QAsm::m_state
protected

Current state (pointer to the current state-handler function)

Backward Traceability

Definition at line 220 of file qp.hpp.

◆ m_temp

QAsmAttr QP::QAsm::m_temp
protected

Temporary storage for target/act-table, etc.

Details

The m_temp data member is used for passing information from the QP Application to the "event processor" of QP. The m_temp member is also used as the Duplicate Inverse Storage of the m_state attribute in between transitions (part of QP Functional Safety (FuSa) Subsystem).

Definition at line 221 of file qp.hpp.


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