Hierarchical State Machine class (QMsm-style state machine implementation strategy). More...
#include <qp.h>
Public Member Functions | |
| QMState const * | QMsm_topQMState (void) |
| QMState const * | QMsm_stateObj (QMsm const *const me) |
| Obtain the current state from a MSM (read only). | |
| QMState const * | QMsm_childStateObj (QMsm const *const me, QMState const *const parentHndl) |
| Obtain the current active child state of a given parent in QMsm. | |
Protected Member Functions | |
| void | QMsm_ctor (QMsm *const me, QStateHandler const initial) |
| Constructor of QMsm. | |
Protected Attributes | |
| QAsm | super |
| Protected Attributes inherited from QAsm | |
| struct QAsmVtable const * | vptr |
| Virtual pointer inherited by all QAsm subclasses (see also SAS_QP_OOA). | |
| union QAsmAttr | state |
| Current state (pointer to the current state-handler function). | |
| union QAsmAttr | temp |
| Temporary storage for target/act-table etc.. | |
Private Member Functions | |
| void | QMsm_init_ (QAsm *const me, void const *const e, uint_fast8_t const qsId) |
| Implementation of the top-most initial transition in QMsm. | |
| void | QMsm_dispatch_ (QAsm *const me, QEvt const *const e, uint_fast8_t const qsId) |
| Implementation of dispatching events to a QMsm. | |
| bool | QMsm_isIn_ (QAsm *const me, QStateHandler const stateHndl) |
| Tests if a given state is part of the current active state configuration. | |
| QStateHandler | QMsm_getStateHandler_ (QAsm const *const me) |
| Implementation of getting the state handler in an QMsm subclass. | |
Static Private Member Functions | |
| static QState | QMsm_execTatbl_ (QAsm *const me, QMTranActTable const *const tatbl, uint_fast8_t const qsId) |
| Execute a transition-action table in QMsm. | |
| static void | QMsm_exitToTranSource_ (QAsm *const me, QMState const *const curr_state, QMState const *const tran_source, uint_fast8_t const qsId) |
| Exit the given current-state up to the given tran-source in QMsm. | |
| static QState | QMsm_enterHistory_ (QAsm *const me, QMState const *const hist, uint_fast8_t const qsId) |
| Enter the history of a given state in QMsm. | |
Hierarchical State Machine class (QMsm-style state machine implementation strategy).
Details
QMsm (QM State Machine) provides a more efficient state machine implementation strategy than QHsm, but requires the use of the QM modeling tool. They are the fastest and need the least run-time support (the smallest event-processor taking up the least code space).
Usage
The following example illustrates how to derive a state machine class from QMsm. Please note that the QMsm member super is defined as the first member of the derived struct. Also, note that the derived class constructor calls the constructor of the base class QMsm_ctor().
Backward Traceability
Forward Traceability
|
protected |
Constructor of QMsm.
Details
Performs the first step of QMsm initialization by assigning the initial pseudostate to the currently active state of the state machine.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | initial | the top-most initial transition for the MSM. |
Usage
The following example illustrates how to invoke QMsm_ctor() in the "constructor" of a derived state machine:
Forward Traceability
|
private |
Implementation of the top-most initial transition in QMsm.
Details
This function synchronously executes the top-most initial transition in a state machine.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | e | pointer to an extra parameter (might be NULL) |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
Implementation of dispatching events to a QMsm.
Details
This function synchronously dispatches an event for processing to a state machine. The processing of an event represents one run-to-completion (RTC) step.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | e | pointer to the event to be dispatched to the MSM |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
Backward Traceability
Forward Traceability
|
private |
Tests if a given state is part of the current active state configuration.
Details
Please note that for an MSM, to "be in a state" means also to be in a superstate of the state.
| [in] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | state | pointer to the state-handler function to be tested |
Forward Traceability
|
private |
Implementation of getting the state handler in an QMsm subclass.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
Obtain the current state from a MSM (read only).
| [in] | me | current instance pointer (see SAS_QP_OOA) |
Forward Traceability
Obtain the current active child state of a given parent in QMsm.
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 QMsm.
| [in] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | parent | pointer to the state-handler object |
|
staticprivate |
Execute a transition-action table in QMsm.
Execute transition-action table.
Details
This helper function executes the provided transition-action table calling each action in the table until the NULL pointer (the end of the table) is reached.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | tatbl | transition-action table to execute |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
Backward Traceability
Forward Traceability
Details
Helper function to execute transition sequence in a transition-action table.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | tatbl | pointer to the transition-action table |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
|
staticprivate |
Exit the given current-state up to the given tran-source in QMsm.
Details
This helper function scans the state hierarchy (by following the state.superstate links) and calls the exit action for each state object, starting with the current-state and ending at the tran-source state.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | curr_state | pointer to the current state object |
| [in] | tran_source | pointer to the transition source object |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
Backward Traceability
Forward Traceability
|
staticprivate |
Enter the history of a given state in QMsm.
Enter history of a composite state.
Details
This helper function dynamically enters the given history state, which is the substate of me->state.obj.
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | hist | pointer to the history state to be entered |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
Backward Traceability
Forward Traceability
Details
Static helper function to execute the segment of transition to history after entering the composite state and
| [in,out] | me | current instance pointer (see SAS_QP_OOA) |
| [in] | hist | pointer to the history substate |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
Forward Traceability