Hello, everyone.
Let's see how to create a composite function block.
In the Solution Overview,
double click on your solution name to open the node.
Right click on Composite and select New Item.
Enter the name of the Composite you want to create ...
... and click on OK.
In our case, we want to implement a simple calculator.
By default, an interface is created.
Let's modify it by removing the INIT event.
Rename the event REQ by event_sub.
This will be the event triggered to do the subtraction.
Delete also the event INITO ...
... and rename the event CNF by event_result.
This event will fire out ...
... when the mathematical operation is done.
Then, rename the existing variable QI by IN1 ...
... and the variable QO by result ...
... both with the type REAL.
Next, open the Composite tab,
press ctrl+w ...
... and type the name of the function block called SUB.
Right click on this icon and select Interface Editor ...
... to change the type of variables in REAL ...
... and click on OK.
Here is a little tip.
In order to create an input without going to the Interface tab,
right click on the desired variable and select Add Input.
By clicking in the text field,
you can change the existing name and type.
A wizard opens.
Check the box to link the variable ...
... with the corresponding event.
Now we will implement the addition.
We can use the basic function block SUM ...
... created in the previous video ...
... or we can use the function block ADD ...
... present in the library.
Right click on the event_IN and select Add Input.
Rename by event_SUM.
A wizard opens to associate the event ...
... with the input variables.
Then link the variables IN1 and IN2 ...
... with the new function block.
And don't forget to link the event_sub.
In order to choose which result to display...
... depending on which mathematical operation has been triggered,
we can use the function block called DS_SELECT.
Increase the number of inputs by extending the block.
Right click on this icon and select Interface Editor ...
... to change the type of variable in REAL ...
... and click on OK.
Finally, link the different variables and events ...
... to the function block DS_SELECT ...
... and save.
Here is a little tip.
Right click on the editor,
select Frame and Add Frame in order to organize your function blocks.
Double left click on the frame to open the properties window.
Here, you can add text,
modify the font size,
change the color, etc.
Here is an example of organization.
To test your composite function block,
you can find the method in the video,
"How to create a new solution ...
... and add a function block from library".
That's it.
Now you know how to create a composite function block ...
... composed with multiple function blocks.