Please take care when modeling activities with decision/merge nodes. The code generator will map decision/merge constructs to if/else chains, so only control flows which can be expressed by if/else chains are supported.
Have a look at the following diagram:
This diagram is invalid.
The reason is that Decision1 can be thought of as an if/else, and Merge2 will close this if/else. There are two paths to take in an if/else, in this case the path beginning with Action1 and the path beginning with Action3.
The control flow from Decision2 to Merge1 violates this mapping to if/else, because you're not allowed to jump between paths in C without using goto.
The code generator will warn you if it encounters such an issue:
The code will not be correct until you resolve this issue in your model.
Some Examples How to Model If - Else - Paths
This example is another invalid approach for modeling an if - else if path, similar to the example shown above:
In the diagram, you can see the code that would result from this model, if code generation would be performed. Again, a goto statement would be needed, which is invalid.
Apart from that, a merge node is missing before final node.
One possible approach of modelling if - else paths could be:
Another possible approach of modelling if - else paths could be:
Ordered Decisions / Solution 3
(available since version 2.2)
This is basically the approach of Solution 2 but with version 2.2 the names of the guards will be used for ordering the if ... elseif ... blocks.
By simply numbering the Control Flows 1, 2, 3,... (in the name field) you can change the position/priority in the if ... elseif ... block