This Guide 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 Software provides a Code Generator that can generate source code for components and data types in the Designer model. It can also generate the required startup code to use the components with the DATAFLOW Runtime. The option to generate unit tests for components and data types is also provided.
Define Build Configuration
The code generator requires a set of configuration values that define, for wich model elements code must be generated, where this code shall be generated and how it must be formated. This is done by defining a Build Configuration on a component or type group. A model can contain any number of build configuration as long as they are not nested. Each build configuration will generate code for the model element it has been assigned to and all child elements below that model element.
To define a build configuration, select the model element, press the right mouse button and select Build Configuration / Define from the context menu:
Enter a name for the build configuration and click the Add button:
Once created, the Project Setting dialog will be opened and the configuration can be adjusted as required for the generated code.
In this guide, we will only adjust the most important settings. All settings in this dialog are documented in the Project Settings Reference Article.
The Display Name of the Build Configuration can be changed in this dialog at any point. It is only used in the Designer to identify a build configuration. It is recomended to use unique names for all build configurations in a system.
A build configuration can be disabled by unchecking the 'Enabled' checkbox. No code generation will be performed for a disabled build configuration. This can be used to avoid overwriting manual changes or for testing purposes.
The platform page is used to define the target platform for this build configuration. The values configured on this page will influence the other pages. Therfore this must be configured first. If changes must be made later, all other pages must be checked again.
The Runtime Architecture will define which runtime package will be deployed. Select to architecture of your target hardware.
The Runtime version defines with DATAFLOW Runtime packages will be deployed for an IDE toolchain and also will define which features of the Runtime will be avaliable for this software. Select the latest version for new projects.
The Target Platform will define which HAL or OS Wrapper package will be deployed. Select the your target hardware if avaliable. Otherwise select 'Custom'.
The Package option defines, if the software used the binary or source code packages of the DATAFLOW Runtime. This depends on the purchased DATAFLOW runtime packages.
This page can be used to customize the used Imt.Base packages. For the initial configuration, this can be left on default.
The Imt.Base Directory must be set to the correct location of the Imt.Base folder for the project structure. This folder will contain all Code provided by IMT.
On the Language page, select the 'Target Language' to use. This must be a Language Version that is supported by all used toolchain (cross compiler, unit test compiler etc.).
Set the 'Documentation Style' to the correct format according to your coding style so that the doxygen comments can be correctly parsed later.
Adjust the 'Root Path' for the generated source code to match your project structure. If required, define sub folders to separate component, data type, callbacks etc. If not required, clear all fields for the sub folder to generate everything into the root folder.
The other settings in this dialog can be used for fine tuning the code generation at a later stage or to use a custom code generator provided by IMT.
Select the 'Brace Style' that macthes your company standard and perform any other adjustment necessary.
If not sure, keep the defaults, this can be changed at any time.
If unit tests shall be generated for this project, check 'Generate Component Tests' and 'Generate Data Type Tests'.
Check 'Generate Custom Test Base Class' when MS Test is used as unit test framework (in V2.0 this is the only avaliable option).
Adjust the 'Root Path' for the generated unit tests to match your project structure. If required, define sub folders to separate component and data type tests or clear both fields if not required.
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.
Once the configuration is sabved (click the Confirm button), the project can be generated by clicking the 'Generate Code' button in the Home ribbon.
When there are errors in the build log, check your model and the build configuration and fix these.
Once the code is generated without an error, click 'Open Folder' to inspect the generated files to check if the location matches the required project structire. If not, adjust the paths and namespaces accordingly, delete the files and generate again untile the structure is correct.
Once you have started to edit the generated handler files, make sure to create a backup of the source code (e.g. by checking it into a version control system) before code is generated again. This is most important when paths or namespaces must be changed again.
Build Configuration on Type Group
A build configuration assigned to a type group will only generate data types. All options for component generation will be hidden for such a toolchain.
This can be used to avoid duplicate source code files in the generated data types:
- Create a Common build configuration on the root type group of the project
- Configure the desired language and coding style (see above)
- Configure the path for source code and unit test files (see above). Make sure that the path does not overlap with the other generated code paths.
- Check 'Generate Data Types' and 'Generate Referenced Data Types' for the common build configuration
- In the component build configurations, uncheck 'Generate Data Types' and 'Generate Referenced Data Types'
- Add the Common build configuration as a reference to each of the component build configurations.
This will generate the data types source code and unit tests only once to a Common folder. Each generated IDE project will reference the same code files instead of using its own duplicate of the same code.
Remove Build Configuration
To remove a build configuration from a component or type group, select the model element, press the right mouse button and select Build Configuration / Clear from the context menu:
Note: This will remove all configuration and all toolchains for this element.
Import/Export Build Configuration
To export a build configuration to a file, select the model element, press the right mouse button and select Build Configuration / Export from the context menu. The build configuration will be saved at the selected location in the local file system.
To import a build configuration to a component, select the model element, press the right mouse button and select Build Configuration / Import from the context menu. Select a previously exported build configuration and confirm.
Note: This will overwrite all previous build configuration for this element.
To generate IDE projects to build the code generated from a build configuration, one ore more toolchains can be added to a build configuration. This is explained in detail in the following article: Project generation for specific Toolchains
Required Module: DATAFLOW Code
This Article has been written based on V2.1.1 of the DATAFLOW software.
Latest update 2023-05-31 by WUE.