Synchronize Model Changes with existing Code
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.
This article explains, how changes can be applied to the generated code during the product lifecylce.
Problem
A common task when working with the DATAFLOW Designer and the Code Generator is the following: A change must be applied to a project for which code has already been generated and developers have written user code in handler files, added unit tests etc.
Solution
The best way to apply such a change depends on the type of change:
- Data Types
- Components
- Ports
- Timers
- Buffers
For each case listed above, this article explains what needs to be done manually and what is done automatically on code generation.
Data Types
Data Types are always overwritten on code generation. Manual changes may be required in the user code that references these types:
Add new Data Types
Adding a new Data Type does not require any changes in user code. The code generation can be performed and the required files including unit tests for any added type will be created. The new type can now be assigned to ports (see below) or used as nested type in other data types.
Manual Changes: No additional changes are required.
Rename/Move existing Data Type
When an existing type is renamed, the files for that type will be updated accordingly. A dialog will be shown on rename to rename/move any generated files in the filesystem.
Manual Changes: If the data type has been moved to another namespace, make sure that any files that are still existing at its original location in your version control system are removed. Even when the files have been moved/renamed automatically (see above), the change must be added to your version control system. This may lead to compile errors if user code contains includes using the old name. Make sure to update all user code that uses the type.
Change Existing Data Type
When an existing type is changed (e.g. by adding or removing fields in a protocol), the files for that type will be updated accordingly including unit tests.
Manual Changes: This may lead to compile errors if user code is accessing these files. Make sure to update all user code that uses the type.
Remove existing Data Type
When an existing type is removed, the files for that type will no longer be generated.
Manual Changes: Make sure that any files that are still existing at its original location in your version control system are removed. This may lead to compile errors if user code is accessing these files. Make sure to update all user code that uses the type.
Components
Components consist of generated and user code, so the user code part needs special attention when a model change is applied:
Add new component
When a new component is defined, the files for the new component will be created on code generation. Any parent container will be updated so that the new component is instantiated, initialized and started and all channels are connected as defined in the model.
Manual Changes: No additional changes are required.
Rename/Move existing component
When an existing component is renamed, the files for that type will be updated accordingly. A dialog will be shown on rename to rename/move any generated files in the filesystem.
Manual Changes: If the component has been moved to another namespace, make sure that any files that are still existing at its original location in your version control system are removed. Even when the files have been moved/renamed automatically (see above), the change must be added to your version control system. The class name in the handler file is not changed automatically to avoid loosing any user code and must be updated manually to avoid compiler errors.
Remove existing Component
When an existing component is removed, the files for that component will no longer be generated.
Manual Changes: Make sure that any files that are still existing at its original location in your version control system are removed. This may lead to compile errors if user code is accessing these files.
Ports / Timers / Buffers
Ports define the protocols, signals and buffers generated for a component. All input ports are merged on code generation, so it does not matter if an input port is added/removed or a protocol is added/removed on an existing port.
Changes may affect the user code of the component:
Add new Input Port / Timer / Buffer
The new protocol, signal, timer event or buffer will be added to the active part class by the code generator.
Manual Changes: The generated code will call a new handler method in the handler class (user code). This must be added to that class. This can be done manually or with the sync button in the built in source code editor.
To perform an automatic sync, follow the following steps:
- Check in all code of the effected active part.
- Edit the active part
- Select the handler header file in the internal source code editor.
- Click the sync button.
- Select the handler source file
- Click the sync button.
The new handler method is now added to the files. Make sure to check the result of the merge to avoid loosing any other code in the process.
Remove existing Input Port / Timer
The generator will remove the handling for the removed signal/protocol/timer event. The existing handler method will no longer be called.
Manual Changes: Remove the handler method in the user code. There is no automatic sync in the current software version.
Rename existing Buffer, Timer or Output Port
When an existing buffer, timer or output port is renamed, the according accessor and send methods will also be renamed in the generated code. User code that uses the existing methods will no longer compile.
Manual Changes: Change the user code to use the new name for these methods. There is no automatic sync in the current software version.
Change type of timer or buffer
When an existing buffer or timer is changed, the according accessor methods may change. User code that uses the old methods may no longer compile.
Manual Changes: Change the user code to use the new methods.
Timers: Start/Stop differs between one shot and periodic timers.
Buffers: Depending on direction and enabled events, the available methods may change.
Required Module: DATAFLOW Designer
This Article has been written based on V2.1.3 of the DATAFLOW Designer software.
Latest update 2023-09-12 by WUM.
Comments
0 comments
Please sign in to leave a comment.