Two projects, two tools, many insights
Author: Joachim Terasa, coming GmbH
Contribution – Embedded Software Engineering Congress 2017
Two tools for MBSE, which differ in their characteristics and unique features, nevertheless appear to have a great deal in common at first glance. In practice, some of these similarities prove to be quite relevant. In the cases considered here, the most striking differences are the polled state machines versus the event-driven state machines, which lead to incomparable behavior of the generated embedded system.
MBSE? – MBSE!
Model-based software development for embedded systems is a fact and has been a reality for many years.
Conventional – Model-based
In conventional development, such as coding in C/C++, there has always been a necessary decision regarding a toolchain, including version control, editor, compiler, linker, debugging tools, and testing tools. The link in this chain that is the focus here is the editor.
From editor to modeling tool
Choosing a suitable editor is not critical. Its use always leads to one defined result: the source code. The programmer determines its content. When using a modeling tool, manually created source code is also used within the model. Even if tools generally adhere to standards like UML, the leeway these standards allow is considerable when it comes to generating code from graphical model components. Two examples of modeling tools will demonstrate that superficial similarity is insufficient. Based on extensive practical experience in several projects over the past five years, these two tools are presented side-by-side:
radCASE / Manufacturer: IMACS GmbH, Germany
QP/QM framework / Manufacturer: Quantum Leaps, LLC, USA
Similarities
Both …
- are modeling tools for embedded systems that generate C code from the model, which is directly targetable.
- They are based on UML and use hierarchical state machines as an essential code-generating graphical component.
- are object-oriented.
- support a form of tasking.
- offer the possibility to break projects down into smaller parts.
- offer the possibility to set up a simulation environment on the PC.
- Supports target debugging.
Detailed comparison of the "similarities"„
The aforementioned similarities are superficial, but would be sufficiently informative in a selection process using a feature list.
How does the software communicate with the hardware?
Keywords: Hardware connectivity / Access to I/O resources / Multiple instances of a class. radCASE requires an API for each piece of hardware, which has a clearly defined interface to the application. This makes the model transferable to any hardware with an existing API. Hardware resource allocation takes place outside the actual software in the "Entity Tab." Here, logical resources within the software and instances are linked to physical resources. Adaptation to hardware changes is possible solely by modifying the Entity Tab, without any code changes.
A BSP must be created for QP. This has no predefined fixed form or interface.
Each object must be designed for a maximum number of instances. Access to physical resources is differentiated by an instance number. A hardware change also necessitates a software change.
How do state machines work?
According to UML, a state contains an entry and an exit action. A transition has a triggering event, a guard condition, and an action (Event[Guard]/Action). Both tools deviate from this (see the accompanying figure)., PDF).
radCASE recognizes an additional Do action in states and only [Guard]/Action in transitions. Actions are C code fragments that are inserted into the code during code generation (see the corresponding figure)., PDF).
In QP/QM, a transition has an Event/Action, which can be extended to the UML form Event[Guard]/Action with a simple workaround. Additionally, there are so-called internal transitions. Actions here are also C code fragments that are mapped to local subroutines during code generation.
The underlying runtime systems are fundamentally different.
State machines in radCASE cyclically poll for state changes based on the guards. The Do action within an active state is executed cyclically. Multiple state machines can exist for each object. The system always has a baseline load due to the polling process.
QP relies on a fully asynchronous concept. Events—messages containing both an identifier and content—are sent either system-wide or selectively. The recipient is always the state machine of an AO; without it, nothing happens. Internal transitions do not result in a state change but execute a local action. The runtime system incorporates a complex event queue mechanism. A state machine does nothing without an event.
Object orientation
Both tools use a textual tree structure to define classes.
QP/QM allows anything for methods and attributes that the compiler used permits. Furthermore, a state machine must be part of a class. Methods are subroutines or functions in C. The instances of a class are called "Active Objects" and are the smallest units of tasking in QP.
radCASE uses the usual visibility types for methods, plus the "Permanent" type, which adds the method to a list of methods to be executed cyclically. These methods form the basis of cooperative tasking in radCASE. A separate type concept is used for attributes. Each variable ("element") contains additional information about its location in code or memory segments, i.e., whether it is constant, persistent, analog I/O, digital I/O, or variable, among other things. All types have metadata, such as unit, representation format, upper and lower bounds, description, and comments, to facilitate their use in GUI components.
Tasking
radCASE uses a round-robin approach, where all methods marked as "permanent" are activated cyclically. State machines are treated identically to methods. Different cycle times are possible. Cooperative tasking is fundamental and must be considered when implementing the methods.
The smallest unit of tasking in QP is the Active Object, where the state machine is the central controlling element; nothing works without it. Actions are performed, events are generated, and calculations are carried out solely based on a triggered event. Each AO receives a unique priority that determines the order in which events are processed.
GUI
Both tools offer the possibility of development with simulation using a GUI on a PC.
QP/QM leverages the capabilities of VC++ with a C API for connecting to the target software. This allows for the simulation of the complete target hardware, including the display of variables, outputs, and the control of inputs. The simulation then serves as a testing tool for the application.
radCASE takes this a step further. It supports local displays on the controller with various control and operating mechanisms. Remote GUIs for PC or web are also supported. These can be used for simulation or as a visualization and user interface via a data connection during operation. These GUI elements are integral parts of the classes. Each GUI element is instantiated with its associated object and displayed via a higher-level GUI, without requiring any copying or modification. Without a GUI, a standard interface is available with access to all variables, I/O values, and animated state machines.
Debugging
In both tools, the built-in debugging capabilities are based on communication with an external computer.
For debugging, radCASE utilizes its extensive GUI functions, including a triggerable record/replay function. This functionality runs entirely on the PC, allowing for targeted isolation of error situations.
QP uses an additional package called QSpy, which reports events and state transitions on the target to a PC equipped with a QSpy client. User-defined output can be inserted. The client outputs the data in a readable format with timestamps. This trace can be filtered at compile time according to various criteria. Nevertheless, the analysis remains complex due to the still immense amount of data.
denomination
radCASE uses "libraries" for this purpose, which typically contain type or class definitions. Libraries are included using "include".
QP/QM offers the option of outsourcing a package to an "External Package". The smallest unit that can be outsourced is therefore a package.
Conclusion
QP/QM presents itself as a speed-optimized environment – complete, but without many additional features. radCASE only has polled state machines, but offers several convenient functions that can greatly simplify the development process.
Modeling – MicroConsult Training & Coaching
Do you want to bring yourself up to date with the latest technology?
Then find out more here MircoConsult offers training courses/seminars/workshops and individual coaching on the topic of modeling/embedded and real-time software development.
Training & coaching on the other topics in our portfolio can be found here. here.
Modeling – Expertise
Valuable expertise in modeling/embedded and real-time software development is available. here Available for you to download free of charge.
You can find expertise on other topics in our portfolio here. here.
