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 Framework classes in QP Applications and is used to address the following concerns:
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 QP Framework and their specializations in the QP Application shown at the bottom of Figure SDS-CLS.
The Sub-Layer View view in the Structure Viewpoint focuses on the internal layering of the QP Framework, which has the following objectives:
QEP Event Processor
Description
QEP Event Processor sub-layer of QP 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 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 QEvt class (see Figure SDS-CLS [11]) represents both immutable and mutable events in QP Framework. It can be instantiated directly (concrete class), in which case it represents events without parameters. QP Applications can also inherit and extend QEvt to add custom event parameters.
Event Attributes
The QEvt class has the following data attributes:
Backward Traceability
Forward Traceability (truncated to 2 level(s))
QAsm Abstract state machine class.
Description
The QAsm class (see Figure SDS-CLS [12]) is the abstract base class (ABC) for all state machines in QP Framework. The QAsm class specifies the abstract state machine interface.
State Machine Interface
The state machine interface defined in the QAsm class consists of:
State Machine Attributes
Safety Function
In the stable state configuration (between the RTC steps), the subclasses of QAsm use the temporary attribute for the Duplicate Inverse Storage of the QAsm::state attribute.
Backward Traceability
Forward Traceability (truncated to 2 level(s))
QHsm State machine class.
Description
The QHsm class (see Figure SDS-CLS [13]) derived from QAsm implements the state machine interface init() and dispatch() according to the State Machine Implementation Strategy optimized for manual coding. 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 QHsm class implements the Fixed Loop Bound technique for all not explicitly terminated loops. This prevents malformed state machine specifications (from the QP Application layer) from "hanging" or crashing the event processor.
Backward Traceability
Forward Traceability (truncated to 2 level(s))
QMsm State machine class.
Description
The QMsm class (Figure SDS-CLS [14]) derived from QAsm implements the state machine interface init() and dispatch() according to the State Machine Implementation Strategy optimized for automatic code generation. 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 QMsm class implements the Fixed Loop Bound technique for all not explicitly terminated loops. This prevents malformed state machine specifications (from the QP Application layer) from "hanging" or crashing the event processor.
Backward Traceability
Forward Traceability (truncated to 2 level(s))
QActive Active Object class.
Description
The QActive class (Figure SDS-CLS [23]) is a base class for the derivation of concrete Active Objects in the QP Application. QActive inherits QAsm, which means that an Active Object in QP can be treated as a state machine with the standard interface. QActive implements this interface by delegating to the QHsm state machine implementation.
Active Object Priority
QActive owns the unique priority attribute, which must be in the range 1..QF_MAX_ACTIVE, inclusive, and conforms to the QP Framework priority numbering scheme.
Auxiliary Priority
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
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 QEQueue. However, when the QP 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 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 Framework, comes at an additional cost in CPU and memory usage.
Thread of Execution
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 QActive thread attribute can be used to hold the MPU settings. When the QP 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
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 QMActive class (Figure SDS-CLS [24]) derives from the QActive base class, so it inherits all its properties. The only difference is that QMActive implements the state machine interface by delegating to the QMsm state machine implementation.
Backward Traceability
Forward Traceability (truncated to 2 level(s))
QTimeEvt time event class.
Description
The QActive class (Figure SDS-CLS [23]) is a base class for the derivation of concrete Active Objects in the QP Application. QActive encapsulates the unique priority, event-queue, execution context, and state machine for the Active Object. QActive inherits QAsm, which means that an Active Object in QP can be treated as a state machine with the standard interface. QActive implements this interface by delegating to the QHsm state machine implementation.
Backward Traceability
Forward Traceability (truncated to 2 level(s))