QMsm implementation
More...
#include "qep_port.h"
#include "qassert.h"
#include "qs_port.h"
Go to the source code of this file.
QMsm implementation
Definition in file qep_msm.c.
◆ QEP_ACT_PTR_INC_
#define QEP_ACT_PTR_INC_ |
( |
|
act_ | ) |
(++(act_)) |
Internal QEP macro to increment the given action table act_
.
- Note
- Incrementing a pointer violates the MISRA-C 2004 Rule 17.4(req), pointer arithmetic other than array indexing. Encapsulating this violation in a macro allows to selectively suppress this specific deviation.
Definition at line 73 of file qep_msm.c.
◆ anonymous enum
internal QEP constants
Enumerator |
---|
QMSM_MAX_ENTRY_DEPTH_ | maximum depth of entry levels in a MSM for transition to history.
|
Definition at line 53 of file qep_msm.c.
◆ QMsm_execTatbl_()
helper function to execute a transition-action table.
- Description
- Helper function to execute transition sequence in a transition-action table.
- Parameters
-
[in,out] | me | pointer (see Object Orientation) |
[in] | tatbl | pointer to the transition-action table |
- Returns
- status of the last action from the transition-action table.
- Note
- This function is for internal use inside the QEP event processor and should not be called directly from the applications.
- Precondition
- the transition-action table pointer must not be NULL
Definition at line 364 of file qep_msm.c.
◆ QMsm_exitToTranSource_()
static void QMsm_exitToTranSource_ |
( |
QMsm *const |
me, |
|
|
QMState const * |
s, |
|
|
QMState const * |
ts |
|
) |
| |
|
static |
helper function to exit the current state up to the transition source
- Description
- 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.
- Parameters
-
[in,out] | me | pointer (see Object Orientation) |
[in] | s | pointer to the current state |
[in] | ts | pointer to the transition source state |
Definition at line 436 of file qep_msm.c.
◆ QMsm_enterHistory_()
helper function to execute a transition to history
- Description
- Static helper function to execute the segment of transition to history after entering the composite state and
- Parameters
-
- Returns
- #Q_RET_INIT, if an initial transition has been executed in the last entered state or Q_RET_NULL if no such transition was taken.
Definition at line 475 of file qep_msm.c.
◆ QMsm_ctor()
Protected "constructor" of QMsm.
- Description
- Performs the first step of QMsm initialization by assigning the initial pseudostate to the currently active state of the state machine.
- Parameters
-
[in,out] | me | pointer (see Object Orientation) |
[in] | initial | the top-most initial transition for the MSM. |
- Note
- Must be called only ONCE before QHSM_INIT().
-
QMsm inherits QHsm, so by the Object Orientation convention it should call the constructor of the superclass, i.e., QHsm_ctor(). However, this would pull in the QHsmVtbl, which in turn will pull in the code for QHsm_init_() and QHsm_dispatch_() implemetations. To avoid this code size penalty, in case QHsm is not used in a given project, the QMsm_ctor() performs direct intitialization of the Vtbl, which avoids pulling in the code for QMsm.
- Usage
- The following example illustrates how to invoke QMsm_ctor() in the "constructor" of a derived state machine:
void Calc_ctor(Calc * const me) {
me->operand1 = 0.0;
me->operand2 = 0.0;
me->len = 0U;
me->opKey = 0U;
}
Definition at line 111 of file qep_msm.c.
◆ QMsm_init_()
void QMsm_init_ |
( |
QMsm *const |
me, |
|
|
QEvt const *const |
e |
|
) |
| |
Implementation of the top-most initial transition in QMsm.
- Description
- Executes the top-most initial transition in a MSM.
- Parameters
-
[in,out] | me | pointer (see Object Orientation) |
[in] | e | pointer to the initialization event (might be NULL) |
- Note
- Must be called only ONCE after the QMsm_ctor().
- Precondition
- the virtual pointer must be initialized, the top-most initial transition must be initialized, and the initial transition must not be taken yet.
Definition at line 133 of file qep_msm.c.
◆ QMsm_dispatch_()
void QMsm_dispatch_ |
( |
QMsm *const |
me, |
|
|
QEvt const *const |
e |
|
) |
| |
Implementation of disparching events to QMsm.
- Description
- Dispatches an event for processing to a meta state machine (MSM). The processing of an event represents one run-to-completion (RTC) step.
- Parameters
-
[in,out] | me | pointer (see Object Orientation) |
[in] | e | pointer to the event to be dispatched to the MSM |
- Note
- This function should be called only via the virtual table (see QHSM_DISPATCH()) and should NOT be called directly in the applications.
- Precondition
- current state must be initialized
Definition at line 184 of file qep_msm.c.
◆ QMsm_isInState()
Tests if a given state is part of the current active state configuration in a MSM.
- Description
- Tests if a state machine derived from QMsm is-in a given state.
- Note
- For a MSM, to "be-in" a state means also to "be-in" a superstate of of the state.
- Parameters
-
- Returns
- 'true' if the MSM "is in" the
state
and 'false' otherwise
Definition at line 539 of file qep_msm.c.
◆ QMsm_childStateObj_()
Helper function to obtain the current active child state of a parent.
- Description
- 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.
- Parameters
-
- Returns
- the child of a given
parent
state, 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.
- See also
- QMsm_childStateObj()
- Postcondition
- the child must be found
Definition at line 570 of file qep_msm.c.
◆ l_msm_top_s
Initial value:= {
}
#define Q_STATE_CAST(handler_)
Perform cast to QStateHandler.
State object for the QMsm class (QM State Machine).
#define Q_ACTION_CAST(action_)
Perform cast to QActionHandler.
Definition at line 58 of file qep_msm.c.