Time ViewpointInterface Viewpoint
The Algorithm Viewpoint focuses on the internal details and logic of design entities. This design viewpoint frames the following design concerns:
- analysis of algorithms in regard to their correctness under various scenarios
- analysis of algorithms in regard of their efficiency and time-space performance
- analysis of algorithms in regard of their testability
QHsm Implementation View
The QP::QHsm class (see Figure SDS-CLS [13]) implements the state machine strategy optimized for "manual coding" (see SRS_QP_SM_20). The QHsm Design View describes how QP Application implements hierarchical state machines based on the QP::QHsm class. This section describes the internal design of the QP::QHsm class.
SDS_QP_QHsm_ctor
QHsm Constructor
- Description
- The QHsm constructor associates the state machine with its top-most initial-transition. The top-most initial transition is not actually executed at this point.
- Pseudocode
explicit QHsm(QStateHandler const initial) noexcept;
SDS_QP_QHsm_init
QHsm Top-most Initial Transition
- Description
- The top-most initial transition in a hierarchical state machine might be complex because the UML semantics require "drilling" into the state hierarchy with any nested initial transitions encountered in the target states until the leaf state is reached. Unfortunately, this direction of navigation through the state hierarchy is opposite to the natural direction. As you recall, a hierarchical state-handler function provides the superstate, so it's easy to traverse the state hierarchy from substates to superstates. Although this order is very convenient for the efficient implementation of the most frequently used dispatch operation, entering states is harder. The solution implemented in the QHsm class is to use an automatic array
path[]
to record the exit path from the target state of the initial transition source, without executing any actions. This is achieved by calling the state handlers with the reserved QEP_EMPTY_SIG
_ signal, which causes every state handler to immediately return the superstate without executing any other actions. These superstates are saved in the path[]
array until the current state is reached. The stored path[]
array is subsequently played backward to enter the target substates (from superstates to substates), which is the exact reversed order in which they were visited.
- Pseudocode
[1] void QHsm::init_(void const * const par) {
. . .
[2] r = (*m_temp.fun)(this, par);
[3] . . .
[4] enter_target_(&path[0], ip);
}
SDS_QP_QHsm_dispatch
QHsm Event Dispatching
- Description
SDS_QP_QHsm_tran-simple
QHsm Simple Transition
- Description
SDS_QP_QHsm_tran-complex
QHsm Complex Transition
- Description
QMsm Implementation View
The QP::QMsm class (see Figure SDS-CLS [14]) derived from QP::QAsm implements the state machine strategy optimized for "automatic code generation" (see SRS_QP_SM_21). The QMsm Design View describes how QP Applications implement hierarchical state machines based on the QP::QMsm class. This section describes how the the QP::QMsm class itself is internally implemented.
SDS_QP_QMsm_ctor
QMsm Constructor
- Description
SDS_QP_QMsm_init
QMsm Top-most Initial Transition
- Description
SDS_QP_QMsm_disp
QMsm Event Dispatching
- Description
SDS_QP_QMsm_tran
QMsm Transition
- Description
SDS_QP_QMsm_tat
QMsm Transition Action Tables
- Description
Time ViewpointInterface Viewpoint