When generating code for Statemachines such as in the example below one would wonder why the code generated (shown on the left) does not meet the users expectations (shown on the right).
This is due to the Completion transitions and completion events defined in the UML Superstructure 2.4.1 which states:
...A completion transition is a transition originating from a state or an exit point but which does not have an explicit trigger, although it may have a guard defined. .... If the state is a composite state or a submachine state, a completion event is generated if either the submachine or the contained region has reached a final state and the state’s internal activities have been completed. This event is the implicit trigger for a completion transition. ...
Therefore the Embedded Engineer will omit the generation of the "test == 1" Transition since State1 is still active since State3 was not deactivated/exited.
Embedded Engineer will warn the user about this during code generation
(available since 3.1)
To resolve this we reccomend using one of the following solutions:
- Change the Transition from State1 → State2 to State3 → State2
- Add a Signal to the Transition to be triggered