Statechart Implementation
Statecharts are used to define the behavior of a Control Activity. For the purposes of code generation in MicroC and our discussion here, a single Statechart is considered to be the Statechart directly connected to a Control Activity, all of its sub-charts, and the generics instantiated within them. In short, all the states under the root are represented by the control Activity.
For example, for the control Activity A11_CTRL, the following two functions will be generated:
The bodies of the generated code for these functions resembles the following:
Note that the function cgActivity_A11_CTRLcnt1() simply calls cgDo_A11_CTRLcnt1(). A more detailed discussion of the cgDo_… function is found below.
● Further Optimization: This might be changed, as the wrapping function, “cgActivity_A11_CTRLcnt1” in the above example, could be dropped.
● Use the Compilation Profile >Setting >General >Use Macros flag to control function generation vs. pre-processor macro.