Hierarchical State Machine class (QMsm-style implementation strategy). More...
Public Member Functions | |
| QMState const * | QMsm_topQMState (void) |
| return top-most state object in a QMsm | |
| 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_TECH_20]) . | |
| 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 transition-action table. | |
| static void | QMsm_exitToTranSource_ (QAsm *const me, QMState const *const curr_state, QMState const *const tran_source, uint_fast8_t const qsId) |
| Exit the current state up to the explicit transition source. | |
| static QState | QMsm_enterHistory_ (QAsm *const me, QMState const *const hist, uint_fast8_t const qsId) |
| Enter the state history in QMsm state machine. | |
Hierarchical State Machine class (QMsm-style 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 | instance pointer (see [SAS_QP_TECH_20]) |
| [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 | instance pointer (see [SAS_QP_TECH_20]) |
| [in] | e | pointer to an extra parameter (might be NULL) |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
Backward Traceability
Forward Traceability
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 | instance pointer (see [SAS_QP_TECH_20]) |
| [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 | instance pointer (see [SAS_QP_TECH_20]) |
| [in] | state | pointer to the state-handler function to be tested |
| true | If the MSM "is in" the state |
| false | Otherwise |
Backward Traceability
Forward Traceability
|
private |
Implementation of getting the state handler in an QMsm subclass.
| [in,out] | me | instance pointer (see [SAS_QP_TECH_20]) |
Backward Traceability
Forward Traceability
| QMState const * QMsm_topQMState | ( | void | ) |
return top-most state object in a QMsm
Details
The top-state-object is the ultimate root of state hierarchy in QMsm state machines.
| pointer | Pointer to the top-state object in QMsm. |
Backward Traceability
Forward Traceability
Obtain the current state from a MSM (read only).
| [in] | me | instance pointer (see [SAS_QP_TECH_20]) |
| state | Pointer to current state object |
Backward Traceability
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 | instance pointer (see [SAS_QP_TECH_20]) |
| [in] | parent | pointer to the state-handler object |
| child | Pointer to the child state object of a given parent state, which is an ancestor of the currently active state. |
| parent | For the corner case when the currently active state is the given parent state, the function returns the parent state. |
Backward Traceability
Forward Traceability
|
staticprivateinternal |
Execute transition-action table.
Details
Helper function to execute transition sequence in a transition-action table.
| [in,out] | me | instance pointer (see [SAS_QP_TECH_20]) |
| [in] | tatbl | pointer to the transition-action table |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
| status | Status of the last action from the transition-action table. |
Forward Traceability
|
staticprivateinternal |
Exit the current state up to the explicit transition source.
Details
Static helper function to exit the current state configuration to the transition source, which in a hierarchical state machine might be a superstate of the current state.
| [in,out] | me | instance pointer (see [SAS_QP_TECH_20]) |
| [in] | curr_state | pointer to the current state |
| [in] | tran_source | pointer to the transition source state |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
Forward Traceability
|
staticprivateinternal |
Enter the state history in QMsm state machine.
Details
Static helper function to dynamically enter the provided state object provided in the history parameter. Please note that because the history state is not fixed, the transition must be dynamic (determined on-the-fly) as opposed to pre-computed statically as a tran-action table.
| [in,out] | me | instance pointer (see [SAS_QP_TECH_20]) |
| [in] | hist | pointer to the history (state object) to be entered |
| [in] | qsId | QS-id of this state machine (for QS local filter) |
| Q_RET_TRAN_INIT | If an initial transition has been executed in the history state |
| Q_RET_SUPER | If the history state has no initial transition |
Forward Traceability