C++ Type and Component Code Generation
This Overview Article has been written for Version 2.1 of the DATAFLOW Software. For Previous Releases use the version selection in the navigation bar at the top of this page.
The DATAFLOW Code Generator can generate C++ classes for Data Types and Software Components defined in the DATAFLOW Designer Project.
Generated Artifacts
The Code Generator can generate classes for the following artifacts:
- Active Container
- Active Part
- Active Interrupt
- Startup Code
- Data Pool (New V2.0)
- Runtime Statistics Configuration (New V2.0)
- Identifier (for Protocols and Signals)
- Enumeration
- Protocol
- Custom Type (New V2.0)
- Struct (New V2.0)
- Buffer (new V2.1)
Active Container
For Active Containers, a class is generated that instantiates all child components (other containers as well as Active Parts and Active Interrupts). The class will call all initialize and startup methods on all children. All DATAFLOW Channels inside the container will also be generated and connected during initialization of the container.
History: Added in V1.0
Active Part
For Active Parts, a class is generated that contains the main execute method. That method calls the correct user defined handler for any received protocol and expired timer. Handlers for initialization and startup are called as well.
To implement the user defined handlers, a handler class is generated. If such a class exists, it is not overwritten by default. See configuration of the overwrite behavior.
History: Added in V1.0
Active Interrupt
For Active Interrupts a static class is generated that contains the interrupt handler(s). That method will notify the runtime on entry and exit of the interrupt service routine (ISR) and calls the user defined handler that implements the behaviour of the ISR. Handlers for initialization and startup are called as well.
To implement the user defined handlers, a handler class is generated. If such a class exists, it is not overwritten by default. See configuration of the overwrite behavior.
History: Added in V1.0
Startup Code
For every build configuration a static class named StartupController is generated that contains the main method for the application. A StartupControllerHandler is generated that provides hook methods called at certain stages of the application and runtime startup.
History: Added in V1.0
Data Pool
All static memory used by the DATAFLOW runtime and Imt.Base libraries is provided as data pools. These pools are allocated outside of the Imt.Base library. The generator generates the implementation for all such data pools to be included in the application code.
History: Added in V2.0
Runtime Statistics Configuration
When the Statistics feature of the DATAFLOW runtime is used, a configuration header must be provided to calibrate the idle tick count of the runtime on the specific target hardware. In addition, an implementation of the Free Running Timer must be created. The generator can generate both files so the developer can adapt them according to the needs of the specific target hardware.
History: Added in V2.0
Identifier
For every protocol and signal in the model, a constant is defined in the ProtocolIdentifiers.h header file. For protocols, a class is generated as well (see below). For signals, the identifier is the only generated artifact.
History: Added in V1.0
Enumeration
For every enumeration in the model, an enum is generated. The class contains all enumerators as constants.
Note:
For C++98 the enum is nested inside a struct to avoid placement in the parent namespace. For C++11 and newer, enum class is used instead.
History: Added in V1.0
Protocol
For every protocol in the model, a class is generated. The protocol will contain all fields defined in the model. It provides compare and assignment operators and can be serialized and de-serialized using the Imt.Base.Core.Serialization package.
History: Added in V1.0
Custom Type
For every cusom type in the model, a class is generated. The class can be used to create strongly typed values of the given custom type. The class provides compare and assignment operators and can be serialized and deserialized using the Imt.Base.Core.Serialization package.
History: Added in V2.0
Struct
For every struct in the model, a struct is generated in the target code. The struct will contain all fields defined in the model. It provides compare and assignment operators and can be serialized and de-serialized using the Imt.Base.Core.Serialization package.
History: Added in V2.0
Buffer
Buffers are arrays of a native or user defined data type with a static size. Buffers are used to exchange data between active parts that must not be sent over the DATAFLOW Runtime event handling. This may be the case for specific timing requirements or for large data that would lead to an event data pool outside of the memory constraints for the specific target hardware.
History: Added in V2.1
Configuration
The source code generation can be configured in the Build Configuration on the Generator Page.
There are 2 groups of values that will be used to configure the generated source code:
- Source Paths
- Source Code
Source Paths Group
In this group, the root path for all generated source code can be configured.
NOTE: The configured folder must not overlap with any other output folder for this or any other build configuration.
When 'Clear Output Directory' is checked, all contents of the folder and all its sub-folders will be erased before code is generated. Warning: This will delete all user defined code in these folder and all sub-folders.
Source Code Group
In this group, the source code that will be generated can be defined.
The generation of source code for components, startup code and data types can be enabled independent of each other. If none is enabled, no unit test code will be generated.
Advanced Configuration
When the button on the upper right corner of the build configuration is toggled, the advanced generator configuration is shown. Please refer to the Build Configuration reference article for a detailed description of all advanced generator settings.
Source Code Coding Style
The coding style configuration of the Build Configuration as described in the article Coding Style Configation will be applied to all generated source code.
Add User Defined Code
The generated source code contains all features known to the DATAFLOW Designer. This does not include behavior of active parts and active interrupts. Therefore it is required for the user to add additional code to these software items. For that purpose, the generator will generate a ...Handler class (*.cpp and *.h file). This file is not overwritten when it already exists on code generation. Therefore the generator will never overwrite any user code.
Note:
Do not modify any other generated files. These files will be overwritten on code generation and all your changes will be lost.
Required Module: DATAFLOW Code, DATAFLOW Frames
This Article has been written based on V2.1.1 of the DATAFLOW software.
Latest update 2023-05-31 by WUM.
Comments
0 comments
Please sign in to leave a comment.