Hierarchical State Machine class (QHsm-style state machine implementation strategy).
More...
|
| void | init (void const *const e, std::uint_fast8_t const qsId) override |
| | Virtual function to take the top-most initial transition in the state machine.
|
| void | dispatch (QEvt const *const e, std::uint_fast8_t const qsId) override |
| | Virtual function to dispatch an event to the state machine.
|
| bool | isIn (QStateHandler const stateHndl) noexcept override |
| | Check whether the HSM is in a given state.
|
| QStateHandler | getStateHandler () const noexcept override |
| | Virtual method for getting the current state handler.
|
| QStateHandler | childState (QStateHandler const parentHndl) noexcept |
| | Obtain the current active child state of a given parent in QP::QMsm.
|
| virtual void | init (std::uint_fast8_t const qsId) |
| | Virtual function to take the top-most initial transition in the state machine (overloaded).
|
| virtual | ~QAsm () noexcept |
| | Virtual destructor of the QP::QAsm abstract base class.
|
| QStateHandler | state () const noexcept |
| QMState const * | stateObj () const noexcept |
|
| std::size_t | tran_simple_ (std::array< QStateHandler, MAX_NEST_DEPTH_ > &path, std::uint_fast8_t const qsId) |
| std::size_t | tran_complex_ (std::array< QStateHandler, MAX_NEST_DEPTH_ > &path, std::uint_fast8_t const qsId) |
| void | enter_target_ (std::array< QStateHandler, MAX_NEST_DEPTH_ > &path, std::size_t const depth, std::uint_fast8_t const qsId) |
| std::size_t | tran_simple_ (std::array< QStateHandler, MAX_NEST_DEPTH_ > &path, std::uint_fast8_t const qsId) |
| std::size_t | tran_complex_ (std::array< QStateHandler, MAX_NEST_DEPTH_ > &path, std::uint_fast8_t const qsId) |
| void | enter_target_ (std::array< QStateHandler, MAX_NEST_DEPTH_ > &path, std::size_t const depth, std::uint_fast8_t const qsId) |
Hierarchical State Machine class (QHsm-style state machine implementation strategy).
Details
QP::QHsm represents a Hierarchical State Machine (HSM) with full support for hierarchical nesting of states, entry/exit actions, initial transitions, and transitions to history in any composite state. This class is designed for ease of manual coding of HSMs in C++, but it is also supported by the QM modeling tool.
- Note
- QP::QHsm is not intended to be instantiated directly, but rather serves as the abstract base class for derivation of state machines in the QP/C++ Application.
Backward Traceability
- SRS_QP_SM_00: QP/C++ Framework shall provide support for hierarchical state machines for Active Objects and for passive stateful objects in the QP/C++ Application.
- SRS_QP_SM_10: QP/C++ Framework shall support multiple and interchangeable State Machine Implementation Strategies
- SDS_QP_QHsm: QHsm State machine class.
Usage
The following example illustrates how to derive a state machine class from QHsm. Please note that the QHsm member super is defined as the FIRST member of the derived class.
public:
static Calc inst;
private:
double m_op1;
double m_op2;
uint8_t m_oper1;
uint8_t m_oper2;
public:
protected:
. . .
};
Hierarchical State Machine class (QHsm-style state machine implementation strategy).
QHsm(QStateHandler const initial) noexcept
#define Q_STATE_CAST(handler_)
Perform cast to QP::QStateHandler.
#define Q_STATE_DECL(state_)
Definition at line 299 of file qp.hpp.
Virtual method for getting the current state handler.
Details
This virtual call applies to all subclasses of QP::QAsm, such as: QP::QHsm, QP::QMsm, QP::QActive, and QP::QMActive.
- Returns
- the current state-handler of the type QP::QStateHandler (pointer to function)
- Note
- This function can be called in any context (including from a critical section) and also not necessarily in the "stable state configuration". When called during a state transition in the state machine, it returns the source state.
Backward Traceability
- SRS_QP_SM_26: All State Machine Implementation Strategies provided by the QP/C++ Framework might supply a method for obtaining the current state.
Usage
The following example illustrates how to obtain the current state handler of an Active Object:
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to a state-handler function.
Implements QP::QAsm.
Definition at line 610 of file qep_hsm.cpp.