Hierarchical State Machine class (QHsm-style state machine implementation strategy)
More...
#include "qp.h"
Hierarchical State Machine class (QHsm-style state machine implementation strategy)
- Details
- 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
- QHsm is not intended to be instantiated directly, but rather serves as the abstract base class for derivation of state machines in the QP Application.
- Backward Traceability
- SRS_QP_SM_00: QP Framework shall provide support for hierarchical state machines both for Active Objects and for passive event-driven objects in the Application
- SRS_QP_SM_10: QP Framework shall support multiple and interchangeable State Machine Implementation Strategies
- SDS_QP_QEP: QEP Event Processor
- 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. typedef struct {
double operand1;
double operand2;
char display[DISP_WIDTH + 1];
uint8_t len;
uint8_t opKey;
} Calc;
void Calc_ctor(void) {
. . .
}
#define Q_STATE_CAST(handler_)
Perform cast to QStateHandler.
Hierarchical State Machine class (QHsm-style state machine implementation strategy)
void QHsm_ctor(QHsm *const me, QStateHandler const initial)
Constructor of the QHsm base class.
Definition at line 251 of file qp.h.
◆ QHsm_ctor()
Constructor of the QHsm base class.
- Details
- The constructor initializes the QHsm::state. The constructor is "protected" because it is only intended to be invoked from the subclasses of the abstract base class QAsm.
- Parameters
-
[in,out] | me | current instance pointer (see SAS_QP_OO) |
[in] | initial | initial pseudostate of the instantiated state machine |
- Backward Traceability
- QHsm: Hierarchical State Machine class (QHsm-style state machine implementation strategy)
Definition at line 154 of file qep_hsm.c.
◆ QHsm_init_()
void QHsm_init_ |
( |
QAsm *const | me, |
|
|
void const *const | e, |
|
|
uint_fast8_t const | qsId ) |
|
private |
Implementation of the top-most initial transition in QHsm.
- Details
- Synchronously executes the top-most initial transition in a state machine.
- Parameters
-
[in,out] | me | current instance pointer (see SAS_QP_OO) |
[in] | e | pointer to an extra parameter (might be NULL) |
[in] | qsId | QS-id of this state machine (for QS local filter) |
- Precondition
qep_msm:200
- the virtual pointer must be initialized,
- the top-most initial transition must be initialized,
- the initial transition must not be taken yet.
- Note
- This function should be called only via the virtual table (see QASM_INIT()) and should NOT be called directly in the applications.
- Backward Traceability
- QHsm: Hierarchical State Machine class (QHsm-style state machine implementation strategy)
Definition at line 173 of file qep_hsm.c.
◆ QHsm_dispatch_()
void QHsm_dispatch_ |
( |
QAsm *const | me, |
|
|
QEvt const *const | e, |
|
|
uint_fast8_t const | qsId ) |
|
private |
Implementation of dispatching events to a QHsm.
- Details
- Synchronously dispatches an event for processing to a state machine. The processing of an event represents one run-to-completion (RTC) step.
- Parameters
-
[in,out] | me | current instance pointer (see SAS_QP_OO) |
[in] | e | pointer to the event to be dispatched to the MSM |
[in] | qsId | QS-id of this state machine (for QS local filter) |
- Precondition
qep_msm:302
- current state must be initialized
- check the internal integrity (Software Self-Monitoring (SSM))
- Note
- This function should be called only via the virtual table (see QASM_DISPATCH()) and should NOT be called directly in the applications.
- Backward Traceability
- QHsm: Hierarchical State Machine class (QHsm-style state machine implementation strategy)
Definition at line 243 of file qep_hsm.c.
◆ QHsm_isIn_()
Check if a given state is part of the current active state configuration.
- Details
- Please note that for a HSM, to "be in a state" means also to be in a superstate of of the state.
- Parameters
-
[in] | me | current instance pointer (see SAS_QP_OO) |
[in] | state | pointer to the state-handler function to be tested |
- Returns
- 'true' if the HSM "is in" the
state
and 'false' otherwise
- Note
- This function should be called only via the virtual table (see QASM_IS_IN()) and should NOT be called directly in the applications.
- Attention
- This function should be only called only when the state machine is in a "stable state configuration".
- Precondition
qep_hsm:602
- internal integrity check (Software Self-Monitoring (SSM))
- Backward Traceability
- SRS_QP_SM_25: All State Machine Implementation Strategies provided by QP Framework might supply a method for checking if a state machine is in a given state
- QHsm: Hierarchical State Machine class (QHsm-style state machine implementation strategy)
Definition at line 333 of file qep_hsm.c.
◆ QHsm_getStateHandler_()
Implementation of getting the state handler in a QHsm subclass.
- Parameters
-
[in,out] | me | current instance pointer (see SAS_QP_OO) |
- Note
- This function is only called internally via the virtual table
Definition at line 356 of file qep_hsm.c.
◆ QHsm_top()
◆ QHsm_state()
Obtain the current active state from a HSM (read only)
- Parameters
-
[in] | me | current instance pointer (see SAS_QP_OO) |
- Returns
- the current active state-handler
- Note
- This function is used for state history (deep history) in the auto-generated code by the QM modeling tool.
- Backward Traceability
- QHsm: Hierarchical State Machine class (QHsm-style state machine implementation strategy)
Definition at line 286 of file qp.h.
◆ QHsm_childState()
Obtain the current active child state of a given parent in QHsm.
- Details
- 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] | me | current instance pointer (see SAS_QP_OO) |
[in] | parent | pointer to the state-handler |
- Returns
- the child of a given
parent
state-handler, which is an ancestor of the currently active state. For the corner case when the currently active state is the given parent
state, function returns the parent
state.
- Postcondition
qep_msm:890
-
- Note
- This function is used in QM for auto-generating code for state history (shallow history)
- Backward Traceability
- QHsm: Hierarchical State Machine class (QHsm-style state machine implementation strategy)
Definition at line 373 of file qep_hsm.c.
◆ QHsm_tran_simple_()
static int_fast8_t QHsm_tran_simple_ |
( |
QAsm *const | me, |
|
|
QStateHandler *const | path, |
|
|
uint_fast8_t const | qsId ) |
|
staticprivate |
◆ QHsm_tran_complex_()
static int_fast8_t QHsm_tran_complex_ |
( |
QAsm *const | me, |
|
|
QStateHandler *const | path, |
|
|
uint_fast8_t const | qsId ) |
|
staticprivate |
◆ QHsm_enter_target_()
static void QHsm_enter_target_ |
( |
QAsm *const | me, |
|
|
QStateHandler *const | path, |
|
|
int_fast8_t const | depth, |
|
|
uint_fast8_t const | qsId ) |
|
staticprivate |
◆ super
Definition at line 252 of file qp.h.
The documentation for this class was generated from the following files: