Skip to main content

Step 7: Compose Modules

After successful scanning the declarations, all modules are available for further use, so that an example application can be composed. Therefore the modules are added to the module tree of the project. For this the view Modules must be opened.

In the first step the toplevel module Room has to be added to the tree.

Figure 59. Add toplevel module to module tree
Add toplevel module to module tree


The Module dialog opens and offers all available toplevel modules. In this dialog, the corresponding icons are displayed which were defined in the image pool, as well as the texts from the text lists. Now the module "Room" can be selected and added to the module tree.

Figure 60. Dialog: "Add Module"
Dialog: "Add Module"


Now the editor of the toplevel module can be opened by double-clicking Room in the module tree. A target application for code generation must be selected on the Toplevel tab. The tasks which have been declared in the module declaration are displayed in the field Standard Tasks.

Figure 61. Settings of the "Room" module
Settings of the "Room" module


Analogous to the steps above the submodule Light can be added to the module tree. Due to the multi slot definition in the declaration of the room, up to three lights can be added. The values for maxLightValue and Speed can be parameterized on the Parameters tab of the editor of the Light module. In the I/O editor the output Brightness is mapped to a local variable uiBrightness for our example.

Figure 62. Settings of the "Light" module
Settings of the "Light" module


Below the newly added Light, a module Switch must be added. In the instance editor of the Switch module, all parameters and I/Os, which are defined in the module declaration, are available. For our example the local variable xPushSwitch is mapped to the input variable xIn. The output of the simple light is mapped to the local variable xSimpleOn.

Figure 63. Settings of the "Switch" module
Settings of the "Switch" module


In a last step of our example a LightSimple with a SwitchSimple are added to the module tree. The output of the simple light is mapped to the local variable xSimpleOn. The input of the simple switch xPushSimpleSwitch is mapped to the variable xPushSimpleSwitch.

Figure 64. Example composition module tree
Example composition module tree


At the end, the project has to be generate by use of the command Generate. After the download to a device the example can be tested by changing the value of xPushSwitch. For dimming the value of uiBrightness should increase slowly and by tapping, its value is directly set to 0 or to the maximum. Changing xPushSimpleSwitch directly switches the output of the corresponding light.

Finally it has to be mentioned, that the last steps, of composing the modules can be done in any combination, without loosing the functionality of the generated code.