Structure Viewpoint
Purpose
The Structure Viewpoint elaborates the base classes and interfaces identified in the architecture Context Viewpoint with their design details and structural static relationships. The Structure Design Viewpoint also provides examples of using the QP/C++ Framework classes in QP Applications.
Design Concerns
Model Kind
The model kind used to illustrate the Structure Viewpoint is the UML class diagram shown in Figure SDS-CLS (static view). It depicts base classes comprising the QP/C++ Framework and their specializations in the QP/C++ Application shown at the bottom of @ Figure SDS-CLS.
The Sub-Layer View in the Structure Viewpoint focuses on the internal layering of the QP/C++ Framework, which has the following objectives:
QEP Event Processor
Description
QEP Event Processor sub-layer of QP/C++ Framework (see Figure SDS-CLS [10]) implements Events and passive State Machines.
Backward Traceability
Forward Traceability (truncated to 1 level(s))
QF Active Object Framework
Description
QF Active Object Framework sub-layer of QP/C++ Framework (see Figure SDS-CLS [20]) implements Active Objects and Time Events.
Backward Traceability
Forward Traceability (truncated to 1 level(s))
The Class View in the Structure Viewpoint focuses on the following key design concerns:
QEvt event class.
Description
The QP::QEvt class (see Figure SDS-CLS [11]) represents both immutable and mutable events in the QP/C++ Framework. It can be instantiated directly (concrete class), in which case it represents events without parameters. QP Applications can also inherit and extend QP::QEvt to add custom event parameters.
Event Attributes
The QP::QEvt class has the following data attributes:
Backward Traceability
Forward Traceability (truncated to 2 level(s))
QAsm Abstract state machine class.
Description
The QP::QAsm class (see Figure SDS-CLS [12]) is the abstract base class (ABC) for all state machines in the QP/C++ Framework. The QP::QAsm class specifies the abstract state machine interface.
State Machine Interface
The state machine interface defined in the QP::QAsm class consists of:
State Machine Attributes
Safety Function
In the stable state configuration (between the RTC steps), the subclasses of QP::QAsm use the temporary attribute for the Duplicate Inverse Storage of the QP::QAsm::state attribute.
Backward Traceability
Forward Traceability (truncated to 2 level(s))
QHsm State machine class.
Description
The QP::QHsm class (see Figure SDS-CLS [13]) derived from QP::QAsm implements the state machine interface init() and dispatch() according to the State Machine Implementation Strategy optimized for manual coding. QP::QHsm provides 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, but it is also supported by the QM modeling and code-generation tool↑.
Safety Function
The QP::QHsm class implements the Fixed Loop Bound technique for all not explicitly terminated loops. This prevents malformed state machine specifications (from the QP/C++ Application layer) from "hanging" or crashing the event processor.
Backward Traceability
Forward Traceability (truncated to 2 level(s))
QMsm State machine class.
Description
The QP::QMsm class (Figure SDS-CLS [14]) derived from QP::QAsm implements the state machine interface init() and dispatch() according to the State Machine Implementation Strategy optimized for automatic code generation. QP::QMsm provides support for all hierarchical state machine features listed in SRS_QP_SM_20. This class is designed for automatic code generation, and requires the QM modeling and code-generation tool↑.
Safety Function
The QP::QMsm class implements the Fixed Loop Bound technique for all not explicitly terminated loops. This prevents malformed state machine specifications (from the QP/C++ Application layer) from "hanging" or crashing the event processor.
Backward Traceability
Forward Traceability (truncated to 2 level(s))
QActive Active Object class.
Description
The QP::QActive class (Figure SDS-CLS [23]) is a base class for the derivation of concrete Active Objects in the QP/C++ Application. QP::QActive inherits QP::QAsm, which means that an Active Object in QP can be treated as a state machine with the standard interface. QP::QActive implements this interface by delegating to the QP::QHsm state machine implementation.
Active Object Priority
QP::QActive owns the unique priority attribute, which must be in the range 1..QF_MAX_ACTIVE, inclusive, and conforms to the QP/C++ Framework priority numbering scheme.
Auxiliary Priority
QP::QActive has the auxiliary priority attribute, which is a number in the range 0..255, and its use depends on the underlying real-time kernel.
Event Queue
QP::QActive owns the event-queue attribute, whose type depends on the underlying real-time kernel. Therefore, the event-queue type is compile-time configurable. When QP is used with one of the built-in kernels (QV, QK, QXK), the QActive event queue is configured to be QP::QEQueue. However, when the QP/C++ Framework runs on a 3rd-party RTOS, typically the RTOS's message queue is adapted as an event queue.
The event queue for Active Objects requires multiple-write, but only single-read capability. Also, blocking the queue is only needed when the event queue is empty, but not when it is full. Finally, the Active Object queue in the QP/C++ Framework passes only pointers to events. Standard RTOS message queues are significantly more complex than required by Active Objects because they typically allow multiple-write as well as multiple-read access and often support variable-length data (not only pointer-sized data). Usually, message queues also allow blocking when the queue is empty and when the queue is full, and both types of blocking can be timed out. Naturally, all this extra functionality, which you don't need in the QP/C++ Framework, comes at an additional cost in CPU and memory usage.
Thread of Execution
QP::QActive has the compile-time configurable thread attribute, whose type depends on the underlying real-time kernel. When QP is used with one of the built-in kernels (QV, QK, QXK), the QP::QActive thread attribute can be used to hold the MPU settings. When the QP/C++ Framework runs on a 3rd-party RTOS, the thread attribute might hold the RTOS-specific thread object, which could be the Thread Control Block, or just a thread handle.
OS-object
QP::QActive has the compile-time configurable OS Object attribute. The OS-object attribute is
Backward Traceability
Forward Traceability (truncated to 2 level(s))
QMActive Active Object class.
Description
The QP::QMActive class (Figure SDS-CLS [24]) derives from the QP::QActive base class, so it inherits all its properties. The only difference is that QP::QMActive implements the state machine interface by delegating to the QP::QMsm state machine implementation.
Backward Traceability
Forward Traceability (truncated to 2 level(s))
QTimeEvt time event class.
Description
The QP::QActive class (Figure SDS-CLS [23]) is a base class for the derivation of concrete Active Objects in the QP/C++ Application. QP::QActive encapsulates the unique priority, event-queue, execution context, and state machine for the Active Object. QP::QActive inherits QP::QAsm, which means that an Active Object in QP can be treated as a state machine with the standard interface. QP::QActive implements this interface by delegating to the QP::QHsm state machine implementation.
Backward Traceability
Forward Traceability (truncated to 2 level(s))