<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.8" -->
<?xml-stylesheet href="https://sinelabore.com/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel xmlns:g="http://base.google.com/ns/1.0">
        <title>SinelaboreRT - wiki:manual</title>
        <description>Productivity for embedded software development</description>
        <link>https://sinelabore.com/</link>
        <lastBuildDate>Wed, 08 Apr 2026 00:03:48 +0000</lastBuildDate>
        <generator>FeedCreator 1.8</generator>
        <image>
            <url>https://sinelabore.com/lib/exe/fetch.php/favicon.ico</url>
            <title>SinelaboreRT</title>
            <link>https://sinelabore.com/</link>
        </image>
        <item>
            <title>1. SinelaboreRT Code Generator Manual</title>
            <link>https://sinelabore.com/doku.php/wiki/manual/editor_general</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;sinelaborert_code_generator_manual&quot;&gt;1. SinelaboreRT Code Generator Manual&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;wrap_center wrap_round wrap_info plugin_wrap&quot; style=&quot;width: 60%;&quot;&gt;
&lt;p&gt;
This documentation was generated by Pandoc from the PDF manual. In case of discrepancies, the PDF file is the authoritative source.
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;
&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;1. SinelaboreRT Code Generator Manual&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;sinelaborert_code_generator_manual&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;232-455&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit4&quot; id=&quot;overview&quot;&gt;1.1. Overview&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
This document serves as a tutorial on how to use the sinelabore code generator. It is intended for software developers who want to generate code from &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state machine diagrams or &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; activity diagrams.
&lt;/p&gt;

&lt;p&gt;
A &lt;em&gt;state machine&lt;/em&gt; shows the dynamic behavior of an application. It is a graph of states and transitions that describes the response to events, depending on the current state. State machines have been used for decades in hardware design. In recent years, they have also become increasingly popular in software development, especially in the embedded real-time domain. The use of state machines is popular in this domain because the behavior of devices can often be very well described using state machines.
&lt;/p&gt;

&lt;p&gt;
One important aspect of state machines is that their design can be directly transformed into executable code. This means that there is no break between the design and the implementation. This is especially important if the device under development must be certified (e.g., according to IEC 61508).
&lt;/p&gt;

&lt;p&gt;
&lt;em&gt;Activity diagrams&lt;/em&gt; show the control flow of an algorithm based on actions which describe the single steps making up the activity. In contrast to state machines, an activity maintains no state.
&lt;/p&gt;

&lt;p&gt;
Please note that the code generator is not certified in any way. It is your responsibility to test the generated code as required for your application domain.
&lt;/p&gt;

&lt;p&gt;
The way the code generator works is depicted in figure 1.1. From a state machine or activity model – either designed with an &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tool or the built-in editor&lt;sup&gt;&lt;a href=&quot;#fn__1&quot; id=&quot;fnt__1&quot; class=&quot;fn_top&quot;&gt;1)&lt;/a&gt;&lt;/sup&gt; – the code generator generates the complete code for the state machine or the activity.
&lt;/p&gt;

&lt;p&gt;
Generating state machine code from a model file called &lt;code&gt;oven.cdd&lt;/code&gt;, the command line to generate C code would look as follows:&lt;br/&gt;

&lt;code&gt;java -cp &amp;quot;path/to/codegen/*&amp;quot; codegen.Main -p CADIFRA -l c -o oven oven.cdd&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/function-codegen.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:function-codegen.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/function-codegen.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure 1.1: From design to code
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The code generator was built especially for embedded real-time developers. It focuses on just one task: code generation from state machine or activity diagrams. A command line tool and a configuration file are all that is needed.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Use the tool only for those parts of your software that benefit from state machine/activity diagram modeling and code generation. Use your existing development environment for all the other code. The code generator does not dictate an “all or nothing” approach as many other commercial tools.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The generated code is based on nested &lt;code&gt;switch/case&lt;/code&gt; and &lt;code&gt;if/then/else&lt;/code&gt; statements. It is easy to read and understand. The generated code will not cause any issues when using static code analyzers.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The code generator does not dictate how you design your system. Therefore, it is no problem to use the generated code in the context of a real-time operating system or within an interrupt service routine or in a foreground/background system.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The generation process can be influenced to meet specific needs.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;1.1. Overview&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;overview&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;456-3487&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit5&quot; id=&quot;what_is_new_in_this_version&quot;&gt;1.2. What is new in this version?&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The latest major release is version 6.5.2. A list of changes in previous versions is available in Appendix K.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Refactored core modules for better maintainability and consistency and improved test coverage.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved C++ code generation to eliminate unnecessary dynamic memory allocations.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;1.2. What is new in this version?&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;what_is_new_in_this_version&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:5,&amp;quot;range&amp;quot;:&amp;quot;3488-3835&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit6&quot; id=&quot;known_limitations&quot;&gt;1.3. Known Limitations&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions are fully supported for code generation, the built-in editor and test case generation purposes. But are ignored when generating state tables on Excel basis. This is an open TODO.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Simulation of a state machine with regions: Presently events with guards are sent to the simulation engine as string. Based on that input the simulator finds the transition to go and changes state accordingly. In machines with regions it might happen that in one region an event (e.g. $ev1$) has guard $[i==2]$ and in another region $[i&amp;gt;=0]$. To simulate the event $ev1$ with guard condition $i==2$ means that both events must trigger a transition but it is only possible to send exactly one event/guard statement – e.g. $ev1[i&amp;gt;0]$ – to the simulator. This means a state change happens only in one region – which is not correct and does not reflect what actually happens in the generated code! To overcome this problem, it would be necessary to &lt;em&gt;understand&lt;/em&gt; the semantics of the guard condition, which would be a major task and is not planned yet.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;1.3. Known Limitations&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;known_limitations&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:6,&amp;quot;range&amp;quot;:&amp;quot;3836-4924&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit7&quot; id=&quot;how_to_go_on_from_here&quot;&gt;1.4. How to go on from here?&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;em&gt;State machines:&lt;/em&gt; If you are not familiar with the state machine notation or need a refresh, consult Chapter 3. With the help of an application that allows you to interactively send events to a rather complex state machine, you can learn how state machines work. Furthermore, the elements of a state machine are briefly explained there.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Section 1.5 describes how to install the code generator on your computer.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Appendix B and following pages describe briefly how to create state diagrams with the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tool of your choice in a way that you can generate code from them. Within the samples folder, ready-made examples for all supported &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tools are available. Start by loading such an example, play with it, and regenerate the code.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Section 2 describes the different possibilities to influence the code generator.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; From Section 3.15 onwards, more advanced features like automated robustness tests, tracing, and interactive simulation are described.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Section 3.2 describes details of the different language backends and the execution model of the generated code.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; In Appendix A, different options are discussed on how to integrate the generated state machine into your code. Also take a look at the tools section in the appendix. It helps you to get started with a specific &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tool.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;em&gt;Activities:&lt;/em&gt; If you want to generate code from activity diagrams, read Chapter 4. It starts with a general introduction about activity diagrams and gives examples of how to use the various node types of activity diagrams.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;1.4. How to go on from here?&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;how_to_go_on_from_here&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:7,&amp;quot;range&amp;quot;:&amp;quot;4925-6504&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit8&quot; id=&quot;installation&quot;&gt;1.5. Installation&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
It is necessary to install both Sinelabore&lt;em&gt;RT&lt;/em&gt; and the state machine modeling tool of your choice. The order doesn’t matter. If you use the internal state machine editor, no &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; modeling tool is required.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;em&gt;Step 1:&lt;/em&gt; Sinelabore&lt;em&gt;RT&lt;/em&gt; is bundled as a Java jar file: No installation is required for the Sinelabore&lt;em&gt;RT&lt;/em&gt; jar file. An installer is also provided for Windows and Mac users. It installs an executable wrapper around the jar file, which can then be used like any other native &lt;abbr title=&quot;Graphical User Interface&quot;&gt;GUI&lt;/abbr&gt; program installed on your computer.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;em&gt;Step 2:&lt;/em&gt; Java Runtime Environment: The editor is completely written in Java. It can therefore run on different operating systems such as Windows, Linux, or MacOS. The required Java Runtime Environment (version 11 or higher recommended) is available for download here: &lt;a href=&quot;https://jdk.java.net&quot; class=&quot;urlextern&quot; title=&quot;https://jdk.java.net&quot; rel=&quot;ugc nofollow&quot;&gt;https://jdk.java.net&lt;/a&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;em&gt;Step 3:&lt;/em&gt; &lt;code&gt;Graphviz&lt;/code&gt; layout engine: The Graphviz layout engine is used internally and is only needed if you want to use the built-in visual state machine editor. Install the version for your operating system from here: &lt;a href=&quot;http://www.graphviz.org/&quot; class=&quot;urlextern&quot; title=&quot;http://www.graphviz.org/&quot; rel=&quot;ugc nofollow&quot;&gt;www.graphviz.org/&lt;/a&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
See also the getting started articles on the website.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;1.5. Installation&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;installation&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:8,&amp;quot;range&amp;quot;:&amp;quot;6505-7672&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit9&quot; id=&quot;limitations_in_the_demo_version&quot;&gt;1.6. Limitations in the Demo Version&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The demo version is fully functional. It is only limited in the following ways:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; the number of possible states and transitions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; the copyright notice in the generated code cannot be changed&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The demo version is intended for evaluation purposes only. It is not allowed to use the generated code for product development.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;1.6. Limitations in the Demo Version&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;limitations_in_the_demo_version&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:9,&amp;quot;range&amp;quot;:&amp;quot;7673-8048&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit10&quot; id=&quot;command-line_and_generator_flags&quot;&gt;2. Command-Line and Generator Flags&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;2. Command-Line and Generator Flags&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;command-line_and_generator_flags&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:10,&amp;quot;range&amp;quot;:&amp;quot;8049-8099&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit11&quot; id=&quot;overview1&quot;&gt;2.1. Overview&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The Code Generator is a command line tool and can be fully controlled by a number of command line parameters and a configuration file. The code generator can be invoked as follows:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;%java -cp &amp;quot;path/to/codegen/jar/file/*&amp;quot; codegen.Main
SinelaboreRT codegen version xxx
Usage: java -cp &amp;quot;PATH-TO-JAR/*&amp;quot; codegen.Main [-xls] \\
[-gencfg] [-doxygen] [-Trace] [-verbose] [-U configfile][-t route:to:class] \\
[-l cppx|cx|SSC|java|swift|csharp|lua|python] [-A] [-s|-S|-E] [-c|-c1] \\
[-p EA|MD|CADIFRA|UMODEL|SSC|ASTAH|VP|Modelio|MM|PAPYRUS] [-o outfilename] modelfile&lt;/pre&gt;

&lt;p&gt;
A real command line to generate C-code from a model created with the integrated state diagram editor on Windows might look like as follows:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;D:\&amp;gt;c:\jdk-11\bin\java.exe -cp &amp;quot;c:\sinelaboreRT5.0\bin\*&amp;quot; codegen.Main -p ssc 
-o manual manual.xml
Config path: D:\\codegen.cfg
Starting robustness tests of state machine ...
State names: ..............
Machine hierarchy: ........
Machine height = 1
Transitions: ..............
Default states: ...........
Final states: .............
Choices: ..................
No. of children in composites: ...
Connectivity of states: ...
Can&amp;#039;t find the License.txt file or invalid file. Codegen is running in demo mode
Expected license file location: /C:/sinelaboreRT5.0/bin/License.txt
Running in demo mode!&lt;/pre&gt;

&lt;p&gt;
The &lt;code&gt; input&lt;/code&gt; file (here manual.xml) is the state diagram file produced from the modeling tool. The &lt;code&gt; outfile&lt;/code&gt; (here manual) – defines the name of the generated files and is used as prefix at many places in the generated code.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;2.1. Overview&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;overview1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:11,&amp;quot;range&amp;quot;:&amp;quot;8100-9697&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit12&quot; id=&quot;command_line_flags&quot;&gt;2.2. Command Line Flags&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Table 2.1: Command-Line Flags
&lt;/p&gt;
&lt;div class=&quot;table sectionedit13&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;&lt;strong&gt;Option&lt;/strong&gt;          &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;&lt;strong&gt;Options&lt;/strong&gt;                                                                                                                                                                                                                                                                                                                                                                                                                    &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt;-verbose&lt;/code&gt;    &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Enables the output of information messages during parsing and code-generation                                                                                                                                                                                                                                                                                                                                                  &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row2&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -t&lt;/code&gt;         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;In case a XMI file shall be parsed the path to the class that contains the state machine definition must be specified. This option allows you to model more than one state-based class and then generate one after the other by calling the code-generator with the corresponding path. See section G.1 for more info. This option is not necessary if you are using the Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; editor.  &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row3&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt;-c or -c1&lt;/code&gt;   &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Print transition coverage information and creates an Excel sheet with test routes. See section 3.19 for more information. -c uses a depth-first tree search algorithm which produces fewer but longer test routes. -c1 uses a breadth first algorithm which creates more but shorter test routes.                                                                                                             &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row4&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -U &amp;lt;file&amp;gt;&lt;/code&gt;  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Use the given name as filename for the configuration file. Useful if in one project different config files are needed.                                                                                                                                                                                                                                                                                                         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row5&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -L &amp;lt;file&amp;gt;&lt;/code&gt;  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Full path to license file e.g. /Users/paul/License.txt                                                                                                                                                                                                                                                                                                                                                                         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row6&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -Lstates&lt;/code&gt;   &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;List the states in the model on the console.                                                                                                                                                                                                                                                                                                                                                                                   &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row7&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -Levents&lt;/code&gt;   &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;List the events in the model on the console.                                                                                                                                                                                                                                                                                                                                                                                   &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row8&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -xls&lt;/code&gt;       &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Creates a file file called ’outfilename.xls’ which contains a state table.                                                                                                                                                                                                                                                                                                                                                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row9&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -doxygen&lt;/code&gt;   &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Creates a dot based description of the state diagram as part of the C/C++ file. This allows Doxygen to add a state machine diagram to the software documentation.                                                                                                                                                                                                                                                          &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row10&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -s&lt;/code&gt;         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Start in interactive simulation mode. Also consider to use the -v flag in addition which enables the printout of the executed C-code per simulation step.                                                                                                                                                                                                                                                                      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row11&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -S&lt;/code&gt;         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Start in graphical interactive mode. Make sure Graphviz  is installed on your PC.                                                                                                                                                                                                                                                                                                                                              &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row12&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -E&lt;/code&gt;         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Start the code generator in editor mode.                                                                                                                                                                                                                                                                                                                                                                                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row13&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -p&lt;/code&gt;         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines the editor tool of the input file. Several formats like Enterprise Architect (EA), Magic Draw (MD), UModel, Visual Paradigm (VP), Papyrus, the sinelabore built-in editor (SSC) or the Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; editor (CADIRFRA) are supported. The webpage informs about newly supported tools.                                                                                                                                   &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row14&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -o &amp;lt;file&amp;gt;&lt;/code&gt;  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Name of the output file without ending. The generator then adds the endings ’*.h’, ’*.c’ automatically to the output file names. If no filename is provided the input filename is used. It is recommended to always specify the output filename! The output name can also contain parts of a path for example to an output folder. Example: &lt;code&gt;-o generated_files\machine&lt;/code&gt;                                                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row15&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -l&lt;/code&gt;         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Define target language. Can be either C, C++, SSC or Java etc. To generate e.g. C++ code type the following ’-l cppx’.                                                                                                                                                                                                                                                                                                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row16&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -Trace&lt;/code&gt;     &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Activates the generation of trace code. Additionally two header files named *_trace.h and *_trace.java are generated that allows to translate the trace id to the event/guard string used in the state chart.                                                                                                                                                                                                                  &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row17&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt; -gencfg&lt;/code&gt;    &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Prints out all configuration options for a specific language (use -l to define the language). To quickly generate a config file e.g. for C type in the following: &lt;code&gt;java -jar codegen.jar -gencfg -l cx &amp;gt; codegen.cfg&lt;/code&gt;                                                                                                                                                                                                    &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row18&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;                    &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;                                                                                                                                                                                                                                                                                                                                                                                                                               &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;secid&amp;quot;:13,&amp;quot;range&amp;quot;:&amp;quot;9765-18071&amp;quot;} --&gt;
&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;2.2. Command Line Flags&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;command_line_flags&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:2,&amp;quot;secid&amp;quot;:12,&amp;quot;range&amp;quot;:&amp;quot;9698-18073&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit14&quot; id=&quot;configuration_file&quot;&gt;2.3. Configuration File&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code generator requires a configuration file named &lt;code&gt;codegen.cfg&lt;/code&gt; which is normally located in the same directory as the input file. The key/value pairs in this file can be used to adjust the code generator to your needs. Table 2.2 lists all the generator flags and explains their role during code generation. If not otherwise stated, all keys are written as one long word (without any spaces and ’-’ characters).
&lt;/p&gt;

&lt;p&gt;
If no configuration file named &lt;code&gt;codegen.cfg&lt;/code&gt; is found in the project folder, a file named &lt;code&gt;codegen.cf&lt;/code&gt; is searched. This is sometimes handy as some IDEs treat .cfg files in a special way which is not always wanted.
&lt;/p&gt;

&lt;p&gt;
If no configuration file is found in the project folder, the codegen looks for a &lt;code&gt;codegen.cfg&lt;/code&gt; file in the user home directory.
&lt;/p&gt;

&lt;p&gt;
If no configuration file is present at all, the internal default settings are used. To generate a configuration file with the relevant keys for e.g. the C-backend use the following command (example on Windows/Linux):
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;Windows:
c:\jdk-11\bin\javaw.exe -cp &amp;quot;c:/sinelaboreRT5.0/bin/*&amp;quot; 
    codegen.Main -gencfg -l cx &amp;gt; codegen.cfg

Linux:
$ java -cp &amp;quot;~/sinelaboreRT5.0/bin/*&amp;quot; codegen.Main -gencfg -l cx &amp;gt; codegen.cfg&lt;/pre&gt;

&lt;p&gt;
There are a number of keys which are language backend independent. Others are only usable for a specific language backend.
&lt;/p&gt;

&lt;p&gt;
Table 2.2: Generator flags in file &lt;code&gt; codegen.cfg&lt;/code&gt; which allow to influence the code generation process. C and C++ refers to the latest CX and CPPX language generator back-ends. To generate a configuration file for the required target language (e.g. C) call the code generator as follows: &lt;code&gt; java -jar codegen.jar -l cx -gencfg &amp;gt; codegen.cfg &lt;/code&gt;
&lt;/p&gt;
&lt;div class=&quot;table sectionedit15&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;&lt;strong&gt;Key&lt;/strong&gt;                                                                                                                                                                                                                      &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;&lt;strong&gt;Value&lt;/strong&gt;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                &lt;/th&gt;&lt;th class=&quot;col2 leftalign&quot;&gt;&lt;strong&gt;Supported language&lt;/strong&gt;  &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;Copyright                                                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines the text each generated file starts with. Use &lt;code&gt;&amp;#039;\n&amp;#039;&lt;/code&gt; for multi-line comments. Default is &lt;code&gt;/*\n * (c) Peter Mueller&lt;/code&gt; …                                                                                                                                                                                                                                                                                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row2&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;StateMachineFunctionPrefixHeader                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Prefix of the state machine function in the header file. Default is void.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row3&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;StateMachineFunctionPrefixCFile                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Prefix of the state machine function in the C file. Default is void.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row4&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ChangeStateFunctionPrefixHeader                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Prefix of the state change function in the header file. Default is void.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row5&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ChangeStateFunctionPrefixCFile                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Prefix of the state change function in the C file. Default is void.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row6&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;HsmFunctionWithInstanceParameters                                                                                                                                                                                            &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines if the state machine function has a pointer to the instance data as parameter. Options are yes or no. Default is yes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row7&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UseInstancePointer                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to ’no’, instance data is accessed by value. If set to ’yes’, instance data is accessed by reference. If a (user defined) instance is handed over to the state machine, this option must be set to ’yes’.                                                                                                                                                                                                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row8&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;HsmFunctionWithEventParameter                                                                                                                                                                                                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to ’yes’, an event is generated as parameter for the state handler function. HsmFunctionWithInstanceParameter must be set to ’yes’ also. Default is ’no’.                                                                                                                                                                                                                                                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row9&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;HsmFunctionUserDefinedEventParameter                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Allows to define a user-defined type as parameter for the state machine handler. Use this parameter in combination with parameter &lt;code&gt;HsmFunctionWithEventParameter&lt;/code&gt;. This parameter is useful if you want to hand over data in addition to the event itself, e.g. data received from a communication interface.                                                                                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row10&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;EventFirstValue                                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines if event definitions start from zero or another value. Default is zero. This parameter is specifically useful if some events are defined outside the state machine and it must be ensured that event definitions does not overlap with the generated ones.                                                                                                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C, C++              &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row11&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;EventDeclarationType                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines the C mechanism used for event definition. Options are ’define’ or ’enum’. Default is ENUM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row12&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;EventsAreBitCoded                                                                                                                                                                                                            &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;This flag can be used to instruct the code generator to generate bit-coded events. Use this flag whenever events are coded as bits within a variable. E.g. in the context of a realtime operating system where every task has e.g. a 1-byte (8-bit) mask, which means that 8 different events can be signaled to and distinguished by every task. Make sure that the number of events used in the state chart is not larger than the available bits of the message data type. This flag only is used if $EventDeclarationType$ is set to $Define$ at the same time.                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row13&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;EventTypeInCaseOfDefine                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;In case the above key is set to ’define’ the event type can be specified here e.g. to $unsigned char$.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row14&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;HsmFunctionUserDefinedParameter                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;A user provided type that is used as parameter for the state handler function. HsmFunction WithInstance Parameter must be set to ’yes’ also.                                                                                                                                                                                                                                                                                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row15&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;InlineChangeToStateCode                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to yes (= default) the code to change the state variables is inlined. If set to ’no’ you have to provide own functions. The required functions are defined in the state machine header file. Provide own functions if you want to run specific code during a state change (e.g. tracing a state change). This switch is only considered from the C code generator back-end.                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row16&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;PrefixStateNamesWithMachineName                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;This parameter allows to prefix state names with the machine name. Use this option if multiple state-machine header files are included into one other file (e.g. &lt;code&gt; main.c&lt;/code&gt;) to avoid definition conflicts due to double used state names. See also parameter PrefixMsgWithMachineName.                                                                                                                                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row17&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;PrefixStateNamesWithParentName                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;This parameter allows to prefix state names with the parent state name. Use this option if you have a hierarchical state machine and want to use the same state names in different child states. Example: There are two parent states called &lt;code&gt; EngineOn&lt;/code&gt; and &lt;code&gt; EngineOff&lt;/code&gt;. And in both states you have children &lt;code&gt; FuelPumpOn&lt;/code&gt; and &lt;code&gt; FuelPumpOff&lt;/code&gt;. To make the children names unique they can be prefixed with the parent name.                                                                                                                                                   &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row18&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;Realtab                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Options ’yes’ and ’no’ select if real tabs or spaces are used for indentation.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row19&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;Tabsize                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;In case of spaces are used for indentation the tabsize can be given here.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row20&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;PrefixMsgWithMachineName                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Prefix the message variable (msg) within the state machine with the machine name. This avoids naming conflicts if several state machines are called from within a single file (e.g. from &lt;code&gt; main.c&lt;/code&gt;) and the message variable is globally defined. Default is ’no’. See also parameter PrefixStateNamesWithMachineName                                                                                                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row21&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ReturnEventProcessed                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to yes the machine returns &lt;em&gt;1U&lt;/em&gt; if a normal event was processed or &lt;em&gt;0x10h&lt;/em&gt; if a conditional event was processed or &lt;em&gt;0U&lt;/em&gt; if no event was processed. Use this flag if the application has to know if an event could be processed. This feature is only supported for hierarchical state machines. Note: Erase the ’void’ value of the keys state machineFunctionPrefixHeader and state machineFunctionPrefixCFile. Otherwise your C-compiler will create an error. For C++ see &lt;code&gt;ReturnAndProcessEventTypeOfStateMachine&lt;/code&gt;                                                            &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All, excl. C++      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row22&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;TypeOfDbgString                                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;User defined string that is used in the debug output file to prefix the state name and event name string array e.g. to place it in a specific segment …                                                                                                                                                                                                                                                                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row23&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ValidationCall                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Create validation code file and insert a call to the user defined validation handler before each state change. By default it is set to ’no’.                                                                                                                                                                                                                                                                                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C, C++              &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row24&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UseHammingCodesForEvents                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Create events that have a defined hamming distance. By default this is switched off.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row25&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UseHammingCodesForStates                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Create states that have a defined hamming distance. By default this is switched off.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row26&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;HammingDistance                                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Set the hamming distance for states and events. By default a distance of two is used. Do not use too high values here. We have tested two and three.                                                                                                                                                                                                                                                                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row27&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;AdditionalValidate Includes                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Allows to define include statements for the validate header file. This is required to define the types used in the validate function. Default is &lt;em&gt;#include &amp;lt;stdint.h&amp;gt;&lt;/em&gt;                                                                                                                                                                                                                                                                                                                                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row28&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;AdditionalMachineInclude                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;One ore more include statements can be provided which will be added to the top of state machine include file. The default is language dependent. Use it for example if you want to provide your own data types. Default is &lt;em&gt;#include &amp;lt;stdint.h&amp;gt;&lt;/em&gt;                                                                                                                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C, C++              &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row29&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UINT8, UINT16, BOOL                                                                                                                                                                                                          &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Allows to change the used data types to your own definition in the generated state machine code. By default the types from stdint.h are used (uint8_t,uint16_t, uint8_t). If you change these parameters you probably also have to change the parameter above (AdditionalMachineInclude).                                                                                                                                                                                                                                                                                                                &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row30&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UMLString = char*&lt;br/&gt;
UMLInt = int&lt;br/&gt;
UMLLong = long&lt;br/&gt;
UMLDouble = double&lt;br/&gt;
UMLFloat = float&lt;br/&gt;
UMLShort = short                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;For attributes and operations in a &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; class it is required to provide the used data types. It is recommended to provide a data type definition in the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; model. But it is also possible to use the standard &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; data types and then provide a mapping in the configuration file. Generation of attributes and operations is only supported for C and EA right now.                                                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row31&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;INSTANCE_ATTRIBUTE_x&lt;br/&gt;
INSTANCE_ATTRIBUTE_DEFAULT_VALUE_x&lt;br/&gt;
INSTANCE_ATTRIBUTE_TYPE_x&lt;br/&gt;
&lt;br/&gt;
Example:&lt;br/&gt;
INSTANCE_ATTRIBUTE_0 = anAttribute&lt;br/&gt;
INSTANCE_ATTRIBUTE_DEFAULT_VALUE_0 = false&lt;br/&gt;
INSTANCE_ATTRIBUTE_TYPE_0 = bool&lt;br/&gt;
  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;These parameters allow you to create additional attributes that are added to the instance variable of the generated state machine. x has to be 0 for the first attribute, 1 for the second attribute and so on in an increasing order. There must be no gap. This allows to define multiple attributes. If you are using EA it is possible to define the attributes directly in the class diagram. Then these parameters are not needed. Details on EA see in the EA chapter G.                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row32&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;AdditionalLocalMachineVars                                                                                                                                                                                                   &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Allows to define local variables etc. within the state machine. Code defined here is inserted at the very beginning of the state machine function even before any action code. Use &lt;code&gt;&amp;#039;\n&amp;#039;&lt;/code&gt; for multi line statements.                                                                                                                                                                                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row33&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;PrefixEvents                                                                                                                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Allows to define naming conventions for events                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row34&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;PrefixSimpleStates                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Allows to define naming conventions for simple states                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row35&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;PrefixCompositeStates                                                                                                                                                                                                        &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Allows to define naming conventions for composite states                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row36&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;PrefixChoice                                                                                                                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Allows to define naming conventions for choice states                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row37&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UnknownStateHandler                                                                                                                                                                                                          &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Allows to define code that is executed if a state variable holds an invalid state. Can be used for debug purposes as an example.                                                                                                                                                                                                                                                                                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row38&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UnknownEventHandler                                                                                                                                                                                                          &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Allows to define code that is executed if an event could not processed in a state. Can be used for debug purposes for example.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C                       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row39&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;DotPath                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Path to ’dot.exe’.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row40&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ShowOnlyHotTransitions                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Options ’yes’ and ’no’ are possible. If set to ’yes’ only hot transitions (i.e. transitions which are accepted from the actually active state) are displayed. If set to ’no’ also all other transitions are displayed in gray.                                                                                                                                                                                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row41&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;NumberOfTransitionChars                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;It is possible to limit the length of the event text. This keeps the image compact. By default a value of 9 is set.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row42&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UdpPort                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Port the graphical simulator listens for event strings. By default the port is set to 4445.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row43&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;DisplayEntryExitDoCode                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to yes action code is displayed in the state diagram of the integrated editor.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row44&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;NumberOfEntryExitDoCodeChars                                                                                                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Limit action code in the integrated editor to the given number of chars e.g. 20 to not blow up the diagram to much.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row45&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;SaveCheckedOnly                                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to ’yes’ it is always possible to save the model. Otherwise only after a successful check.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row46&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;IncludeDateFileHeaders                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to ’no’ the data and time info is suppressed                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row47&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;IncludeTransitionsIntoStatesTheyStartFrom                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Export SCXML from the graphical editor in a hierarchical manner. Otherwise exported in a flat way.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row48&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;OptimizeExitCode                                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If multiple transitions are triggered from the same event leaving the same state the exit code is copied into each transition (I.e. multiple times). This can be a problem if the result of the exit code should be used as guard for the leaving transitions. With this option the exit code is placed in front of the exit evaluation code. But &lt;strong&gt;you&lt;/strong&gt; have to make sure that the exit code should really be executed each time an event fires even if no guard is true (i.e. no state change happens). Using this options must be considered quite well! Ensure that at least one guard is true.!!!  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;All                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row49&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;BaseClassStates, BaseClassMachine                                                                                                                                                                                            &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Define an optional base classes for the generated state classes or the machine class.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++, Java, C#       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row50&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UseEventObject, EventObjectType                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If UseEventObject set to ’yes’, EventObjectType allows to set a user defined type as parameter to the state machine handler - e.g. EventObjectType=UserData.                                                                                                                                                                                                                                                                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C#                      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row51&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;AdditionalTraceInclude                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Allows to define additional include code for the trace header file                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C, C++              &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row52&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;CreateFactoryMethodsVirtual                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to yes virtual create methods are generated in the factory class. Useful if it the state classes should be specifically initialized after creation.                                                                                                                                                                                                                                                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row53&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;CreateOneCppStateHeaderFileOnly                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to yes all state classes are generated into a single cpp/h file.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row54&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;SeparateStateClasses                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Do not create separate state classes. Inline all state code into the state machine.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++ , C#            &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row55&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;StateMachineClassHasDestructor                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to &lt;code&gt;yes&lt;/code&gt; a destructor for the state machine class is generated. If set to &lt;code&gt;virtual&lt;/code&gt; a virtual destructor is generated. If set to &lt;code&gt;no&lt;/code&gt; no destructor is generated.                                                                                                                                                                                                                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row56&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;Namespace                                                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Namespace the class is generated inside.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++, Java, C#       &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row57&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UseUnderlineForIncludeProtection                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Avoid using __ to protect the state machine include headers. Set &lt;em&gt;UseUnderlineForIncludeProtection=NO&lt;/em&gt; to remove the underlines.                                                                                                                                                                                                                                                                                                                                                                                                                                                                   &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C,C++               &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row58&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UseStdLibrary                                                                                                                                                                                                                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Activates the use of several C++ feature introduced in more modern releases of the standard e.g. &lt;em&gt;std::string&lt;/em&gt; instead of &lt;em&gt;char*&lt;/em&gt; for managing the event/state strings for debugging purposes. Your compiler must support at least &lt;em&gt;-std=c++11&lt;/em&gt; features. See parameters below for further details.                                                                                                                                                                                                                                                                                        &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row59&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;UseEnumBaseTypes                                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Activates the scoped and typed definition of the state and event enumerations. Compile with clang requires &lt;em&gt;–std=c++11&lt;/em&gt; to be set. Also set parameter &lt;em&gt;UseStdLibrary&lt;/em&gt;                                                                                                                                                                                                                                                                                                                                                                                                                            &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row60&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;NotUseRedundantVoidArgument                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Not use &lt;em&gt;void&lt;/em&gt; for methods without any parameter.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row61&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;EnableTrailingReturnType                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Switch on trailing-return-type syntax. Requires &lt;em&gt;–std=c++11&lt;/em&gt; and &lt;em&gt;UseStdLibrary=yes&lt;/em&gt; to be set.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row62&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;EnumBaseTypeForEvents                                                                                                                                                                                                        &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Type of event enumeration e.g. &lt;em&gt;std::uint16_t&lt;/em&gt;. See also &lt;em&gt;UseEnumBaseTypes&lt;/em&gt;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row63&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;EnumBaseTypeForStates                                                                                                                                                                                                        &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Type of state enumeration e.g. &lt;em&gt;std::uint16_t&lt;/em&gt;. See also &lt;em&gt;UseEnumBaseTypes&lt;/em&gt;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row64&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ReturnAndProcessEventTypeOfStateMachine                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines the type of the &lt;em&gt;evConsumed&lt;/em&gt; variable and thereof the return type of the &lt;code&gt;p&lt;/code&gt;rocessEvent() method                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row65&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ReturnAndProcessEventTypeOfStateMachineIsBool                                                                                                                                                                                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Sets the &lt;em&gt;evConsumed&lt;/em&gt; type and thereof the return type of the &lt;code&gt;p&lt;/code&gt;rocessEvent() method as bool. Default setting is ’no’                                                                                                                                                                                                                                                                                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row66&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;InitializedFlagTypeOfStateMachine                                                                                                                                                                                            &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines the type of the &lt;em&gt;m_initialized&lt;/em&gt; variable                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row67&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;VisibilityInitializedVar                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines the visibility of the variable &lt;em&gt;m_initialized&lt;/em&gt;. By default it is set as &lt;em&gt;protected:&lt;/em&gt;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row68&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;VisibilityStateVars                                                                                                                                                                                                          &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines the visibility of the state variables. By default it is set as &lt;em&gt;protected:&lt;/em&gt;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row69&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;CppHsmFunctionWithEventParameter                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines whether the &lt;code&gt;p&lt;/code&gt;rocessEvent() method has an event parameter. In case of your state machine is based the concept of conditional triggered transitions (see ) you can avoid warnings from the compiler.                                                                                                                                                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row70&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;CallInitializeInCtor                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines whether the state machine initialise method is called within the CTOR or must be called by the user separately. If called in the CTOR don’t call it a second time yourself                                                                                                                                                                                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row71&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ProtectHeaderPrefixString                                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Provide own prefix for include header protection                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row72&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;IncludeNamespaceInHeaderProtection                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Includes the namespace in the header protection string                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row73&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;CppxTemplateUse                                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to yes the code generator will generate the state machine function with a template parameter. Also note the two parameters below. Default is ’yes’.                                                                                                                                                                                                                                                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row74&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;CppxTemplateParameter                                                                                                                                                                                                        &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Use this parameter to specify the template parameter. Default is &lt;code&gt;c&lt;/code&gt;onst T&amp;amp; userdata. Also note the parameter below and above.                                                                                                                                                                                                                                                                                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row75&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;CppxTemplateMsgAccessor                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Use this parameter to specify how to access the event embedded in the template parameter. Default is userdata.msg;. Change this according to your needs. Also note the two parameters above.                                                                                                                                                                                                                                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;C++                 &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row76&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;EnabledSCXMLObfuscation                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to yes (default is false) the code generator can generate a xml file with obfuscated state machine information. The state names, entry/action/exit code, event names are all modified in a way that the state machine still works, but no internal information is published.                                                                                                                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;ssc                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row77&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;SplitEventGuardActionInSeparateLines                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;If set to yes (default) event/guard/action data is displayed on a transition is broken up into different lines. This makes the diagram more compact.                                                                                                                                                                                                                                                                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row78&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ShowStateNotes                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Set to ’yes’ by default state and region nodes are displayed in the state diagram                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row79&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;StateNotesFillColor                                                                                                                                                                                                          &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Notes fill color in the state diagram. Set to #fffceb by default (light brown)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row80&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;StateNotesFont                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Font used for the notes field in the state diagram. Set to ’Arial’ by default.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row81&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;StateNotesFontSize                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Font size used for the notes field in the state diagram. Set to font size ’9’ by default.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row82&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;StateNotesFontColor                                                                                                                                                                                                          &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Font color used for notes in the state diagram. Set to #a18148 by default                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row83&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;StateNotesFrameColor                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines the frame of the note field in the state diagram. Set to #8a6e3d by default.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Built-in Editor         &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row84&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;PythonUseEnums                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Use enums for event and states. Set to ’yes’ by default.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Python                  &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row85&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;PythonUseFunctionAnnotation                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Use function annotations. Set to ’yes’ by default.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Python                  &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row86&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;                                                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;                        &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table1&amp;quot;,&amp;quot;secid&amp;quot;:15,&amp;quot;range&amp;quot;:&amp;quot;19814-92582&amp;quot;} --&gt;
&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;2.3. Configuration File&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;configuration_file&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:2,&amp;quot;secid&amp;quot;:14,&amp;quot;range&amp;quot;:&amp;quot;18074-92585&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit16&quot; id=&quot;statemachine_code_generator&quot;&gt;3. Statemachine Code Generator&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
A state machine shows the dynamic behaviour of an application. It is a graph of states and transitions that describes the response to events depending on the current state. State machines have been used for decades in hardware design. And during the last years also more and more in the area of software development. &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state machines have some significant improvements compared to classical Moore or Mealy state machines. They support hierarchical designs, it is possible to model parallel execution (and states) and several pseudo-states were added to further improve expressiveness.
&lt;/p&gt;

&lt;p&gt;
Especially in the embedded real-time domain the use of state machines is popular because the behaviour of devices in this domain can be often very well described with state machines.
&lt;/p&gt;

&lt;p&gt;
An important aspect of state machines is that the design can be directly transformed into executable code. This means that there is no break between the design and the implementation. This is all the more important if the device under development has to be certified &lt;em&gt;(e.g. according to IEC61508)&lt;/em&gt;.
&lt;/p&gt;

&lt;p&gt;
The remainder of this chapter explains the state diagram elements in more detail. But before you go into details play with the interactive example presented in the next section.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3. Statemachine Code Generator&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;statemachine_code_generator&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:16,&amp;quot;range&amp;quot;:&amp;quot;92586-93884&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit17&quot; id=&quot;introduction&quot;&gt;3.1. Introduction&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:17,&amp;quot;range&amp;quot;:&amp;quot;93885-93915&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit18&quot; id=&quot;representing_statemachines&quot;&gt;3.1.1. Representing Statemachines&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Basically a state machine can be represented as a tree of states (see figure 3.1). A transition e.g. $\xrightarrow{e13}$ in figure 3.1 connects the two states &lt;em&gt;S12&lt;/em&gt; and &lt;em&gt;S22&lt;/em&gt;. If the transition is triggered you have to walk upwards in the tree starting from &lt;em&gt;S12&lt;/em&gt; until you reach a common parent of &lt;em&gt;S12&lt;/em&gt; and &lt;em&gt;S22&lt;/em&gt;. Then walk downwards in the tree until the target state (in this case &lt;em&gt;S22&lt;/em&gt;) is reached. On the way all the entry and exit code of the visited states has to be executed.
&lt;/p&gt;

&lt;p&gt;
If the starting state is a composite state, it must also be determined which child state is to be exited. If the target state is a composite state, it must also be determined which child state is to be entered. If history states are used, their history must be taken into account when entering states.
&lt;/p&gt;

&lt;p&gt;
Fortunately, the code generator takes care of all these conditions in the generated code. So you don’t have to worry about all the details involved in implementing state machines in a particular language.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/machinetree.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:machinetree.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/machinetree.png?w=226&amp;amp;tok=ee9aa0&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;226&quot; /&gt;&lt;/a&gt;
Figure 3.1: The code generator internally creates a tree from a state diagram. Here the state tree of the state chart from figure 3.2 is shown.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1.1. Representing Statemachines&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;representing_statemachines&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:18,&amp;quot;range&amp;quot;:&amp;quot;93916-95153&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit19&quot; id=&quot;state_machines_at_work&quot;&gt;3.1.2. State machines at work&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
For a quick start into state machines play with an example state machine which is available in the learning subfolder within both the &lt;em&gt;Windows&lt;/em&gt; and &lt;em&gt;LinuxMacBSD&lt;/em&gt; folder on GitHub. Start the code generator in simulation mode&lt;sup&gt;&lt;a href=&quot;#fn__2&quot; id=&quot;fnt__2&quot; class=&quot;fn_top&quot;&gt;2)&lt;/a&gt;&lt;/sup&gt; and type in events used in the state diagram (e.g. $\xrightarrow{e13}$ or $\xrightarrow{e2}$ followed by a return). Then the simulation performs the state change and calls the related entry / exit and other action code. You can follow what is going on by watching the printouts. Observe especially:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The order the entry and exit actions are executed in case of event $\xrightarrow{e13}$&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; When $\xrightarrow{e1}$ triggers a state change to &lt;em&gt;S2&lt;/em&gt; and when it triggers a self-transition to &lt;em&gt;S11&lt;/em&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Make sure you understand what happens if transitions start or end at composite states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Make sure you understand the effect of the history marker in &lt;em&gt;S2&lt;/em&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/complex.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:complex.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/complex.png?w=604&amp;amp;tok=40e0a9&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;604&quot; /&gt;&lt;/a&gt;
Figure 3.2: This state diagram example shows many of the features supported from the code generator. It was created using the Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; editor.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1.2. State machines at work&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;state_machines_at_work&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:19,&amp;quot;range&amp;quot;:&amp;quot;95154-96488&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit20&quot; id=&quot;states&quot;&gt;3.1.3. States&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
State machines can be hierarchical or flat. A state with sub-states is called a hierarchical state machine. States can have entry code that is always executed if a state is entered. Exit code is executed whenever the state is left. Note that the entry and exit code is also executed if a self transition takes place. If events shall be processed without triggering the entry and exit actions so called inner events&lt;sup&gt;&lt;a href=&quot;#fn__3&quot; id=&quot;fnt__3&quot; class=&quot;fn_top&quot;&gt;3)&lt;/a&gt;&lt;/sup&gt; can be used. If for a state no entry and exit actions were declared an inner event behaves exactly like a self transition.
&lt;/p&gt;

&lt;p&gt;
A state can also have a &lt;em&gt;do&lt;/em&gt; activity. The &lt;em&gt;do&lt;/em&gt; activity code is executed whenever the state is active just before event transitions are evaluated. This means that calculation results from the action code can be used as triggers for state transitions.
&lt;/p&gt;

&lt;p&gt;
Actions within states shall be non-blocking and short regarding their execution time. On every hierarchy level a default state must be specified. A final state is a state that can’t be left anymore. I.e. the state-machine must be re-initialised to be reactive again.
&lt;/p&gt;

&lt;p&gt;
It is possible to specify inner events, entry and exit code … for a state by linking a note to a state. See figure 3.3 on the right side for an example. The note must start with the text &lt;code&gt;compartment:&lt;/code&gt;. Sometimes it is useful to use this option despite the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tool allows to specify entry/action/exit code directly. As the ’constraints:’ is not supported by any &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tool it must be always defined within an attached comment note (see section 3.19 for more about using constraints).
&lt;/p&gt;

&lt;p&gt;
In principle states can be nested again and again. The code generator was intensively tested with up to four hierarchy levels. If you use more levels reconsider your design!
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/entry_exit_action.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:entry_exit_action.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/entry_exit_action.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;entry_exit_action.jpg&quot; alt=&quot;entry_exit_action.jpg&quot; /&gt;&lt;/a&gt;
Figure 3.3: Left: A state with &lt;em&gt;entry-&lt;/em&gt;, &lt;em&gt;exit-&lt;/em&gt;, &lt;em&gt;do-code&lt;/em&gt; and inner events. Right: Complex state with &lt;em&gt;entry-&lt;/em&gt; and &lt;em&gt;entry-code&lt;/em&gt; specified in a linked note.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1.3. States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:20,&amp;quot;range&amp;quot;:&amp;quot;96489-98603&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit21&quot; id=&quot;transitions&quot;&gt;3.1.4. Transitions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
There are two types of transitions supported from the code generator. a) event based transitions and b) conditional triggered transitions. An event based transition has the following syntax: &lt;code&gt;eventName[guardExpression]/action&lt;/code&gt;. The transition is only taken if the guard expression evaluates to &lt;em&gt;true&lt;/em&gt; and the event was sent to the state machine. Only in this case the action code is executed.
&lt;/p&gt;

&lt;p&gt;
From a transition like
&lt;/p&gt;
&lt;blockquote&gt;&lt;div class=&quot;no&quot;&gt;
 &lt;code&gt;evDoorClosed[timer_preset()&amp;gt;0]/timer_start();&lt;/code&gt;&lt;/div&gt;&lt;/blockquote&gt;

&lt;p&gt;
the code generator generates the following source code:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;if((msg==(OVEN_EVENT_T)evDoorClosed) &amp;amp;&amp;amp; (timer_preset()&amp;gt;0)){
    /*Transition from Idle to Cooking*/
    evConsumed = 1U;

    /*Action code for transition */
    timer_start();
    ...&lt;/pre&gt;

&lt;p&gt;
A conditional (or guard) transition is not triggered from an outside event but when a guard expression is evaluated to true. It has the syntax: &lt;code&gt;#condition/action&lt;/code&gt;. Please note that the hash character &lt;code&gt;#&lt;/code&gt; must be typed in (i.e. prefix your code statement) to indicate this special type of trigger. From a transition like this
&lt;/p&gt;
&lt;blockquote&gt;&lt;div class=&quot;no&quot;&gt;
 &lt;code&gt;#i==1/printf(&amp;quot;i==1\n&amp;quot;);&lt;/code&gt;&lt;/div&gt;&lt;/blockquote&gt;

&lt;p&gt;
the code generator generates the following code:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;if((i==1)){
    ...
    /*Action code for transition*/
    printf(&amp;quot;i==1\n&amp;quot;);
    ...&lt;/pre&gt;

&lt;p&gt;
Externally defined events: Normally, for all events used in a state machine diagram, the necessary event definitions are generated in the header file &lt;code&gt;*_ext.h&lt;/code&gt;. And only these events can be handled by the state machine.
&lt;/p&gt;

&lt;p&gt;
But sometimes it is required to react on events defined externally from the state machine diagram (e.g. existing code is re-used defining own events or the operating system sends predefined events e.g. in case of a timer timeout). The code generator needs to know that a specific event should be or shouldn’t be included in the event definition process. Therefore such events must be prefixed with an exclamation mark (!). In all other areas of the generation process (state machine handler code, debug helpers) they are included as any other event. Note: Only the C/C++ backend consider externally marked events.
&lt;/p&gt;

&lt;p&gt;
Action code defined in transitions must be non-blocking! Figure 3.4 shows examples for all types of supported transitions. Action code from an initial pseudostate is only used if the target state of the transition is not in a parent state with history. &lt;em&gt;In history states the usage of actions on the init transition is often misapplied and therefore ignored!&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/transitions.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:transitions.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/transitions.png?w=302&amp;amp;tok=82ae7a&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;302&quot; /&gt;&lt;/a&gt;
Figure 3.4: All possible transitions.
&lt;/p&gt;

&lt;p&gt;
From top to bottom:
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transition from an init pseudostate. Only an action expression is allowed here.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Simple event with no guard and no action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Event with guard. The guard expression enclosed in brackets [] is denoting that this expression must be true for the transition to take place.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Event with guard and action. If the transition takes place the action code is executed. The action code must be one or more lines of valid C code.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Conditional transition. The transition takes place if the variable i is zero.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Conditional transition with action. The transition takes place if the variable i is zero. Additionally the action code is executed.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Externally defined event&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1.4. Transitions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;transitions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:21,&amp;quot;range&amp;quot;:&amp;quot;98604-101885&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit22&quot; id=&quot;regions&quot;&gt;3.1.5. Regions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
In state diagrams usually only one state is active at a time. In &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state diagrams regions also allow to model concurrency – i.e. more than one state is active at a time (AND states).
&lt;/p&gt;

&lt;p&gt;
A &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state may be divided into regions. Each region contains sub-states. Regions are executed in parallel. You can think of regions as independent state machines displayed in a diagram. The state machine in figure 3.5 shows the well-known example of a microwave oven designed using regions. Several regions, each running in parallel in the state Active. Dashed lines are used to divide a state into regions.
&lt;/p&gt;

&lt;p&gt;
The power setting, light and microwave are considered as independent (concurrent) parts of the oven, each with its own state. The door and the timer as the main triggers are used in the regions to trigger state transitions. For example, the radiator is switched on when the door is closed and the timer is $&amp;gt;$ zero.
&lt;/p&gt;

&lt;p&gt;
As you can see multiple concurrent regions can be used to explicitly visualize different parts of a device. And all the states in the one diagram.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/oven_with_regions_umodel.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:oven_with_regions_umodel.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/oven_with_regions_umodel.png?w=377&amp;amp;tok=85c8d1&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure 3.5: A microwave oven designed with regions.
&lt;/p&gt;

&lt;/div&gt;

&lt;h4 id=&quot;points_to_consider_with_regions&quot;&gt;3.1.5.1. Points to consider with regions&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:23,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
Transitions must not cross region boundaries: In the figure 3.5 state transitions do not cross region boundaries and therefore the modelers’ intention is clear. But look at the next diagram 3.6. Now it is not clear anymore what the modeler had in mind. And it is also not very obvious what a code generator should generate. For that reason the following constraints were defined.
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/problems_with_regions-1.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:problems_with_regions-1.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/problems_with_regions-1.png?w=264&amp;amp;tok=86c480&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;264&quot; /&gt;&lt;/a&gt;
Figure 3.6: Transitions must not cross region borders. From this diagram no code can be generated.
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:24,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:25,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
Regions must work on the same instance data: State diagrams follow the &lt;em&gt;run-to-completion&lt;/em&gt; concept. Transitions that fire are fully executed and the state machine reaches a stable state configuration until it returns and can respond to the next event. To ensure this a copy of the instance data is kept and state changes are only performed on that copy. In practice this means that changes in one region does not influence other regions. Look into the following figure below.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; If the event $\xrightarrow{evClosed}$ is sent – region &lt;em&gt;ValveA&lt;/em&gt; and &lt;em&gt;ValveB&lt;/em&gt; change state.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; But there is no state change in region &lt;code&gt;Motor&lt;/code&gt; at the same time. The reason is that the transition from &lt;em&gt;Stop&lt;/em&gt; $\rightarrow$ &lt;em&gt;Run&lt;/em&gt; was not triggered at the beginning of the machine execution.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; This behavior ensures that the result of a machine execution step is 100% predictable and not dependent of the execution order of the regions.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; But on the other side it means that a second run of the machine is required to reach state &lt;em&gt;MachineRun&lt;/em&gt;. I.e. the region &lt;em&gt;Motor&lt;/em&gt; is always one cycle behind the ”Valve” regions.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/problems_with_regions_2.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:problems_with_regions_2.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/problems_with_regions_2.png?w=453&amp;amp;tok=2e8e0c&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure 3.7: Each region should ’see’ the same state set of the whole state machine. Independent of the execution order of the region code. Therefore regions work on copies of the instance variable.
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:26,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1.5. Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;regions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:5,&amp;quot;secid&amp;quot;:22,&amp;quot;range&amp;quot;:&amp;quot;101886-105080&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit27&quot; id=&quot;header_action_postaction_and_unknownstatehandler_notes&quot;&gt;3.1.6. Header, action, postAction and unknownStateHandler Notes&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To adapt the generated code to your needs you can add notes to your design that have to start with either ’&lt;em&gt;header:&lt;/em&gt;’ or ’&lt;em&gt;postAction:&lt;/em&gt;’ or ’&lt;em&gt;action:&lt;/em&gt;’ or ’&lt;em&gt;unknownStateHandler:&lt;/em&gt;’.
&lt;/p&gt;

&lt;p&gt;
All code following the ’&lt;em&gt;header:&lt;/em&gt;’ keyword is added at the top of the generated statemachine code code file (i.e. the c-file for example). This allows to include required header files or the definition of local variables needed within the statemachine.
&lt;/p&gt;

&lt;p&gt;
See figure 3.8 for an example.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/class_with_header_comment.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:class_with_header_comment.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/class_with_header_comment.png?w=453&amp;amp;tok=5c96c5&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure 3.8: It is possible to define own code inserted on top of the generated file. This allows to specify own include files or other required local code in the state machine file.
&lt;/p&gt;

&lt;p&gt;
Code following the ’&lt;em&gt;action:&lt;/em&gt;’ keyword is inserted at the &lt;em&gt;begin&lt;/em&gt; of the statemachine function. This allows to execute own code whenever the statemachine is called just before event processing starts. In section  this was used to receive events via a message queue.
&lt;/p&gt;

&lt;p&gt;
Code following the ’&lt;em&gt;postAction:&lt;/em&gt;’ keyword is inserted at the &lt;em&gt;end&lt;/em&gt; of the statemachine function. This allows to execute own code after the statemachine code was processed e.g. to enable an interrupt at the end of an interrupt handler function implemented as state machine. &lt;em&gt;Please note that this generator keyword is only available for the following backends: cx, cppx, java, ssc&lt;/em&gt;.
&lt;/p&gt;

&lt;p&gt;
Code following the ’&lt;em&gt;unknownStateHandler:&lt;/em&gt;’ keyword is inserted between each default/break pair of the generated code. The given code will be executed if the state variables do not have a valid state. This should never happen and indicates a serious problem in the system (e.g. memory is corrupted due to a stack overflow). Alternatively, it is possible to include the code in the in the &lt;em&gt;codegen.cfg&lt;/em&gt; file.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/unknownstatecode.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:unknownstatecode.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/unknownstatecode.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;unknownstatecode.jpg&quot; alt=&quot;unknownstatecode.jpg&quot; /&gt;&lt;/a&gt;
Figure 3.9: A message is printed whenever an invalid statevar was found.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1.6. Header, action, postAction and unknownStateHandler Notes&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;header_action_postaction_and_unknownstatehandler_notes&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:5,&amp;quot;secid&amp;quot;:27,&amp;quot;range&amp;quot;:&amp;quot;105081-107089&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit28&quot; id=&quot;choices&quot;&gt;3.1.7. Choices&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The &lt;abbr title=&quot;Object Management Group&quot;&gt;OMG&lt;/abbr&gt; &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; specification states: &lt;em&gt;“…choice vertices which, when reached, result in the dynamic evaluation of the guards of the triggers of its outgoing transitions. This realizes a dynamic conditional branch. It enables splitting of transitions into multiple outgoing paths such that the decision on which path to take may be a function of the results of prior actions performed in the same run-to-completion step. If more than one of the guards evaluates to true, an arbitrary one is selected. If none of the guards evaluates to true, then the model is considered ill-formed. (To avoid this, it is recommended to define one outgoing transition with the predefined ’else’ guard for every choice vertex.”&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
The simplified state chart in figure 3.10 shows different options how choices can be used. A choice can be placed within a composite state or at root level. A choice must have at least one incoming transition. &lt;em&gt;Guards specified at the incoming transition(s) are ignored from the code-generator. Actions are simply copied to the outgoing transitions&lt;/em&gt;. Place them at the outgoing transitions.
&lt;/p&gt;

&lt;p&gt;
Usually choices can have only one incoming transition and multiple outgoing transitions (at least two). But the code–generator also allows more than one incoming transition. This is a convenient function to allow the compact specification of complex structures. Internally this construct is handled like two choices with one incoming transition each and the same outgoing transitions.
&lt;/p&gt;

&lt;p&gt;
If more than one incoming transition is found, the choice is doubled for each incoming transition. I.e. it is like modelling two choices with one transition each and having the same outgoing transitions. At least two outgoing transitions must be defined, each with a guard. One of the guards must be an &lt;em&gt;else&lt;/em&gt; statement as described above. Depending on the target state of each outgoing transition, the corresponding entry/exit code is generated. The creation of choice chains is not supported by the code generation
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/choice.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:choice.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/choice.jpg?w=529&amp;amp;tok=674761&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;choice.jpg&quot; alt=&quot;choice.jpg&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure 3.10: Different options to use choices. A default path marked with &lt;em&gt;else&lt;/em&gt; must always exist.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1.7. Choices&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;choices&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:5,&amp;quot;secid&amp;quot;:28,&amp;quot;range&amp;quot;:&amp;quot;107090-109273&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit29&quot; id=&quot;determining_the_default_state_dynamically_init_to_choice&quot;&gt;3.1.8. Determining the default state dynamically (Init to Choice)&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Sometimes the initial state of a state machine or sub–machine shall be determined during run–time and not design–time. Examples:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; If the hardware self-test of a device fails the machine should enter an error state and not a normal operation state&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Depending on a parameter (for example set by a user) a specific state shall be entered&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
In such cases it is possible to connect the initial pseudo–state with the input side of a choice and connect the outgoing transitions with the target states. &lt;strong&gt;It is important that there exists one else path to ensure that there is always one option that can be taken by default&lt;/strong&gt;. Several examples are shown in the following figure 3.11. Note that it is possible to define an action on the incoming transition of a choice that reads a value or performs a check and use the result of that function as guard for the outgoing transitions of a choice.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/init2choice.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:init2choice.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/init2choice.jpg?w=529&amp;amp;tok=814a0e&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;init2choice.jpg&quot; alt=&quot;init2choice.jpg&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure 3.11: Choices can be used to determine the initial state at run–time. The figure shows several possibilities how to use this feature.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1.8. Determining the default state dynamically (Init to Choice)&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;determining_the_default_state_dynamically_init_to_choice&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:5,&amp;quot;secid&amp;quot;:29,&amp;quot;range&amp;quot;:&amp;quot;109274-110434&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit30&quot; id=&quot;junctions&quot;&gt;3.1.9. Junctions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The &lt;abbr title=&quot;Object Management Group&quot;&gt;OMG&lt;/abbr&gt; &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; specification states: &lt;em&gt;…junction vertices are semantic-free vertices that are used to chain together multiple transitions. They are used to construct compound transition paths between states. For example, a junction can be used to converge multiple incoming transitions into a single outgoing transition representing a shared transition path (this is known as a merge).&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
The &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; specification also discusses the possibility of multiple outgoing transitions. &lt;strong&gt;This is not supported by the codegen!&lt;/strong&gt;
&lt;/p&gt;

&lt;p&gt;
The Junctions can be seen as a kind of drawing helper in the case you have several transitions ending all in the same state and all of these transitions share some common action. In such a case place the different triggers, guards and action code to the incoming transitions and the common part the the outgoing transition.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/cadifra_junction.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:cadifra_junction.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/cadifra_junction.png?w=453&amp;amp;tok=0c66a9&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure 3.12: Junction example drawn with Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt;. There is no junction symbol available in Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt;. The shown (J) state is the supported replacement.
&lt;/p&gt;

&lt;p&gt;
The code-generator creates two separate transitions out of this model. The first one from S1 to S3. The second one from S2 to S3.
&lt;/p&gt;

&lt;p&gt;
Limitations and rules:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A junction should have at least two incoming transitions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A junction must have exactly one outgoing transition.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; On the outgoing transition no guard and trigger must be defined.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The action in the outgoing path is appended to actions defined on the incoming paths.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Incoming transitions must not start from a pseudo state e.g. another junction, choice, …&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The outgoing transition must not end in a pseudo state e.g. another junction, choice, …&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1.9. Junctions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;junctions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:5,&amp;quot;secid&amp;quot;:30,&amp;quot;range&amp;quot;:&amp;quot;110435-112131&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit31&quot; id=&quot;final_states&quot;&gt;3.1.10. Final States&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Final states have only incoming transitions. Once a state machine enters a final state it will not react on any other event.
&lt;/p&gt;

&lt;p&gt;
Exceptions are final states inside a hierarchical state machine. Transitions leaving the parent state of a final state can still be taken. In figure 3.13 state &lt;code&gt;Final&lt;/code&gt; can be left via event $\xrightarrow{ev3}$ or $\xrightarrow{evRealEnd}$ while state &lt;code&gt;Final1&lt;/code&gt; can’t be left anymore..
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/final.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:final.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/final.png?w=302&amp;amp;tok=bfe326&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;302&quot; /&gt;&lt;/a&gt;
Figure 3.13: Example usage of final states. Once the machine is in state &lt;code&gt;Final1&lt;/code&gt; it can’t be left anymore. State &lt;code&gt;Final&lt;/code&gt; can be left via event $\xrightarrow{ev3}$ or $\xrightarrow{evRealEnd}$.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1.10. Final States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;final_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:5,&amp;quot;secid&amp;quot;:31,&amp;quot;range&amp;quot;:&amp;quot;112132-112830&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit32&quot; id=&quot;history_states&quot;&gt;3.1.11. History States&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Since version 6.4 of the code generator, the history state handling was changed. It is now possible to end a transition at a history state. Only if a transition ends in a history state will the previous history be considered when entering the state set. Otherwise the default entry chain is used. The new &lt;code&gt;TransitionsCanEndInHistoryStates&lt;/code&gt; parameter has been added to enable this feature. Consider the example shown in figure 3.14. After reset the state machine is in state &lt;code&gt;S1&lt;/code&gt;. State &lt;code&gt;S2&lt;/code&gt; can be entered in two ways. Either via $S1\xrightarrow{evA}S2$ or $S1\xrightarrow{evB}S2/H$. There is not yet any difference. Both will enter state &lt;code&gt;S22&lt;/code&gt; because there is no history for S2 yet. Now let’s enter state &lt;code&gt;S21&lt;/code&gt;, triggered by event $S22\xrightarrow{evA}S21$. Then let’s leave state &lt;code&gt;S2&lt;/code&gt; to state &lt;code&gt;S1&lt;/code&gt; with the transition $S21\xrightarrow{evB}S1$. There is a difference now if we re-enter state &lt;code&gt;S2&lt;/code&gt; via transitions triggered by event $S1\xrightarrow{evA}S2$ or event $S1\xrightarrow{evB}S2/H$. If entering via transition triggered by event $S1\xrightarrow{evB}S2/H$ the previous history will be used and thus state &lt;code&gt;S21&lt;/code&gt; is entered. If entering via transition triggered by event $S1\xrightarrow{evA}S2$ the default state is entered which is state &lt;code&gt;S22&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
This new possibility makes history state handling more powerful and the designer’s intention more clear than before.
&lt;/p&gt;

&lt;p&gt;
Note: It is also possible to reset the history to its default state using the generated reset history function. Consider the situation where a user is interacting with an HMI and has left the configuration menu. But has forgotten to make a setting. The designer wants the user to re-enter the last menu they left before, to make it easy to resume work where they left off. But after a minute, the user should reach the top configuration menu by default. This behaviour is easily achieved by resetting the history on a timed event.
&lt;/p&gt;

&lt;p&gt;
Note: The integrated state machine editor does not allow transitions to end in history states. Also, models with transitions ending in a history state can’t be used with the integrated state machine editor.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/sm_with_omg_history.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:sm_with_omg_history.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/sm_with_omg_history.png?w=604&amp;amp;tok=957a55&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;604&quot; /&gt;&lt;/a&gt;
Figure 3.14: Example that shows the new style of history handling.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.1.11. History States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;history_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:5,&amp;quot;secid&amp;quot;:32,&amp;quot;range&amp;quot;:&amp;quot;112831-115161&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit33&quot; id=&quot;generating_code&quot;&gt;3.2. Generating Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.2. Generating Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:5,&amp;quot;secid&amp;quot;:33,&amp;quot;range&amp;quot;:&amp;quot;115162-115195&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit34&quot; id=&quot;execution_model_of_the_generated_code&quot;&gt;3.2.1. Execution Model of the Generated Code&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The generated code follows this execution model:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Single Event Processing: The state machine function processes one event at a time. Each transition is triggered by at most one event. After consuming an event, the machine returns control. Users can implement queuing mechanisms as needed (see appendix section ).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Run-to-Completion Semantics: Each event triggers a complete execution cycle. All releated code related to the event is executed in one go. No further events are processed until the state machine function returns.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transition Priority: When multiple transitions are triggered by the same event, priority is determined by state hierarchy depth - deeper states have higher priority (&lt;abbr title=&quot;Object Management Group&quot;&gt;OMG&lt;/abbr&gt; state machine semantics).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1 node&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transition Types: Transitions can be triggered by either:&lt;/div&gt;
&lt;ul&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; External events sent to the state machine&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; Internal conditions evaluated within the state machine (see section )&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Machine execution: To process a transition the user has to execute the state machine function. There is no principle limitation regarding the context the state machine function can be called in. It can be integrated in an operating system task, called from within an interrupt service routine or in the main loop of a foreground-background system.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Cycle time: If all transitions are triggered from events created outside of the machine it is not necessary to call the state machine if no event is available for processing. If the state machine also contains transitions triggered by internal conditions (e.g. testing if a port pin has changed from low to high) then it should be called as often as the conditions needs be checked. In this case the event variable must be set to ’NO_EVENT’. The cycle time for calling the state machine depends solely on the application needs.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1 node&quot;&gt;&lt;div class=&quot;li&quot;&gt; Implementation: The state machine uses:&lt;/div&gt;
&lt;ul&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; Nested switch/case statements for state selection&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; if/then/else statements for event handling within states&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; State Exit Behavior: All transitions leaving a state trigger its exit code, including local transitions (treated as external transitions).&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The code generator supports multiple programming languages, configurable via command line options. The generated code structure varies based on language-specific features. The following sections detail the implementation specifics for each supported language.
&lt;/p&gt;

&lt;p&gt;
The code generator supports state machines with up to four hierarchy levels.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.2.1. Execution Model of the Generated Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;execution_model_of_the_generated_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:5,&amp;quot;secid&amp;quot;:34,&amp;quot;range&amp;quot;:&amp;quot;115196-117705&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit35&quot; id=&quot;generating_code_from_state_machines_with_regions&quot;&gt;3.2.2. Generating Code from State Machines with Regions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
This section describes the implementation of regions in the generated code.
&lt;/p&gt;

&lt;p&gt;
Each region is implemented as a separate function, with its name derived from the region name. When a state contains multiple regions, they execute sequentially in alphabetical order. Event processing follows these rules:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; If a region processes the event, the parent state does not handle it&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; If no region processes the event, the parent state handles it&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
To ensure consistent execution across regions:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The state machine creates a copy of instance data at startup&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; All condition checks use the original instance data&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; All modifications apply to the copy&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The modified instance data is copied back to the original at completion&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
This approach guarantees that all regions operate on consistent data during execution.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.2.2. Generating Code from State Machines with Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_code_from_state_machines_with_regions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:5,&amp;quot;secid&amp;quot;:35,&amp;quot;range&amp;quot;:&amp;quot;117706-118586&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit36&quot; id=&quot;generating_c_code&quot;&gt;3.3. Generating C Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Sinelabore generates efficient and maintainable C code from &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state charts. The code generation can be customized through configuration parameters to follow established patterns:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Object pattern: Instance data is encapsulated in a struct. All state machine functions operate on this data structure. This approach provides clear data flow, re-entrant code (no global state), and support for multiple instances.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Opaque object pattern: Similar to the object pattern, but with hidden implementation details. This reduces coupling between the state machine and other code.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Single instance pattern: Used when only one instance exists, eliminating the need for instance pointers. Common for interrupt handlers or hardware-specific state machines.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The generated code maps state hierarchies to nested switch/case statements and event handling to if/else-if/else structures. Configuration parameters allow optimization for your specific system requirements. See section 2.2 for available options.
&lt;/p&gt;

&lt;p&gt;
To generate C code, use the command line flag &lt;code&gt;&amp;#039;-l cx&amp;#039;&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
To create a configuration file with all C code generation parameters, run:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;java &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;cp path_to_bin_folder&lt;span class=&quot;coMULTI&quot;&gt;/* codegen.Main -l cx -gencfg &amp;gt; codegen.cfg&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3. Generating C Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_c_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:5,&amp;quot;secid&amp;quot;:36,&amp;quot;range&amp;quot;:&amp;quot;118587-119854&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit37&quot; id=&quot;data_types&quot;&gt;3.3.1. Data Types&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The state machine header file defines all required data types.
&lt;/p&gt;

&lt;p&gt;
Since version 2.40, the code generator uses standard integer types from &lt;code&gt;stdint.h&lt;/code&gt;&lt;sup&gt;&lt;a href=&quot;#fn__4&quot; id=&quot;fnt__4&quot; class=&quot;fn_top&quot;&gt;4)&lt;/a&gt;&lt;/sup&gt; instead of basic types like &lt;code&gt;unsigned char&lt;/code&gt; or &lt;code&gt;unsigned int&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
To specify custom data types, modify these parameters in the codegen configuration file:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; AdditionalMachineInclude - default: #include $&amp;lt;$stdint.h$&amp;gt;$&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; UINT8 - default: uint8_t&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; UINT16 - default: uint16_t&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; BOOL - default: uint8_t&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.1. Data Types&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;data_types&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:6,&amp;quot;secid&amp;quot;:37,&amp;quot;range&amp;quot;:&amp;quot;119855-120405&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit38&quot; id=&quot;custom_include_files_attributes_and_operations&quot;&gt;3.3.2. Custom Include Files, Attributes and Operations&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The code generator includes a standard set of header files by default. To add custom includes or code, attach a note to the class as described in section 3.1.6. See figure 3.15 for an example.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/class_with_header_comment.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:class_with_header_comment.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/class_with_header_comment.png?w=453&amp;amp;tok=5c96c5&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure 3.15: Define custom code to be inserted at the top of the generated file. This allows specification of custom include files or other required code in the state machine file.
&lt;/p&gt;

&lt;p&gt;
For some &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; modeling tools (e.g. for the built-in editor, EA, UModel) additional attributes and functions specified in the state machine class are also generated in the state machine code. This enables custom functionality like state entry functions or parameters needed in state machine guards or actions. Figure 3.15 shows an example.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.2. Custom Include Files, Attributes and Operations&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;custom_include_files_attributes_and_operations&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:6,&amp;quot;secid&amp;quot;:38,&amp;quot;range&amp;quot;:&amp;quot;120406-121239&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit39&quot; id=&quot;state_machine_function_return_value&quot;&gt;3.3.3. State Machine Function Return Value&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The state machine handler function’s return value can be configured. If &lt;strong&gt;ReturnEventProcessed&lt;/strong&gt; is set to &lt;em&gt;no&lt;/em&gt;, the function returns void. If set to &lt;em&gt;yes&lt;/em&gt;, it returns a flag indicating whether an event or conditional trigger was processed.
&lt;/p&gt;

&lt;p&gt;
When &lt;strong&gt;ReturnEventProcessed&lt;/strong&gt; is &lt;em&gt;yes&lt;/em&gt;, the return type can be specified using:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;strong&gt;StateMachineFunctionPrefixHeader&lt;/strong&gt; - for the header file&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;strong&gt;StateMachineFunctionPrefixCFile&lt;/strong&gt; - for the C file&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Both parameters default to &lt;em&gt;void&lt;/em&gt;. Use these parameters for compiler-specific decorations (e.g., placing the function in a specific code segment or defining it as an interrupt service routine).
&lt;/p&gt;

&lt;p&gt;
A warning is issued if both &lt;strong&gt;ReturnEventProcessed&lt;/strong&gt; and &lt;strong&gt;StateMachineFunctionPrefixHeader&lt;/strong&gt; or &lt;strong&gt;StateMachineFunctionPrefixCFile&lt;/strong&gt; are set. In this case, &lt;strong&gt;ReturnEventProcessed&lt;/strong&gt; takes precedence.
&lt;/p&gt;

&lt;p&gt;
For interrupt handler configuration, see section . Also refer to section A.7.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.3. State Machine Function Return Value&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;state_machine_function_return_value&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:6,&amp;quot;secid&amp;quot;:39,&amp;quot;range&amp;quot;:&amp;quot;121240-122221&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit40&quot; id=&quot;state_machine_function_parameters&quot;&gt;3.3.4. State Machine Function Parameters&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The state handler signature can be optimized by combining generator parameters. Common configurations include:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;strong&gt;HsmFunctionWithEventParameter and HsmFunctionWithInstanceParameters&lt;/strong&gt;: Set both to &lt;em&gt;yes&lt;/em&gt; for the object pattern. Use this for multiple state machine instances. The generated header file exposes all relevant structures.&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TESTCASE_INSTANCEDATA_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; TESTCASE_EVENT_T msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    TESTCASE_EV_CONSUMED_FLAG_T evConsumed &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; 0U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    ...
    &lt;span class=&quot;kw1&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; S1&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
        ...
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TESTCASE_EVENT_T&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;evA&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;strong&gt;EnableOpaqueStateMachinePattern, UseTypedefForInstanceData&lt;/strong&gt;: Set the first to &lt;em&gt;yes&lt;/em&gt; and the second to &lt;em&gt;no&lt;/em&gt; for the opaque object pattern. The state machine &lt;strong&gt;_ext.h&lt;/strong&gt; header file contains declarations but not the instance data struct. See the &lt;em&gt;microwave_builtin_editor_c_opaque&lt;/em&gt; example.&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; TESTCASE_INSTANCEDATA &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; TESTCASE_EVENT_T msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; testcaseInitMachine&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; TESTCASE_INSTANCEDATA &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; instanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; TESTCASE_INST_ID_T instId&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;size_t&lt;/span&gt; testcaseSizeOf&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;strong&gt;HsmFunctionWithInstanceParameters&lt;/strong&gt;: When set to &lt;em&gt;yes&lt;/em&gt;, the state handler expects an instance variable pointer. No other parameters are allowed. The message variable must be defined in the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; file’s ’header’ comment, typically as a global variable. Use this for interrupt handlers.&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TESTCASE_INSTANCEDATA_T&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; instanceVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    TESTCASE_EV_CONSUMED_FLAG_T evConsumed &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; 0U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; S1&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
        ...&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;strong&gt;HsmFunctionWithEventParameter&lt;/strong&gt;: When set to &lt;em&gt;yes&lt;/em&gt; and the above option is &lt;em&gt;no&lt;/em&gt;, the state handler accepts only an event parameter. Use this for single-instance state machines where events are sent externally. The instance variable must be defined in the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; file’s ’header’ comment.&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TESTCASE_EVENT_T msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    TESTCASE_EV_CONSUMED_FLAG_T evConsumed &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; 0U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;switch&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; S1&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
        ...&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:41,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
&lt;strong&gt;HsmFunctionUserDefinedParameter&lt;/strong&gt;: This parameter allows a custom struct type as the state handler parameter. Use this for flexible parameter passing, including events, instance variables, and additional data. The struct must contain a field named &lt;code&gt;instanceVar&lt;/code&gt;.
For example, with multiple serial ports requiring parameters like baud rate and parity:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; InstanceData MY_TESTCASE_INSTANCEDATA_T&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdint.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;testcase_ext.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;testcase.h&amp;quot;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; InstanceData&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;uint16_t&lt;/span&gt; baudrate&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; noBits&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; parity&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; stopBit&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; 
    TESTCASE_INSTANCEDATA_T instanceVar&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
The generated state machine handler:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdint.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;own_inst_type.h&amp;quot;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;testcase_ext.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;testcase.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;MY_TESTCASE_INSTANCEDATA_T&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; userInstanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; TESTCASE_EVENT_T msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    TESTCASE_INSTANCEDATA_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* ptr to instance data */&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;coMULTI&quot;&gt;/* Set instance var once */&lt;/span&gt;
    instanceVar&lt;span class=&quot;sy0&quot;&gt;=&amp;amp;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;userInstanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;instanceVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;coMULTI&quot;&gt;/* Execute entry code of default state once to init machine */&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;s1Entry&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;1U&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Baudrate   = %d&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;userInstanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;baudrate&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;NumberBits = %d&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;userInstanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;noBits&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Parity     = %c&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;userInstanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;parity&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Stopbit    = %d&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;userInstanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stopBit&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;s1Entry&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;0U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    ...&lt;/pre&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:42,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:43,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
&lt;strong&gt;HsmFunctionWithEventParameter, HsmFunctionWithInstanceParameters, and HsmFunctionUserDefinedEventParameter&lt;/strong&gt;: Define a custom type for the state machine handler parameter. Useful for passing additional data with events, such as communication interface data.
Example configuration:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;UseInstancePointer=yes&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;HsmFunctionWithEventParameter=yes&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;HsmFunctionUserDefinedEventParameter=USER_EVENT_T&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The &lt;code&gt;USER_EVENT_T&lt;/code&gt; definition must include the msg parameter:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;string.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdint.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;testcase_ext.h&amp;quot;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;struct&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    TESTCASE_EVENT_T msg&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; i&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; something_else&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; USER_EVENT_T&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
The generated code accesses the message through the user-defined type:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;user_defined_event.h&amp;quot;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;testcase.h&amp;quot;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;testcase_ext.h&amp;quot;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TESTCASE_INSTANCEDATA_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; USER_EVENT_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;userData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    ...
    &lt;span class=&quot;kw1&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; S1&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;userData&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TESTCASE_EVENT_T&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;ev2&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
                &lt;span class=&quot;co1&quot;&gt;// Use user-defined data in guards&lt;/span&gt;
                &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;userData&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;i&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
                    ...&lt;/pre&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:44,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:45,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
&lt;strong&gt;State Machine as Interrupt Handler&lt;/strong&gt;: Interrupt handlers often require compiler-specific keywords and have no parameters or return value. Use &lt;code&gt;StateMachineFunctionPrefixHeader&lt;/code&gt;, &lt;code&gt;StateMachineFunctionPrefixCFile&lt;/code&gt;, and &lt;code&gt;HsmFunctionWithInstanceParameters&lt;/code&gt; to meet these requirements.
Example for mspgcc&lt;sup&gt;&lt;a href=&quot;#fn__5&quot; id=&quot;fnt__5&quot; class=&quot;fn_top&quot;&gt;5)&lt;/a&gt;&lt;/sup&gt;:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;interrupt (INTERRUPT_VECTOR) IntServiceRoutine(void)
{
    /* State machine code */
}&lt;/pre&gt;

&lt;p&gt;
Configuration:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;StateMachineFunctionPrefixCFile=interrupt (INTERRUPT_VECTOR)
HsmFunctionWithInstanceParameters=no&lt;/pre&gt;

&lt;p&gt;
For multi-line prefixes, use the &lt;code&gt;&amp;#039;\n&amp;#039;&lt;/code&gt; indicator:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;StateMachineFunctionPrefixCFile=#pragma vector=UART0TX_VECTOR\n__interrupt void &lt;/pre&gt;

&lt;p&gt;
Header and C file prefixes can be specified separately.
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:46,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.4. State Machine Function Parameters&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;state_machine_function_parameters&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:6,&amp;quot;secid&amp;quot;:40,&amp;quot;range&amp;quot;:&amp;quot;122222-127917&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit47&quot; id=&quot;using_externally_defined_events&quot;&gt;3.3.5. Using Externally Defined Events&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Typically, the state machine header file (&lt;code&gt;*_ext.h&lt;/code&gt;) contains all event definitions used in the state machine diagram.
&lt;/p&gt;

&lt;p&gt;
To use events defined outside the state machine diagram (e.g., from existing code or operating system events), prefix them with an exclamation mark (!). The code generator excludes these events from the definition process but includes them in the state machine handler and debug helpers.
&lt;/p&gt;

&lt;p&gt;
Include the event definition header using the method described in section 3.1.6. See figure 3.16.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/machine_with_externally_defined_events.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:machine_with_externally_defined_events.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/machine_with_externally_defined_events.png?w=453&amp;amp;tok=c5744c&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure 3.16: Events excluded from definition can be marked with an exclamation mark (!). They must be declared elsewhere (e.g., in existing code).
&lt;/p&gt;

&lt;p&gt;
To avoid conflicts between generated and external event values, use the &lt;code&gt;EventFirstValue&lt;/code&gt; parameter (see table 2.2).
&lt;/p&gt;

&lt;p&gt;
Example with external events:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#ifndef __EXTERNAL_EVENTS_H__&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#define __EXTERNAL_EVENTS_H__&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co2&quot;&gt;#define ev1 1U&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#define ev2 2U&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#define ev3 3U&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#define ev4 4U&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co2&quot;&gt;#endif&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
With &lt;code&gt;EventFirstValue=10&lt;/code&gt;, the generated header:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#ifndef __TESTCASE_EXT_H__ &lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#define __TESTCASE_EXT_H__ &lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;coMULTI&quot;&gt;/* Events which can be sent to the state machine */&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;enum&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    ev10&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;10U&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
    TESTCASE_NO_MSG
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; TESTCASE_EVENT_T&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co2&quot;&gt;#endif&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h4 id=&quot;initializing_the_instance_variable&quot;&gt;3.3.5.1. Initializing the Instance Variable&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;

&lt;p&gt;
The state machine instance data type contains state variables and flags needed by the state handler function. Initialize this variable before the first state machine call using the provided macro:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;TESTCASE_INSTANCEDATA_T instData &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; TESTCASE_INSTANCEDATA_INIT&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.5. Using Externally Defined Events&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;using_externally_defined_events&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:17,&amp;quot;secid&amp;quot;:47,&amp;quot;range&amp;quot;:&amp;quot;127918-129589&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit48&quot; id=&quot;resetting_the_state_machine&quot;&gt;3.3.6. Resetting the State Machine&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To reset the machine to its default state, use the generated reset function. Note that the instance ID remains unchanged.
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;testcaseResetMachine&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// testcase is the machine name&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.6. Resetting the State Machine&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;resetting_the_state_machine&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:20,&amp;quot;secid&amp;quot;:48,&amp;quot;range&amp;quot;:&amp;quot;129590-129841&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit49&quot; id=&quot;high-availability_features&quot;&gt;3.3.7. High-Availability Features&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
For high-availability applications, detecting errors outside the state machine code is crucial. These errors might result from:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Runaway pointers overwriting key variables&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Power brownout corrupting bits&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Bad RAM cells losing bits&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The code generator provides two mechanisms to detect state machine inconsistencies:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:50,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
Error handler code in the default path of switch/case statements detects undefined state variable values. See the &lt;code&gt;UnknownStateHandler&lt;/code&gt; configuration key.
Example:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; S1&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            ...
        &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; S2&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            ...
        &lt;span class=&quot;kw1&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            error_handler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kw2&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:51,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:52,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
A validate function checks if transitions between states are allowed (i.e., modeled in the state diagram). Enable this with &lt;code&gt;ValidationCall=yes&lt;/code&gt; in the config file. The validate function is called from a user-provided handler function, allowing custom reactions to invalid transitions.
In single-CPU setups, validation runs on the same controller as the state machine. In redundant CPU setups, it can run on a second CPU.
Example state machine:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; S22&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TESTCASE_EVENT_T&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;ev32&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Transition from S22 to S21 */&lt;/span&gt;
            testcaseValidationHandler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;S22&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; S21&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;inst_id&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
            evConsumed&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;1U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* OnExit code of state S22 */&lt;/span&gt;
            ...&lt;/pre&gt;

&lt;p&gt;
User-defined handler:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; testcaseValidationHandler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;uint16_t&lt;/span&gt; from&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;uint16_t&lt;/span&gt; to&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; machineId&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; retCode&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
        retCode &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; testcaseValidate&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;from&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; to&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;retCode&lt;span class=&quot;sy0&quot;&gt;!=&lt;/span&gt;0U&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span class=&quot;co1&quot;&gt;// Transition not allowed&lt;/span&gt;
            reboot&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// Or appropriate system response&lt;/span&gt;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Transition allowed&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
Define required types in a header file and include it using the &lt;code&gt;AdditionalValidateIncludes&lt;/code&gt; parameter.
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:53,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1 node&quot;&gt;&lt;div class=&quot;li&quot;&gt; States and event enumerations can be generated with a user-defined Hamming distance between values. This helps detect accidental bit flips, as the state machine will enter the default path (calling the error handler) if bits are corrupted. See parameters:&lt;/div&gt;
&lt;ul&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;UseHammingCodesForEvents&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;UseHammingCodesForStates&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level2&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;HammingDistance&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.7. High-Availability Features&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;high-availability_features&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:21,&amp;quot;secid&amp;quot;:49,&amp;quot;range&amp;quot;:&amp;quot;129842-132220&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit54&quot; id=&quot;regions1&quot;&gt;3.3.8. Regions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Regions model parallel activities in state diagrams and can be defined in top-level states. See the microwave oven example in the samples folder.
&lt;/p&gt;

&lt;p&gt;
Example C code for the oven state machine:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; oven&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;OVEN_INSTANCEDATA_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    OVEN_EV_CONSUMED_FLAG_T evConsumed &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; 0U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    OVEN_INSTANCEDATA_T instanceVarCopy &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;// Create copy of instance variable&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; Active&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Calling region code */&lt;/span&gt;
            evConsumed &lt;span class=&quot;sy0&quot;&gt;|=&lt;/span&gt; ovenActiveLight&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instanceVarCopy&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
            evConsumed &lt;span class=&quot;sy0&quot;&gt;|=&lt;/span&gt; ovenActivePower&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instanceVarCopy&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
            evConsumed &lt;span class=&quot;sy0&quot;&gt;|=&lt;/span&gt; ovenActiveRadioator&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instanceVarCopy&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Check if event was already processed */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;evConsumed&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;0U&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
                &lt;span class=&quot;coMULTI&quot;&gt;/* Handle event on parent level */&lt;/span&gt;
            &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
            &lt;span class=&quot;kw2&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* end switch stateVar_root */&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;coMULTI&quot;&gt;/* Save the modified instance data */&lt;/span&gt;
    &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVar &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; instanceVarCopy&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
OVEN_EV_CONSUMED_FLAG_T ovenActiveLight&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;OVEN_INSTANCEDATA_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; 
    OVEN_INSTANCEDATA_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVarCopy&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; OVEN_EVENT_T msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    ...
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
OVEN_EV_CONSUMED_FLAG_T ovenActivePower&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;OVEN_INSTANCEDATA_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; 
    OVEN_INSTANCEDATA_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVarCopy&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; OVEN_EVENT_T msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    ...
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
OVEN_EV_CONSUMED_FLAG_T ovenActiveRadioator&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;OVEN_INSTANCEDATA_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVar&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; 
    OVEN_INSTANCEDATA_T &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;instanceVarCopy&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; OVEN_EVENT_T msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    ...
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.8. Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;regions1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:24,&amp;quot;secid&amp;quot;:54,&amp;quot;range&amp;quot;:&amp;quot;132221-133717&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit55&quot; id=&quot;multiple_state_machine_instances&quot;&gt;3.3.9. Multiple State Machine Instances&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To run multiple instances of the same state machine (e.g., processing multiple interfaces), follow these steps:
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Set &lt;code&gt;HsmFunctionWithInstanceParameters&lt;/code&gt; to &lt;code&gt;yes&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Set &lt;code&gt;HsmFunctionWithEventParameter&lt;/code&gt; to &lt;code&gt;yes&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Declare and initialize instance variables using the predefined macro:&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// Initialize three different serial ports&lt;/span&gt;
MY_TESTCASE_INSTANCEDATA_T instDataA &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;9600&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&#039;N&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;TESTCASE_INSTANCEDATA_INIT&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
MY_TESTCASE_INSTANCEDATA_T instDataB &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;19200&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&#039;E&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;TESTCASE_INSTANCEDATA_INIT&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
MY_TESTCASE_INSTANCEDATA_T instDataC &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;9600&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&#039;N&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;TESTCASE_INSTANCEDATA_INIT&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; argc&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; argv&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    TESTCASE_EVENT_T msg&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;TESTCASE_NO_MSG&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co1&quot;&gt;// Set object ID for each instance&lt;/span&gt;
    instDataA.&lt;span class=&quot;me1&quot;&gt;instanceVar&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;inst_id&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    instDataB.&lt;span class=&quot;me1&quot;&gt;instanceVar&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;inst_id&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    instDataC.&lt;span class=&quot;me1&quot;&gt;instanceVar&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;inst_id&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co1&quot;&gt;// Call each instance&lt;/span&gt;
    testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instDataA&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instDataB&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instDataC&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:56,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
To distinguish between instances inside the state machine (e.g., initializing different serial ports), use the instance ID as shown in figure 3.17.
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/multiple_instances.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:multiple_instances.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/multiple_instances.png?w=226&amp;amp;tok=fe1da1&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;226&quot; /&gt;&lt;/a&gt;
Figure 3.17: Use the instance ID to distinguish between multiple instances inside the state machine.
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:57,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
Expected output:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;I&lt;span class=&quot;st0&quot;&gt;&#039;m instance A
I&#039;&lt;/span&gt;m instance B
I&lt;span class=&quot;st0&quot;&gt;&#039;m instance C&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
For additional instance-specific variables, define a custom instance data type as described in section 3.3.4.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.9. Multiple State Machine Instances&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;multiple_state_machine_instances&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:25,&amp;quot;secid&amp;quot;:55,&amp;quot;range&amp;quot;:&amp;quot;133718-135264&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit58&quot; id=&quot;important_types_and_helper_functions&quot;&gt;3.3.10. Important Types and Helper Functions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
This section describes key type definitions and helper functions required to compile the state machine code.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.10. Important Types and Helper Functions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;important_types_and_helper_functions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:27,&amp;quot;secid&amp;quot;:58,&amp;quot;range&amp;quot;:&amp;quot;135265-135430&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit59&quot; id=&quot;user-defined_typedefs&quot;&gt;3.3.11. User-Defined Typedefs&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The generated state machine header file contains all required type definitions by default. To use custom types, set the define shown below.
&lt;/p&gt;

&lt;p&gt;
For a state machine named ’testcase’, these definitions are generated:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;// Predefined types required by the codegen. 
// Provide your own definitions by setting this define in your build environment.
#ifndef __PROVIDE_OWN_TESTCASE_STATEMACHINE_TYPES__
    typedef uint8_t TESTCASE_ENTRY_FLAG_T;
    typedef TESTCASE_STATES_T TESTCASE_STATEVAR_T;
    typedef uint8_t TESTCASE_INST_ID_T;
    typedef uint8_t TESTCASE_EV_CONSUMED_FLAG_T;
#endif&lt;/pre&gt;

&lt;p&gt;
Table 3.1 explains these definitions.
&lt;/p&gt;

&lt;p&gt;
Table 3.1: The ’xxx’ is replaced with the state machine name.
&lt;/p&gt;
&lt;div class=&quot;table sectionedit60&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;&lt;strong&gt;Typedef&lt;/strong&gt;                     &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;&lt;strong&gt;Meaning&lt;/strong&gt;                                                                                                                       &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt;xxx_ENTRY_FLAG_T&lt;/code&gt;        &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Flag indicating first-time execution. If true, the default state’s onEntry code executes. Reset afterward.                        &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row2&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt;xxx_STATEVAR_T&lt;/code&gt;          &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Type of the variable storing the current state.                                                                                   &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row3&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt;xxx_INST_ID_T&lt;/code&gt;           &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Type for distinguishing between multiple instances. Set different values per instance to identify them within the state machine.  &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row4&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt;xxx_EV_CONSUMED_FLAG_T&lt;/code&gt;  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Internal flag indicating if an event was handled in an inner state or needs handling in the outer state.                          &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table2&amp;quot;,&amp;quot;secid&amp;quot;:60,&amp;quot;range&amp;quot;:&amp;quot;136180-137011&amp;quot;} --&gt;
&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.11. User-Defined Typedefs&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;user-defined_typedefs&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:27,&amp;quot;secid&amp;quot;:59,&amp;quot;range&amp;quot;:&amp;quot;135431-137013&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit61&quot; id=&quot;important_type_definitions&quot;&gt;3.3.12. Important Type Definitions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
This subsection lists the typedefs generated in the state machine’s header file.
&lt;/p&gt;

&lt;p&gt;
Table 3.2: Important type definitions generated by the code generator. ’xxx’ is replaced with the state machine name, ’yyy’ with the state name.
&lt;/p&gt;
&lt;div class=&quot;table sectionedit62&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;&lt;strong&gt;Type Definition&lt;/strong&gt;             &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;&lt;strong&gt;Meaning&lt;/strong&gt;                                                                                                                                                                                     &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt;xxx_INSTANCEDATA_T&lt;/code&gt;      &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Structure containing all instance-specific variables.                                                                                                                                           &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row2&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt;xxx_STATES_T&lt;/code&gt;            &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Enumeration of all possible states.                                                                                                                                                             &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row3&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt;xxx_INSTANCEDATA_INIT&lt;/code&gt;   &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Macro for initializing the instance variable, setting all state variables to their default states.                                                                                              &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row4&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt;xxx_IS_IN_yyy&lt;/code&gt;           &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Macro returning 1 if the machine is in the specified state or 0 if not. Returns 1 for all parent states of the current state. Useful for triggering transitions in cooperating state machines.  &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row5&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;code&gt;xxx__RESET_HISTORY_yyy&lt;/code&gt;  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Macro for resetting history states.                                                                                                                                                             &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table3&amp;quot;,&amp;quot;secid&amp;quot;:62,&amp;quot;range&amp;quot;:&amp;quot;137297-138664&amp;quot;} --&gt;
&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.3.12. Important Type Definitions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;important_type_definitions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:28,&amp;quot;secid&amp;quot;:61,&amp;quot;range&amp;quot;:&amp;quot;137014-138666&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit63&quot; id=&quot;generating_c_code1&quot;&gt;3.4. Generating %%C++%% Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.4. Generating %%C++%% Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_c_code1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:28,&amp;quot;secid&amp;quot;:63,&amp;quot;range&amp;quot;:&amp;quot;138667-138708&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit64&quot; id=&quot;introduction1&quot;&gt;3.4.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
C++ is used more and more also in smaller embedded systems. Therefore the code generator can generate code using only a very small subset of C++. Actually only classes, public/protected/private member variables and methods are used. Features such as virtual functions, templates etc. are not used by default, but can be enabled if required. Since version 4.0 several new configuration parameters have been added. With the new parameters there is much more flexibility to customise the generated code to suit your needs. Some of the new parameters require a compiler that supports at least the C++ 2011 standard (i.e. set &lt;code&gt;–std=c++11&lt;/code&gt; for g++ or clang++). Generated code was checked with &lt;code&gt;clang-tidy and -checks=’modernize-*’&lt;/code&gt; switched on.
&lt;/p&gt;

&lt;p&gt;
For your convenience there is a codegen command line parameter that activates all C++11 features by default. If &lt;code&gt;-std c++11&lt;/code&gt; is used on the command line the following parameters are used for code generation:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;UseEnumBaseTypes = YES
EnumBaseTypeForEvents = std::uint16_t
EnumBaseTypeForStates = std::uint32_t
ReturnAndProcessEventTypeOfStateMachine = std::uint16_t
InitializedFlagTypeOfStateMachine = std::uint16_t
VisibilityInitializedVar = private:
VisibilityStateVars = private:
CallInitializeInCtor = yes
NotUseRedundantVoidArgument=YES
EnableTrailingReturnType=YES
UseStdLibrary = YES&lt;/pre&gt;

&lt;p&gt;
If &lt;code&gt;-std c++14&lt;/code&gt; is used on the codegen command line the code generator uses either &lt;code&gt;make_unique&lt;/code&gt; or &lt;code&gt;make_shared&lt;/code&gt;. You as user must define which type you want to use. Set the following parameter:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;StatePointerStyle = SHARED | UNIQUE&lt;/pre&gt;

&lt;p&gt;
To generate C++ code call the code generator with the command line flag &lt;code&gt;’-l cppx’&lt;/code&gt; and optionally with the standard option &lt;code&gt;’-std c++11’&lt;/code&gt; or &lt;code&gt;’-std c++14’&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
To generate a configuration file with all parameters related to the C++ code generation call the code generator as follows once:
&lt;/p&gt;

&lt;p&gt;
&lt;code&gt;java -cp &amp;quot;path to bin folder&amp;quot; codegen.Main -l cppx -gencfg &amp;gt; codegen.cfg&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
The generated code does not follow the state pattern as you might expect in case you are familiar with common design patterns. This is because the machine code is completely generated and no hand coding is involved. The following figure 3.18 on page shows the structure of the generated code. The classes marked as &lt;code&gt;&amp;lt;&amp;lt;generated&amp;gt;&amp;gt;&lt;/code&gt; are generated from the code generator. Classes marked with &lt;code&gt;&amp;lt;&amp;lt;optional&amp;gt;&amp;gt;&lt;/code&gt; are optional and must be provided by you if needed.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The &lt;code&gt;StateMachine&lt;/code&gt; class realises the state machine as modelled in the state diagram. The name of the class (here StateMachine) can be defined with the command line flag &lt;code&gt;-o&lt;/code&gt;. The &lt;code&gt;initialize()&lt;/code&gt; method must be called once to init the machine (i.e. set default states …). After initialisation the &lt;code&gt;processEvent()&lt;/code&gt; method can be called with the actual event as parameter. Methods to reset the history of a composite state and to check in which state the machine is are available too. It is possible to specify a base class the machine should be derived from (here shown as &lt;code&gt;MachineBaseClass&lt;/code&gt;). To do so specify the base class name in the &lt;code&gt;codgen.cfg&lt;/code&gt; file.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; For each state defined in the state chart diagram a class is created with the methods &lt;code&gt;onEntry()&lt;/code&gt;, &lt;code&gt;onExit()&lt;/code&gt; and &lt;code&gt;action()&lt;/code&gt; if needed (here shown as &lt;code&gt;StateClass&lt;/code&gt;). The state classes are named like the states in the state chart diagram. It is possible to specify a base class (here shown as &lt;code&gt;BaseStateClass&lt;/code&gt;) the states should be derived from. To do so specify the base class name in the &lt;code&gt;codgen.cfg&lt;/code&gt; file. If the key &lt;code&gt;CreateOneCppStateHeaderFileOnly&lt;/code&gt; is set to &lt;code&gt;Yes&lt;/code&gt; all state classes are generated in one cpp/h file. if the key &lt;code&gt;SeparateStateClasses&lt;/code&gt; is set to no (= default for the new cppx backend) no state classes and no factory class is generated. Using the keyword &lt;code&gt;stateheader&lt;/code&gt; in an &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; comment (like header or action) allows to define additional include files in the generated state cpp files.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A &lt;code&gt;StateMachineFactory&lt;/code&gt; can be optionally provided in the constructor of the &lt;code&gt;StateMachine&lt;/code&gt; class. The factory separates the construction of the state classes from the machine class but let the factory decide which state class to instantiate. See &lt;em&gt;Design Patterns, Elements of Reusable Object- Oriented Software; Addison-Wesley 1997&lt;/em&gt; for background information about the factory design pattern.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The generated machine class can optionally have a base class provided by you. Set the base class name in the configuration file as follows: &lt;code&gt;BaseClassMachine=YourMachineBaseClassName&lt;/code&gt;. By default no base class is expected.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The generated state classes can optionally have a base class provided by you. Set the base class name in the configuration file as follows: &lt;code&gt;BaseClassStates=YourStateBaseClassName&lt;/code&gt;. By default no base class is expected.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The generated state handler method can optionally have a template parameter. This makes it easily possible to hand over all kind of data together with the event to process.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/cpp_class_diagram.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:cpp_class_diagram.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/cpp_class_diagram.png?w=604&amp;amp;tok=00fe13&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;604&quot; /&gt;&lt;/a&gt;
Figure 3.18: Class diagram of the generated state machine classes and optional base classes. CPPX backend: The Factory and State classes are only generated if you have set the related configuration key. Otherwise the state classes action code is simply integrated in the generated state machine code.
&lt;/p&gt;

&lt;p&gt;
Sometimes it is necessary to access the state machine object from the state classes. To make this possible the code generator can automatically set a reference to the state machine object in each generated state class.
&lt;/p&gt;

&lt;p&gt;
To enable this feature set parameter &lt;code&gt;BackrefToMachineInStateClasses&lt;/code&gt; = &lt;code&gt;yes&lt;/code&gt;. The class diagram on page shows the classes and methods generated for this configuration. During the generation of the state objects a back reference to the state machine object is set into the state objects. The &lt;code&gt;entry()/do()/exit()&lt;/code&gt; code of the state objects can then access the state machine object. Typically methods or members of the state machine that should be accessed from state classes are implemented in a base class of the generated state machine. The base class must be written by hand.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/class_diagram_cpp_backref.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:class_diagram_cpp_backref.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/class_diagram_cpp_backref.png?w=377&amp;amp;tok=cc09b1&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure 3.19: Class diagram of the generated state machine classes if parameter &lt;code&gt; BackrefToMachineInStateClasses=yes&lt;/code&gt;. Factory class not shown here.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.4.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:28,&amp;quot;secid&amp;quot;:64,&amp;quot;range&amp;quot;:&amp;quot;138709-145271&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit65&quot; id=&quot;regions2&quot;&gt;3.4.2. Regions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Regions are supported since version 3. See 3.1.5 for more information.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.4.2. Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;regions2&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:30,&amp;quot;secid&amp;quot;:65,&amp;quot;range&amp;quot;:&amp;quot;145272-145369&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit66&quot; id=&quot;state_machine_destruction&quot;&gt;3.4.3. State Machine Destruction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
In embedded systems, objects are often created at startup and not deleted (at power-down). Therefore, no destructor is generated by default. If your system is more dynamic and objects are created and deleted at runtime, it is necessary to delete the state classes. There are several ways to do this:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Write a destructor for the factory class and delete the created state classes there&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Set the keyword &lt;code&gt;StateMachineClassHasDestructor&lt;/code&gt; to &lt;code&gt;yes&lt;/code&gt; to create a non virtual destructor for the state machine class.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Set the keyword &lt;code&gt;StateMachineClassHasDestructor&lt;/code&gt; to &lt;code&gt;virtual&lt;/code&gt; to create a virtual destructor for the state machine class. Create a virtual destructor if a base or subclass of the state machine class exists and &lt;em&gt;delete&lt;/em&gt; is called on the parent and not the subclass of the two classes. See the example code below:&lt;pre class=&quot;code c&quot;&gt;class testcase&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; public MachineBase
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
public&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
    testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;testcaseFactory&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; ptr&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    virtual ~testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    ...
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; argc&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; argv&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    testcase&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; machine&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;new testcase&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;new ownTestcaseFactory&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    ...
&amp;nbsp;
    &lt;span class=&quot;co1&quot;&gt;// creates a memory leak if the destructor of the state &lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// machine and the base class are not virtual.&lt;/span&gt;
    delete &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;MachineBase&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;machine&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; 
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.4.3. State Machine Destruction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;state_machine_destruction&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:30,&amp;quot;secid&amp;quot;:66,&amp;quot;range&amp;quot;:&amp;quot;145370-146685&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit67&quot; id=&quot;how_to_define_the_processevent_method_s_signature&quot;&gt;3.4.4. How to define the processEvent method’s signature&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
It is possible to flexibly configure the signature of the event handler method. The following list shows the different options for a machine name ’testcase’:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:68,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
Method only with the event parameter&lt;br/&gt;

&lt;/p&gt;

&lt;p&gt;
Table 3.3
&lt;/p&gt;
&lt;div class=&quot;table sectionedit70&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;Signature:                    &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;&lt;code&gt;int processEvent(const TESTCASE_EVENT_T msg);&lt;/code&gt;                      &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;Set the following parameter:  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;&lt;code&gt;CppHsmFunctionWithEventParameter=yes&lt;/code&gt;&lt;br/&gt;
&lt;code&gt;CppxTemplateUse=no&lt;/code&gt;  &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table4&amp;quot;,&amp;quot;secid&amp;quot;:70,&amp;quot;range&amp;quot;:&amp;quot;146980-147197&amp;quot;} --&gt;&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:69,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:71,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
Method with event and template parameter&lt;br/&gt;

&lt;/p&gt;

&lt;p&gt;
Table 3.4
&lt;/p&gt;
&lt;div class=&quot;table sectionedit73&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;Signature:                     &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;&lt;code&gt;template &amp;lt;typename T&amp;gt;&lt;/code&gt;&lt;br/&gt;
&lt;code&gt;int processEvent(const TESTCASE_EVENT_T msg, const T&amp;amp; userdata)&lt;/code&gt;  &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;Set the following parameters:  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;&lt;code&gt;CppHsmFunctionWithEventParameter=yes&lt;/code&gt;&lt;br/&gt;
&lt;code&gt;CppxTemplateUse=yes&lt;/code&gt;                               &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table5&amp;quot;,&amp;quot;secid&amp;quot;:73,&amp;quot;range&amp;quot;:&amp;quot;147272-147551&amp;quot;} --&gt;&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:72,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:74,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
Method template parameter that contains also the event&lt;br/&gt;

&lt;/p&gt;

&lt;p&gt;
Table 3.5
&lt;/p&gt;
&lt;div class=&quot;table sectionedit76&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;Signature:                     &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;&lt;code&gt;template &amp;lt;typename T&amp;gt;&lt;/code&gt;&lt;br/&gt;
&lt;code&gt;int processEvent(const T&amp;amp; userdata)&lt;/code&gt;                                                                                                                       &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;Set the following parameters:  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;&lt;code&gt;CppHsmFunctionWithEventParameter=no&lt;/code&gt;&lt;br/&gt;
&lt;code&gt;CppxTemplateUse=yes&lt;/code&gt;&lt;br/&gt;
&lt;code&gt;CppxTemplateParameter=const T&amp;amp; userdata&lt;/code&gt;&lt;br/&gt;
&lt;code&gt;CppxTemplateMsgAccessor=TESTCASE_EVENT_T msg=userdata.msg;&lt;/code&gt;  &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table6&amp;quot;,&amp;quot;secid&amp;quot;:76,&amp;quot;range&amp;quot;:&amp;quot;147640-148097&amp;quot;} --&gt;&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:75,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:77,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
Method without any parameter&lt;br/&gt;

&lt;/p&gt;

&lt;p&gt;
Table 3.6
&lt;/p&gt;
&lt;div class=&quot;table sectionedit79&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;Signature:                     &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;&lt;code&gt;int processEvent(void);&lt;/code&gt;                                           &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;Set the following parameters:  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;&lt;code&gt;CppxTemplateUse=no&lt;/code&gt;&lt;br/&gt;
&lt;code&gt;CppHsmFunctionWithEventParameter=no&lt;/code&gt;  &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table7&amp;quot;,&amp;quot;secid&amp;quot;:79,&amp;quot;range&amp;quot;:&amp;quot;148160-148377&amp;quot;} --&gt;&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:78,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
With the two parameters &lt;code&gt;ReturnAndProcessEventTypeOfStateMachine&lt;/code&gt;&lt;br/&gt;

and &lt;code&gt;ReturnAndProcessEventTypeOfStateMachineIsBool&lt;/code&gt; the return type of the &lt;code&gt;processEvent()&lt;/code&gt; method can be influenced.&lt;br/&gt;

If &lt;code&gt;ReturnAndProcessEventTypeOfStateMachineIsBool=yes&lt;/code&gt;, &lt;code&gt;bool&lt;/code&gt; is choosen as return type. In this case the information whether a normal event or a conditional event was processed is not available anymore to the caller.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.4.4. How to define the processEvent method\u2019s signature&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;how_to_define_the_processevent_method_s_signature&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:31,&amp;quot;secid&amp;quot;:67,&amp;quot;range&amp;quot;:&amp;quot;146686-148825&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit80&quot; id=&quot;validation_handler_unknown_state_handler_and_tracing_the_event_flow&quot;&gt;3.4.5. Validation Handler, Unknown State Handler and Tracing the Event Flow&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
With the parameter &lt;em&gt;ValidationCall=yes&lt;/em&gt; it is possible to automatically insert method calls that allow to check if a transtion is allowed or simply to trace state changes. The validation method has to be implemented by the user e.g. in a base class.
&lt;/p&gt;

&lt;p&gt;
With the parameter &lt;em&gt;UnknownStateHandler=unknownStateHandler();&lt;/em&gt; it is possible to insert a method that is called in case no fitting state could be found (e.g. due to memory corruption).
&lt;/p&gt;

&lt;p&gt;
And finally the code generator can be called with the &lt;em&gt;-Trace&lt;/em&gt; command line parameter which then adds methods that allows to trace the event flow e.g. for debugging, test or validation purposes.
&lt;/p&gt;

&lt;p&gt;
The following first code snippet exemplarily shows generated code for validate handler.
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; StateMachineBlinkBase&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;validationHandler&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; States from&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; States to&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        cout &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Change from: &amp;quot;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; getNameByState&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;from&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot; to &amp;quot;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; getNameByState&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;to&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; endl&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
And then how the generated code looks like.
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;...
&lt;span class=&quot;kw1&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;stateVars.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; State_LedBlink&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;EVENT_CHANGE_MODE&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Transition from State_LedBlink to State_LedOn */&lt;/span&gt;
            validationHandler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;State_LedBlink&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; State_LedOn&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
            stateVarsCopy.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; State_LedOn&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
            StateMachineBlinkTraceEvent&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;0U&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;EVENT_UPDATE&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Action code for inner transition  */&lt;/span&gt;
            led_blink&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span class=&quot;kw2&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* end of case State_LedBlink  */&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; State_LedOff&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;EVENT_CHANGE_MODE&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Transition from State_LedOff to State_LedBlink */&lt;/span&gt;
            validationHandler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;State_LedOff&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; State_LedBlink&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
            stateVarsCopy.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; State_LedBlink&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
            StateMachineBlinkTraceEvent&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;0U&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
        unknownStateHandler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw2&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
...&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.4.5. Validation Handler, Unknown State Handler and Tracing the Event Flow&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;validation_handler_unknown_state_handler_and_tracing_the_event_flow&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:31,&amp;quot;secid&amp;quot;:80,&amp;quot;range&amp;quot;:&amp;quot;148826-150841&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit81&quot; id=&quot;separate_generated_from_non-generated_code&quot;&gt;3.4.6. Separate generated from non-generated Code&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Even if the state machine is fully generated this is usually only a smaller part of your application whereas the lager part is coded manually. For several reasons it is important to clearly separate generated code from non-generated code. Using the features of C++ the code generator offers several possibilities to achieve this.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The most basic method is to put hand written code into libraries and call the library from within the state machine.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Generated classes can also subclass non-generated classes (base class of StateMachine or StateClass). Such base classes can contain useful methods that can be called from within the generated subclasses.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Using the StateMachineFactory user provided state classes can be created and used from the StateMachine class.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Hand written code is located in a child class of the state machine. I.e. the state machine classes are parts of other classes.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.4.6. Separate generated from non-generated Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;separate_generated_from_non-generated_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:33,&amp;quot;secid&amp;quot;:81,&amp;quot;range&amp;quot;:&amp;quot;150842-151813&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit82&quot; id=&quot;realising_active_objects_in_c&quot;&gt;3.4.7. Realising Active Objects in %%C++%%&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
An active object is an object with its own thread of control. A common design pattern is to design an application as a number of active objects. Active objects usually interact through an asynchronous event exchange. The received events are then processed in a state machine (here in &lt;code&gt;processEvent()&lt;/code&gt;). The machine might react with sending events back or to another active object.
&lt;/p&gt;

&lt;p&gt;
A very good introduction on ActiveObjects can be found in &lt;em&gt;Pattern-Oriented Software Architecture, Vol. 2 published by WILEY&lt;/em&gt;. This book describes also a number of other interesting patterns that are usually used to design concurrent (realtime) applications.
&lt;/p&gt;

&lt;p&gt;
As nowadays real-time operating systems are still mostly written in C-code and do not provide a C++ interface for tasks, queues, timers etc. a typical problem is how to wrap a task (or thread) into a C++ class so that the thread body can access methods of the C++ class (e.g. the processEvent method). The commonly used approach is as follows:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Define a static member function with a signature of underlying &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; task&lt;br/&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
(e.g. &lt;code&gt;void tasks(void* thisPtr)&lt;/code&gt;)
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Usually it is possible to handover a parameter to the task creation function which is then available in the task body. Provide the &lt;code&gt;this&lt;/code&gt; pointer as parameter.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Cast the &lt;code&gt;this&lt;/code&gt; pointer in the task body back to the object which owns the task.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The following listing shows an example based on the Posix pthreads library. The static method &lt;code&gt;doWork()&lt;/code&gt; has the signature as needed for a Posix thread. The same procedure works also for other realtime operating systems (e.g. RTEMS).
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// file ActiveMachine.h&lt;/span&gt;
&amp;nbsp;
class ActiveMachine &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; public SomeStateMachine
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
public&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; start&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; stop&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
private&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;static&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; doWork&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;thisPtr&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// thread body&lt;/span&gt;
    TUSIGN8 shouldRun&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// file ActiveMachine.cpp&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; ActiveMachine&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;doWork&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;ptr&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    ActiveMachine&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; mePtr  &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;ActiveMachine&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;ptr&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Hello World! It&#039;s me&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;mePtr&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;shouldRun&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;co1&quot;&gt;// wait for event&lt;/span&gt;
        &lt;span class=&quot;co1&quot;&gt;// process event in state machine&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    pthread_exit&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;NULL&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; ActiveMachine&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;start&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    pthread_t threads&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; rc&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    rc &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; pthread_create&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;threads&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; NULL&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;ActiveMachine&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;doWork&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;this&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;rc&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;ERROR; return code from pthread_create() is %d&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; rc&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.4.7. Realising Active Objects in %%C++%%&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;realising_active_objects_in_c&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:33,&amp;quot;secid&amp;quot;:82,&amp;quot;range&amp;quot;:&amp;quot;151814-154311&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit83&quot; id=&quot;virtual_create_methods&quot;&gt;3.4.8. Virtual Create Methods&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Sometimes it might be required to initialize the state objects from the factory. In this case the create functions in the factory can be generated as virtual functions. So they can be overloaded in a subclass of the factory. Set the &lt;code&gt;CreateFactoryMethodsVirtual&lt;/code&gt; flag to &lt;code&gt;yes&lt;/code&gt; to instruct the code generator to generate virtual methods.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.4.8. Virtual Create Methods&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;virtual_create_methods&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:34,&amp;quot;secid&amp;quot;:83,&amp;quot;range&amp;quot;:&amp;quot;154312-154702&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit84&quot; id=&quot;generating_scc&quot;&gt;3.5. Generating SCC&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
SinelaboreRT supports the generation of SCC as output format. SCC is a simple XML format used from the built-in visual editor to store its model information. To use a model file given in SCC format use the following parser option: &lt;code&gt;-p SCC&lt;/code&gt;. To generate SCC from a file exported by any of the supported &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; modeling tools use the following language option: &lt;code&gt;-l SCC&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
Example to create a ssc xml file from a Cadifra input file:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;java -jar codegen.jar -p CADIFRA -l ssc -o model inputModel.ccd&lt;/pre&gt;

&lt;p&gt;
In the next step we can edit the generated ssc file in the codegen’s editor.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;java -jar codegen.jar -p ssc -E -o model.xml model.xml&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.5. Generating SCC&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_scc&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:34,&amp;quot;secid&amp;quot;:84,&amp;quot;range&amp;quot;:&amp;quot;154703-155406&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit85&quot; id=&quot;generating_c_code2&quot;&gt;3.6. Generating C# Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.6. Generating C# Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_c_code2&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:36,&amp;quot;secid&amp;quot;:85,&amp;quot;range&amp;quot;:&amp;quot;155407-155443&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit86&quot; id=&quot;introduction2&quot;&gt;3.6.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Sinelabore&lt;em&gt;RT&lt;/em&gt; supports the generation of C# code.
&lt;/p&gt;

&lt;p&gt;
To generate C# code call the code generator with the command line flag &lt;code&gt;&amp;#039;-l csharp&amp;#039;&lt;/code&gt;. All states are created into one source file. The file name is determined by the &lt;code&gt;&amp;#039;-o&amp;#039;&lt;/code&gt; command line switch. An optional namespace can be provided in the &lt;code&gt;codgen.cfg&lt;/code&gt; file as well as the following C# specific parameters:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; SeparateStateClasses: If set to yes separate state classes are generated. The entry/do/exit code from the state diagram is copied over into methods and called from the generated code.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; BaseClassStates: Allows to define an own base class for the generated state classes. Generated code example:&lt;pre class=&quot;code java&quot;&gt;namespace MyNamespace
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
	&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;class&lt;/span&gt; S3 &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; StateBase&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; S3&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
		&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; virtual &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; Entry&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
			Console.&lt;span class=&quot;me1&quot;&gt;Write&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Enter S3&lt;span class=&quot;es0&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
		&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; virtual &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; Exit&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
			Console.&lt;span class=&quot;me1&quot;&gt;Write&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Exit S3&lt;span class=&quot;es0&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
		&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; virtual &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; &lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+action&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Action&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
			Console.&lt;span class=&quot;me1&quot;&gt;Write&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Action S3&lt;span class=&quot;es0&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
		...
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; BaseClassMachine: Allows to define an own state machine base class. This is useful if you have longer action code that you want to place into own methods and call them from within the generated code.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; AdditionalLocalMachineVars: Allows to provide own code inserted at the beginning of the state machine handler method.&lt;pre class=&quot;code java&quot;&gt; &lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;class&lt;/span&gt; testcase &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; BaseMachine
	&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
		...
&amp;nbsp;
		&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; ProcessEvent&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Events msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
			...
&amp;nbsp;
			&lt;span class=&quot;co1&quot;&gt;//AdditionalLocalMachineVars goes here&lt;/span&gt;
&amp;nbsp;
			...
&amp;nbsp;&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Possibility to hand over an object with user defined type.&lt;pre class=&quot;code java&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; ProcessEvent&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;UserData userData&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
		&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; evConsumed &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
		&lt;span class=&quot;co1&quot;&gt;// event handler with user data&lt;/span&gt;
		&lt;span class=&quot;co1&quot;&gt;// Set the following parameters:&lt;/span&gt;
		&lt;span class=&quot;co1&quot;&gt;// UseEventObject = yes&lt;/span&gt;
		&lt;span class=&quot;co1&quot;&gt;// EventObjectType=UserData&lt;/span&gt;
		&lt;span class=&quot;co1&quot;&gt;// AdditionalLocalMachineVars=Events msg = userData.msg; // access event parameter&lt;/span&gt;
		Events msg &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; userData.&lt;span class=&quot;me1&quot;&gt;msg&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// access event parameter&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The generated code does not follow the state pattern as you might expect (if you are familiar with common design patterns). The reason is that the machine code is completely generated and no hand-coding is involved. The following figure 3.20 shows the structure of the generated code. The classes marked with &amp;lt;generated&amp;gt;are generated from the code generator. Classes marked with &amp;lt;optional&amp;gt;are optional and must be provided by yourself if needed.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/csharpgen.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:csharpgen.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/csharpgen.png?w=529&amp;amp;tok=5bd7e3&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure 3.20: Class diagram of the generated state machine classes and optional base classes.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The &lt;code&gt;StateMachine&lt;/code&gt; class realises the state machine as modelled in the state diagram. The name of the class (here StateMachineClass) can be defined with the command line flag &lt;code&gt;-o&lt;/code&gt;. The &lt;code&gt;Initialise()&lt;/code&gt; method must be called once to initialise the machine (i.e. to set default states …). After initialisation the &lt;code&gt;ProcessEvent()&lt;/code&gt; method can be called with the actual event as parameter. Methods to reset the history of a composite state and to check in which state the machine is are available too. It is possible to specify a base class of the machine (here shown as &lt;code&gt;BaseMachine&lt;/code&gt;).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Beside some helper methods the code generator generates &lt;code&gt;ChangeToState&lt;/code&gt; and the &lt;code&gt;Trace&lt;/code&gt; methods for you too if the appropriate configuration options are set. To provide own code create a derived class from the state machine class and overwrite the methods according to your needs.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; For each state defined in the state chart diagram optionally a class is created in the state machine class file (same namespace) with the methods &lt;code&gt;OnEntry()&lt;/code&gt;, &lt;code&gt;OnExit()&lt;/code&gt; and &lt;code&gt;Action()&lt;/code&gt;. The state classes are named like the states in the state chart diagram. It is possible to specify a base class (here shown as &lt;code&gt;StateBase&lt;/code&gt;) the states should be derived from. You can also create subclasses of these state classes. Overwrite the needed methods in the factory in this case.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A &lt;code&gt;Factory&lt;/code&gt; is generated in the &lt;code&gt;StateMachine&lt;/code&gt; class file (same namespace). The factory separates the construction of the state classes from the machine class but let the factory decide which state class to instantiate. An example for an own simple factory is shown below. It creates S1 and S2 on its own but lets the state machine factory generate all the other state classes.&lt;pre class=&quot;code java&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;class&lt;/span&gt; myFactory &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; testcaseFactory
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; override S2 CreateS2&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;new&lt;/span&gt; myHandwrittenS2&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; override S1 CreateS1&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;new&lt;/span&gt; myHandwrittenS1&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.6.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction2&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:36,&amp;quot;secid&amp;quot;:86,&amp;quot;range&amp;quot;:&amp;quot;155444-160022&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit87&quot; id=&quot;supportedunsupported&quot;&gt;3.6.2. Supported / Unsupported&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The C# backend of the code generator has the following features and limitations.
&lt;/p&gt;

&lt;p&gt;
The supported elements are as follows:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Hierarchical states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry/Exit/Do Activities of states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; (Signal-)Events with event name, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial and final pseudo-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; History states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choices&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Constraints&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Sync-states and junctions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry and exit points (not to compare with entry/exit actions within states)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Submachines&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Terminate and Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.6.2. Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;supportedunsupported&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:40,&amp;quot;secid&amp;quot;:87,&amp;quot;range&amp;quot;:&amp;quot;160023-160586&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit88&quot; id=&quot;generating_java_code&quot;&gt;3.7. Generating Java Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.7. Generating Java Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_java_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:40,&amp;quot;secid&amp;quot;:88,&amp;quot;range&amp;quot;:&amp;quot;160587-160625&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit89&quot; id=&quot;introduction3&quot;&gt;3.7.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To generate Java code call the code generator with the command line flag &lt;code&gt;&amp;#039;-l java&amp;#039;&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
To generate a configuration file with all parameters related to the Java code generation call the code generator as follows once: &lt;code&gt; java -cp &amp;quot;path to bin folder&amp;quot; codegen.Main -l java -gencfg &amp;gt; codegen.cfg &lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
The generator generates just one Java class which implements the complete state machine. This has the benefit that your Java project does not become bloated with all kinds of helper classes. If required an optional base class can be specified in the config file. Also the package (Namespace=…) can be defined there. The events that can be sent to the machine are defined in a public enumeration.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.7.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction3&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:40,&amp;quot;secid&amp;quot;:89,&amp;quot;range&amp;quot;:&amp;quot;160626-161362&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit90&quot; id=&quot;regions3&quot;&gt;3.7.2. Regions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Not yet supported in this back-end.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.7.2. Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;regions3&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:40,&amp;quot;secid&amp;quot;:90,&amp;quot;range&amp;quot;:&amp;quot;161363-161425&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit91&quot; id=&quot;typically_needed_configuration_parameters&quot;&gt;3.7.3. Typically needed Configuration Parameters&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Use the configuration parameter &lt;code&gt;Namespace&lt;/code&gt; to set the package the generated Java code is in. Example: &lt;code&gt;Namespace=package oven.Model;&lt;/code&gt; Use the configuration parameter &lt;code&gt;BaseClassMachine&lt;/code&gt; to set the base class. Example: &lt;code&gt;BaseClassMachine=ReactorBase&lt;/code&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.7.3. Typically needed Configuration Parameters&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;typically_needed_configuration_parameters&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:40,&amp;quot;secid&amp;quot;:91,&amp;quot;range&amp;quot;:&amp;quot;161426-161759&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit92&quot; id=&quot;example_usage&quot;&gt;3.7.4. Example Usage&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The Java back-end was used to define the logic behind the check button of the visual editor. This logic was designed as state machine and controls if the ’save’ and ’save as’ buttons are enabled or disabled. This depends on a configuration flag and several events sent from other parts of the code. The configuration flag &lt;code&gt;SaveCheckedOnly&lt;/code&gt; determines if the machine is in the state ’&lt;code&gt;SaveAllowedAlways&lt;/code&gt;’ or in ’&lt;code&gt;SaveOnlyIfErrorFree&lt;/code&gt;’. Within the latter state two sub-states define when the save buttons are enabled or disabled. Several transitions are going back and forth between these two states. In a base class the methods to actually access the buttons were implemented. The code generated from this design is directly used in the code generator.
&lt;/p&gt;

&lt;p&gt;
The state machine and parts of the generated code are shown in the following figures.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/check_design.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:check_design.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/check_design.png?w=604&amp;amp;tok=fd5162&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;604&quot; /&gt;&lt;/a&gt;
Figure 3.21: State machine controlling the activation / deactivation of the two save buttons depending on several conditions. 
&lt;/p&gt;
&lt;pre class=&quot;code java&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;class&lt;/span&gt; CheckLogic &lt;span class=&quot;kw1&quot;&gt;extends&lt;/span&gt; CheckLogicBase
&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
	&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;enum&lt;/span&gt; States &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
		Unchecked,
		...
	&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
	&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;enum&lt;/span&gt; Events	&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
		evSave,
		evCheckOk,
		...
	&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
	...
&amp;nbsp;
	&lt;span class=&quot;me1&quot;&gt;States&lt;/span&gt; stateVar&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
	States stateVarSaveOnlyIfErrorFree&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	...
&amp;nbsp;
	&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; initialize&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
			...
		&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
	&lt;span class=&quot;kw1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; processEvent&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Events msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
		&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; evConsumed &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
		&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;m_initialized&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
		&lt;span class=&quot;kw1&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;stateVar&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; SaveAllowedAlways&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
			&lt;span class=&quot;kw1&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* end of case SaveAllowedAlways	 */&lt;/span&gt;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; SaveOnlyIfErrorFree&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
&amp;nbsp;
				&lt;span class=&quot;kw1&quot;&gt;switch&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;stateVarSaveOnlyIfErrorFree&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; Checked&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
						&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;Events.&lt;span class=&quot;me1&quot;&gt;evCheckError&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from Checked to Unchecked */&lt;/span&gt;
							evConsumed&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* OnEntry code of state Unchecked */&lt;/span&gt;
							setEditorGuiUnchecked&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
							...
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
				&lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&lt;/span&gt;
			&lt;span class=&quot;kw1&quot;&gt;break&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* end switch stateVar_root */&lt;/span&gt;
		&lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; evConsumed&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;	&lt;/pre&gt;

&lt;p&gt;
The state machine can be used the following way:
&lt;/p&gt;
&lt;pre class=&quot;code java&quot;&gt;CheckLogic checkLogic&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;new&lt;/span&gt; CheckLogic&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
checkLogic.&lt;span class=&quot;me1&quot;&gt;initialize&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// init state machine&lt;/span&gt;
checkLogic.&lt;span class=&quot;me1&quot;&gt;processEvent&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;CheckLogic.&lt;span class=&quot;me1&quot;&gt;Events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evAllowSaveAlways&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.7.4. Example Usage&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;example_usage&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:40,&amp;quot;secid&amp;quot;:92,&amp;quot;range&amp;quot;:&amp;quot;161760-163964&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit93&quot; id=&quot;generating_swift_code&quot;&gt;3.8. Generating Swift Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Please note that the Swift back-end is work-in-progress. Your feedback is highly welcome!
&lt;/p&gt;

&lt;p&gt;
Swift is a new object-oriented programming language for iOS and &lt;abbr title=&quot;Operating System&quot;&gt;OS&lt;/abbr&gt; X development. To generate Swift code call the code generator with the command line flag &lt;code&gt; -l swift &lt;/code&gt;. To generate a configuration file with all parameters related to the Swift code generation call the code generator as follows once: &lt;code&gt; java -jar codegen.jar -l swift -gencfg &amp;gt; codegen.cfg &lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
The events that can be sent to the machine are defined in a public enumeration.
&lt;/p&gt;

&lt;p&gt;
The generator generates just one Swift class which implements the complete state machine. This has the benefit that your Swift project does not become bloated with all kinds of helper classes. This means that the generated code does not follow the usual state pattern as you might expect (if you are familiar with common design patterns). The reason is that the machine code is completely generated and no hand-coding is involved.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.8. Generating Swift Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_swift_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:42,&amp;quot;secid&amp;quot;:93,&amp;quot;range&amp;quot;:&amp;quot;163965-164981&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit94&quot; id=&quot;separate_generated_from_non-generated_code1&quot;&gt;3.8.1. Separate generated from non-generated Code&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Even if the state machine is fully generated this is usually only a smaller part of your application whereas the lager part is coded manually. For several reasons it is important to clearly separate generated code from non-generated code. Use one of the following possibilities to achieve this.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The most basic method is to put hand written code into libraries and call the library from within the state machine.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Generated classes can also subclass non-generated classes (base class of StateMachine). Such base classes can contain useful methods that can be called from within the generated subclasses.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Hand written code is located in a child class of the state machine. I.e. the state machine classes are parts of other classes.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.8.1. Separate generated from non-generated Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;separate_generated_from_non-generated_code1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:42,&amp;quot;secid&amp;quot;:94,&amp;quot;range&amp;quot;:&amp;quot;164982-165785&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit95&quot; id=&quot;supported_state_machine_features&quot;&gt;3.8.2. Supported state machine features&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; States and sub-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Deep – and flat hierarchy&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry, Exit and Action code of states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions are supported and implemented as sub-functions called from the main state machine handler.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Option to define state machine signature&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choice pseudo-states&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.8.2. Supported state machine features&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;supported_state_machine_features&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:42,&amp;quot;secid&amp;quot;:95,&amp;quot;range&amp;quot;:&amp;quot;165786-166110&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit96&quot; id=&quot;generating_python_code&quot;&gt;3.9. Generating Python Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.9. Generating Python Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_python_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:42,&amp;quot;secid&amp;quot;:96,&amp;quot;range&amp;quot;:&amp;quot;166111-166151&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit97&quot; id=&quot;introduction4&quot;&gt;3.9.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To generate Python code call the code generator with the command line flag &lt;code&gt;&amp;#039;-l python&amp;#039;&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
To generate a configuration file with all parameters related to Python call the code generator as follows once: &lt;code&gt; java -cp &amp;quot;*&amp;quot; codegen.Main -l python -gencfg &amp;gt; codegen.cfg &lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
The generator produces a Python class that implements the entire state machine. This approach offers the advantage of keeping your Python project clean without cluttering it with various helper classes. Additionally, you have the option to specify an optional base class in the configuration file if needed.
&lt;/p&gt;

&lt;p&gt;
To get started, you can find the microwave oven project introduced in the earlier section. It’s available at this GitHub link. This project is fully functional and includes a graphical user interface (&lt;abbr title=&quot;Graphical User Interface&quot;&gt;GUI&lt;/abbr&gt;) implemented with Tkinter. The &lt;abbr title=&quot;Graphical User Interface&quot;&gt;GUI&lt;/abbr&gt; enables you to send events to the state machine and observe its reactions.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/tkinker_oven.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:tkinker_oven.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/tkinker_oven.png?w=377&amp;amp;tok=9319b0&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure 3.22: Tkinker oven frontend. Use the buttons to send events to the state machine
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.9.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction4&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:42,&amp;quot;secid&amp;quot;:97,&amp;quot;range&amp;quot;:&amp;quot;166152-167216&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit98&quot; id=&quot;supported_state_machine_features1&quot;&gt;3.9.2. Supported state machine features&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; States and sub-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Deep – and flat hierarchy&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry, Exit and Action code of states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choice pseudo-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transitions with event, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.9.2. Supported state machine features&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;supported_state_machine_features1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:42,&amp;quot;secid&amp;quot;:98,&amp;quot;range&amp;quot;:&amp;quot;167217-167438&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit99&quot; id=&quot;unsupported_state_machine_features&quot;&gt;3.9.3. Unsupported state machine features&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Submachines&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.9.3. Unsupported state machine features&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;unsupported_state_machine_features&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:42,&amp;quot;secid&amp;quot;:99,&amp;quot;range&amp;quot;:&amp;quot;167439-167520&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit100&quot; id=&quot;generating_lua_code&quot;&gt;3.10. Generating Lua Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Please note that the Lua back-end is work-in-progress. Your feedback is highly welcome!
&lt;/p&gt;

&lt;p&gt;
Lua is a powerful, efficient, lightweight, embeddable scripting language (http://&lt;a href=&quot;http://www.lua.org/&quot; class=&quot;urlextern&quot; title=&quot;http://www.lua.org/&quot; rel=&quot;ugc nofollow&quot;&gt;www.lua.org/&lt;/a&gt;). To generate Lua code call the code generator with the command line flag &lt;code&gt; -l lua &lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
The generator generates one Lua module which implements the complete state machine. For a simple state machine with 4 states and 2 events the generated module looks like this:
&lt;/p&gt;
&lt;pre class=&quot;code lua&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; testcase&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;new&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;local&lt;/span&gt; new_inst &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
        &lt;span class=&quot;kw3&quot;&gt;setmetatable&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; new_inst&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; testcase&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
        &lt;span class=&quot;co1&quot;&gt;-- machine states&lt;/span&gt;
        new_inst&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;states &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
                S1&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;S1&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
                S11&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;S11&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
                S12&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;S12&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
                S3&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;S3&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
                __UNKNOWN_STATE__&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;__UNKNOWN_STATE__&amp;quot;&lt;/span&gt;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
        &lt;span class=&quot;co1&quot;&gt;-- machine events&lt;/span&gt;
        new_inst&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;events &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
                evB&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evB&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
                evA&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evA&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
                TESTCASE_NO_MSG&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;TESTCASE_NO_MSG&amp;quot;&lt;/span&gt;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
        &lt;span class=&quot;co1&quot;&gt;-- Set state vars to default states&lt;/span&gt;
        new_inst&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;stateVar &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; new_inst&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;states&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;S1
        new_inst&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;stateVarS1 &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; new_inst&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;states&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;S11 &lt;span class=&quot;co1&quot;&gt;-- set init state of S1 &lt;/span&gt;
&amp;nbsp;
        new_inst&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;init&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;false&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; new_inst
&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; testcase&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;processEvent&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Event&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span class=&quot;sy0&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; evConsumed&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;end&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; testcase&lt;/pre&gt;

&lt;p&gt;
The statemachine can be used as follows:
&lt;/p&gt;
&lt;pre class=&quot;code lua&quot;&gt;testcase &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw3&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;testcase&amp;quot;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;local&lt;/span&gt; testcase1 &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; testcase&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;new&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
Event &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;event &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; testcase1&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;events&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;TESTCASE_NO_MSG&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; condition&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
testcase1&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;processEvent&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Event&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
Event&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;event&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;testcase1&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;events&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;evA&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
testcase1&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;processEvent&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Event&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.10. Generating Lua Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_lua_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:42,&amp;quot;secid&amp;quot;:100,&amp;quot;range&amp;quot;:&amp;quot;167521-169122&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit101&quot; id=&quot;supported_state_machine_features2&quot;&gt;3.10.1. Supported state machine features&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; States and sub-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Deep – and flat hierarchy&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry, Exit and Action code of states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions are supported and implemented as sub-functions called from the main state machine handler.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choice pseudo-states&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.10.1. Supported state machine features&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;supported_state_machine_features2&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:44,&amp;quot;secid&amp;quot;:101,&amp;quot;range&amp;quot;:&amp;quot;169123-169403&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit102&quot; id=&quot;generating_rust_code&quot;&gt;3.11. Generating Rust Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Please note that the Rust back-end is work-in-progress. Your feedback is highly welcome!
&lt;/p&gt;

&lt;p&gt;
Rust a is a relatively new programming language aiming to guarantee memory-safety and thread-safety. Rust is fast and memory-efficient with no runtime or garbage collector. More information about Rust is available at https://&lt;a href=&quot;http://www.rust-lang.org&quot; class=&quot;urlextern&quot; title=&quot;http://www.rust-lang.org&quot; rel=&quot;ugc nofollow&quot;&gt;www.rust-lang.org&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
To generate Rust code call the code generator with the following command line flag &lt;code&gt; -l Rust -o test&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
The generated code is using basic Rust features like &lt;code&gt;match&lt;/code&gt;, &lt;code&gt;if/then/else&lt;/code&gt; and can easily be understood.
&lt;/p&gt;

&lt;p&gt;
The output name defines the generated state machine file name (Note the lower case ’t’ to follow Rust convention), the name of the state machine type and the prefix for the event and state enums.
&lt;/p&gt;

&lt;p&gt;
The simplified code looks as follows:
&lt;/p&gt;
&lt;pre class=&quot;code Rust&quot;&gt;&lt;span class=&quot;co0&quot;&gt;// states of the state machine&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;enum&lt;/span&gt; TestStates&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    S1&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
    ...
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co0&quot;&gt;// Events that can be sent to the state machine&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;enum&lt;/span&gt; TestEvents &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    Ev1&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
    ...
    TestNoMsg&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    #&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;macro_export&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt;
    macro_rules&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt; def_fsm&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;$data_t&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;ty &lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; $timer_service_t&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;ty $&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;$element&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;ident&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; $ty&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;ty &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; $ex&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;expr&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
            &lt;span class=&quot;co0&quot;&gt;// Test struct definitions ... comes here&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;struct&lt;/span&gt; Test &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
                &lt;span class=&quot;kw1&quot;&gt;pub&lt;/span&gt; is_init&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kw3&quot;&gt;bool&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
                &lt;span class=&quot;kw1&quot;&gt;pub&lt;/span&gt; state_var&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; TestStates&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
                ...
                &lt;span class=&quot;coMULTI&quot;&gt;/* Start of user defined attributes */&lt;/span&gt;
                $&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;$element&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; $ty&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,*&lt;/span&gt;
                &lt;span class=&quot;coMULTI&quot;&gt;/* End of user defined attributes */&lt;/span&gt;
            &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
            &lt;span class=&quot;kw1&quot;&gt;impl&lt;/span&gt; Default &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; Test &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
                &lt;span class=&quot;kw1&quot;&gt;fn&lt;/span&gt; default&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt; Self&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
                    Test &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
                        is_init &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
                        state_var &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; TestStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;S1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* Set init for top level state */&lt;/span&gt;
                        ...
                        &lt;span class=&quot;coMULTI&quot;&gt;/* Start of user defined attributes */&lt;/span&gt;
                        $&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;$element&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; $ex&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,*&lt;/span&gt;
                        &lt;span class=&quot;coMULTI&quot;&gt;/* End of user defined attributes */&lt;/span&gt;
                    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
                &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
            &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
            &lt;span class=&quot;kw1&quot;&gt;impl&lt;/span&gt; Test&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
                &lt;span class=&quot;kw1&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;fn&lt;/span&gt; handle_event&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; ev&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; TestEvents&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
                    data&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;$data_t&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; timer_service&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;$timer_service_t
                    &lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt; usize &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
                        &lt;span class=&quot;co0&quot;&gt;// generated state machine handler code&lt;/span&gt;
                        ...
                    &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
                &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
        &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
The generator uses the macro features of Rust. A concrete type of a machine must be defined by using a &lt;code&gt;def_fsm&lt;/code&gt; macro call before the machine can be used.
&lt;/p&gt;
&lt;pre class=&quot;code Rust&quot;&gt;&lt;span class=&quot;co0&quot;&gt;//def_fsm!(UserData, &amp;amp;mut crate::Timers&amp;lt;TestEvents&amp;gt;, x:i32=99, y:i32=99);&lt;/span&gt;
def_fsm&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;UserData&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; crate&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Timers&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;TestEvents&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; timers &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; Timers&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;let&lt;/span&gt; some_data &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; UserData &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;guard1 &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; myfsm &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; Test &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; Default&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;default&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
myfsm.initialize&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;some_data&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; timers&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co0&quot;&gt;// sending events to the machine&lt;/span&gt;
myfsm.handle_event&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TestEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Ev1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; some_data&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; timers&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
myfsm.handle_event&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TestEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Ev2&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; some_data&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; timers&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
myfsm.handle_event&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TestEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Ev3&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; some_data&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; timers&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
The first macro parameter is a user defined type used as a parameter of the state machine handler. It is available inside the event handler with variable name &lt;code&gt;data&lt;/code&gt; and type &lt;code&gt;UserData&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
The intended purpose is to provide a way for the user to hand over any kind of data to the state machine handler function which can then be used in the state machine. A simple use case is to hand over variables that acts as guards in state transitions.
&lt;/p&gt;

&lt;p&gt;
The other intended purpose is that the &lt;code&gt;UserData&lt;/code&gt; type must provide a log function of a predefined signature in case the state machine was generated with the trace command line parameter &lt;code&gt;-Trace&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
If tracing is enabled log calls are automatically added to the code such as
&lt;/p&gt;
&lt;pre class=&quot;code Rust&quot;&gt;data.&lt;span class=&quot;kw1&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;S1&amp;quot;&lt;/span&gt;.to_string&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;S3&amp;quot;&lt;/span&gt;.to_string&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Ev1&amp;quot;&lt;/span&gt;.to_string&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
The UserData type has to implement the log function e.g as follows:
&lt;/p&gt;
&lt;pre class=&quot;code Rust&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; from&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;String&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;String&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; event&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;String&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    println&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Trace: from:{}, to:{}, event:{}&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; from&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;to&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; event&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
The second macro parameter allows to hand over another user defined type intended to realise a timer service. Whether the state machine needs and uses a timer service and how it is implemented is totally in the user’s hand. A microwave oven example is provided in the samples folder. It implements a basic timer service for realising the timeout for the cooking time.
&lt;/p&gt;

&lt;p&gt;
Note: presently there is no possibly to avoid the handover of the &lt;code&gt;UserData&lt;/code&gt; and &lt;code&gt;Timer&lt;/code&gt; struct. This might change in later versions.
&lt;/p&gt;

&lt;p&gt;
All further parameters are optional and simply added to the state machine struct. In the code above an example with parameters &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; is shown.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.11. Generating Rust Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_rust_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:44,&amp;quot;secid&amp;quot;:102,&amp;quot;range&amp;quot;:&amp;quot;169404-174156&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit103&quot; id=&quot;regions4&quot;&gt;3.11.1. Regions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Regions are fully supported by the code generator. See 3.2.2 for more information how regions are implemented in general. In Rust an internal clone is crated at runtime which is then becoming the new state at the end of the state handler.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.11.1. Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;regions4&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:48,&amp;quot;secid&amp;quot;:103,&amp;quot;range&amp;quot;:&amp;quot;174157-174423&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit104&quot; id=&quot;supported_state_machine_features3&quot;&gt;3.11.2. Supported state machine features&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Flat or hierarchical state machines&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Deep – and flat history&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry, Exit and Action code of states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choice pseudo-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Final states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transitions with event, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.11.2. Supported state machine features&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;supported_state_machine_features3&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:48,&amp;quot;secid&amp;quot;:104,&amp;quot;range&amp;quot;:&amp;quot;174424-174687&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit105&quot; id=&quot;unsupported_state_machine_features1&quot;&gt;3.11.3. Unsupported state machine features&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Submachines&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.11.3. Unsupported state machine features&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;unsupported_state_machine_features1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:48,&amp;quot;secid&amp;quot;:105,&amp;quot;range&amp;quot;:&amp;quot;174688-174758&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit106&quot; id=&quot;generating_go_code&quot;&gt;3.12. Generating GO Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.12. Generating GO Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_go_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:48,&amp;quot;secid&amp;quot;:106,&amp;quot;range&amp;quot;:&amp;quot;174759-174796&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit107&quot; id=&quot;introduction5&quot;&gt;3.12.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To generate GO code, call the code generator with the command line flag &lt;code&gt;&amp;#039;-l go&amp;#039;&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
To generate a configuration file with all parameters related to the GO code generation, call the code generator as follows once: &lt;code&gt; java -cp &amp;quot;path to bin folder\*&amp;quot; codegen.Main -l go -gencfg &amp;gt; codegen.cfg &lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
The generated code does not follow any state pattern as you might expect (if you are familiar with common design patterns). This is because the machine code is completely generated and no hand coding is involved.
&lt;/p&gt;

&lt;p&gt;
In the generated GO code, state hierarchies are mapped to nested switch/case code. Event handling code is mapped to if/else-if/else structures. There are several configuration/command line options to adjust the generated code. Before calling the event handler function , call the init function to initialise the state machine and run all the state’s entry code once.
&lt;/p&gt;

&lt;p&gt;
Example:
&lt;/p&gt;
&lt;pre class=&quot;code numberLines&quot;&gt;events := []MachineEvent{Ev1, EvFinal}
&amp;nbsp;
sm := Machine{}
sm.Init()
&amp;nbsp;
for _, event := range events {
    _, err := sm.ProcessEvent(event)	
&amp;nbsp;&lt;/pre&gt;

&lt;p&gt;
Configuration file options:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;BaseClassMachine&lt;/code&gt;: GO supports the language concept of embedding of structs to express a more seamless composition of types. With the &lt;code&gt;BaseClassMachine&lt;/code&gt; parameter the parent’s structure Type (embedding) can be specified. The nice thing in GO is the possibility to access structure members or functions of the embedding structure in the generated state machine code. This feature is used for example in the oven tutorial example to provide access to a Timer service and to store some data (timer IDs).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;Namespace&lt;/code&gt;: The specified value is used as package name of the generated code.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;ValidationCall&lt;/code&gt;: With the parameter &lt;em&gt;ValidationCall=yes&lt;/em&gt; it is possible to automatically insert method calls that allow to check if a transition is allowed or simply to trace state changes. The validation method has to be implemented by the user usually as function of the structure that embeds the state machine (see oven example in GO).&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.12.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction5&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:48,&amp;quot;secid&amp;quot;:107,&amp;quot;range&amp;quot;:&amp;quot;174797-176883&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit108&quot; id=&quot;regions5&quot;&gt;3.12.2. Regions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Regions are supported. See 3.2.2 for more information.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.12.2. Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;regions5&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:49,&amp;quot;secid&amp;quot;:108,&amp;quot;range&amp;quot;:&amp;quot;176884-176966&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit109&quot; id=&quot;error_handling&quot;&gt;3.12.3. Error Handling&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
GO has a built-in error type. Several generated functions uses error values to indicate an abnormal state.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.12.3. Error Handling&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;error_handling&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:49,&amp;quot;secid&amp;quot;:109,&amp;quot;range&amp;quot;:&amp;quot;176967-177108&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit110&quot; id=&quot;tracing_the_event_flow&quot;&gt;3.12.4. Tracing the Event Flow&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The code generator can be called with the &lt;em&gt;-Trace&lt;/em&gt; command line parameter which then adds methods that allows to trace the event flow e.g. for debugging, test or validation purposes.
&lt;/p&gt;

&lt;p&gt;
The following first code snippet exemplarily shows generated code for validate handler.
&lt;/p&gt;
&lt;pre class=&quot;code numberLines&quot;&gt;// called by the state machine if tracing is enabled
func (smBase *Reactor) TraceEvent(traceIdx int) {
	var traceString = smBase.Statemachine.TraceLookup(traceIdx)
	debugPrint(fmt.Sprintf(&amp;quot;Trace msg: %s\n&amp;quot;, traceString))
}
&amp;nbsp;
// called by the state machine if validation hander is enabled
func (smBase *Reactor) ValidationHandler(from OvenState, to OvenState) {
	toString, _ := smBase.Statemachine.StateToString(to)
	fromString, _ := smBase.Statemachine.StateToString(from)
	debugPrint(fmt.Sprintf(&amp;quot;Change state from %s to %s\n&amp;quot;, fromString, toString))
}&lt;/pre&gt;

&lt;p&gt;
And then what the generated code looks like. Line 4 shows how the validation function is called. And line 21 shows the trace call. There are utility functions to convert both the state and event numbers to text strings. into text strings.
&lt;/p&gt;
&lt;pre class=&quot;code numberLines&quot;&gt;...
if msg == EvError {
	/* Transition from Super to Error*/
	smBase.ValidationHandler(Super, Error)
	eventConsumed=1
&amp;nbsp;
	/* Exit code for regions in state Super*/
&amp;nbsp;
	if(sm.stateVarMainRegion==Cooking){
		smBase.Timers.Stop(smBase.idBlink)
		fmt.Println(&amp;quot;LED Off&amp;quot;)
&amp;nbsp;
	}else {
		/* Intentionally left blank */
	};
&amp;nbsp;
&amp;nbsp;
	smCopy.stateVar = Error;/* Default in entry chain */
	smCopy.stateVarError = Error1;/* Default in entry chain */
&amp;nbsp;
	smBase.TraceEvent(3)
}
...&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.12.4. Tracing the Event Flow&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;tracing_the_event_flow&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:49,&amp;quot;secid&amp;quot;:110,&amp;quot;range&amp;quot;:&amp;quot;177109-178729&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit111&quot; id=&quot;realising_active_objects_in_go&quot;&gt;3.12.5. Realising Active Objects in GO&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
An active object is an object with its own thread of control. A common design pattern is to design an application as a number of active objects. Active objects usually interact through an asynchronous event exchange. The received events are then processed in a state machine (here in &lt;code&gt;processEvent()&lt;/code&gt;). The machine might react with sending events back or to another active object.
&lt;/p&gt;

&lt;p&gt;
A very good introduction on ActiveObjects can be found in &lt;em&gt;Pattern-Oriented Software Architecture, Vol. 2 published by WILEY&lt;/em&gt;. This book describes also a number of other interesting patterns that are usually used to design concurrent (realtime) applications.
&lt;/p&gt;

&lt;p&gt;
GO provides excellent out-of-the-box functionality to implement active objects using only the built-in language features and standard library types. No additional classes or libraries are required. GO routines with the &lt;code&gt;select&lt;/code&gt; and &lt;code&gt;channel&lt;/code&gt; concepts are the basis for creating active objects.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.12.5. Realising Active Objects in GO&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;realising_active_objects_in_go&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:51,&amp;quot;secid&amp;quot;:111,&amp;quot;range&amp;quot;:&amp;quot;178730-179736&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit112&quot; id=&quot;supported_state_machine_features4&quot;&gt;3.12.6. Supported state machine features&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; States and sub-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Deep – and flat hierarchy&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry, Exit and Action code of states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choice pseudo-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transitions with event, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Final states&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.12.6. Supported state machine features&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;supported_state_machine_features4&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:51,&amp;quot;secid&amp;quot;:112,&amp;quot;range&amp;quot;:&amp;quot;179737-179988&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit113&quot; id=&quot;unsupported_state_machine_features2&quot;&gt;3.12.7. Unsupported state machine features&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Submachines&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.12.7. Unsupported state machine features&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;unsupported_state_machine_features2&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:51,&amp;quot;secid&amp;quot;:113,&amp;quot;range&amp;quot;:&amp;quot;179989-180059&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit114&quot; id=&quot;generating_javascript_code&quot;&gt;3.13. Generating JavaScript Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The JavaScript documentation is available online here: &lt;a href=&quot;https://www.sinelabore.de/doku.php/wiki/backends/javascript&quot; class=&quot;urlextern&quot; title=&quot;https://www.sinelabore.de/doku.php/wiki/backends/javascript&quot; rel=&quot;ugc nofollow&quot;&gt;https://www.sinelabore.de/doku.php/wiki/backends/javascript&lt;/a&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.13. Generating JavaScript Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_javascript_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:51,&amp;quot;secid&amp;quot;:114,&amp;quot;range&amp;quot;:&amp;quot;180060-180221&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit115&quot; id=&quot;generating_doxygen_documentation&quot;&gt;3.14. Generating Doxygen Documentation&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Doxygen (&lt;a href=&quot;https://www.doxygen.nl&quot; class=&quot;urlextern&quot; title=&quot;https://www.doxygen.nl&quot; rel=&quot;ugc nofollow&quot;&gt;https://www.doxygen.nl&lt;/a&gt;) is a popular tool to generate different kinds of documentation from annotated source code. Doxygen also allows to embed dot based descriptions of graphs in the source code. The graph visualisation is then integrated in the generated html documentation.
&lt;/p&gt;

&lt;p&gt;
With the command line option &lt;code&gt;-doxygen&lt;/code&gt; the code generator embeds a dot based diagram of the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state machine into the generated state machine source file. An example of the documentation for the microwave machine is shown in figure 3.23.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/doxygen_example.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:doxygen_example.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/doxygen_example.png?w=377&amp;amp;tok=74c3f9&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure 3.23: Doxygen generated source code documentation of the microwave-oven example.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.14. Generating Doxygen Documentation&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_doxygen_documentation&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:51,&amp;quot;secid&amp;quot;:115,&amp;quot;range&amp;quot;:&amp;quot;180222-180939&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit116&quot; id=&quot;robustness_of_uml_state_machines&quot;&gt;3.15. Robustness of UML State Machines&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.15. Robustness of UML State Machines&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;robustness_of_uml_state_machines&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:51,&amp;quot;secid&amp;quot;:116,&amp;quot;range&amp;quot;:&amp;quot;180940-180991&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit117&quot; id=&quot;introduction6&quot;&gt;3.15.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Quality assurance is one of the most essential aspects in the development of embedded real-time systems. One possibility to ensure quality is to perform code reviews but they are time-consuming and very dependent on the reviewer. Therefore it is very attractive to find possibilities for automated error prevention and detection, i.e., a software performing robustness checks. For &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state machines, the &lt;abbr title=&quot;Object Management Group&quot;&gt;OMG&lt;/abbr&gt; has specified a set of wellformedness rules within the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; specification . These rules, as well as a number of additional rules, are performed by the codegen before starting the real code generation.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.15.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction6&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:51,&amp;quot;secid&amp;quot;:117,&amp;quot;range&amp;quot;:&amp;quot;180992-181633&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit118&quot; id=&quot;syntactical_robustness_rules&quot;&gt;3.15.2. Syntactical Robustness Rules&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The following set of rules test the syntactical correctness of the state machine model. These rules are organized into several categories:
&lt;/p&gt;

&lt;/div&gt;

&lt;h4 id=&quot;state_naming_and_structure_rules&quot;&gt;3.15.2.1. State Naming and Structure Rules&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; State names must be unique&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; State names must not contain spaces&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A state follows the naming conventions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Composite states should have more than one child state&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; States should have not only incoming or even no transitions at all (isolated states)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; States must be connected by a sequence of transitions outgoing from an initial state (connectivity)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial states must be defined on every state hierarchy and must have exactly one outgoing transition&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;

&lt;h4 id=&quot;transition_rules&quot;&gt;3.15.2.2. Transition Rules&lt;/h4&gt;
&lt;div class=&quot;level4&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transitions must have a source and a target state&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transitions must have an associated event (excluding transitions from initial states and transitions starting from choice states)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A transition follows the naming conventions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; If there are two or more transitions starting from the same state and triggered from the same event, then their guards must not be true at the same time (see figure 3.25b and c. The code generator just checks that guards are present. It can’t check if the guards are ambiguous (e.g. guard one is &lt;code&gt;i&amp;lt;4&lt;/code&gt; and guard two is &lt;code&gt;i&amp;gt;0&lt;/code&gt;);&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transitions triggered by the same event leave a child and its parent. This is not a problem because a transition has higher priority than another one if its source state is a sub-state of the source of the other one. Make sure that this is what you want (unambiguous specification). See figure 3.25a for an example.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Inter level transitions from states at level three (state is child of two parents) are not allowed (high complexity)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A choice must have only one incoming transition&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A choice state should have at least two outgoing transitions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; One default transition must be specified for a choice state - i.e. the guard is defined as ’else’ (default from choice).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Every outgoing transition from a choice must have a guard defined&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A junction must have only one outgoing transition&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Outgoing transitions of junctions must not have triggers or guards defined&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A junction must have a trigger for each incoming transition&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; States should have not only incoming or even no transitions at all (isolated states). Those states are superfluous and just waste space. See figure 3.24 left side. State &lt;code&gt;S12&lt;/code&gt; has no incoming transition and is therefore not reachable.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; States must be connected by a sequence of transitions outgoing from an initial state (connectivity). Else states are superfluous as they will never be entered. See figure 3.24 right side. In this case every state has at least one incoming transition but still &lt;code&gt;S12&lt;/code&gt; and &lt;code&gt;S23&lt;/code&gt; are not reachable.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial states must be defined on every state hierarchy and must have exactly one outgoing transition.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/reachability.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:reachability.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/reachability.png?w=377&amp;amp;tok=e8bce6&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure 3.24: States are not reachable. The code-generator prints a warning during code generation.
&lt;/p&gt;

&lt;p&gt;
Running the code-generator with the startchart from Figure 3.24 (right machine) creates the warnings as shown below. The states &lt;code&gt;S23&lt;/code&gt; and &lt;code&gt;S11&lt;/code&gt; violate the rules for state names as defined in &lt;code&gt;codegen.cfg&lt;/code&gt;. The non-reachable states &lt;code&gt;s12&lt;/code&gt; and &lt;code&gt;S23&lt;/code&gt; are reported twice because different rules detect the problem in this case.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;Starting robustness tests of state machine ...
State names: ..............
Simple state S23 violates naming conventions as defined in codegen.cfg
Simple state S11 violates naming conventions as defined in codegen.cfg
Machine hierarchy: ........
Default states: ...........
Final states: .............
Connectivity of states: ...
State s12 is not reachable -&amp;gt; check your design.
State S23 is not reachable -&amp;gt; check your design.
State s12 is not reachable -&amp;gt; check your design.
State S23 is not reachable -&amp;gt; check your design.
Transitions: ..............
Choices: ..................
Children in composites: ...&lt;/pre&gt;

&lt;p&gt;
In &lt;code&gt;codegen.cfg&lt;/code&gt;, the prefixes for state names were defined as follows:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;PrefixSimpleStates=s
PrefixCompositeStates=S&lt;/pre&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/conflicting_transitions.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:conflicting_transitions.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/conflicting_transitions.png?w=491&amp;amp;tok=edda96&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;491&quot; /&gt;&lt;/a&gt;
Figure 3.25: This figure shows several examples where transitions and their guards are not unambiguous. In figures b) and c), transitions triggered by event ’ev1’ and starting from state S11 cause the problem. In figure a), transitions triggered by event ’ev2’ all have no guard but this is a valid specification because transitions starting from inner states have higher priority.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.15.2. Syntactical Robustness Rules&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;syntactical_robustness_rules&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:51,&amp;quot;secid&amp;quot;:118,&amp;quot;range&amp;quot;:&amp;quot;181634-186285&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit119&quot; id=&quot;semantical_robustness_rules&quot;&gt;3.15.3. Semantical Robustness Rules&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
It would be highly beneficial to also check semantic rules. For example that there is no overlap in the guard specifications of transitions starting from a choice state. But such checks are not performed yet.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.15.3. Semantical Robustness Rules&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;semantical_robustness_rules&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:53,&amp;quot;secid&amp;quot;:119,&amp;quot;range&amp;quot;:&amp;quot;186286-186542&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit120&quot; id=&quot;command_line_simulation_mode&quot;&gt;3.16. Command Line Simulation Mode&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
If the command line flag &lt;code&gt;’-s’&lt;/code&gt; (for simulation) is used, the code generator enters interactive mode after parsing the input file. No code is generated in this mode. After parsing the input file, you can type in events and observe the state machine’s reactions&lt;sup&gt;&lt;a href=&quot;#fn__6&quot; id=&quot;fnt__6&quot; class=&quot;fn_top&quot;&gt;6)&lt;/a&gt;&lt;/sup&gt;.
&lt;/p&gt;

&lt;p&gt;
During a simulation step, all code executed in response to an event (such as OnEntry code) is printed if the &lt;code&gt;’-v’&lt;/code&gt; command line flag was set. The simulator does not evaluate guards that you might have defined. It assumes that a guard would evaluate to true and takes the transition.
&lt;/p&gt;

&lt;p&gt;
The behavior is different when a transition ends in a choice because the guard information is needed to select the correct outgoing transition of the choice. In this case, you must specify the guard of the outgoing transition to take.
&lt;/p&gt;

&lt;p&gt;
Example: If one guard of an outgoing transition is &lt;code&gt;&amp;#039;[i==5]&amp;#039;&lt;/code&gt; and the other is &lt;code&gt;&amp;#039;[else]&amp;#039;&lt;/code&gt;, and the event to enter the choice is named &lt;code&gt;&amp;#039;evC&amp;#039;&lt;/code&gt;, you can take either outgoing transition by typing &lt;code&gt;&amp;#039;evC[i==5]&amp;#039;&lt;/code&gt; or &lt;code&gt;&amp;#039;evC[else]&amp;#039;&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
To view the currently active state, type &lt;code&gt;&amp;#039;dump&amp;#039;&lt;/code&gt; instead of an event name. This will print the innermost active state.
&lt;/p&gt;

&lt;p&gt;
The following example uses the ’complex’ state diagram from figure 3.2. After startup, the simulator initializes the state machine. As a result, the entry code of the default states is executed.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;$ java -cp &amp;quot;../bin/&amp;quot; codegen.Main -v -p CADIFRA -s complex.cdd
Command line simulation mode enabled--&amp;gt;No C-code will be generated!
No output file name specified. Using complex.c/.h
Used license file: ....
printf(&amp;quot;Outer test action\n&amp;quot;);
printf(&amp;quot;S12Entry\n&amp;quot;);
Enter event name and press return&lt;/pre&gt;

&lt;p&gt;
You can then type event names followed by pressing &lt;code&gt;&amp;#039;return&amp;#039;&lt;/code&gt;. The following is the output for the event &lt;code&gt;e1&lt;/code&gt;:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;e1
msg: e1
printf(&amp;quot;Outer test action\n&amp;quot;);
printf(&amp;quot;S12 Action\n&amp;quot;);
printf(&amp;quot;S12Exit\n&amp;quot;);
printf(&amp;quot;e1Act\n&amp;quot;);
printf(&amp;quot;S21Entry\n&amp;quot;);
----------------------&lt;/pre&gt;

&lt;p&gt;
To check the current state, type &lt;code&gt;&amp;#039;dump&amp;#039;&lt;/code&gt; followed by return:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;dump
Innermost active state is: S21&lt;/pre&gt;

&lt;p&gt;
You can also create a file containing one event per line and use it as input for the simulator. The command line (on the console) for a test file named &lt;code&gt;&amp;#039;tst_input.txt&amp;#039;&lt;/code&gt; would look like this:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;$ java -cp &amp;quot;../bin/codegen.jar&amp;quot; codegen.Main -v -p CADIFRA -s complex.cdd &amp;lt; tst_input.txt&lt;/pre&gt;

&lt;p&gt;
The simulator reads each event and prints the corresponding reaction. It exits after processing the last line.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.16. Command Line Simulation Mode&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;command_line_simulation_mode&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:53,&amp;quot;secid&amp;quot;:120,&amp;quot;range&amp;quot;:&amp;quot;186543-189210&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit121&quot; id=&quot;visual_state_chart_simulation_and_editor&quot;&gt;3.17. Visual State Chart Simulation and Editor&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The description of the graphical editor built into Sinelabore&lt;code&gt;IT&lt;/code&gt; is available online here: &lt;a href=&quot;https://www.sinelabore.de/doku.php/wiki/manual/editor&quot; class=&quot;urlextern&quot; title=&quot;https://www.sinelabore.de/doku.php/wiki/manual/editor&quot; rel=&quot;ugc nofollow&quot;&gt;https://www.sinelabore.de/doku.php/wiki/manual/editor&lt;/a&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.17. Visual State Chart Simulation and Editor&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;visual_state_chart_simulation_and_editor&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:57,&amp;quot;secid&amp;quot;:121,&amp;quot;range&amp;quot;:&amp;quot;189211-189423&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit122&quot; id=&quot;state_tables&quot;&gt;3.18. State Tables&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
State tables are just a different representation of state machines. A state table is a table showing what state the machine will move to, based on the current state and the given event and guard. The code-generator automatically generates a state table for your state machine if the ’-xls’ command line switch is used. The generated output is an Excel table.
&lt;/p&gt;

&lt;p&gt;
The horizontal dimension indicates current states, the vertical dimension indicates next states, and the row/column intersections contain the event which will lead to a particular next state.
&lt;/p&gt;

&lt;p&gt;
A state table and the state diagram show the same information and can be transformed into each other.
&lt;/p&gt;

&lt;p&gt;
A state table has the great benefit of allowing a more systematic check if all transitions were considered in the design. This can be usefully employed in a design review. State tables can also be of great help to create test specification.
&lt;/p&gt;

&lt;p&gt;
Regions are not yet considered during state table generation.
&lt;/p&gt;

&lt;p&gt;
The following figure shows the state table of the state machine from figure 3.2. Compare the two representations and form your own opinion which one to use for which purpose.
&lt;/p&gt;

&lt;p&gt;
Examples:&lt;br/&gt;

From State S3 the events e21 and e8 lead to State S3. From State S21 the event e16 leads to State S22.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/state_table.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:state_table.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/state_table.png?w=453&amp;amp;tok=beb14d&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure 3.26: State tables are a different representation of a state machine. Example: From State S22, event e15 leads to State S21. Even for an example which looks quite complex, the state table shows that only 16 fields are filled out of 64 possible.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.18. State Tables&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;state_tables&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:57,&amp;quot;secid&amp;quot;:122,&amp;quot;range&amp;quot;:&amp;quot;189424-191005&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit123&quot; id=&quot;model_based_testing_of_statemachines&quot;&gt;3.19. Model–Based Testing of Statemachines&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.19. Model\u2013Based Testing of Statemachines&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;model_based_testing_of_statemachines&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:57,&amp;quot;secid&amp;quot;:123,&amp;quot;range&amp;quot;:&amp;quot;191006-191063&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit124&quot; id=&quot;introduction7&quot;&gt;3.19.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Testing is an important but also time consuming part of a project. In general it covers the following steps: (1) building a model, (2) generating test cases, (3) generating expected test results, (4) running the tests, (5) comparison of actual outputs with expected outputs, and (6) decision on further actions (e.g. whether to modify the model, generate more tests, or stop testing).
&lt;/p&gt;

&lt;p&gt;
You can find several articles about testing state machines, but the one written by Martin Gomez  nicely summarises the usually used approach even if model based testing gets more and more interest nowadays.
&lt;/p&gt;

&lt;p&gt;
&lt;em&gt;The beauty of coding even simple algorithms as state machines is that the test plan almost writes itself. All you have to do is to go through every state transition. I usually do it with a highlighter in hand, crossing off the arrows on the state transition diagram as they successfully pass their tests. This is a good reason to avoid ’hidden states’ - they’re more likely to escape testing than explicit states. Until you can use the ’real’ hardware to induce state changes, either do it with a source-level debugger, or build an ’input poker’ utility that lets you write the values of the inputs into your application.&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
Written in 2000 this still describes the common practice. The following sections show how the sinelabore code generator supports you in testing state machines and makes testing state machines more efficient. Sinelabore helps you to make a step towards model based testing.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.19.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction7&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:57,&amp;quot;secid&amp;quot;:124,&amp;quot;range&amp;quot;:&amp;quot;191064-192604&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit125&quot; id=&quot;model&quot;&gt;3.19.2. Model&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
There is some discussion whether the test model should be different from the implementation model. We don’t want to discuss this here. Sinelabore can be used in both cases. For the following discussion we assume that the implementation model (i.e. the model you generate code from) is also also used to derive test cases from.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.19.2. Model&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;model&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:57,&amp;quot;secid&amp;quot;:125,&amp;quot;range&amp;quot;:&amp;quot;192605-192959&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit126&quot; id=&quot;defining_test_cases&quot;&gt;3.19.3. Defining test cases&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Defining test cases is another important step that usually consumes a lot of time if it must be done manually. The code generator can save you a lot of time by automatically suggesting test routes through a given state machine. The used algorithm ensures that all transitions are taken at least once (100% coverage)&lt;sup&gt;&lt;a href=&quot;#fn__7&quot; id=&quot;fnt__7&quot; class=&quot;fn_top&quot;&gt;7)&lt;/a&gt;&lt;/sup&gt;. So it is not anymore necessary to go through the diagram with a highlighter in hand. The following output shows the coverage information from the microwave machine (see folder example 3). &lt;em&gt;The command line option ’-c’ or ’-c1’ switches on the coverage data generation. The first algorithm uses a depth-first tree search algorithm and tries to follow one route as long as possible. This results usually in long but fewer test routes than using -c1. When using -c a breadth-first tree search algorithm is used that produces more but shorter test routes compared to -c.&lt;/em&gt;
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;make
java -jar codegen.jar -c -p CADIFRA -o oven first_example_step3.cdd
Used license file: ...

Transition Coverage:
0:       |From Idle taking event evPwr ending in Idle
1:       |From Idle taking event evInc ending in Idle
2:       |From Idle taking event evDec ending in Idle
3:       |From Idle taking event evDoorClosed ending in Cooking
4:       | |From Cooking taking event evDoorOpen ending in CookingPause
5:       | | |From CookingPause taking event evDoorClosed ending in Cooking
6:       | | | |From Cooking taking event evTimeout ending in Completed
7:       | | | | |From Completed taking event evDoorOpen ending in Idle
Transition Coverage for suggested path(s) 100%
gcc -Wall -g oven.c -c -o oven.o
gcc -Wall -g main.c -c -o main.o
gcc -Wall -g oven_hlp.c -c -o oven_hlp.o
gcc  -o oven oven.o main.o oven_hlp.o&lt;/pre&gt;

&lt;p&gt;
You can see that the first test route starts from the initial state at line 0 and ends at line 7 where no untaken transitions are left to go. The output moves to the right at every new transition on the route that ends in a different state. In this simple example it was possible to trigger all transitions on one test route. For more complex state machines this is usually not possible.
&lt;/p&gt;

&lt;p&gt;
The output for the more complex PLCopen &lt;code&gt;equivalent function block&lt;/code&gt; (see example one on our webside &lt;a href=&quot;https://www.sinelabore.de/doku.php/wiki/examples/plcopen_function_block&quot; class=&quot;urlextern&quot; title=&quot;https://www.sinelabore.de/doku.php/wiki/examples/plcopen_function_block&quot; rel=&quot;ugc nofollow&quot;&gt;https://www.sinelabore.de/doku.php/wiki/examples/plcopen_function_block&lt;/a&gt;) is given below.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;Transition Coverage:
0:       |From Idle taking event enable==1 ending in Init
1:       | |From Init taking event a &amp;amp;&amp;amp; !b &amp;amp;&amp;amp; enable ending in WaitChannelB
2:       | | |From WaitChannelB taking event !a &amp;amp;&amp;amp; !b &amp;amp;&amp;amp; enable ending in Init
3:       | | | |From Init taking event a &amp;amp;&amp;amp; b &amp;amp;&amp;amp; enable ending in SafetyOutEnabled
4:       | | | | |From SafetyOutEnabled taking event !a &amp;amp;&amp;amp; !b &amp;amp;&amp;amp; enable ending in Init
5:       | | | | | |From Init taking event !a &amp;amp;&amp;amp; b &amp;amp;&amp;amp; enable ending in WaitChannelA
6:       | | | | | | |From WaitChannelA taking event evTimeout ending in Error12
7:       | | | | | | | |From Error12 taking event !a &amp;amp;&amp;amp; !b &amp;amp;&amp;amp; enable ending in Init
8:       | | | | | | | | |From Init taking event enable==0 ending in Idle
9:       | | | | | | |From WaitChannelA taking event !a &amp;amp;&amp;amp; !b &amp;amp;&amp;amp; enable ending in Init
10:      | | | | | | |From WaitChannelA taking event a &amp;amp;&amp;amp; b &amp;amp;&amp;amp; enable ending in SafetyOutEnabled
11:      | | | | | | | |From SafetyOutEnabled taking event a &amp;amp;&amp;amp; !b &amp;amp;&amp;amp; enable ending in FromActiveWait
12:      | | | | | | | | |From FromActiveWait taking event evTimeout ending in Error3
13:      | | | | | | | | | |From Error3 taking event !a &amp;amp;&amp;amp; !b &amp;amp;&amp;amp; enable ending in Init
14:      | | | | | | | | |From FromActiveWait taking event !a &amp;amp;&amp;amp; !b &amp;amp;&amp;amp; enable ending in Init
15:      | | | | | | | |From SafetyOutEnabled taking event !a &amp;amp;&amp;amp; b &amp;amp;&amp;amp; enable ending in FromActiveWait
16:      | | |From WaitChannelB taking event a &amp;amp;&amp;amp; b &amp;amp;&amp;amp; enable ending in SafetyOutEnabled
17:      | | |From WaitChannelB taking event evTimeout ending in Error12
Transition Coverage for suggested path(s) 100%&lt;/pre&gt;

&lt;p&gt;
In this case not all transitions can be tested on one route. There are several routes necessary each starting from the init state. In the output new routes have the same indentation level. E.g. from &lt;code&gt;Init&lt;/code&gt; three routes start (line 2, 16 and 17). Altogether seven test routes are necessary to achieve 100% transition coverage.
&lt;/p&gt;

&lt;p&gt;
Beside the console output which gives an overview about the test effort an Excel file is created. It contains one route per sheet. Each line is a single test step on the test route starting from the init state. There are as many sheets as routes are necessary to achieve the 100% transition coverage. A sheet lists the present state and the trigger to reach the listed next state. In addition the constraints of the source and the target states are listed. The constraint information is taken from the state diagram if specified (see next section). The following figure &lt;code&gt;equivalent function block&lt;/code&gt; shows the Excel sheet created for the equivalent machine.
&lt;/p&gt;

&lt;p&gt;
&lt;em&gt;Usually it is necessary to model just the transition that leads to a state change. Transitions that do not lead to a state change can be omitted. But from a testing point of view the latter can be very useful too. Because usually you want to test also if the machine reacts correctly on events which shall not trigger a state change.&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/constraints_excel_equivalent.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:constraints_excel_equivalent.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/constraints_excel_equivalent.png?w=491&amp;amp;tok=827eff&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;491&quot; /&gt;&lt;/a&gt;
Figure 3.27: Test routes to achieve 100% transition coverage are specified in an Excel sheet. Constraints define the expected behaviour in each state. The constraints can be directly specified in the state diagram and are taken over from there. 
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.19.3. Defining test cases&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;defining_test_cases&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:57,&amp;quot;secid&amp;quot;:126,&amp;quot;range&amp;quot;:&amp;quot;192960-198666&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit127&quot; id=&quot;specify_constraints_test_oracle_data_in_state_diagrams&quot;&gt;3.19.4. Specify constraints (test oracle data) in state diagrams&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Constraints can be used to specify the expected output of a state (step 3). This is a valuable input for the tester. The format can be a more formal specification as shown in figure 3.27 which might be used directly in a testbed. Or it can be just informal text providing instructions for a tester. ’Test oracle’ is another name sometimes used for this data.
&lt;/p&gt;

&lt;p&gt;
State constraints must be specified within the state diagram. The code generator uses &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; comments for that purpose. The comment must be attached to a state (either parent or child state or both). If constraints are specified for both parent and child they are merged together.
&lt;/p&gt;

&lt;p&gt;
The comment follows the same syntax as used to define a state compartment e.g. to define entry/exit …actions. Use the keyword &lt;strong&gt;’Constraints:’&lt;/strong&gt; to start the ’constraints’ part. See section 3.28 for more information and the following figure for an example.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/equivalent_md_constraint.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:equivalent_md_constraint.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/equivalent_md_constraint.png?w=340&amp;amp;tok=44f32a&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;340&quot; /&gt;&lt;/a&gt;
Figure 3.28: Defining constraints by attaching a note to a state.
&lt;/p&gt;

&lt;p&gt;
For the codegen internal state diagram editor you can directly specify the constraints as the following figure 3.29 shows for the state &lt;code&gt;&amp;#039;&lt;/code&gt;SafetyOutputEnabled’.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/ssc_equivalent.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:ssc_equivalent.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/ssc_equivalent.png?w=491&amp;amp;tok=004796&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;491&quot; /&gt;&lt;/a&gt;
Figure 3.29: The notes field can be used to specify expected outputs of a state. This information is valuable input for a tester.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.19.4. Specify constraints (test oracle data) in state diagrams&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;specify_constraints_test_oracle_data_in_state_diagrams&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:59,&amp;quot;secid&amp;quot;:127,&amp;quot;range&amp;quot;:&amp;quot;198667-200115&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit128&quot; id=&quot;writing_the_testbed_and_executing_tests&quot;&gt;3.19.5. Writing the testbed and executing tests&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The next step (4) is to write a test-bed that allows you to execute the state machine and to send events to it. Usually test-beds are very hardware specific and different for most embedded systems. Therefore the code-generator does not generate test-bed code for you. This is a step that requires manual work.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.19.5. Writing the testbed and executing tests&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;writing_the_testbed_and_executing_tests&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:59,&amp;quot;secid&amp;quot;:128,&amp;quot;range&amp;quot;:&amp;quot;200116-200485&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit129&quot; id=&quot;analysing_the_test_results&quot;&gt;3.19.6. Analysing the test results&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To finally anaylse (steps 5 and 6) the test results the execution must be traced and stored. Partly the trace feature of the code-generator can help here. See the next chapter 3.20 for more information. But mostly test evaluation is also a manual step.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.19.6. Analysing the test results&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;analysing_the_test_results&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:59,&amp;quot;secid&amp;quot;:129,&amp;quot;range&amp;quot;:&amp;quot;200486-200785&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit130&quot; id=&quot;summary&quot;&gt;3.19.7. Summary&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Gomez  says that testing state machines &lt;em&gt;’require a fair amount of patience and coffee, because even a mid-size state machine can have 100 different transitions. However, the number of transitions is an excellent measure of the system’s complexity. The complexity is driven by the user’s requirements: the state machine makes it blindingly obvious how much you have to test. With a less-organised approach, the amount of testing required might be equally large-you just won’t know it.’&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
The suggested test route(s) ensure that every transition was taken at least once. Consider this as the minimum number of test steps that needs to be performed to test a state machine. Often this is not sufficient. In our example other possible test cases are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Running the transition coverage tests multiple times to test longterm behaviour (e.g. is the timer correctly restarted …)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Testing with different cooking time settings (i.e. testing the timer)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Decrementing the timer to zero after the cooking has started&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.19.7. Summary&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;summary&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:59,&amp;quot;secid&amp;quot;:130,&amp;quot;range&amp;quot;:&amp;quot;200786-201841&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit131&quot; id=&quot;tracing_the_event_flow_of_a_state_machine&quot;&gt;3.20. Tracing the Event flow of a State Machine&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.20. Tracing the Event flow of a State Machine&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;tracing_the_event_flow_of_a_state_machine&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:59,&amp;quot;secid&amp;quot;:131,&amp;quot;range&amp;quot;:&amp;quot;201842-201902&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit132&quot; id=&quot;introduction8&quot;&gt;3.20.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Sometimes it is useful to monitor a system in real-time and trace the sequence of events. For that purpose events are usually written into a buffer for postmortem analysis or sent via a serial link to a monitoring device e.g. a PC.
&lt;/p&gt;

&lt;p&gt;
Also for security reasons it is useful to trace the event flow of a state machine. Some safety standards require this.
&lt;/p&gt;

&lt;p&gt;
In any case it is necessary to instrument the state machine code. This can be done automatically by the code-generator. The command line switch &lt;code&gt;-Trace&lt;/code&gt; enables the generation of trace code. The following code snippet shows the generated trace code for a machine called ’complex’. Lines 2 and 4 are not generated if the trace flag is absent.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;1 if((msg==(COMPLEX_EVENT_T)e1)){
2	 complexTraceEvent(8U);
	 ...
3 }else if((msg==(COMPLEX_EVENT_T)e12)){
4	 complexTraceEvent(12U);
	 ...&lt;/pre&gt;

&lt;p&gt;
The trace code uses unique ids to represent an event. The type of the ids is the same as you have defined for the events itself. The translation back into the event name etc. can be done outside of the embedded system (e.g. on the PC) where memory/performance is not limited.
&lt;/p&gt;

&lt;p&gt;
Therefore additionally to the trace code a C/C++ header file (see below) is generated which allows you to easily translate the trace id (&lt;code&gt;8U&lt;/code&gt; and &lt;code&gt;12U&lt;/code&gt; in the shown case) into the event/guard text string as used in the state machine diagram. This string can be used e.g. to print out the event on the PC side&lt;sup&gt;&lt;a href=&quot;#fn__8&quot; id=&quot;fnt__8&quot; class=&quot;fn_top&quot;&gt;8)&lt;/a&gt;&lt;/sup&gt;. Separate trace ids are generated if different guards for the same event are used. This allows to follow the event flow in all cases. Line 8 and 9 in the header file below shows such a case.
&lt;/p&gt;

&lt;p&gt;
The trace code is prefixed with the machine name (&lt;code&gt;complex&lt;/code&gt; in this case) as the other generated code.
&lt;/p&gt;

&lt;p&gt;
The header file for the shown example looks the following:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;1 #define complexTraceEventLen 17 // number of text strings
2 // prototype of trace fct.
3 void complexTraceEvent(COMPLEX_EVENT_T evt); 
4
5 const char* const complexTraceEvents[] = {
6   &amp;quot;e2&amp;quot;,
7   &amp;quot;e6&amp;quot;,
8   &amp;quot;evC[i==5]&amp;quot;,
9   &amp;quot;evC&amp;quot;,
10 	...
11 	&amp;quot;e16&amp;quot;
12 };&lt;/pre&gt;

&lt;p&gt;
The trace calls are generated automatically but you must implement the function &lt;code&gt;xxxTraceEvent()&lt;/code&gt; which allows you to use the trace data in the way you want. In one case you might want to fill a circular buffer. In another case you might want to send the trace data to a PC. In a third case you want to just toggle a port pin if a certain event occurs. It is up to you how to use the trace data. The following example just prints out the event string.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;void testcaseTraceEvent(TESTCASE_EVENT_T evt){
  printf(&amp;quot;Trace: %s\n&amp;quot;, testcaseTraceEvents[evt]);
}&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.20.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction8&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:59,&amp;quot;secid&amp;quot;:132,&amp;quot;range&amp;quot;:&amp;quot;201903-204793&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit133&quot; id=&quot;using_the_visual_simulator_to_trace_the_event_flow&quot;&gt;3.20.2. Using the Visual Simulator to Trace the Event Flow&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The visual simulator can be stimulated by selecting events from the event tree as discussed in section 3.17. But it can also be stimulated by event strings sent via UDP to port 4445&lt;sup&gt;&lt;a href=&quot;#fn__9&quot; id=&quot;fnt__9&quot; class=&quot;fn_top&quot;&gt;9)&lt;/a&gt;&lt;/sup&gt;.
&lt;/p&gt;

&lt;p&gt;
Under examples a folder named &lt;code&gt;guisim_client_server&lt;/code&gt; shows how this can be used to send trace data via UDP to the visual simulator. If the target executing the state machine has an Ethernet interface (as the PC in the example) the events can be directly sent from the state machine code to the visual simulator.
&lt;/p&gt;

&lt;p&gt;
In this case the function &lt;code&gt;complexTraceEvent()&lt;/code&gt; might look like this:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;// called from the state machine
void complexTraceEvent(COMPLEX_EVENT_T evt){
  rc=sendto(s,complexTraceEvents[evt],
            strlen(complexTraceEvents[evt]),
            0,(SOCKADDR*)&amp;amp;addr,sizeof(SOCKADDR_IN));
  if(rc==SOCKET_ERROR)
  {
    // handle send error
  }
}&lt;/pre&gt;

&lt;p&gt;
In any other case e.g. if there is a RS232 or a CAN interface a small program must be written which receives the event id sent from the embedded target, translates it into the event string using the generated translation table and forwards it via UDP. The following figure 3.30 shows the principal setup in this case. The upper part shows the hardware point of view. The lower part the software side.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/trace_with_target.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:trace_with_target.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/trace_with_target.png?w=529&amp;amp;tok=2b939c&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure 3.30: Sending trace data to the visual simulation.
&lt;/p&gt;

&lt;p&gt;
The visual simulator was intentionally separated from the required relay application. The reason is that the relay application is probably very special because of the event transport mechanism and protocol which might be different for every embedded system.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.20.2. Using the Visual Simulator to Trace the Event Flow&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;using_the_visual_simulator_to_trace_the_event_flow&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:62,&amp;quot;secid&amp;quot;:133,&amp;quot;range&amp;quot;:&amp;quot;204794-206556&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit134&quot; id=&quot;reset_the_simulation&quot;&gt;3.20.3. Reset the simulation&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To reset the visualisation e.g. after rebooting the embedded target you can send the following command to the visualisation. This command should not be used as a normal event within the state machine.
&lt;/p&gt;

&lt;p&gt;
Reset command: __RESET__
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;3.20.3. Reset the simulation&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;reset_the_simulation&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:63,&amp;quot;secid&amp;quot;:134,&amp;quot;range&amp;quot;:&amp;quot;206557-206832&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit135&quot; id=&quot;activity_code_generator&quot;&gt;4. Activity Code Generator&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4. Activity Code Generator&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;activity_code_generator&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:63,&amp;quot;secid&amp;quot;:135,&amp;quot;range&amp;quot;:&amp;quot;206833-206874&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit136&quot; id=&quot;introduction9&quot;&gt;4.1. Introduction&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
There are two diagrams that can be used to express dynamic behaviour in the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt;. State machine diagrams express the states of an object and the events and transitions to change the state (see chapter 3). In contrast activity diagrams (aka flow diagrams) describe the control flow of an algorithm. How to generate code from activity diagrams is described in this chapter. For more information about activity diagrams see the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; Superstructure Specification .
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction9&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:63,&amp;quot;secid&amp;quot;:136,&amp;quot;range&amp;quot;:&amp;quot;206875-207365&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit137&quot; id=&quot;basic_node_types&quot;&gt;4.2. Basic Node Types&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
To describe algorithms &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tools provide activity diagrams. Activity diagrams describes an algorithm (e.g. a function in C or a method in C++) that runs from the begin (defined by the &lt;em&gt;Initial Node&lt;/em&gt; represented by a filled black circle) to the end (defined by the &lt;em&gt;Final Node&lt;/em&gt; represented as circle with a filled black circle inside). Between the initial node and the final node &lt;em&gt;Action Nodes&lt;/em&gt; define the single steps of an activity (shown as rectangles with rounded edges). Inside an action the action name can be shown and more important the code executed during this step. Actions can also contain activities again (nesting). Action names are used in the generated code to enumerate the actions. The name must be a valid code name of the generated language. If the name is missing a unique name is generated automatically (not recommended). If the name contains spaces they are replaced by underline characters.
&lt;/p&gt;

&lt;p&gt;
Nodes are connected by arrows that depict the control flow between nodes.
&lt;/p&gt;

&lt;p&gt;
Use a &lt;em&gt;Decision Node&lt;/em&gt; to represent alternatives in the control flow. A decision node must have at least one incoming arrow and at least two outgoing arrows. Each outgoing arrow must have a guard. One of the guard must be the &lt;em&gt;else&lt;/em&gt; statement to indicate the default path if no other guard evaluates to true (same with choices in state diagrams). Please note that also arrows between normal actions can be guarded. This is not recommended because it might lead to dead locks if there is no alternative path modeled!
&lt;/p&gt;

&lt;p&gt;
&lt;em&gt;Merge Nodes&lt;/em&gt; allow to merge alternative control flows back into one single flow.
&lt;/p&gt;

&lt;p&gt;
The following figure 4.1 shows a basic activity diagram using the elements described so far.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/activitydiagram.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:activitydiagram.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/activitydiagram.png?w=302&amp;amp;tok=6c1af9&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;302&quot; /&gt;&lt;/a&gt;
Figure 4.1: Very simple activity diagram showing the main node types.
&lt;/p&gt;

&lt;p&gt;
Table 4.1: Basic activity elements
&lt;/p&gt;
&lt;div class=&quot;table sectionedit138&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/init.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:init.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/init.png?w=37&amp;amp;tok=805bfe&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot;image&quot; alt=&quot;image&quot; width=&quot;37&quot; /&gt;&lt;/a&gt;            &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;An initial node is a control node at which flow starts when the activity is invoked (&lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; &lt;abbr title=&quot;specification&quot;&gt;spec&lt;/abbr&gt;.). There must only be one initial state in an activity. If the activity contains other activities each level requires an initial state.  &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/action.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:action.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/action.png?w=75&amp;amp;tok=8fb4e6&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot;image&quot; alt=&quot;image&quot; width=&quot;75&quot; /&gt;&lt;/a&gt;          &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Actions define single steps of an activity.                                                                                                                                                                                            &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row2&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/decision_merge.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:decision_merge.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/decision_merge.png?w=37&amp;amp;tok=f53626&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot;image&quot; alt=&quot;image&quot; width=&quot;37&quot; /&gt;&lt;/a&gt;  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Decision and merge nodes allows to split or merge the control flow.                                                                                                                                                                    &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row3&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/final.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:final.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/final.png?w=37&amp;amp;tok=e181dd&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot;image&quot; alt=&quot;image&quot; width=&quot;37&quot; /&gt;&lt;/a&gt;           &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Indicates the end of the activity (i.e. the return of the function). It is allowed to have more than once final node in a diagram.                                                                                                     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row4&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;                                                                 &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;                                                                                                                                                                                                                                       &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table8&amp;quot;,&amp;quot;secid&amp;quot;:138,&amp;quot;range&amp;quot;:&amp;quot;209265-210752&amp;quot;} --&gt;
&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.2. Basic Node Types&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;basic_node_types&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:63,&amp;quot;secid&amp;quot;:137,&amp;quot;range&amp;quot;:&amp;quot;207366-210754&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit139&quot; id=&quot;complex_node_types&quot;&gt;4.3. Complex Node Types&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; defines also &lt;em&gt;Loop Nodes&lt;/em&gt; and &lt;em&gt;Conditional Nodes&lt;/em&gt;. The definition from the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; specification is. “A loop node is a structured activity node that represents a loop with setup, test, and body sections.“ Loop nodes consist of a setup part, a test part and a body part. It is possible to specify if the test is at the begin or the end of the loop. Other attributes that tools allow to define are not used from the code generator.
&lt;/p&gt;

&lt;p&gt;
Table 4.2: Loop generation depends on &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; attribute &lt;em&gt;isTestedFirst&lt;/em&gt;. The left code is produced if &lt;em&gt;isTestedFirst&lt;/em&gt; is set to &lt;em&gt;true&lt;/em&gt;, the right code if it is set to &lt;em&gt;false&lt;/em&gt;.
&lt;/p&gt;
&lt;div class=&quot;table sectionedit140&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/loop.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:loop.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/loop.png?w=151&amp;amp;tok=687aec&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot;image&quot; alt=&quot;image&quot; width=&quot;151&quot; /&gt;&lt;/a&gt;                                                                                     &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;                                                                                                                                             &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;pre class=&quot;code&quot;&gt;\\ /* Loop setup code  */\\ i=0;\\ \\ while(i&amp;lt;100){\\   /* Loop body code  */\\   printf(&amp;quot;Loop running\n&amp;quot;);\\   i++;\\ } \\ &lt;/pre&gt;
&lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;&lt;pre class=&quot;code&quot;&gt;\\ /* Loop setup code  */\\ i=0;\\ \\ do{\\   /* Loop body code  */\\   printf(&amp;quot;Loop running\n&amp;quot;);\\   i++;\\ }while(i&amp;lt;100);\\ &lt;/pre&gt;
&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table9&amp;quot;,&amp;quot;secid&amp;quot;:140,&amp;quot;range&amp;quot;:&amp;quot;211415-211980&amp;quot;} --&gt;
&lt;p&gt;
A conditional node is a structured activity node that represents an exclusive choice among some number of alternatives . A conditional node consists of one or more clauses. Each clause consists of a test section and a body section. The sinelabore code generator generates &lt;em&gt;if/else if/else&lt;/em&gt; code from conditional nodes. It is possible to leave the last test section empty. The body section is then automatically used in the &lt;em&gt;else&lt;/em&gt; part of the generated code.
&lt;/p&gt;

&lt;p&gt;
Table 4.3: The code generator generates &lt;em&gt;if/else if/else&lt;/em&gt; structures from conditional nodes.
&lt;/p&gt;
&lt;div class=&quot;table sectionedit141&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/condition2.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:condition2.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/condition2.png?w=264&amp;amp;tok=19305f&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot;image&quot; alt=&quot;image&quot; width=&quot;264&quot; /&gt;&lt;/a&gt;  &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/condition1.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:condition1.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/condition1.png?w=264&amp;amp;tok=6fce5a&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot;image&quot; alt=&quot;image&quot; width=&quot;264&quot; /&gt;&lt;/a&gt;                                                                    &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;&lt;pre class=&quot;code&quot;&gt;\\ if(i==4){\\   printf(&amp;quot;Action 15\n&amp;quot;);\\ } \\ &lt;/pre&gt;
&lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;&lt;pre class=&quot;code&quot;&gt;\\ if(i==0){\\   printf(&amp;quot;i==0\n&amp;quot;);\\ }else if(i==1){\\   printf(&amp;quot;i==1\n&amp;quot;);\\ }else{\\   printf(&amp;quot;i &amp;gt; 1\n&amp;quot;);\\ }\\ &lt;/pre&gt;
&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table10&amp;quot;,&amp;quot;secid&amp;quot;:141,&amp;quot;range&amp;quot;:&amp;quot;212541-212923&amp;quot;} --&gt;
&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.3. Complex Node Types&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;complex_node_types&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:63,&amp;quot;secid&amp;quot;:139,&amp;quot;range&amp;quot;:&amp;quot;210755-212925&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit142&quot; id=&quot;generator_flags&quot;&gt;4.3.1. Generator Flags&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
The code generator supports a number of generator flags to influence the generation process according to your needs.
&lt;/p&gt;

&lt;p&gt;
The following table shows the available generator flags, their purpose and and example for the generated code.
&lt;/p&gt;

&lt;p&gt;
Table 4.4: Generator parameters for the &lt;code&gt;codegen.cfg&lt;/code&gt; file to influence the generation process. The spaces in the parameters are only here for layout reasons. In reality the names have to be written without any spaces.
&lt;/p&gt;
&lt;div class=&quot;table sectionedit143&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;ActivityFileNamePostfix                 &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;The postfix of the activity c-file name. The first part is defined from the -o command line parameter. The second part from this parameter                                                                                                                                                                                                       &lt;/th&gt;&lt;th class=&quot;col2 leftalign&quot;&gt;-                                                                                                                                                                  &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ActivitySubfunction ParameterDefintion  &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;In case a diagram has sub-activities this parameter defines the function parameters used for sub-function declaration. E.g. set this parameter to $uint8\_t i$ generates                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;&lt;pre class=&quot;code&quot;&gt;\\ // used in header file\\ void subactivity(unit8_t i);\\ ...\\ &lt;/pre&gt;
&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row2&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ActivitySubfunction CallingParameter    &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;In case a diagram has sub-activities this parameter defines the function parameters used for function calling the sub-activity. E.g. set this parameter to $43$ generates                                                                                                                                                                        &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;&lt;pre class=&quot;code&quot;&gt;\\ ...\\ subactivity(32);\\ ... \\ &lt;/pre&gt;
&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row3&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ActivityFunction ParameterDefinition    &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines the function parameters used for main activity function declaration. E.g. set this parameter to $uint8\_t parA, uint8\_t parB$. Then you must call the activity function as                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;&lt;pre class=&quot;code&quot;&gt;\\ // call activity \\ //   form your code\\ activity(3,4);\\ ...\\ // declation in header\\ void activity(uint8_t parA, \\        uint8_t parB);\\ &lt;/pre&gt;
&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row4&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ActivityFunctionPrefixHeader            &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Return type definition of the main activity function e.g. $unit8\_t$ defines that the activity function has to return that type. If the function requires additional prefixes it is also possible to define e.g. specific linker hints where to place the function …                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;-                                                                                                                                                                  &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row5&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ActivityFunctionPrefixCFile             &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Prefix of the main activity function e.g. $unit8\_t$ used in the c-file. Similar to the previous parameter but sometimes it is necessary to have different prefixes in the header and c file.                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;-                                                                                                                                                                  &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row6&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;ActivityFunctionReturnCode              &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Defines the return statement of the main activity function. If empty the generator will not return anything. This must be in line with the definition of parameter ActivityFunctionPrefixCFile. If you defined that the activity function should return a value which is stored locally in variable $retVal$ define that parameter to $retVal$.  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;&lt;pre class=&quot;code&quot;&gt;\\  ... \\  return retVal;\\ }\\ &lt;/pre&gt;
&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row7&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;                                        &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;                                                                                                                                                                                                                                                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;                                                                                                                                                                   &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table11&amp;quot;,&amp;quot;secid&amp;quot;:143,&amp;quot;range&amp;quot;:&amp;quot;213415-217776&amp;quot;} --&gt;
&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.3.1. Generator Flags&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generator_flags&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:67,&amp;quot;secid&amp;quot;:142,&amp;quot;range&amp;quot;:&amp;quot;212926-217778&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit144&quot; id=&quot;optimizations&quot;&gt;4.3.2. Optimizations&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
After model check the code generator performs the following optimizations:
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.3.2. Optimizations&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;optimizations&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:71,&amp;quot;secid&amp;quot;:144,&amp;quot;range&amp;quot;:&amp;quot;217779-217886&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit145&quot; id=&quot;generating_c-code&quot;&gt;4.3.3. Generating C-Code&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Sinelabore creates compact and clearly readable C code from &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; activity diagrams. There are various configuration parameters to adjust the generation process. This allows to generate code that is optimal for your system. See table 4.4 for a list of all available options. To generate C code call the code generator with the command line flag &lt;code&gt;-l cx&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
For each activity in the selected &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; class the generator generates an own C-code and header file. The header file contains only the declaration of the main activity – nothing else.
&lt;/p&gt;

&lt;p&gt;
The code is generated as &lt;code&gt;while loop&lt;/code&gt; that ends if a final node is reached. This kind of generation allows all kind of loops and back links in the model. An alternative generation is to use &lt;em&gt;goto&lt;/em&gt; statements. But this was considered as not acceptable for most embedded developers and is not used for that reason. The following listing shows the principle structure of the generated C-code for a simple example without sub-activities.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;/* User defined header text  */
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;

extern uint8_t n;
extern uint8_t m;

uint8_t product;
/*Enumeration of all node names */
typedef enum {
	TEST_OPERATION_ACTION2,
	TEST_OPERATION_ACTION3,
	TEST_OPERATION_ACTIVITYFINAL,
	TEST_OPERATION_ACTIVITYINITIAL,
	TEST_OPERATION,__END__,
} BRANCHES;


uint8_t test_operation(void ){

	BRANCHES id;

	id = TEST_OPERATION_ACTION2;
	while(id != __END__) { 
		switch(id) {
			case TEST_OPERATION_ACTION2:
				printf(&amp;quot;action 2\n&amp;quot;);
				id=TEST_OPERATION_ACTION3;
				break;

			case TEST_OPERATION_ACTION3:
				printf(&amp;quot;action 3\n&amp;quot;);
				product=n*m;
				id=TEST_OPERATION_ACTIVITYFINAL;
				break;

			case TEST_OPERATION_ACTIVITYFINAL:
				id= __END__;
				break;

			default:
				break;

		}
	}
	return product;
}&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.3.3. Generating C-Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_c-code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:71,&amp;quot;secid&amp;quot;:145,&amp;quot;range&amp;quot;:&amp;quot;217887-219713&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit146&quot; id=&quot;activity_diagrams_with_enterprise_architect&quot;&gt;4.4. Activity Diagrams with Enterprise Architect&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.4. Activity Diagrams with Enterprise Architect&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;activity_diagrams_with_enterprise_architect&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:72,&amp;quot;secid&amp;quot;:146,&amp;quot;range&amp;quot;:&amp;quot;219714-219775&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit147&quot; id=&quot;introduction10&quot;&gt;4.4.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
It is possible to create one or more activity diagrams for a class. Right click on the class and insert a new Activity with Activity Diagram. Each activity must have a unique name.
&lt;/p&gt;

&lt;p&gt;
Also like for state diagrams it is necessary to specify the path in the XMI file to the class to generate code for. Use the &lt;em&gt;-t&lt;/em&gt; command line parameter for that purpose. It is important that you export the model using version 2.4.1 of the XMI standard. The version can be selected in the export dialog and then pressing &lt;em&gt;Publish&lt;/em&gt;. Don’t simply export the model. Then an old XMI version is used not fully supporting activity diagrams.
&lt;/p&gt;

&lt;p&gt;
To generate code from activity diagram diagrams use the &lt;em&gt;-A&lt;/em&gt; command line switch. For the shown EA diagram the following command line is used for code generation. Note that for all activity diagrams of a class code is generated!
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;java -cp &amp;quot;path to codegen bin folder&amp;quot; codegen.Main -A -p EA -o testcase -t
&amp;quot;Model:test:class_with_activities&amp;quot;  testcase.xml&lt;/pre&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/ea_activity.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:ea_activity.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/ea_activity.png?w=453&amp;amp;tok=145361&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure 4.2: An EA activity diagram with all node types currently supported by the code generator.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.4.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction10&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:72,&amp;quot;secid&amp;quot;:147,&amp;quot;range&amp;quot;:&amp;quot;219776-220954&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit148&quot; id=&quot;actions&quot;&gt;4.4.2. Actions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To add code to actions use the &lt;em&gt;Effect&lt;/em&gt; field. To show the code in the diagram check the option &lt;em&gt;Show Effect in Diagram&lt;/em&gt; in the same dialog. Unfortunately EA does display all your code in one long line in an action even separate lines were used in the effect field. The code generator tries to format your code best possible.
&lt;/p&gt;

&lt;p&gt;
&lt;strong&gt;To add an action or guard into the body field of a loop or conditional node just place an action into the field. Make sure the place for the action is large enough. Even if it looks like the action is correctly placed in the body area check in the model browser whether the action is shown in the correct hierarchy level. Otherwise the generation will not work!&lt;/strong&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.4.2. Actions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;actions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:73,&amp;quot;secid&amp;quot;:148,&amp;quot;range&amp;quot;:&amp;quot;220955-221678&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit149&quot; id=&quot;defining_own_include_statements&quot;&gt;4.4.3. Defining own Include Statements&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To include your own set of headers, define local variables or make other definitions attach a note to the class. The first line of the node must contain the text &lt;em&gt;activity_header:&lt;/em&gt;  . An example is shown in the next figure 4.3.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/ea_activity_header.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:ea_activity_header.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/ea_activity_header.png?w=453&amp;amp;tok=809e2f&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure 4.3: To define own code at the beginning of the generated code use a note with the text &lt;em&gt;activity_header:&lt;/em&gt;  as first line.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.4.3. Defining own Include Statements&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;defining_own_include_statements&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:73,&amp;quot;secid&amp;quot;:149,&amp;quot;range&amp;quot;:&amp;quot;221679-222153&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit150&quot; id=&quot;supportedunsupported1&quot;&gt;4.4.4. Supported / Unsupported&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Decision&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Merge&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Loop&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Condition&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Object related data flow&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Using activities or multiple actions in the body part of loop – or conditional nodes&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Activities in activities (might work, but untested)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choice behind choice. Use conditional node for that purpose&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Crossing border with connections between nodes when using nested activities.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.4.4. Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;supportedunsupported1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:73,&amp;quot;secid&amp;quot;:150,&amp;quot;range&amp;quot;:&amp;quot;222154-222620&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit151&quot; id=&quot;activity_diagrams_with_umodel&quot;&gt;4.5. Activity Diagrams with UModel&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.5. Activity Diagrams with UModel&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;activity_diagrams_with_umodel&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:73,&amp;quot;secid&amp;quot;:151,&amp;quot;range&amp;quot;:&amp;quot;222621-222668&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit152&quot; id=&quot;introduction11&quot;&gt;4.5.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
UModel provides basic activity diagrams modeling features. Add add an activity diagram right click on the class in the class diagram and select &lt;em&gt;New Diagram $\to$ Activiy Diagram&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
Tt is necessary to specify the path to the class in the XMI file on the command line. Use the &lt;em&gt;-t&lt;/em&gt; command line parameter for that purpose. It is important that you export the model using the latest version of the XMI standard supported by UModel (e.g. 2.4.1). The version can be selected in the export dialog.
&lt;/p&gt;

&lt;p&gt;
To generate code from an activity diagram use the &lt;em&gt;-A&lt;/em&gt; command line switch. For the shown EA diagram the following command line is used for code generation. See figures 4.4 and 4.5
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;java -jar -ea codegen.jar -A -p UModel -o testcase -t
&amp;quot;Component View:Class1&amp;quot;  testcase.xml&lt;/pre&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/modeltreeumodel.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:modeltreeumodel.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/modeltreeumodel.png?w=302&amp;amp;tok=efcfdf&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;302&quot; /&gt;&lt;/a&gt;
Figure 4.4: Use the ’-t’ command line option to specify the path to the class containing the activity diagram. For the shown example use -t “Component View:Class1”
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/activitydiagramumodel.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:activitydiagramumodel.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/activitydiagramumodel.png?w=302&amp;amp;tok=36a41f&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;302&quot; /&gt;&lt;/a&gt;
Figure 4.5: An UModel activity diagram with all node types currently supported by the code generator and UModel.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.5.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction11&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:73,&amp;quot;secid&amp;quot;:152,&amp;quot;range&amp;quot;:&amp;quot;222669-223897&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit153&quot; id=&quot;actions1&quot;&gt;4.5.2. Actions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Actions must have valid C names. When adding an action use the &lt;em&gt;Opaque Action&lt;/em&gt; type indicated by a question mark (?) in the icon bar. Only this type of action allows you to define code in the &lt;em&gt;body&lt;/em&gt; attribute available in the properties of an action.
&lt;/p&gt;

&lt;p&gt;
UModel does not export multi-line code as expected. For multi-line code statements add a paragraph sign $§$ at the end of each line. The code generator replaces each paragraph character with a &lt;em&gt;CRLF&lt;/em&gt; symbol.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/actionumodel.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:actionumodel.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/actionumodel.png?w=453&amp;amp;tok=d8613d&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure 4.6: To define action code use the body attribute available in the action property dialog. For multi-line comments add a paragraph symbol as line end.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.5.2. Actions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;actions1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:74,&amp;quot;secid&amp;quot;:153,&amp;quot;range&amp;quot;:&amp;quot;223898-224605&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit154&quot; id=&quot;defining_own_include_statements1&quot;&gt;4.5.3. Defining own Include Statements&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
It is usually necessary to provide own includes, define local variables or make other definitions at the begin of the generated code. Define this code by attaching a &lt;em&gt;Comment&lt;/em&gt; to the class. See example in figure 4.7. The first line of the node must contain the text &lt;em&gt;activity_header:&lt;/em&gt;. It is important to use the &lt;em&gt;Comment&lt;/em&gt; icon and not the &lt;em&gt;Note&lt;/em&gt; icon. An example is shown below.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/classdiagramumodel.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:classdiagramumodel.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/classdiagramumodel.png?w=377&amp;amp;tok=e06583&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure 4.7: Provide a user defined include statement by adding a comment to the class. Text is copied to the begin of the generated code. Use also paragraph symbols as line ends.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.5.3. Defining own Include Statements&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;defining_own_include_statements1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:74,&amp;quot;secid&amp;quot;:154,&amp;quot;range&amp;quot;:&amp;quot;224606-225285&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit155&quot; id=&quot;supportedunsupported2&quot;&gt;4.5.4. Supported / Unsupported&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Supported:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Decision&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Merge&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Loop&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Condition&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Object related data flow&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Using activities or multiple actions in the body part of loop – or conditional nodes&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Activities in activities (might work, but untested)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choice behind choice. Use conditional node for that purpose&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Crossing border with connections between nodes when using nested activities.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.5.4. Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;supportedunsupported2&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:74,&amp;quot;secid&amp;quot;:155,&amp;quot;range&amp;quot;:&amp;quot;225286-225764&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit156&quot; id=&quot;activity_diagrams_with_astah&quot;&gt;4.6. Activity Diagrams with Astah&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.6. Activity Diagrams with Astah&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;activity_diagrams_with_astah&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:74,&amp;quot;secid&amp;quot;:156,&amp;quot;range&amp;quot;:&amp;quot;225765-225811&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit157&quot; id=&quot;introduction12&quot;&gt;4.6.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Astah provides basic activity diagrams modelling features. To add an activity diagram right click on a class in the class diagram and select &lt;em&gt;Create Diagram $\to$ Activity Diagram&lt;/em&gt;. The &lt;em&gt;microwave_handbook_astah&lt;/em&gt; example (part of the download) contains a full example.
&lt;/p&gt;

&lt;p&gt;
It is necessary to specify the path to the activity diagram in the model on the command line. Use the &lt;em&gt;-t&lt;/em&gt; command line parameter for that purpose.
&lt;/p&gt;

&lt;p&gt;
To switch on activity code generation from a model file use the &lt;em&gt;-A&lt;/em&gt; command line switch. Use &lt;em&gt;-D&lt;/em&gt;  to add the astah jar files to the class path (see installation section for more information).
&lt;/p&gt;

&lt;p&gt;
The following example shows how the command line looks on *nix (e.g. Linux or &lt;abbr title=&quot;Operating System&quot;&gt;OS&lt;/abbr&gt; X) like operating systems. The parts of the Java class path are separated by colon (Windows uses spaces). The Astah path depends on your installation. For the shown model tree the following command line is used for code generation.
&lt;/p&gt;

&lt;p&gt;
See figure 4.8 for the related model tree, figure 4.10 for a simple activity diagram and figure 4.9 for an example how to use a generated activity in a state diagram.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;java java -Djava.ext.dirs=&amp;quot;../../bin/&amp;quot;:&amp;quot;/Applications/astah community/astah
community.app/Contents/Java/&amp;quot; -Djava.awt.headless=true -jar -ea codegen.jar
-A -p ASTAH -o oven -t &amp;quot;final:oven:selftest&amp;quot;  oven_model.asta&lt;/pre&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/astah_activity_model.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:astah_activity_model.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/astah_activity_model.png?w=188&amp;amp;tok=8eab0c&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;188&quot; /&gt;&lt;/a&gt;
Figure 4.8: Use the ’-t’ command line option to specify the path to the activity diagram. For the shown example use -t “final:oven:selftest”.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/astah_machine.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:astah_machine.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/astah_machine.png?w=491&amp;amp;tok=95dffd&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;491&quot; /&gt;&lt;/a&gt;
Figure 4.9: This machine is an extension of the microwave oven from the introduction section. It shows how to use generated activity code in a state diagram. Here the self-test function (from init to choice) is fully generated. Depending of the result the &lt;em&gt;Error&lt;/em&gt; state or the &lt;em&gt;Super&lt;/em&gt; state is entered.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/astah_selftest.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:astah_selftest.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/astah_selftest.png?w=491&amp;amp;tok=98afa7&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;491&quot; /&gt;&lt;/a&gt;
Figure 4.10: The self-test function is simple but shows the principles. Please note that the generator combines linear actions to generate more compact code!
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.6.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction12&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:74,&amp;quot;secid&amp;quot;:157,&amp;quot;range&amp;quot;:&amp;quot;225812-227972&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit158&quot; id=&quot;actions2&quot;&gt;4.6.2. Actions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Actions must have valid C names. When adding an action use the  &lt;em&gt;Action&lt;/em&gt; type. Specify the action name in the field &lt;em&gt;Entry&lt;/em&gt; and the code for the action in the field &lt;em&gt;Definition&lt;/em&gt;.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/astah_action_definition.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:astah_action_definition.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/astah_action_definition.png?w=188&amp;amp;tok=b6ce6d&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;188&quot; /&gt;&lt;/a&gt;
Figure 4.11: To define action code use the entry attribute available in the action property dialog.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.6.2. Actions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;actions2&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:75,&amp;quot;secid&amp;quot;:158,&amp;quot;range&amp;quot;:&amp;quot;227973-228351&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit159&quot; id=&quot;defining_own_include_statements2&quot;&gt;4.6.3. Defining own Include Statements&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
It is usually necessary to provide own includes, define local variables or make other definitions at the begin of the generated code. Define this code by placing a &lt;em&gt;Comment&lt;/em&gt; to the activity diagram. See example in figure 4.12. The first line of the node must contain the text &lt;em&gt;activity_header:&lt;/em&gt;. It is important to use the &lt;em&gt;Comment&lt;/em&gt; icon and not the &lt;em&gt;Note&lt;/em&gt; icon. An example is shown below.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/astah_activity_header.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:astah_activity_header.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/astah_activity_header.png?w=188&amp;amp;tok=756806&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;188&quot; /&gt;&lt;/a&gt;
Figure 4.12: Provide a user defined include statement by adding a comment to the activity diagram. Text is copied to the begin of the generated code. Use also paragraph symbols as line ends.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.6.3. Defining own Include Statements&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;defining_own_include_statements2&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:75,&amp;quot;secid&amp;quot;:159,&amp;quot;range&amp;quot;:&amp;quot;228352-229056&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit160&quot; id=&quot;supportedunsupported3&quot;&gt;4.6.4. Supported / Unsupported&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Supported:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Decision&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Merge&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Final&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Object related data flow&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choice after choice.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.6.4. Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;supportedunsupported3&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:75,&amp;quot;secid&amp;quot;:160,&amp;quot;range&amp;quot;:&amp;quot;229057-229267&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit161&quot; id=&quot;activity_diagrams_with_modelio&quot;&gt;4.7. Activity Diagrams with Modelio&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.7. Activity Diagrams with Modelio&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;activity_diagrams_with_modelio&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:75,&amp;quot;secid&amp;quot;:161,&amp;quot;range&amp;quot;:&amp;quot;229268-229316&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit162&quot; id=&quot;introduction13&quot;&gt;4.7.1. Introduction&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
It is possible to model more or less complex algorithms and functions used in the class and generate code from that model. Right click on the class and select &lt;em&gt;Create Diagram / Create an Activity Diagram&lt;/em&gt;. Each activity must have a unique name. Before you start read section &lt;em&gt;Drawing State-Charts with Modelio&lt;/em&gt; on page . Also import the Modelio oven example and play with the sample.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.7.1. Introduction&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;introduction13&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:75,&amp;quot;secid&amp;quot;:162,&amp;quot;range&amp;quot;:&amp;quot;229317-229736&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit163&quot; id=&quot;exporting_the_model_as_xmi_file&quot;&gt;4.7.2. Exporting the model as XMI file&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Like for state diagrams it is necessary to specify the path of the class in the XMI file. Use the &lt;em&gt;-t&lt;/em&gt; command line parameter for that purpose. It is important that you export the model using XMI version &lt;abbr title=&quot;Object Management Group&quot;&gt;OMG&lt;/abbr&gt; UML2.4.1. Select the correct settings in the export XMI dialog.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.7.2. Exporting the model as XMI file&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;exporting_the_model_as_xmi_file&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:75,&amp;quot;secid&amp;quot;:163,&amp;quot;range&amp;quot;:&amp;quot;229737-230061&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit164&quot; id=&quot;generating_activity_code&quot;&gt;4.7.3. Generating activity code&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To generate code from activity diagrams use the &lt;em&gt;-A&lt;/em&gt; command line switch. For the shown Modelio diagram the following command line has to be used for code generation. Note that you can use more than one activity diagram to define multiple algorithms. Presently all algorithms share the same include part.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;java -jar -ea codegen.jar -A -p Modelio -o testcase -t
&amp;quot;OvenClass&amp;quot;  oven.xmi&lt;/pre&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/modelio_full_window.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:modelio_full_window.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/modelio_full_window.png?w=529&amp;amp;tok=7d3f12&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure 4.13: A Modelio activity diagram with all node types currently supported by the code generator.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.7.3. Generating activity code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_activity_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:75,&amp;quot;secid&amp;quot;:164,&amp;quot;range&amp;quot;:&amp;quot;230062-230671&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit165&quot; id=&quot;actions3&quot;&gt;4.7.4. Actions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To add an action drag and drop an element from the &lt;em&gt;Control Nodes&lt;/em&gt; palette to the action diagram. Show the action element properties and give the action a name and action code (&lt;em&gt;Body&lt;/em&gt; field). Action code can span multiple lines.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.7.4. Actions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;actions3&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:76,&amp;quot;secid&amp;quot;:165,&amp;quot;range&amp;quot;:&amp;quot;230672-230931&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit166&quot; id=&quot;loop_node&quot;&gt;4.7.5. Loop Node&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
A loop none requires a test and setup part. To define the code executed inside the loop place an action in the loop and define the code there. See figure H for an example.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.7.5. Loop Node&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;loop_node&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:76,&amp;quot;secid&amp;quot;:166,&amp;quot;range&amp;quot;:&amp;quot;230932-231132&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit167&quot; id=&quot;conditional_node&quot;&gt;4.7.6. Conditional Node&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
A conditional node allows to execute code depending on one or multiple conditions. For each condition a test must be defined. To add code executed if the condition is true add an action and define the code in the action. See figure H for an example.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.7.6. Conditional Node&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;conditional_node&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:76,&amp;quot;secid&amp;quot;:167,&amp;quot;range&amp;quot;:&amp;quot;231133-231418&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit168&quot; id=&quot;defining_own_include_statements3&quot;&gt;4.7.7. Defining own include statements&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To define includes or other code at the beginning of the generated activity file, attach a note to the class. The first line of the node must contain the text &lt;em&gt;activity_header:&lt;/em&gt;  . An example is shown in the next figure 4.14.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/dokuwiki_output/wiki/manual/modelio_activity_header.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;dokuwiki_output:wiki:manual:modelio_activity_header.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/dokuwiki_output/wiki/manual/modelio_activity_header.png?w=302&amp;amp;tok=c1f791&quot; class=&quot;media&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;302&quot; /&gt;&lt;/a&gt;
Figure 4.14: To define own code at the beginning of the generated code use a note with the text &lt;em&gt;activity_header:&lt;/em&gt;  as first line.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.7.7. Defining own include statements&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;defining_own_include_statements3&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:76,&amp;quot;secid&amp;quot;:168,&amp;quot;range&amp;quot;:&amp;quot;231419-231897&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit169&quot; id=&quot;supportedunsupported4&quot;&gt;4.7.8. Supported / Unsupported&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Decision&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Merge&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Loop&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Condition&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Object related data flow&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Using activities or multiple actions in the body part of loop – or conditional nodes&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Activities in activities (might work, but untested)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choice behind choice. Use conditional node for that purpose&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Crossing border with connections between nodes when using nested activities.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;4.7.8. Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;supportedunsupported4&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:76,&amp;quot;secid&amp;quot;:169,&amp;quot;range&amp;quot;:&amp;quot;231898-232364&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit170&quot; id=&quot;appendix&quot;&gt;5. Appendix&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;5. Appendix&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:76,&amp;quot;secid&amp;quot;:170,&amp;quot;range&amp;quot;:&amp;quot;232365-232391&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit171&quot; id=&quot;appendix_a_design_questions&quot;&gt;Appendix A Design Questions&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix A Design Questions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_a_design_questions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:76,&amp;quot;secid&amp;quot;:171,&amp;quot;range&amp;quot;:&amp;quot;232392-232434&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit172&quot; id=&quot;appendix_a1_defining_the_state_processing_order&quot;&gt;Appendix A.1 Defining the state processing order&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
For &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state charts it is defined that events are handled from inside out. I.e., if there are two transitions ready to fire, the transition starting from the innermost state will be taken (see also 3.2.1).
&lt;/p&gt;

&lt;p&gt;
Sometimes it can be useful to influence the processing order of transitions starting from the same state. Consider the following case: There is an emergency stop and if it is pressed, only a specific transition should be taken even if other transitions are ready too (e.g., start pressed at the same time).
&lt;/p&gt;

&lt;p&gt;
&lt;strong&gt;Event based machine:&lt;/strong&gt; If your machine receives its events via a queue, it is usually possible to enqueue events to the front of the queue. So the sender of the event has simply to put emergency events to the front of the queue.
&lt;/p&gt;

&lt;p&gt;
&lt;strong&gt;Condition based machine:&lt;/strong&gt; In the case where transitions are triggered by boolean expressions (conditions), it becomes more tricky. Because then it can happen that several transitions might be ready at the same time (the emergency button and the stop button are pressed at the same time!). One solution is for example to include the inverted input of the emergency stop button into the boolean expression to trigger just one transitions. Unfortunately this often creates lengthy condition expressions. Example:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// transitions&lt;/span&gt;
emStopInput&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;action
inputA&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; emStopInput&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;action
inputB&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; emStopInput&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;action &lt;/pre&gt;

&lt;p&gt;
A more elegant solution is based on the fact that the generator generates the transition handling code in alphabetical order of the event name. This makes the following possible:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co1&quot;&gt;// define this in mydef.h or where appropriate&lt;/span&gt;
&lt;span class=&quot;co1&quot;&gt;// you can also define other names or more prios&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#typedef unsigned char PRIO_A&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#typedef unsigned char PRIO_B&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// transitions&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;PRIO_A&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;emStopInput&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;action
&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;PRIO_B&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;inputA&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;...
&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;PRIO_B&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;inputB&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;...
&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;PRIO_B&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;inputC&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;...
...&lt;/pre&gt;

&lt;p&gt;
&lt;strong&gt;Outgoing transitions of choices:&lt;/strong&gt; Transitions leaving a choice are ordered based on the guard whereas the ’else’ guard is used always as last option. Example:
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/choice_ordering.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:choice_ordering.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/choice_ordering.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure A.1: A choice pseudo state with evB as input transition and four output transitions.
&lt;/p&gt;

&lt;p&gt;
From the figure A.1 the following code is produced. The &lt;code&gt;if/else if/else&lt;/code&gt; structure triggered by &lt;code&gt;evB&lt;/code&gt; is ordered according the guard specification.
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;...
&lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; S1&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;
	&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;CHOICETEST_EVENT_T&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;evA&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from S1 to S2 */&lt;/span&gt;
		evConsumed&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;1U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
		&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
		instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; S2&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;CHOICETEST_EVENT_T&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;evB&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;a&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from S1 to S2 */&lt;/span&gt;
			evConsumed&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;1U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
			instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; S2&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;b&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from S1 to S2 */&lt;/span&gt;
			evConsumed&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;1U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
			instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; S2&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;u&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from S1 to S2 */&lt;/span&gt;
			evConsumed&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;1U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
			instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; S2&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from S1 to S1 */&lt;/span&gt;
			evConsumed&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;1U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
			instanceVar&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; S1&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/*end of event selection */&lt;/span&gt;
	&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;CHOICETEST_EVENT_T&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;evC&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from S1 to S2 */&lt;/span&gt;
		...
&amp;nbsp;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix A.1 Defining the state processing order&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_a1_defining_the_state_processing_order&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:76,&amp;quot;secid&amp;quot;:172,&amp;quot;range&amp;quot;:&amp;quot;232435-235682&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit173&quot; id=&quot;appendix_a2_running_the_state_machine_in_context_of_a_rtos&quot;&gt;Appendix A.2 Running the state machine in context of a RTOS&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
A frequently used design pattern with real-time operating systems is shown in the following figure A.2.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/multitasking_machine.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:multitasking_machine.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/multitasking_machine.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;multitasking_machine.jpg&quot; alt=&quot;multitasking_machine.jpg&quot; /&gt;&lt;/a&gt;
Figure A.2: Communicating tasks exchanging messages between each other (Asynchronous Event Handling). At least one of the tasks executes a state machine that reacts on the received events. As reaction new events to other tasks might be sent out.
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A task executes a state machine (often called an active object, which is a task that encapsulates a state machine).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; It waits for events by calling a blocking operating system function that returns only when a new event is available for processing.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The system mechanism for event signaling can vary, but often a message queue is used.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Events might be fired from within another task or inside an interrupt service routine&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; If an event was received, the state machine reacts to the new event&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Jump to step 2&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
This pattern can be realised with every real-time operating system. The generated state machine code can be easily integrated in such a design.
&lt;/p&gt;

&lt;p&gt;
In the following example, the microwave oven state machine is embedded into a real-time operating system task. In this example RTEMS was used. But any other &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; integration looks in principle the same. RTEMS is the Real-Time Operating System for Multiprocessor Systems&lt;sup&gt;&lt;a href=&quot;#fn__10&quot; id=&quot;fnt__10&quot; class=&quot;fn_top&quot;&gt;10)&lt;/a&gt;&lt;/sup&gt;. To compile the example you have to install a full RTEMS build environment. The example was created for the PC386 target. In &lt;code&gt;init.c&lt;/code&gt; two tasks were created. One task (&lt;code&gt;init&lt;/code&gt;) scans the keyboard and creates events according to the input. Then the events are sent via message queue to a second task named &lt;code&gt;oven_task&lt;/code&gt;. This task calls the state machine code which waits blocking until a new event is available. Figure A.3 shows the slightly modified microwave oven example. In the state machine design some code was added to read events from a queue. This was done with the help of an action text note. As the action code is executed just before the state machine itself the machine reacts to the latest keyboard event.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/active_machine.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:active_machine.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/active_machine.png?w=642&amp;amp;tok=cbbd9d&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;642&quot; /&gt;&lt;/a&gt;
Figure A.3: Event handling code added as text note to the oven state machine.
&lt;/p&gt;

&lt;p&gt;
In the context of &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; the configuration flag ’EventsAreBitCoded’ can be of interest. Some RTOSs provide a mechanism for communication between tasks (e.g. called Task Events). Every task has e.g. a one-byte (eight bit) mask, which means that eight different events can be signalled to and distinguished by every task. Then no translation between bit coded events received from the task and the events accepted from the state machine is necessary. It is your responsibility to ensure that the number of events used in the state machine is not larger than the number of bits offered by the task mask.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix A.2 Running the state machine in context of a RTOS&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_a2_running_the_state_machine_in_context_of_a_rtos&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:173,&amp;quot;range&amp;quot;:&amp;quot;235683-238604&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit174&quot; id=&quot;appendix_a3_multiple_instances_of_a_state_machine&quot;&gt;Appendix A.3 Multiple Instances of a State Machine&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
This is straightforward in object-oriented languages where you can instantiate the same class multiple times (e.g., in C++, Java, or C#).
&lt;/p&gt;

&lt;p&gt;
If you want to execute the same state machine in C multiple times (e.g., processing the serial protocol of 2 serial interfaces), please continue reading section 3.3.9 on page .
&lt;/p&gt;

&lt;p&gt;
The other option is to generate the state machine more than once using a different command line parameter for the machine name. This is probably not needs frequently but available for special cases.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix A.3 Multiple Instances of a State Machine&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_a3_multiple_instances_of_a_state_machine&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:174,&amp;quot;range&amp;quot;:&amp;quot;238605-239189&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit175&quot; id=&quot;appendix_a4_synchronous_event_handling&quot;&gt;Appendix A.4 Synchronous Event Handling&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Sometimes it is required to process an event synchronously i.e. executing the state machine in the context of the caller task. The caller is blocked as long as the state machine executes. Is can be realised by simply calling the state machine handler or implementing a proxy calling the state machine handler.
&lt;/p&gt;

&lt;p&gt;
This method is usually used in the context of a real-time operating system. See section  for more info.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix A.4 Synchronous Event Handling&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_a4_synchronous_event_handling&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:175,&amp;quot;range&amp;quot;:&amp;quot;239190-239658&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit176&quot; id=&quot;appendix_a5_cooperating_state_machines&quot;&gt;Appendix A.5 Cooperating State Machines&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Sometimes it is useful to create a state transition in one state machine in dependency of the present status of a second state machine. Consider a device that should be stopped immediately when an emergency stop button is pressed. A possible design is to implement supervision of the emergency stop button and all other functions of the device like controlling a motor or driving a display in one big state chart. However, this approach typically creates complex and unmaintainable designs.
&lt;/p&gt;

&lt;p&gt;
It is much more useful to create separate state charts and let them work together. For each state the code generator generates a macro which returns &lt;code&gt;1U/0U&lt;/code&gt; to indicate if the state machine is in that state or not (e.g. &lt;code&gt;OVEN_IS_IN_COOKING&lt;/code&gt;). See table 3.2 for more information.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix A.5 Cooperating State Machines&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_a5_cooperating_state_machines&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:176,&amp;quot;range&amp;quot;:&amp;quot;239659-240496&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit177&quot; id=&quot;appendix_a6_optimisations_for_lowest_memory_consumption&quot;&gt;Appendix A.6 Optimisations for Lowest Memory Consumption&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
In deeply embedded systems, code/RAM size is usually limited and every optimization is welcome to reduce the resource usage. If only one instance of a state machine is used in a design, the memory consumption can be reduced by avoiding the usage of pointers. Therefore the following two configuration switches can be used:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; HsmFunctionWithInstanceParameters=no&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; UseInstancePointer=no&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
If both switches are set to ’no’, the instance variable is accessed by value within the state machine code. Also other helpers (like changeToState) do not use a pointer anymore.
&lt;/p&gt;

&lt;p&gt;
If your state machine is flat (i.e., has no hierarchical states), you can also disable generation of the eventProcessed flag. Set parameter &lt;em&gt;ReturnEventProcessed&lt;/em&gt; to ’no’ in this case.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix A.6 Optimisations for Lowest Memory Consumption&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_a6_optimisations_for_lowest_memory_consumption&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:177,&amp;quot;range&amp;quot;:&amp;quot;240497-241333&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit178&quot; id=&quot;appendix_a7_was_an_event_processed&quot;&gt;Appendix A.7 Was an Event processed?&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Sometimes the code calling the state machine needs to know if an event was processed in the presently active state. It is possible to instruct the code generator to generate code that returns &lt;em&gt;1U&lt;/em&gt; if the event was handled and &lt;em&gt;0U&lt;/em&gt; if it was not handled in the current state.
&lt;/p&gt;

&lt;p&gt;
To enable this feature set the configuration option &lt;code&gt;ReturnEventProcessed&lt;/code&gt; to &lt;code&gt;yes&lt;/code&gt; in the codegen.cfg file.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix A.7 Was an Event processed?&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_a7_was_an_event_processed&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:178,&amp;quot;range&amp;quot;:&amp;quot;241334-241785&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit179&quot; id=&quot;appendix_b_drawing_state-charts_with_cadifra_uml_editor&quot;&gt;Appendix B Drawing State-Charts with Cadifra UML editor&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
The Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; editor is a very easy to use and lightweight &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; modelling tool. It was not directly designed to generate code from its diagrams. Because of this it does not provide special means such as dialogs to enter events, guards, entry or exit actions and so forth. This section describes how to draw diagrams with all needed information using the available editor features.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix B Drawing State-Charts with Cadifra UML editor&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_b_drawing_state-charts_with_cadifra_uml_editor&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:179,&amp;quot;range&amp;quot;:&amp;quot;241786-242239&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit180&quot; id=&quot;appendix_b1_events&quot;&gt;Appendix B.1 Events&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
To add an event to a transition right click to the transition line and select &lt;code&gt;’New Text’&lt;/code&gt; as shown in figure B.1. For the event definition you must follow the syntax as described in section . Only text associated with the transition (indicated with a dashed line) is detected by the code generator. A free text element will be ignored and the generator will complain about the missing event. Even if it might look ok for you as the free text is located close to the transition. For layout reasons it is allowed to put the event and guard in different lines.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/enterevent.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:enterevent.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/enterevent.png?w=188&amp;amp;tok=355c82&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;188&quot; /&gt;&lt;/a&gt;
Figure B.1: To enter events right click to the transition and use a text field to enter the event definition.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix B.1 Events&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_b1_events&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:180,&amp;quot;range&amp;quot;:&amp;quot;242240-242991&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit181&quot; id=&quot;appendix_b2_hierarchical_states&quot;&gt;Appendix B.2 Hierarchical States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
To draw hierarchical states (aka composite states) increase the size of the parent state (e.g. S1) until there is enough space to carry the new child state (e.g. S11) . Then move the child state into the parent state’s border. The &lt;code&gt;’Large’&lt;/code&gt; flag is automatically set on the parent state. With the this flag set the state name is shown in the upper left corner. To add another child (e.g S111 or S12) repeat the steps from above. In total 3 levels of nesting are supported from the code-generator. For flags on the third level the &lt;code&gt;’Large’&lt;/code&gt; flag shall not be set (see figure B.2).
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/large.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:large.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/large.png?w=188&amp;amp;tok=4cd947&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;188&quot; /&gt;&lt;/a&gt;
Figure B.2: Composition of states. Move the child into the parent create a composition. 
&lt;/p&gt;

&lt;p&gt;
The following figure B.3 shows a fictious example with three levels of nesting.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/3rd_level_cadifra.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:3rd_level_cadifra.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/3rd_level_cadifra.png?w=491&amp;amp;tok=d4a067&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;491&quot; /&gt;&lt;/a&gt;
Figure B.3: Three levels of states drawn with the Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; Editor. For states on level one and two the &lt;code&gt;’Large’&lt;/code&gt; flag shall be set.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix B.2 Hierarchical States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_b2_hierarchical_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:181,&amp;quot;range&amp;quot;:&amp;quot;242992-244035&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit182&quot; id=&quot;appendix_b3_adding_state_details&quot;&gt;Appendix B.3 Adding State Details&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
To add entry, exit, action or inner events a compartment must be added to the state. To do so right click to the state and select &lt;code&gt;’Add compartment’&lt;/code&gt; as shown in figure B.4. To edit the compartment double click on it and enter the definitions as needed. The definitions must follow the syntax as described in section . Compartments can only be used for states without children. For states with children attach a note to the state and put the state details into the note. The note must start with the text ’Compartment’. See figure B.3 for an example.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/addstatedetails.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:addstatedetails.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/addstatedetails.png?w=188&amp;amp;tok=f8628a&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;188&quot; /&gt;&lt;/a&gt;
Figure B.4: To enter state details right click to the state and add a compartment to it.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix B.3 Adding State Details&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_b3_adding_state_details&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:182,&amp;quot;range&amp;quot;:&amp;quot;244036-244781&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit183&quot; id=&quot;appendix_b4_history_states&quot;&gt;Appendix B.4 History States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Append the text ’&lt;code&gt; (H)&lt;/code&gt;’ to the state state name if you want to make a state a history state (shallow history) (e.g. ’&lt;code&gt;S1 (H)&lt;/code&gt;’).
&lt;/p&gt;

&lt;p&gt;
Append the text ’&lt;code&gt; (H*)&lt;/code&gt;’ to the state name if you want to make all child states history states (deep history). This has the same effect as adding a Shallow History marker to all composite child states (e.g. ’&lt;code&gt;S1 (H*)&lt;/code&gt;’).
&lt;/p&gt;

&lt;p&gt;
Since version 6.4 transitions can also end in history states. See section  for further explanations. Cadifra does not support history states. Therefore a special syntax for the state name must be used.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A shallow history pseudostate must begin with &lt;em&gt;(H&lt;/em&gt; and end with &lt;em&gt;)&lt;/em&gt;. Examples: &lt;em&gt;(H), (Hist1)&lt;/em&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A deep history pseudostate must begin with &lt;em&gt;(H&lt;/em&gt; and end with &lt;em&gt;)&lt;/em&gt;. Examples: &lt;em&gt;(H*), (Hist1*)&lt;/em&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
An example for a diagram with history state usage is shown in figure B.5.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/cadifra_history.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:cadifra_history.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/cadifra_history.png?w=415&amp;amp;tok=11c3ec&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;415&quot; /&gt;&lt;/a&gt;
Figure B.5: History states can have one or more incoming transitions but must have no outgoind transition.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix B.4 History States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_b4_history_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:183,&amp;quot;range&amp;quot;:&amp;quot;244782-245853&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit184&quot; id=&quot;appendix_b5_choices&quot;&gt;Appendix B.5 Choices&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Choices are not directly supported from the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; Editor. However with the help of a naming convention it is possible to use choices. If a state name begins and ends with angle brackets it is assumed by the codegen that it is a choice state. Valid names are e.g. &lt;code&gt;&amp;lt;&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt; &amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;C1&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;AnyText&amp;gt;&lt;/code&gt;. The following figure shows an example state chart with three choice states.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/cadifra_choices.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:cadifra_choices.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/cadifra_choices.png?w=415&amp;amp;tok=833685&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;415&quot; /&gt;&lt;/a&gt;
Figure B.6: Choice states must have angled brackets in its name.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix B.5 Choices&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_b5_choices&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:184,&amp;quot;range&amp;quot;:&amp;quot;245854-246394&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit185&quot; id=&quot;appendix_b6_junctions&quot;&gt;Appendix B.6 Junctions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Junctions are not directly supported from the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; Editor. However with the help of a naming convention it is possible to use junctions. If a state name begins and ends with round brackets it is assumed by the codegen that it is a junction state. Valid junction names are e.g. &lt;code&gt;(J)&lt;/code&gt;, &lt;code&gt;(J1)&lt;/code&gt; or &lt;code&gt;(JAnyText)&lt;/code&gt;. The following figure shows an example state chart with a junction.
&lt;/p&gt;

&lt;p&gt;
For more background information about junctions see section .
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/cadifra_junction.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:cadifra_junction.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/cadifra_junction.png?w=415&amp;amp;tok=1a6e50&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;415&quot; /&gt;&lt;/a&gt;
Figure B.7: Junction states must have round brackets in its name.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix B.6 Junctions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_b6_junctions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:185,&amp;quot;range&amp;quot;:&amp;quot;246395-246997&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit186&quot; id=&quot;appendix_b7_connection_points&quot;&gt;Appendix B.7 Connection Points&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
This is a feature only available for the Cadifra editor and also not available in &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt;. The concept of connection points is well known from circuit diagram drawing tools. Because Cadifra has no direct support the realization is similar to Junctions. Exactly two states must have the same name, each surrounded by square brackets. Internally the code generator removes these states and creates a single transition. One of these states must have an incoming transition, and the other must have an outgoing transition. Event name, guard and action are only taken from the entering transition. An example is shown below in figure B.8.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/cadifra_connection_points.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:cadifra_connection_points.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/cadifra_connection_points.png?w=415&amp;amp;tok=1dc8b1&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;415&quot; /&gt;&lt;/a&gt;
Figure B.8: Connection point states must have square brackets around their name. In this example transition $S1 \xrightarrow{evC} S3$ and transition $S3\xrightarrow{evB} S11$ were realized with connection points .
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix B.7 Connection Points&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_b7_connection_points&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:186,&amp;quot;range&amp;quot;:&amp;quot;246998-247940&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit187&quot; id=&quot;appendix_b8_supportedunsupported&quot;&gt;Appendix B.8 Supported / Unsupported&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The codegenerator supports the following features for Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt;:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Hierarchical states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; (Signal-)Events with eventname, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial and final pseudostates&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; History states, Extended history handling (see section )&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choices&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Junctions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Constraints&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Multiple state machines/regions in a diagram&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Syncstates&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry and exit points (not to compare with entry/exit actions within states)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Terminate and Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix B.8 Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_b8_supportedunsupported&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:187,&amp;quot;range&amp;quot;:&amp;quot;247941-248479&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit188&quot; id=&quot;appendix_c_drawing_state-charts_with_magic_draw&quot;&gt;Appendix C Drawing State-Charts with Magic Draw&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
When using Magic Draw some tool specific things must be taken care of. The following section discusses these points. First take a look how a rather complex state chart looks like in Magic Draw.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/md_complex.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:md_complex.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/md_complex.jpg?w=604&amp;amp;tok=e76537&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;md_complex.jpg&quot; alt=&quot;md_complex.jpg&quot; width=&quot;604&quot; /&gt;&lt;/a&gt;
Figure C.1: A rather complex state chart designed in Magic Draw 
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix C Drawing State-Charts with Magic Draw&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_c_drawing_state-charts_with_magic_draw&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:188,&amp;quot;range&amp;quot;:&amp;quot;248480-248841&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit189&quot; id=&quot;appendix_c1_organizing_your_project&quot;&gt;Appendix C.1 Organizing your project&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code-generator needs to know how to find your state-based class in the XMI file. The path to your class in your project tree must be specified on the command line using the -t flag.
&lt;/p&gt;

&lt;p&gt;
The following figure shows the project browser window for the state diagram from above. From figure C.2 you can directly derive the path which is &lt;code&gt;-t &amp;#039;MyModel:Class Model:complex_class&amp;#039;&lt;/code&gt;. The different parts of the path must be separated with colons.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/md_project_browser.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:md_project_browser.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/md_project_browser.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;md_project_browser.jpg&quot; alt=&quot;md_project_browser.jpg&quot; /&gt;&lt;/a&gt;
Figure C.2: Magic Draw’s project browser. The package structure defines the path to the class you want to generate code from.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix C.1 Organizing your project&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_c1_organizing_your_project&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:189,&amp;quot;range&amp;quot;:&amp;quot;248842-249507&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit190&quot; id=&quot;appendix_c2_attaching_action_and_include_comments&quot;&gt;Appendix C.2 Attaching action and include comments&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Remember that you can specify code that is just copied at the beginning of the state machine c-file. Also you can add action code that is called every time the state machine is called. This can be done by using comments starting with the keywords &lt;code&gt;action:&lt;/code&gt; and &lt;code&gt;include:&lt;/code&gt; (see section 3.1.6). It is important that you use a &lt;em&gt;comment and not a note&lt;/em&gt;! In Magic Draw these two comments must be linked to the class owning the state machine.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/md_include_action.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:md_include_action.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/md_include_action.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;md_include_action.jpg&quot; alt=&quot;md_include_action.jpg&quot; /&gt;&lt;/a&gt;
Figure C.3: Action and inlcude comments must be linked to the class which owns the state machine.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix C.2 Attaching action and include comments&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_c2_attaching_action_and_include_comments&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:190,&amp;quot;range&amp;quot;:&amp;quot;249508-250163&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit191&quot; id=&quot;appendix_c3_saving_your_project_to_xmi&quot;&gt;Appendix C.3 Saving your project to XMI&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Magic Draw allows you to save a project directly in XMI format. All the project information is stored in the XMI file. No other project file is needed. This is very handy as no export of the XMI file is required. Please remember to &lt;em&gt;tick the XMI 2.1 (rich XMI) check box in the save dialog&lt;/em&gt;. If not checked the generated XML export can’t be processed from the code generator.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix C.3 Saving your project to XMI&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_c3_saving_your_project_to_xmi&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:191,&amp;quot;range&amp;quot;:&amp;quot;250164-250597&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit192&quot; id=&quot;appendix_c4_state_details&quot;&gt;Appendix C.4 State Details&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Magic Draw allows you to define entry, do and exit actions as well as inner transitions for a state. Actions are usually operations (i.e. functions) which are triggered in case of the event. This means that for each of these actions a C-function (operation) must be defined. Sometimes this is not what you want especially if the action code is very short and a function would add a lot of overhead. There are two options to overcome this.
&lt;/p&gt;

&lt;p&gt;
Option A: Just misuse the operation name as field where you can type in the C-code you want to execute. It is important that the &lt;code&gt;Behavior Type&lt;/code&gt; is defined as &lt;code&gt;Opaque Behavior&lt;/code&gt; as shown in C.5.
&lt;/p&gt;

&lt;p&gt;
Option B: You can attach a comment (not a note!) to a state (either a child state or a composite state) and specify entry/exit or action code in there. To edit the comment click on it and enter the definitions as needed. The definitions must follow the syntax as described in section . Make sure you use plain text. The code-generator is not able handle html text.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/md_state.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:md_state.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/md_state.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;md_state.jpg&quot; alt=&quot;md_state.jpg&quot; /&gt;&lt;/a&gt;
Figure C.4: A state with entry/exit/do code plus an inner event following option A
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/md_state_details.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:md_state_details.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/md_state_details.jpg?w=566&amp;amp;tok=7cf94e&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;md_state_details.jpg&quot; alt=&quot;md_state_details.jpg&quot; width=&quot;566&quot; /&gt;&lt;/a&gt;
Figure C.5: Actions must have the behaviour type set to &lt;code&gt;Opaque Behaviour&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
To define an inner transition double click on a state and select &lt;code&gt;Internal Transitions&lt;/code&gt;. The definition of an internal transition is done the same way as a normal transition is defined. See the next section for more info.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix C.4 State Details&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_c4_state_details&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:192,&amp;quot;range&amp;quot;:&amp;quot;250598-252122&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit193&quot; id=&quot;appendix_c5_transitions&quot;&gt;Appendix C.5 Transitions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Double clicking on a transition brings up the transition properties dialog (see figure C.6. This dialog allows you to define the event that triggers the state transition. As usual you can specify a guard (a valid C-statement evaluating to true or false), the effect and the trigger itself. The trigger type &lt;strong&gt;must be&lt;/strong&gt; set to type &lt;code&gt;SignalEvent&lt;/code&gt;. The effect behaviour type must be set to &lt;code&gt;Opaque Behaviour&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
To add a guard click on the guard field and then on the tree appearing dots. Now select &lt;code&gt;Constraint&lt;/code&gt; as guard type. Now type in the guard in the &lt;code&gt;Specification&lt;/code&gt; field (not in the name field!). The guard should appear in bracket braces after the event name if you click &lt;code&gt;close&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/md_transition.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:md_transition.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/md_transition.jpg?w=566&amp;amp;tok=ce2c58&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;md_transition.jpg&quot; alt=&quot;md_transition.jpg&quot; width=&quot;566&quot; /&gt;&lt;/a&gt;
Figure C.6: Magic Draw’s transition properties dialog.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix C.5 Transitions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_c5_transitions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:193,&amp;quot;range&amp;quot;:&amp;quot;252123-252976&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit194&quot; id=&quot;appendix_c6_history_state&quot;&gt;Appendix C.6 History State&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Use the &lt;code&gt;Shallow History&lt;/code&gt; if you want to make a state a history state.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix C.6 History State&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_c6_history_state&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:194,&amp;quot;range&amp;quot;:&amp;quot;252977-253094&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit195&quot; id=&quot;appendix_c7_deep_history&quot;&gt;Appendix C.7 Deep History&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Use the &lt;code&gt;Deep History&lt;/code&gt; if you want to make all child states history states. This has the same effect as adding a Shallow History marker to all composite child states.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix C.7 Deep History&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_c7_deep_history&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:195,&amp;quot;range&amp;quot;:&amp;quot;253095-253307&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit196&quot; id=&quot;appendix_c8_sub-machines&quot;&gt;Appendix C.8 Sub-Machines&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Sub-machine states allow to “hide” the child states of a state with hierarchy. You only see the child states etc. if you double click on the state which opens the internal view. From the code generator point of view a sub-machine is a normal state with children. There is absolutely no difference compared to a normal hierarchical state.
&lt;/p&gt;

&lt;p&gt;
But using a sub-machine state instead of a state has some other consequences:
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; MD does not allow to provide entry/do/exit actions for a sub-state. You have to attach a comment field to specify state actions to overcome this MD limitation.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; It is not possible to connect a transition starting from a state outside the sub-machine state to a state in the sub-machine. And vice versa. Use entry and exit pseudo states for this purpose (see next section).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; MD does not allow to “transform” a sub-machine state into a state with children. You have to do this manually by moving states etc. in the Model Browser.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix C.8 Sub-Machines&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_c8_sub-machines&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:196,&amp;quot;range&amp;quot;:&amp;quot;253308-254311&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit197&quot; id=&quot;appendix_c9_entry_and_exit_points&quot;&gt;Appendix C.9 Entry and Exit Points&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
&lt;em&gt;Note: Entry and exit points are only useful together with a sub-machine. Read the previous section before if you are not familiar with the usage of sub-machines.&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
When entering a sub-machine usually the initial state is entered. I.e. the transition ends at the border of the sub-machine state If this should not be the case for a specific transition it is possible to place an entry point inside the sub-machine state. This entry point serves as glue between the sub-machine state and the internal of the sub-machine.
&lt;/p&gt;

&lt;p&gt;
Exit states provide a similar function. By default only transition can be modelled starting from the sub-machine. If a transition should start from a specific state inside the sub-machine and enter a state outside the sub-machine an exit state can be used. Again this exit state serves as glue between the transition starting inside the sub-machine and ending one level up at another state.
&lt;/p&gt;

&lt;p&gt;
To use entry and exit points in your model use the following recipe:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Double click on the sub-machine state to open the sub-machine diagram&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Drag and drop an entry and/or exit point inside your sum-machine diagram&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Give the points a meaningful name.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Go up to the outside diagram&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Place references of the entry / exit points on the boarder of the sub-machine state.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Connect transitions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The sub-machine must be placed below the main state machine and its name must start with for underlines (’&lt;code&gt;____&lt;/code&gt;’). This is needed that the code-generator can identify the machine as sub-machine. See figure C.7.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/md7_substate_model_organization.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:md7_substate_model_organization.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/md7_substate_model_organization.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure C.7: Place your sub-machine below the main state as shown in this figure.
&lt;/p&gt;

&lt;p&gt;
Limitations when using entry and exit points:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; An exit point can have more than one incoming transitions inside the sub-machine. But only one outgoing transition from the sub-machine state.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; An entry state can have more than one incoming transitions on the sub-machine state. But only one outgoing transition inside the sub-machine.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The transition leaving the exit or entry point most end in a normal state. Chaining of entry / exit states or connecting these transitions to choices or junctions is not allowed.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The following figure C.8 shows an example for a diagram with a sub-machine and the internals of this sub-machine.
&lt;/p&gt;

&lt;p&gt;
Figure C.8: This figure shows the top level diagram with a sub-machine state and the internals of the sub-machine state. The transitions between these two diagrams are glued together using entry and exit points.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix C.9 Entry and Exit Points&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_c9_entry_and_exit_points&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:197,&amp;quot;range&amp;quot;:&amp;quot;254312-256897&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit198&quot; id=&quot;appendix_c10_supportedunsupported&quot;&gt;Appendix C.10 Supported / Unsupported&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code generator supports a subset of the design elements provided by Magic Draw. The supported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Hierarchical states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; (Signal-)Events with eventname, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial and final pseudostates&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Sub-machines and entry / exit points&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; History states (deep, flat), Extended history handling (see section )&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choices&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Junctions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Constraints&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Multiple state machines/regions in a diagram&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Syncstates&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Terminate and Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix C.10 Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_c10_supportedunsupported&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:198,&amp;quot;range&amp;quot;:&amp;quot;256898-257455&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit199&quot; id=&quot;appendix_d_drawing_state-charts_with_umodel&quot;&gt;Appendix D Drawing State-Charts with UModel&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
When using UModel some tool specific things must be taken care of. The following section discusses these points. First take a look on figure D.1 that shows how a rather complex state chart looks like in UModel.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/umodel_complex.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:umodel_complex.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/umodel_complex.png?w=529&amp;amp;tok=1ef29c&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure D.1: A rather complex state chart designed in UModel. Most of the supported elements are used in this diagram.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix D Drawing State-Charts with UModel&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_d_drawing_state-charts_with_umodel&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:199,&amp;quot;range&amp;quot;:&amp;quot;257456-257887&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit200&quot; id=&quot;appendix_d1_organizing_your_project&quot;&gt;Appendix D.1 Organizing your project&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code-generator needs to know how to find your state-based class in the XMI file. The path to the class containing the state machine in your project tree must be specified on the command line using the -t flag.
&lt;/p&gt;

&lt;p&gt;
Figure D.2 shows the project browser window for the state diagram from above. From there you can directly derive the path which is &lt;code&gt;-t &amp;#039;Model:class&amp;#039;&lt;/code&gt; for the shown example. The different parts of the path must be separated with colons.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/umodel_project_browser.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:umodel_project_browser.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/umodel_project_browser.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure D.2: UModel’s project browser. The package structure defines the path to the class you want to generate code from.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix D.1 Organizing your project&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_d1_organizing_your_project&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:200,&amp;quot;range&amp;quot;:&amp;quot;257888-258566&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit201&quot; id=&quot;appendix_d2_attaching_action_and_include_comments&quot;&gt;Appendix D.2 Attaching action and include comments&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Remember that you can specify code (so called header code) that is simply copied at the beginning of the state machine c-file. Also you can specify action code that is called every time the state machine gets executed. Add the &lt;code&gt;action-&lt;/code&gt; and &lt;code&gt;header code&lt;/code&gt; in the documentation window of the class containing the state machine. The text must start with either &lt;code&gt;action:&lt;/code&gt; or &lt;code&gt;header:&lt;/code&gt; (see section 3.1.6). It is not possible to use a &lt;code&gt;Note&lt;/code&gt; which is attached to the class as UModel does unfortunately not export notes in the XMI file. The documentation window can contain &lt;code&gt;action -&lt;/code&gt; and/or &lt;code&gt;include code&lt;/code&gt;. The order does not matter.
&lt;/p&gt;

&lt;p&gt;
UModel does not export line end information correctly from the documentation window. Therefore it was necessary to define a specific line break character. Use the paragraph §character for that purpose. It is usually not used in normal C-code. An example documentation window with &lt;code&gt;action -&lt;/code&gt; and &lt;code&gt;include code&lt;/code&gt; is shown in figure D.3.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/umodel_include_action.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:umodel_include_action.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/umodel_include_action.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure D.3: Action and include comments can be specified in the documentation window of the class which owns the state machine.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix D.2 Attaching action and include comments&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_d2_attaching_action_and_include_comments&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:201,&amp;quot;range&amp;quot;:&amp;quot;258567-259824&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit202&quot; id=&quot;appendix_d3_saving_your_project_to_xmi&quot;&gt;Appendix D.3 Saving your project to XMI&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
UModel allows you to export your project in XMI format. All the project information is stored in the XMI file. Check the tick boxes as shown in figure D.4 to export a XMI file which can be processed from the code generator.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/umodel_export_xmi.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:umodel_export_xmi.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/umodel_export_xmi.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure D.4: Exporting the project to XMI.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix D.3 Saving your project to XMI&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_d3_saving_your_project_to_xmi&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:202,&amp;quot;range&amp;quot;:&amp;quot;259825-260186&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit203&quot; id=&quot;appendix_d4_states&quot;&gt;Appendix D.4 States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
UModel allows you to define entry, do and exit activities as well as inner transitions for a state. Do not use the &lt;code&gt;interactions&lt;/code&gt; for that purpose but the &lt;code&gt;activities&lt;/code&gt;. Only one single line can be specified for the entry, do and exit activities. If you want to execute more code define a function which contains the code.
&lt;/p&gt;

&lt;p&gt;
There are different type of states in the toolbar. Simple states can’t contain children. A composite state can contain further children. If you are unsure if a state will have substates later on draw a composite state right from the beginning. There seems to be no way to change a simple state into a composite one later on. The use of orthogonal states is not supported from the code generator so far. See appendix A.5 for a possible solution.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix D.4 States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_d4_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:203,&amp;quot;range&amp;quot;:&amp;quot;260187-261002&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit204&quot; id=&quot;appendix_d5_transitions&quot;&gt;Appendix D.5 Transitions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
To create a transition click the transition handle of the source state (on the right of the element). Then drag-and-drop the transition arrow onto the target state. A text field is shown. Type in the event name and optionally the guard and the action. This is quite convenient as it allows fast editing. The event, guard and actions can also be specified later on by adding the element in the model tree below the transition.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix D.5 Transitions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_d5_transitions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:204,&amp;quot;range&amp;quot;:&amp;quot;261003-261467&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit205&quot; id=&quot;appendix_d6_history_state&quot;&gt;Appendix D.6 History State&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Use the &lt;code&gt;Shallow History&lt;/code&gt; if you want to make a state a history state.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix D.6 History State&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_d6_history_state&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:205,&amp;quot;range&amp;quot;:&amp;quot;261468-261585&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit206&quot; id=&quot;appendix_d7_deep_history&quot;&gt;Appendix D.7 Deep History&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Use the &lt;code&gt;Deep History&lt;/code&gt; if you want to make all child states history states. This has the same effect as adding a Shallow History marker to all composite child states.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix D.7 Deep History&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_d7_deep_history&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:206,&amp;quot;range&amp;quot;:&amp;quot;261586-261798&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit207&quot; id=&quot;appendix_d8_adding_operations_and_attributes_to_classes&quot;&gt;Appendix D.8 Adding Operations and Attributes to Classes&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
It is possible to add attributes and operations to the class containing the state machine. Attributes are added to the instance data and always require a default value. Operations are mapped to C-functions and added to the state machine header file. Hint: Directly use data types that you want to use in your code later on.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/umodel/class_single_pulse.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;wiki:manual:umodel:class_single_pulse.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/umodel/class_single_pulse.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure D.5: Class with user defined attributes and operations. The code generator includes them into the generated code.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix D.8 Adding Operations and Attributes to Classes&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_d8_adding_operations_and_attributes_to_classes&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:207,&amp;quot;range&amp;quot;:&amp;quot;261799-262364&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit208&quot; id=&quot;appendix_d9_supportedunsupported&quot;&gt;Appendix D.9 Supported / Unsupported&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code generator supports a subset of the design elements provided by UModel. The supported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Hierarchical states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Events with event name, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial and final pseudo states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; History states (deep, flat), Extended history handling (see section )&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choices&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Junctions&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Constraints&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Multiple state machines/regions in a diagram&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Sync states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry and exit points (not to compare with entry/exit actions within states)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Terminate and Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix D.9 Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_d9_supportedunsupported&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:208,&amp;quot;range&amp;quot;:&amp;quot;262365-262951&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit209&quot; id=&quot;appendix_e_drawing_state-charts_with_astah_and_astah_sysml&quot;&gt;Appendix E Drawing State-Charts with astah* and astah SysML&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
astah* formerly known as JUDE is a &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; modeling tool created by Japanese company ChangeVision. It is written in Java and can therefore run on different operating systems. This text considers both astah and astah SysML. Differences are explained where necessary.
&lt;/p&gt;

&lt;p&gt;
In opposite to some other tools astah provides a Java &lt;abbr title=&quot;Application Programming Interface&quot;&gt;API&lt;/abbr&gt; for direct access to the model file. Therefore it is not necessary to export the model (e.g. in XMI format). The Sinelabore&lt;em&gt;RT&lt;/em&gt; code generator can directly access the model file. This makes the development cycle very fast.
&lt;/p&gt;

&lt;p&gt;
To make it possible for the java runtime to access the astah jar file there are to options:
&lt;/p&gt;

&lt;/div&gt;

&lt;h5 id=&quot;appendix_e0001_acopy_the_astah_jar_files_to_your_java_installation&quot;&gt;Appendix E.0.0.0.1 a: Copy the astah jar files to your Java installation:&lt;/h5&gt;
&lt;div class=&quot;level5&quot;&gt;

&lt;p&gt;
To make this possible it is necessary to copy the astah* jar interface jar file &lt;code&gt;astah-community.jar&lt;/code&gt; (or e.g. &lt;code&gt;astah-pro.jar &lt;/code&gt; if you use astah* professional) from the astah* installation folder into the Java CLASSPATH. This can be done in the same way as for the jdom.jar file. The easiest way is to copy it into the folder where the &lt;code&gt;codegen.jar&lt;/code&gt; is located. See section 1.5 Installation for the different options. Since version 6.7 also additional jar files are required. For latest information check the Astah* Howto Page on the Sinelabore web site.
&lt;/p&gt;

&lt;p&gt;
Example: You have copied the astah* jar file into the &lt;code&gt;bin&lt;/code&gt; folder of sinelabore: Let’s assume you have two folderes. A &lt;code&gt;bin&lt;/code&gt; and a &lt;code&gt;prj&lt;/code&gt; folder. In the &lt;code&gt;bin&lt;/code&gt; folder all the jar files were located. The model file is located in the &lt;code&gt;prj&lt;/code&gt; folder. To call the codegen from the &lt;code&gt;prj&lt;/code&gt; folder use the following command line:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;&lt;span class=&quot;co4&quot;&gt;user$ &lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;ls&lt;/span&gt; ..&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;..&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;bin&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;
JDOM\ LICENSE.txt  POI\ LICENSE.txt  astah-community.jar  codegen.jar  jdom.jar
log4j-over-slf4j-1.6.6.jar logback-loader-1.0.9b.jar  slf4j-api-1.6.6.jar
&amp;nbsp;
&lt;span class=&quot;co4&quot;&gt;user$&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;java&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-cp&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;path to codegen bin folder&amp;quot;&lt;/span&gt; codegen.Main &lt;span class=&quot;re5&quot;&gt;-t&lt;/span&gt;
&lt;span class=&quot;st0&quot;&gt;&amp;quot;oven_pkg:machine_class:oven&amp;quot;&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-l&lt;/span&gt; cx &lt;span class=&quot;re5&quot;&gt;-p&lt;/span&gt; ASTAH &lt;span class=&quot;re5&quot;&gt;-o&lt;/span&gt; oven oven.asta&lt;/pre&gt;

&lt;/div&gt;

&lt;h5 id=&quot;appendix_e0002_badd_the_path_to_the_jar_files_in_to_the_classpath_when_calling_the_code_generator&quot;&gt;Appendix E.0.0.0.2 b: Add the path to the jar files in to the classpath when calling the code generator:&lt;/h5&gt;
&lt;div class=&quot;level5&quot;&gt;

&lt;p&gt;
This method was used in the example model for astah SysML which can be found in the examples folder. Check out the Makefile how this is done. The class path on your system might be different. On Windows make sure to use the right separator characters in the class path.
&lt;/p&gt;
&lt;pre class=&quot;code make&quot;&gt;JAVA&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;java
JFLAGS&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;cp&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;../../bin/&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;/Applications/astah sysml/astah
 sysml.app/Contents/Java/&amp;quot;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;Djava&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;awt&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;headless&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;true codegen&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;Main
&lt;span class=&quot;sy0&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;sy0&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;JAVA&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;re2&quot;&gt;JFLAGS&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;l cx &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;v &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;p ASTAH &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;o oven &lt;span class=&quot;sy0&quot;&gt;-&lt;/span&gt;t &lt;span class=&quot;st0&quot;&gt;&amp;quot;final:oven:machine&amp;quot;&lt;/span&gt; 
oven_model&lt;span class=&quot;sy0&quot;&gt;.&lt;/span&gt;asml&lt;/pre&gt;

&lt;p&gt;
In case you see a Java exception like shown below the astah* jar files were not found. Carefully check your class path or the path provided in &lt;code&gt;-Djava.ext.dirs=&lt;/code&gt;
&lt;/p&gt;
&lt;pre class=&quot;code java&quot;&gt;&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+exception&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;Exception&lt;/span&gt;&lt;/a&gt; in thread &lt;span class=&quot;st0&quot;&gt;&amp;quot;main&amp;quot;&lt;/span&gt; java.&lt;span class=&quot;me1&quot;&gt;lang&lt;/span&gt;.&lt;a href=&quot;http://www.google.com/search?hl=en&amp;amp;q=allinurl%3Adocs.oracle.com+javase+docs+api+noclassdeffounderror&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;NoClassDefFoundError&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;\\
com&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;change\_vision&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;jude&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;api&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;inf&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;model&lt;span class=&quot;sy0&quot;&gt;/&lt;/span&gt;INamedElement at codegen \ldots&lt;/pre&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/astah_complex.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:astah_complex.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/astah_complex.png?w=529&amp;amp;tok=db67d3&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure E.1: A rather complex state chart designed in astah*. Most of the supported elements are used in this diagram.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix E Drawing State-Charts with astah* and astah SysML&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_e_drawing_state-charts_with_astah_and_astah_sysml&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:79,&amp;quot;secid&amp;quot;:209,&amp;quot;range&amp;quot;:&amp;quot;262952-266106&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit210&quot; id=&quot;appendix_e1_attaching_action_and_include_comments&quot;&gt;Appendix E.1 Attaching action and include comments&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Remember that you can specify code (so called header code) that is simply copied to the beginning of the state machine implementation file. This mechanism allows to add own include files to the generated code. Also you can specify action code that is called every time the state machine gets executed. Put the action- and header code in a &lt;code&gt;Note&lt;/code&gt; and place it in the class diagram / block definition diagram where it must be linked to the class / block you want to generate code from. The text must start with either &lt;code&gt;action:&lt;/code&gt; or &lt;code&gt;header:&lt;/code&gt; as shown in figure E.2. In section 3.1.6 you can find more information about the used syntax.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/astah_class_diagram.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:astah_class_diagram.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/astah_class_diagram.png?w=377&amp;amp;tok=d3e67f&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure E.2: Place header and action code in a comment linked to the correct class for astah. When using asta SysML use blocks instead of classes.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix E.1 Attaching action and include comments&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_e1_attaching_action_and_include_comments&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:210,&amp;quot;range&amp;quot;:&amp;quot;266107-267016&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit211&quot; id=&quot;appendix_e2_specify_the_path_to_a_state_diagram&quot;&gt;Appendix E.2 Specify the Path to a State Diagram&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
With the command line flag ’-t’ you have to specify the path to the state diagram in your model file where you want to generate code from. Start from the root node and then just go down the tree until you reach the state diagram of your choice. The root node itself must be left out as it is the name of the model. Separate each level with a colon. Figure E.3 gives an example.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/astah_tree.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:astah_tree.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/astah_tree.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;astah_tree.jpg&quot; alt=&quot;astah_tree.jpg&quot; /&gt;&lt;/a&gt;
Figure E.3: To generate code from testcase set the path to &lt;code&gt;&amp;quot;-t peters_package:testcase_class:testcase&amp;quot;&lt;/code&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix E.2 Specify the Path to a State Diagram&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_e2_specify_the_path_to_a_state_diagram&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:211,&amp;quot;range&amp;quot;:&amp;quot;267017-267607&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit212&quot; id=&quot;appendix_e3_states&quot;&gt;Appendix E.3 States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Astah* allows you to define &lt;em&gt;entry&lt;/em&gt;, &lt;em&gt;do&lt;/em&gt; and &lt;em&gt;exit&lt;/em&gt; activities as well as inner transitions for a state. Unfortunately only one line of text is possible per action. If you want to specify multiple action lines (i.e. code lines) link a comment to a state and provide the code there. An example is shown in figure E.1 for state &lt;em&gt;S3&lt;/em&gt;. Take care of the required keywords to begin an action in a linked comment. The keywords are &lt;em&gt;onEntry:&lt;/em&gt; or &lt;em&gt;onExit&lt;/em&gt; and &lt;em&gt;action:&lt;/em&gt;.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix E.3 States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_e3_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:212,&amp;quot;range&amp;quot;:&amp;quot;267608-268118&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit213&quot; id=&quot;appendix_e4_regions&quot;&gt;Appendix E.4 Regions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
A region is an orthogonal part of a state. It allows to express parallelism within a state. A state can have two or more regions. Region contains states and transitions. To add a region in astah* right click to a state and select &lt;code&gt;Add region&lt;/code&gt; from the context menu. See figure E.4 for an example.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/astah_regions.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:astah_regions.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/astah_regions.png?w=566&amp;amp;tok=46e05b&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;566&quot; /&gt;&lt;/a&gt;
Figure E.4: Example diagram with regions
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix E.4 Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_e4_regions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:213,&amp;quot;range&amp;quot;:&amp;quot;268119-268539&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit214&quot; id=&quot;appendix_e5_transitions&quot;&gt;Appendix E.5 Transitions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Transitions can be drawn from and to states on all levels in the diagram. Click on a transition to specify its details like the triggering event the guard and the action. Transitions can’t cross region borders.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/astah_comment_transition_normal.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:astah_comment_transition_normal.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/astah_comment_transition_normal.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure E.5: Definition of an event, guard an action for a transition between states
&lt;/p&gt;

&lt;p&gt;
&lt;em&gt;Alternatively&lt;/em&gt; it is possible to attach a comment to a transition and specify the &lt;code&gt; event[guard]/action &lt;/code&gt; in the comment. Usually you don’t require to do this (e.g. &lt;code&gt; #rxbuf[i]==0x0d &lt;/code&gt;). This type of definition makes most sense together with conditional triggers.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/astah_comment_transition.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:astah_comment_transition.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/astah_comment_transition.jpg?w=302&amp;amp;tok=989154&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;astah_comment_transition.jpg&quot; alt=&quot;astah_comment_transition.jpg&quot; width=&quot;302&quot; /&gt;&lt;/a&gt;
Figure E.6: Definition of an event using a comment attached to a transition
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix E.5 Transitions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_e5_transitions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:214,&amp;quot;range&amp;quot;:&amp;quot;268540-269342&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit215&quot; id=&quot;appendix_e6_history_state&quot;&gt;Appendix E.6 History State&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Use the &lt;code&gt;Shallow History&lt;/code&gt; symbol and put it in a state to make it a history state.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix E.6 History State&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_e6_history_state&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:215,&amp;quot;range&amp;quot;:&amp;quot;269343-269472&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit216&quot; id=&quot;appendix_e7_deep_history&quot;&gt;Appendix E.7 Deep History&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Use the &lt;code&gt;Deep History&lt;/code&gt; icon and put it in a state to make it a deep history state. This has the same effect as adding a Shallow History marker to all composite child states.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix E.7 Deep History&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_e7_deep_history&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:216,&amp;quot;range&amp;quot;:&amp;quot;269473-269692&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit217&quot; id=&quot;appendix_e8_supportedunsupported&quot;&gt;Appendix E.8 Supported / Unsupported&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code generator supports a subset of the design elements provided by astah*. The supported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Hierarchical states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Events with event name, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial and final pseudo states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; History states (deep, flat), Extended history handling (see section )&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choices&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Junctions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Constraints&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Multiple state machines in a diagram&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Sync states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry and exit points (not to compare with entry/exit actions within states)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Terminate and Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix E.8 Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_e8_supportedunsupported&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:217,&amp;quot;range&amp;quot;:&amp;quot;269693-270283&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit218&quot; id=&quot;appendix_f_drawing_state-charts_with_visual_paradigm&quot;&gt;Appendix F Drawing State-Charts with Visual Paradigm&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
When using Visual Paradigm some tool specific things must be taken care of. The following section discusses these points. First take a look how a rather complex state chart looks like in Visual Paradigm.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/vp_complex.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:vp_complex.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/vp_complex.jpg?w=377&amp;amp;tok=c2c9aa&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;vp_complex.jpg&quot; alt=&quot;vp_complex.jpg&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure F.1: A rather complex state chart designed in Visual Paradigm 
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix F Drawing State-Charts with Visual Paradigm&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_f_drawing_state-charts_with_visual_paradigm&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:218,&amp;quot;range&amp;quot;:&amp;quot;270284-270665&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit219&quot; id=&quot;appendix_f1_organising_your_project&quot;&gt;Appendix F.1 Organising your project&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code-generator needs to know how to find your state-based class in the exported XMI diagram. The path to your class in your project tree must be specified on the command line using the -t flag.
&lt;/p&gt;

&lt;p&gt;
The following figure shows the project browser window for the ’oven’ example state diagram from the tutorial section. From figure F.2 you can directly derive the path which is &lt;code&gt;-t &amp;#039;ModelModel:OvenClass&amp;#039;&lt;/code&gt;. The different parts of the path must be separated with colons. The class diagram must not be specified.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/vp_project_browser.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:vp_project_browser.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/vp_project_browser.jpg?w=264&amp;amp;tok=99a265&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;vp_project_browser.jpg&quot; alt=&quot;vp_project_browser.jpg&quot; width=&quot;264&quot; /&gt;&lt;/a&gt;
Figure F.2: Visual Paradigm’s project browser. From the used structure the path can be directly derived.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix F.1 Organising your project&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_f1_organising_your_project&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:219,&amp;quot;range&amp;quot;:&amp;quot;270666-271388&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit220&quot; id=&quot;appendix_f2_exporting_your_project_to_xmi&quot;&gt;Appendix F.2 Exporting your project to XMI&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The main purpose of XMI is to enable easy interchange of metadata between modelling tools. Several &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; modelling tools support the import and export of XMI file. The exported XMI file is then used as as input for the code-generator. During the development of the XMI standard different versions were created. The latest are based on a XML schema. The code-generator expects version 2.1 for VP generated XMI files. Therefore select &lt;code&gt;UML 2.1 (XMI 2.1)&lt;/code&gt; in the export dialog before exporting.
&lt;/p&gt;

&lt;p&gt;
The code-generator expects your class at a certain hierarchy in the model (model, class model, class). Tools allow to export a XMI downwards from a selected node e.g. the class model. Then the code-generator will not be able to find the right class to generate code from. Therefore make sure that you select the top level node in the project browser before opening the export dialog. The following figure shows the export dialog. You can open it by selecting &lt;code&gt;Project -&amp;gt; Import/Export -&amp;gt; Export Package to XMI&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/vp_xmi_export.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:vp_xmi_export.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/vp_xmi_export.jpg?w=377&amp;amp;tok=716bc9&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;vp_xmi_export.jpg&quot; alt=&quot;vp_xmi_export.jpg&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure F.3: VP’s export dialog. Ensure that XMI Type is set to &lt;code&gt;UML 2.1&lt;/code&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix F.2 Exporting your project to XMI&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_f2_exporting_your_project_to_xmi&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:220,&amp;quot;range&amp;quot;:&amp;quot;271389-272583&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit221&quot; id=&quot;appendix_f3_attaching_action_and_include_comments&quot;&gt;Appendix F.3 Attaching action and include comments&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
You can specify code that is just copied at the beginning of the state machine c-file. Also you can add action code that is called every time the state machine is called. This can be done by using comments starting with the keywords &lt;code&gt;action:&lt;/code&gt; and &lt;code&gt;include:&lt;/code&gt; (see section 3.1.6). Link these two comments to the class owning the state machine. See figure F.4. You must use plain text in the comment. It is not possible to use html comments. See figure F.4 on page .
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/vp_header.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:vp_header.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/vp_header.jpg?w=453&amp;amp;tok=5403c2&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;vp_header.jpg&quot; alt=&quot;vp_header.jpg&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure F.4: Specify header and action code using comments. Make sure the format of the comment is ’plain text’.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix F.3 Attaching action and include comments&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_f3_attaching_action_and_include_comments&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:221,&amp;quot;range&amp;quot;:&amp;quot;272584-273278&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit222&quot; id=&quot;appendix_f4_states&quot;&gt;Appendix F.4 States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
VP allows you to define entry, do and exit activities as well as inner transitions for a state. Also multiline code statements are possible per action. To specify child states you have to add a region to a state first. If you have doubts cross-check in the model view that a state is a child of the parent. See figures F.1 and F.2 for an example. If you edit actions the action name should be deleted for clarity. See figure F.5 on page .
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/vp_state.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:vp_state.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/vp_state.jpg?w=453&amp;amp;tok=6c1d00&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;vp_state.jpg&quot; alt=&quot;vp_state.jpg&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure F.5: State definition. Define the action code and eventually an internal event of a state.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix F.4 States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_f4_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:222,&amp;quot;range&amp;quot;:&amp;quot;273279-273886&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit223&quot; id=&quot;appendix_f5_transitions&quot;&gt;Appendix F.5 Transitions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Open the property dialog of the transition and add a trigger (i.e. event) that triggers the transition. You must select ’Signal Trigger’ as trigger type. Then close the dialog. Open the properties dialog again. Now you can add an optional action code and guard. It is possible to provide multiple code lines for the transition’s action which is a nice feature. Delete the transition name (’action’ by default) for clarity. To display the action code right click on the diagram and select ’Presentation Options $\rightarrow$ Transition Display Options $\rightarrow$ Show Transition Effect Body’. Otherwise the action code is not shown. See figure F.6 on page .
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/vp_trigger.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:vp_trigger.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/vp_trigger.jpg?w=453&amp;amp;tok=54a6e0&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;vp_trigger.jpg&quot; alt=&quot;vp_trigger.jpg&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure F.6: Trigger definition. Define signal triggers only and select the one which should trigger the transition. On the tab card ’General’ you can set the guard and action code.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix F.5 Transitions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_f5_transitions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:223,&amp;quot;range&amp;quot;:&amp;quot;273887-274823&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit224&quot; id=&quot;appendix_f6_history_state_and_other_pseudo_states&quot;&gt;Appendix F.6 History State and other Pseudo States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Just add final states or history states from the tool bar into your diagram.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix F.6 History State and other Pseudo States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_f6_history_state_and_other_pseudo_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:224,&amp;quot;range&amp;quot;:&amp;quot;274824-274965&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit225&quot; id=&quot;appendix_f7_supportedunsupported&quot;&gt;Appendix F.7 Supported / Unsupported&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code generator supports a subset of the design elements provided by VP. The supported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Hierarchical states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; (Signal-)Events with event name, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial and final pseudo states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; History states (deep, flat)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choices&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions in a diagram&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Constraints&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Syncstates and junctions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry and exit points (not to compare with entry/exit actions within states)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Terminate and Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Extended history handling&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix F.7 Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_f7_supportedunsupported&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:225,&amp;quot;range&amp;quot;:&amp;quot;274966-275520&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit226&quot; id=&quot;appendix_g_drawing_state-charts_with_enterprise_architect&quot;&gt;Appendix G Drawing State-Charts with Enterprise Architect&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
When using Enterprise Architect, there are a number of tool specific issues that need to be considered. These are discussed in the following section. Let us first look at how a rather complex state machine looks in Enterprise Architect.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/ea_complex.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:ea_complex.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/ea_complex.jpg?w=604&amp;amp;tok=230706&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;ea_complex.jpg&quot; alt=&quot;ea_complex.jpg&quot; width=&quot;604&quot; /&gt;&lt;/a&gt;
Figure G.1: A rather complex state chart designed in Enterprise Architect. It shows regions, sub-machines and several pseudo-states like a choice state.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G Drawing State-Charts with Enterprise Architect&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g_drawing_state-charts_with_enterprise_architect&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:226,&amp;quot;range&amp;quot;:&amp;quot;275521-276023&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit227&quot; id=&quot;appendix_g1_organizing_your_project&quot;&gt;Appendix G.1 Organizing your project&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Typically you have organized your project into packages. These packages contains classes which again can contain a state machine. The code-generator needs to know how to find your state-based class in the exported XMI diagram. The path to your class in your project tree must be specified on the command line using the &lt;em&gt;-t&lt;/em&gt; flag. If you want to create several state diagrams it is necessary to put them into separate packages!
&lt;/p&gt;

&lt;p&gt;
The following figure G.2 shows the project browser window for the state diagram from above. In this project not just the &lt;em&gt;complex_class&lt;/em&gt; is present but also two other classes &lt;em&gt;Class1&lt;/em&gt; and &lt;em&gt;Class2&lt;/em&gt;. From the EA &lt;em&gt;Project Browser&lt;/em&gt; window you can directly derive the path to the state machine which is &lt;code&gt;-t &amp;quot;Model:Class Model:complex_class&amp;quot;&lt;/code&gt; in this case. The different parts of the path must be separated by colons.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/ea_project_browser.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:ea_project_browser.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/ea_project_browser.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;LEAD Technologies Inc. V1.01&quot; alt=&quot;LEAD Technologies Inc. V1.01&quot; /&gt;&lt;/a&gt;
Figure G.2: Enterprise Architect’s project browser. From the used structure the path can be directly derived.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.1 Organizing your project&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g1_organizing_your_project&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:227,&amp;quot;range&amp;quot;:&amp;quot;276024-277085&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit228&quot; id=&quot;appendix_g2_exporting_your_project_to_xmi&quot;&gt;Appendix G.2 Exporting your project to XMI&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The main purpose of XMI is to enable the exchange of models between between modelling tools from different vendors. Therefore, most &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; modelling tools support the import and export of XMI files. The exported XMI file is the basis for the code generator. During the development of the XMI standard, several versions have been have been created. Use the latest available version of &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt;/XMI. At the time of writing, it is version &lt;em&gt;version 2.5.1&lt;/em&gt;.
&lt;/p&gt;

&lt;p&gt;
The code-generator expects your class at a certain hierarchy in the model (model, class-model, class). EA always exports from the selected node – e.g. the class model – downwards. Then the code-generator is not able to find the right class. Therefore &lt;em&gt;always select the top level node in the project browser before opening the publish dialog&lt;/em&gt;. E.g. &lt;em&gt;Model&lt;/em&gt; in the example above.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.2 Exporting your project to XMI&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g2_exporting_your_project_to_xmi&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:228,&amp;quot;range&amp;quot;:&amp;quot;277086-277977&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit229&quot; id=&quot;appendix_g3_state_details&quot;&gt;Appendix G.3 State Details&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Enterprise Architect allows you to define &lt;em&gt;entry&lt;/em&gt;, &lt;em&gt;do&lt;/em&gt; and &lt;em&gt;exit&lt;/em&gt; actions of a state. There are currenty three options to specifiy the enty/do/exit action code.
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:230,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
Simply select the state and use the Features/Behaviour field to directly type in the action. See figure G.3 as example.
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/ea/ea_code_in_action_name.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;wiki:manual:ea:ea_code_in_action_name.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/ea/ea_code_in_action_name.png?w=302&amp;amp;tok=27f09a&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;302&quot; /&gt;&lt;/a&gt;
Figure G.3: Action code specified in the name field of the action function. This is ok if the action code fits in one line.
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:231,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:232,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
It is also possible to specify code for the entry/exit/do action code using the &lt;em&gt;Behaviour&lt;/em&gt; text field. See figure G.4 as example. This makes it easier to specify longer action codes. If the code is found in the behaviour property field, the text in the action name field is no longer used. If you have specified more than one entry/exit/do action, the code from the different entry/exit/do behaviour fields will be merged. Note that you must always enter some text in the action name field. As example type in a short description of what the action code does, as shown in the diagram. &lt;em&gt;Note: For some reason there is no syntax highlighting for this field.&lt;/em&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/ea/behaviour_window.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;wiki:manual:ea:behaviour_window.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/ea/behaviour_window.png?w=529&amp;amp;tok=9592f3&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure G.4: A state with entry/exit/do code specified following option b) in the state function’s behaviour field.
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:233,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:234,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
It is also possible to specify code for the entry/exit/do action code using the &lt;em&gt;Code&lt;/em&gt; text field. This entry field has syntax highlighting. If code is available there all other fields from above are ignored. Please note that you always have to put in some text in the operation name field. As example type in a short description of what the action code does, as shown in the diagram. &lt;em&gt;Note: The code field is not in the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; part of the XMI export but in the EA specific part.&lt;/em&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/ea/code_window.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media wikilink2&quot; title=&quot;wiki:manual:ea:code_window.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/ea/code_window.png?w=529&amp;amp;tok=a7bb5f&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure G.5: A state with entry/exit/do code specified following option b) in the state function’s behaviour field.
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:235,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:236,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
You can use a comment and specify entry/do/exit action code as plain text. The comment text must follow the syntax as described in section . The comment must be &lt;em&gt;linked to the appropriate state&lt;/em&gt;. To edit the text double click on the comment and enter the definitions as needed. You can attach such comment to a normal state, a child state of a composite state or a sub-state machine state. Make sure to use &lt;em&gt;plain text&lt;/em&gt; (i.e. no special font or color etc.) the code-generator is not able to extract the text correctly otherwise. Use this option if you want to specify &lt;em&gt;inner events&lt;/em&gt; in a state. There seems to be no other way to specify such events in EA.
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/ea_state.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:ea_state.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/ea_state.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;ea_state.jpg&quot; alt=&quot;ea_state.jpg&quot; /&gt;&lt;/a&gt;
Figure G.6: A state with entry/exit/do code specified following option a). And an inner-event following option c)
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:237,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.3 State Details&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g3_state_details&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:229,&amp;quot;range&amp;quot;:&amp;quot;277978-280831&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit238&quot; id=&quot;appendix_g4_regions&quot;&gt;Appendix G.4 Regions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
A region is an orthogonal part of a state. It allows to express parallelism within a state. A state can have two or more regions. Region contains states and transitions. To add a region in EA
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Right click to a state and select &lt;code&gt;Advanced&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Then select &lt;code&gt;Define Concurrent Substates&lt;/code&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Then add as much concurrent regions as you need&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.4 Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g4_regions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:238,&amp;quot;range&amp;quot;:&amp;quot;280832-281219&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit239&quot; id=&quot;appendix_g5_transitions&quot;&gt;Appendix G.5 Transitions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Double-clicking on a transition brings up the &lt;em&gt;transition properties&lt;/em&gt; dialog (see figure G.7 a). This dialog allows you to define the event that triggers the state transition. You can specify a guard (i.e. a statement that evaluates to true or false), an effect of the trigger and the trigger itself. The trigger type &lt;em&gt;must be&lt;/em&gt; set to type &lt;em&gt;Signal&lt;/em&gt;. EA enforces the event type specification. This type is not needed by the code-generator and it is recommended to use only one type for all the triggers. To re-use an existing trigger text use the selection field (three dots). Otherwise a new event is created every time even if you use the same trigger text.
&lt;/p&gt;

&lt;p&gt;
A transition can have more than one trigger. This is the same as two transitions with one trigger each. But can lead to clearer diagrams in case of many transitions between two states sharing the same action code.
&lt;/p&gt;

&lt;p&gt;
The code-generator expects triggers on class level in your model. Move the triggers to that level in the Project Browser. See figure G.7 b) for an example.
&lt;/p&gt;

&lt;p&gt;
Figure G.7: Relevant aspects when using transitions.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.5 Transitions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g5_transitions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:239,&amp;quot;range&amp;quot;:&amp;quot;281220-282350&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit240&quot; id=&quot;appendix_g6_history_state&quot;&gt;Appendix G.6 History State&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Use the &lt;em&gt;Shallow History&lt;/em&gt; pseudo-state if you want to make a state a history state. Place the pseudo-state in the state that should have history.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.6 History State&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g6_history_state&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:240,&amp;quot;range&amp;quot;:&amp;quot;282351-282539&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit241&quot; id=&quot;appendix_g7_deep_history&quot;&gt;Appendix G.7 Deep History&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Use the &lt;em&gt;Deep History&lt;/em&gt; pseudo state if you want to make all child states history states. Place the pseudo-state in the state that should have history. Using a Deep History pseudo state has the same effect as adding a Shallow History marker to all composite child states.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.7 Deep History&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g7_deep_history&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:241,&amp;quot;range&amp;quot;:&amp;quot;282540-282852&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit242&quot; id=&quot;appendix_g8_choices&quot;&gt;Appendix G.8 Choices&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
With EA 7.5 it seems to be not possible anymore to specify transitions without a trigger name (which is in general ok). But for transitions starting from a choice state only guards should be specified (no trigger!). To ensure a clear design only type in one or more spaces as trigger name. The generator detects this and ignores the trigger name. It is recommended to use the same “empty” event for all the transitions starting from choices.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.8 Choices&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g8_choices&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:242,&amp;quot;range&amp;quot;:&amp;quot;282853-283333&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit243&quot; id=&quot;appendix_g9_constraints&quot;&gt;Appendix G.9 Constraints&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code-generator can automatically derive testcases from the EA state-machine model. See section 3.19 Testing Statemachines for more details.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.9 Constraints&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g9_constraints&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:243,&amp;quot;range&amp;quot;:&amp;quot;283334-283516&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit244&quot; id=&quot;appendix_g10_adding_operations_and_attributes_to_classes&quot;&gt;Appendix G.10 Adding Operations and Attributes to Classes&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
It is possible to add attributes and operations to the class containing the state machine. Clicking on the class shows the class features where attributes and operations can be easily added. For operations it is also possible to add code in the behaviour field (not the code field). Attributes are added to the instance data and always require a default value. Operations are mapped to C-functions and added to the header and implementation files of the state machine (only if an implementation is given)
&lt;/p&gt;

&lt;p&gt;
The following figure G.8 shows an attribute and operation added to a class. For operations and attributes it is recommended to use own data types defined as primitive types. Create them in the same package where the class is in. If you use standard EA data types there is an automatic mapping of EA types to own data types provided in the configuration file.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/ea_adding_features_to_class.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:ea_adding_features_to_class.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/ea_adding_features_to_class.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;ea_adding_features_to_class.jpg&quot; alt=&quot;ea_adding_features_to_class.jpg&quot; /&gt;&lt;/a&gt;
Figure G.8: Adding a new attribute to a class with a state machine. Use own data types defined as primitive types in the same package where the class is in.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.10 Adding Operations and Attributes to Classes&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g10_adding_operations_and_attributes_to_classes&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:244,&amp;quot;range&amp;quot;:&amp;quot;283517-284662&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit245&quot; id=&quot;appendix_g11_sub-machine_states&quot;&gt;Appendix G.11 Sub-Machine States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Sub-machine states allow to “hide” the children states of a parent state with hierarchy. You only see the content of the sub-machine state if you double click on the state which opens the internal view. From the code generator point of view a sub-machine is a normal state with children. There is absolutely no difference compared to a normal hierarchical state.
&lt;/p&gt;

&lt;p&gt;
To create a sub-machine do the following:
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Place a normal state&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Right click on the state and select &lt;code&gt;New Diagram&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Select &lt;code&gt;Composite Structure Diagram&lt;/code&gt;. Now an $\infty$ symbol indicates the transformation.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Double click to the state and you are able to place children into the sub-machine.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
Note: Do not mix up a &lt;strong&gt;sub-machine&lt;/strong&gt; with a &lt;strong&gt;state-machine&lt;/strong&gt;. In EA both have the same symbol i.e. a state with $\infty$ sign on the lower right. But a sub-machine is a normal state transformed into a sub-machine. Placing state-machines in another state is possible in EA but has no meaning and is not supported by the code generator!
&lt;/p&gt;

&lt;p&gt;
Using a sub-machine state instead of a state has some other consequences:
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; It is not possible to connect a transition starting from a state outside the sub-machine to a state inside the sub-machine. Or vice versa. Use entry and exit pseudo states for this purpose (see next section).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; EA does not allow to “transform” a sub-machine state into a state with children. You have to do this manually by moving states etc. in the Model Browser.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
The following figure shows two state machines which produce exactly the same code – one using a sub-machine, one using a normal hierarchical design.
&lt;/p&gt;

&lt;p&gt;
Figure G.9: This figure shows two state machines producing exactly the same code but one is using a sub-machine state (internals set visible) and one uses a normal hierarchical design. I.e. m1 $\Leftrightarrow$ m2.
&lt;/p&gt;

&lt;p&gt;
In principle sub-machines can be located in normal states (or states) or regions.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.11 Sub-Machine States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g11_sub-machine_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:245,&amp;quot;range&amp;quot;:&amp;quot;284663-286635&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit246&quot; id=&quot;appendix_g12_entry_and_exit_points&quot;&gt;Appendix G.12 Entry and Exit Points&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
&lt;em&gt;Note: Entry and exit points are only useful together with a sub-machine. Read the previous section before if you are not familiar with the usage of sub-machines.&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
When entering a sub-machine usually the initial state is entered. I.e. the transition ends at the border of the sub-machine state. If this should not be the case for a specific transition it is possible to place an entry point inside the sub-machine state. This entry point serves as glue between the sub-machine state and the internal of the sub-machine.
&lt;/p&gt;

&lt;p&gt;
Exit states provide a similar function. By default only transitions can be modelled starting from the sub-machine. If a transition should start from a specific state inside the sub-machine and enter a state outside the sub-machine an exit state can be used. Again this exit state serves as glue between the transition starting inside the sub-machine and ending one level up at another state.
&lt;/p&gt;

&lt;p&gt;
To use entry and exit points in your model use the following recipe:
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Drag and drop an entry and/or exit point in a sub-machine state&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Give the points a meaningful name.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Double click on the sub-machine state to open the sub-machine diagram&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Place references of the points here. &lt;strong&gt;Do not create new entry/exit points with the same name!&lt;/strong&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Connect transitions&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
Alternatively (since version 12 of EA) follow the recipe below. In this case the entry and exit points are displayed on the border of the state with sub-machine.
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Select the sub-machine state that should have and entry or exit point&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Right click on the sub-machine state to bring up the context menu and then select ’Add’.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:247,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;plugin_wrap&quot;&gt;
&lt;p&gt;
Add either and entry or exit point. See figure G.10.
Figure G.10: Create an entry or exit point using the context menu of a sub-machine state.
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:248,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Inside the sub-machine state drag and drop the existing entry/exit point into the diagram (as link). &lt;strong&gt;Do not create new entry/exit points with the same name here!&lt;/strong&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Connect transitions&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
Limitations when using entry and exit points:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; An exit point can have more than one incoming transitions inside the sub-machine. But only one outgoing transition from the sub-machine state.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; An entry state can have more than one incoming transitions on the sub-machine state. But only one outgoing transition inside the sub-machine.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The transition leaving the exit or entry point most end in a normal state. Chaining of entry / exit states or connecting these transitions to choices or junctions is not allowed.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The following figure G.11 shows an example for a diagram with a sub-machine and the internals of this sub-machine.
&lt;/p&gt;

&lt;p&gt;
Figure G.11: This figure shows the top level diagram with a sub-machine state and the internals of the sub-machine state. The transitions between these two diagrams are glued together using entry and exit points.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.12 Entry and Exit Points&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g12_entry_and_exit_points&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:246,&amp;quot;range&amp;quot;:&amp;quot;286636-289526&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit249&quot; id=&quot;appendix_g13_supportedunsupported&quot;&gt;Appendix G.13 Supported / Unsupported&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code-generator supports a subset of the design elements provided by Enterprise Architect. The supported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Hierarchical states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; (Signal-)Events with event name, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial and final pseudo-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; History states (deep, flat), Extended history handling (see section )&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choices&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Junctions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Constraints&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Sub-machine states on various levels&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry and exit pseudo-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions on various levels&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Syncstates&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Terminate and Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix G.13 Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_g13_supportedunsupported&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:249,&amp;quot;range&amp;quot;:&amp;quot;289527-290110&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit250&quot; id=&quot;appendix_h_drawing_state-charts_with_modelio&quot;&gt;Appendix H Drawing State-Charts with Modelio&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
When using Modelio some tool specific things must be taken care of. The following section discusses these points. First take a look how the microwave oven example from the introduction section looks like in Modelio.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/modelio_oven_model.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:modelio_oven_model.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/modelio_oven_model.png?w=529&amp;amp;tok=3707bb&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure H.1: The microwave oven state chart designed in Modelio
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix H Drawing State-Charts with Modelio&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_h_drawing_state-charts_with_modelio&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:250,&amp;quot;range&amp;quot;:&amp;quot;290111-290497&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit251&quot; id=&quot;appendix_h1_organizing_your_project&quot;&gt;Appendix H.1 Organizing your project&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code-generator needs to know how to find your state-based class in the exported XMI file. The path to your class in your project tree must be specified on the command line using the -t flag.
&lt;/p&gt;

&lt;p&gt;
The following figure H.2 shows the project browser window for the ’oven’ example state diagram from the tutorial section. You can easily derive the path which is &lt;code&gt;-t &amp;#039;OvenClass&amp;#039;&lt;/code&gt; in this case. In case of multiple packages the different parts of the path must be separated with colons.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/modelio_model_view.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:modelio_model_view.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/modelio_model_view.png?w=188&amp;amp;tok=2e3d3a&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;188&quot; /&gt;&lt;/a&gt;
Figure H.2: Modelio’s project browser. From the used structure the path can be directly derived.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix H.1 Organizing your project&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_h1_organizing_your_project&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:251,&amp;quot;range&amp;quot;:&amp;quot;290498-291185&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit252&quot; id=&quot;appendix_h2_exporting_your_project_to_xmi&quot;&gt;Appendix H.2 Exporting your project to XMI&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The exported XMI file is used as input for the code-generator. Right click on the oven package in the model tree and select &lt;code&gt;’XMI’ &lt;/code&gt;$\rightarrow$&lt;code&gt; ’Export to XMI’&lt;/code&gt;. Select &lt;code&gt;’OMG UML 2.4.1’&lt;/code&gt; and deselect &lt;code&gt;’Added Modelio annotations’&lt;/code&gt; in the export dialog before exporting.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix H.2 Exporting your project to XMI&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_h2_exporting_your_project_to_xmi&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:252,&amp;quot;range&amp;quot;:&amp;quot;291186-291554&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit253&quot; id=&quot;appendix_h3_states&quot;&gt;Appendix H.3 States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Modelio allows you to define &lt;em&gt;entry&lt;/em&gt;, &lt;em&gt;do&lt;/em&gt; and &lt;em&gt;exit&lt;/em&gt; activities for a state. Right click to the state and select ’Create an element’ $\rightarrow$ ’Internal transition’. Activities created this way directly in the graphics are immediately visible. If created in the model tree (right click on the state in the model tree $\rightarrow$ Create an element $\rightarrow$ Internal transition) it is necessary to drop the activity into the state before they are displayed.
&lt;/p&gt;

&lt;p&gt;
Internal transitions are presently not supported by Modelio. To add an internal transition to an state attach a &lt;em&gt;note&lt;/em&gt; to a state and specify the transition following the syntax shown in figure .
&lt;/p&gt;

&lt;p&gt;
To add child states to a parent state just drop a new state inside its parent.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix H.3 States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_h3_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:253,&amp;quot;range&amp;quot;:&amp;quot;291555-292349&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit254&quot; id=&quot;appendix_h4_regions&quot;&gt;Appendix H.4 Regions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
A region is an orthogonal part of a state. It allows to express parallelism within a state. A state can have two or more regions. Region contains states and transitions. States in regions can contain regions again.
&lt;/p&gt;

&lt;p&gt;
The following figure H.3 shows a state machine with a state containing two regions.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/and_states_modelio.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:and_states_modelio.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/and_states_modelio.png?w=377&amp;amp;tok=c444db&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure H.3: Specify the linked sub-machine in the state properties.
&lt;/p&gt;

&lt;p&gt;
Rules when using regions:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transitions must not cross region borders. I.e. it is not allowed to add a transition from &lt;code&gt;Right&lt;/code&gt; to &lt;code&gt;Off&lt;/code&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A region might contain a history state, choices, final states and normal states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; To express that a transition should fire if the machine is in &lt;code&gt;Right&lt;/code&gt; and &lt;code&gt;Off&lt;/code&gt; use a conditional transition like follows: &lt;code&gt;#machineIsInRight(…) &amp;amp;&amp;amp; machineIsInOff(…)&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions can contain states which contain regions again&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix H.4 Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_h4_regions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:254,&amp;quot;range&amp;quot;:&amp;quot;292350-293288&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit255&quot; id=&quot;appendix_h5_sub-machines&quot;&gt;Appendix H.5 Sub-Machines&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
A sub-machine state specifies the insertion of the specification of a sub-machine state machine. The state machine that contains the sub-machine state is called the containing state machine. A sub-machine state is semantically equivalent to a composite state but you only see the top level state. Sub-machines are usually used to “hide” complexity in the containing state machine.
&lt;/p&gt;

&lt;p&gt;
To connect a sub-machine with the containing state you have to link the state containing the sub-machine to the sub-machine diagram.
&lt;/p&gt;

&lt;p&gt;
To link a state to a sub-machine specify the sub-machine in the state properties as shown in figure H.4.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/submachine_spec_subm_modelio.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:submachine_spec_subm_modelio.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/submachine_spec_subm_modelio.png?w=377&amp;amp;tok=d9ae7e&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure H.4: Specify the linked sub-machine in the state properties.
&lt;/p&gt;

&lt;p&gt;
To link transitions between states of the containing state machine with states in the sub-machine diagram you have to use entry and exit points. In Modelio add &lt;em&gt;connection points&lt;/em&gt; to the parent state of the sub-machine (e.g. S2). And add &lt;em&gt;entry - and exit points&lt;/em&gt; to the sub-machine diagram (e.g. EX1).
&lt;/p&gt;

&lt;p&gt;
Defining the &lt;em&gt;connection point reference&lt;/em&gt; in the &lt;em&gt;connection point properties&lt;/em&gt; finally links the connection point on the top level state to an entry - or exit point in the sub-machine as shown in figure H.5.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/connection_point_ref_properties.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:connection_point_ref_properties.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/connection_point_ref_properties.png?w=377&amp;amp;tok=15a627&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure H.5: Link the connection point to an entry – or exit point in the sub-machine.
&lt;/p&gt;

&lt;p&gt;
After linking the connection point to the entry - or exit point the connection point changes its icon and shows either an exit icon or an entry icon. The following figure H.6 show the top level diagram with a state containing a sub-machine (S2) and the sub-machine in figure H.7.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/submachine_sub_modelio.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:submachine_sub_modelio.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/submachine_sub_modelio.png?w=377&amp;amp;tok=d0e780&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure H.6: Diagram with state S2 referencing a sub-machine.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/sub_machine_top_modelio.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:sub_machine_top_modelio.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/sub_machine_top_modelio.png?w=377&amp;amp;tok=e657dd&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure H.7: Sub-machine diagram.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix H.5 Sub-Machines&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_h5_sub-machines&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:255,&amp;quot;range&amp;quot;:&amp;quot;293289-295225&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit256&quot; id=&quot;appendix_h6_transitions&quot;&gt;Appendix H.6 Transitions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
To set transition properties select the transition. Now you define the trigger, guard and action statements. To make sure Modelio knows the Signal it must be defined beforehand in the model tree (add a signal and set its &lt;em&gt;kind property&lt;/em&gt; to &lt;em&gt;Signal&lt;/em&gt;). See figure H.1 how the model tree looks like with some signals defined.
&lt;/p&gt;

&lt;p&gt;
To display the transition text enable the &lt;code&gt;Show label&lt;/code&gt; property. Otherwise the transition trigger and action code is not shown.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/modelio_transition.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:modelio_transition.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/modelio_transition.png?w=529&amp;amp;tok=fa935d&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure H.8: Transition properties. Ensure that the ’received event’ was previously defined and the (from …) is shown. Otherwise the code generator generates an error later on.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix H.6 Transitions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_h6_transitions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:256,&amp;quot;range&amp;quot;:&amp;quot;295226-295955&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit257&quot; id=&quot;appendix_h7_history_state_and_other_pseudo_states&quot;&gt;Appendix H.7 History State and other Pseudo States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Just add final states or history states from the tool bar into your diagram.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix H.7 History State and other Pseudo States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_h7_history_state_and_other_pseudo_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:257,&amp;quot;range&amp;quot;:&amp;quot;295956-296097&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit258&quot; id=&quot;appendix_h8_attaching_action_and_include_comments&quot;&gt;Appendix H.8 Attaching action and include comments&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
By default the code generator includes the minimally needed header files into the generated code. But often it is necessary to add further includes or define local variables etc. In this case you can specify code that is just copied at the beginning of the state machine implementation file.
&lt;/p&gt;

&lt;p&gt;
You can also add code that is added to the beginning of the state machine handler function. The code can be used to perform some actions each time the state machine is executed.
&lt;/p&gt;

&lt;p&gt;
Add this code to your model by using comments starting with the keywords &lt;code&gt;action:&lt;/code&gt; and &lt;code&gt;include:&lt;/code&gt; (see section 3.1.6). Link those comments to the class owning the state machine. An example is shown in figure H.9. You must use plain text in the comment. It is not possible to use html comments.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/modelio_header.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:modelio_header.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/modelio_header.png?w=302&amp;amp;tok=3f30cb&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;302&quot; /&gt;&lt;/a&gt;
Figure H.9: Specify header and action code using comments. Make sure the format of the comment is ’plain text’.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix H.8 Attaching action and include comments&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_h8_attaching_action_and_include_comments&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:258,&amp;quot;range&amp;quot;:&amp;quot;296098-297099&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit259&quot; id=&quot;appendix_h9_supportedunsupported&quot;&gt;Appendix H.9 Supported / Unsupported&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code generator supports a subset of the design elements provided by Modelio. The supported elements are as follows:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Hierarchical states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions and “regions in regions”&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Sub-machines in a top level state&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; (Signal-)Events with event name, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial and final pseudo-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; History states (deep, flat), Extended history handling (see section )&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choices&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Junctions&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Constraints&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Sync-states and junctions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry and exit points (not to compare with entry/exit actions within states)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Terminate and Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix H.9 Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_h9_supportedunsupported&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:259,&amp;quot;range&amp;quot;:&amp;quot;297100-297751&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit260&quot; id=&quot;appendix_i_drawing_state-charts_with_eclipse_papyrustm&quot;&gt;Appendix I Drawing State-Charts with Eclipse PapyrusTM&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
Code generation is supported for Eclipse Papyrus version 2022-12. When using Papyrus, some tool-specific things need to be considered. The following sections cover these points.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/apapyrusstatemachine.jpg?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:apapyrusstatemachine.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/apapyrusstatemachine.jpg?w=529&amp;amp;tok=980e1e&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;apapyrusstatemachine.jpg&quot; alt=&quot;apapyrusstatemachine.jpg&quot; width=&quot;529&quot; /&gt;&lt;/a&gt;
Figure I.1: An example state machine diagram created with Papyrus
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix I Drawing State-Charts with Eclipse PapyrusTM&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_i_drawing_state-charts_with_eclipse_papyrustm&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:260,&amp;quot;range&amp;quot;:&amp;quot;297752-298115&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit261&quot; id=&quot;appendix_i1_organizing_your_project&quot;&gt;Appendix I.1 Organizing your project&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code-generator needs to know how to find your state-based class in the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; file. The path to your class in your project tree must be specified on the command line using the &lt;code&gt;-t&lt;/code&gt; flag. For the model tree shown in figure I.2 an example command line to generate C-code from a file called would look like as follows:&lt;br/&gt;

&lt;code&gt;... -t &amp;quot;MyModel:MyPackage:A&amp;quot; -l cx -p Papyrus -o testcase Papyrus.uml&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/papyrus_model_view.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:papyrus_model_view.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/papyrus_model_view.png?w=377&amp;amp;tok=8c4fdb&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure I.2: Papyrus’ project browser. From the used structure the path can be directly derived.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix I.1 Organizing your project&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_i1_organizing_your_project&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:261,&amp;quot;range&amp;quot;:&amp;quot;298116-298714&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit262&quot; id=&quot;appendix_i2_states&quot;&gt;Appendix I.2 States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Papyrus allows you to define &lt;em&gt;entry&lt;/em&gt;, &lt;em&gt;do&lt;/em&gt; and &lt;em&gt;exit&lt;/em&gt; activities for a state. Right click to the state and select ’show properties’ to bring up the properties view. In the view you can add the activities. It is important that actions are always only created as OpaqueBehaviour. Otherwise code generation cannot generate activity code.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/state_opaque_behaviour_view.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:state_opaque_behaviour_view.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/state_opaque_behaviour_view.png?w=377&amp;amp;tok=08810e&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;377&quot; /&gt;&lt;/a&gt;
Figure I.3: Activities must always be created as OpaqueBehaviour. Inside the dialog click on the plus symbol to define the implementation language - e.g. C. Then add the activity code in the shown text box.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix I.2 States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_i2_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:262,&amp;quot;range&amp;quot;:&amp;quot;298715-299356&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit263&quot; id=&quot;appendix_i3_regions&quot;&gt;Appendix I.3 Regions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
A region is an orthogonal part of a state. It allows to express parallelism within a state. A state can have two or more regions. Region contains states and transitions. States in regions can contain regions again. See figure I.1 for an example state diagram with regions.
&lt;/p&gt;

&lt;p&gt;
General rules when using regions:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transitions must not cross region borders. I.e. it is not allowed to add a transition from &lt;code&gt;Right&lt;/code&gt; to &lt;code&gt;Off&lt;/code&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A region might contain a history state, choices, final states and normal states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; To express that a transition should fire if the machine is in both regions &lt;code&gt;Right&lt;/code&gt; and &lt;code&gt;Off&lt;/code&gt; use a conditional transition like follows: &lt;code&gt;#machineIsInRight(…) &amp;amp;&amp;amp; machineIsInOff(…)&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions can contain states which contain regions again&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix I.3 Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_i3_regions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:263,&amp;quot;range&amp;quot;:&amp;quot;299357-300174&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit264&quot; id=&quot;appendix_i4_transitions&quot;&gt;Appendix I.4 Transitions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Select the transition to set any transition properties. In the properties window the trigger, guard and effect statements can be defined. A transition must usually have a triggering event. To add a new signal event right click on the package that contains the class with the state-machine. Select menu &lt;code&gt;New Child&lt;/code&gt; and add a &lt;code&gt;SignalEvent&lt;/code&gt;. It is important to add the signal events at the correct hierarchical level. Otherwise the code generator does not find them. For the code generation only signal events are supported!
&lt;/p&gt;

&lt;p&gt;
The effect of a transition must be defined as &lt;code&gt;OpaqueBehaviour&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
To add a guard first add a &lt;code&gt;Constraint&lt;/code&gt; and then add a &lt;code&gt;OpaqueExpression&lt;/code&gt; to the Specification.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix I.4 Transitions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_i4_transitions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:264,&amp;quot;range&amp;quot;:&amp;quot;300175-300928&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit265&quot; id=&quot;appendix_i5_history_state_and_other_pseudo_states&quot;&gt;Appendix I.5 History State and other Pseudo States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Just add final states or history states from the tool bar into your diagram.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix I.5 History State and other Pseudo States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_i5_history_state_and_other_pseudo_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:265,&amp;quot;range&amp;quot;:&amp;quot;300929-301070&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit266&quot; id=&quot;appendix_i6_attaching_action_and_include_comments&quot;&gt;Appendix I.6 Attaching action and include comments&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
By default the code generator includes the minimally needed header files into the generated code. But often it is necessary to add further includes or define local variables etc. In this case you can specify code that is just copied at the beginning of the state machine implementation file.
&lt;/p&gt;

&lt;p&gt;
You can also add code that is added to the beginning of the state machine handler function. The code can be used to perform some actions each time the state machine is executed.
&lt;/p&gt;

&lt;p&gt;
Add this code to your model by using comments starting with the keywords &lt;code&gt;action:&lt;/code&gt; and &lt;code&gt;include:&lt;/code&gt;. Link those comments to the class owning the state machine. An example is shown in figure I.4. You must use plain text in the comment. It is not possible to use html comments.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/papyrus_class_diagram.png?id=wiki%3Amanual%3Aeditor_general&quot; class=&quot;media&quot; title=&quot;wiki:manual:papyrus_class_diagram.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/papyrus_class_diagram.png?w=453&amp;amp;tok=5b6f27&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;453&quot; /&gt;&lt;/a&gt;
Figure I.4: Connect comments with the class that contains the state machine to define generation details. Classes can contain properties of various types.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix I.6 Attaching action and include comments&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_i6_attaching_action_and_include_comments&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:266,&amp;quot;range&amp;quot;:&amp;quot;301071-302098&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit267&quot; id=&quot;appendix_i7_adding_attributes_and_operations_to_classes&quot;&gt;Appendix I.7 Adding Attributes and Operations to Classes&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
It is possible to add attributes and operations to the class containing the state machine. To add a property drag and drop a &lt;code&gt;Property&lt;/code&gt; symbol from the tool bar to the class. Then specify the name, data type and default value in the properties dialog. The initial value must be specified as &lt;code&gt;OpaqueExpression&lt;/code&gt;. The data type can be a built-in data type, an own defined &lt;code&gt;primitive data types&lt;/code&gt; as shown in I.4 or a class. In case of a class, specify the &lt;code&gt;Aggregation&lt;/code&gt; type.
&lt;/p&gt;

&lt;p&gt;
To add operations drag an &lt;code&gt;operation&lt;/code&gt; from the toolbar to the class. Add details using the operation’s property dialog. If no return type is specified &lt;code&gt;void&lt;/code&gt; is assumed. Using the &lt;code&gt;Owned Parameter&lt;/code&gt; feature you can add parameters to the operation. For each parameter specify the name, type and default value. Parameters marked as &lt;code&gt;out&lt;/code&gt; or &lt;code&gt;inoout&lt;/code&gt; are generated as pointers.
&lt;/p&gt;

&lt;p&gt;
There is a default mapping of &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; data types to C/C++ types. If you want to use own data types (e.g. uint16_t) define own primitive data types. The default mapping of the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; data types can be changed in the configuration file.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix I.7 Adding Attributes and Operations to Classes&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_i7_adding_attributes_and_operations_to_classes&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:267,&amp;quot;range&amp;quot;:&amp;quot;302099-303305&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit268&quot; id=&quot;appendix_i8_supportedunsupported&quot;&gt;Appendix I.8 Supported / Unsupported&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code generator supports a subset of the design elements provided by Papyrus. The supported elements are as follows:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Hierarchical states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions and “regions in regions”&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; (Signal-)Events with event name, guard and action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial and final pseudo-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; History states (deep, flat), Extended history handling&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choices&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Junctions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Attributes / Operations&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The unsupported elements are:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Constraints&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Sync-states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry and exit points (not to compare with entry/exit actions within states)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Terminate and Fork/Join&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Submachines&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix I.8 Supported \/ Unsupported&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_i8_supportedunsupported&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:268,&amp;quot;range&amp;quot;:&amp;quot;303306-303934&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit269&quot; id=&quot;appendix_j_error_warning_and_info_messages&quot;&gt;Appendix J Error, Warning and Info Messages&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
Table J.1: Message overview. Info and warning messages give hints how to improve the design. Errors must be fixed before the generator generates code.
&lt;/p&gt;
&lt;div class=&quot;table sectionedit270&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt;&lt;strong&gt;Message number&lt;/strong&gt;  &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt;&lt;strong&gt;Explanation&lt;/strong&gt;                                                                                                                                                                                                                                                                              &lt;/th&gt;&lt;th class=&quot;col2 leftalign&quot;&gt;&lt;strong&gt;Type&lt;/strong&gt;  &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1000                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;More than one default state on root level                                                                                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row2&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1001                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;No default state on root level                                                                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row3&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1002                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;More than one default state in composite state &amp;lt;state name&amp;gt;                                                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row4&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1003                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;An initial vertex can have at most one outgoing transition and no incoming transitions                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row5&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1004                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Hint: State “state name” has only one substate. This does not make much sense. Reconsider your design!                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Warning   &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row6&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1005                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Found two incoming transitions going into a choice state. Only one incoming transition is supported!                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row7&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1006                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;There is a choice with just one outgoing transition. Check your design!                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row8&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1007                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;There is a choice with no outgoing transition. This is not allowed.                                                                                                                                                                                                                          &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row9&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1008                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;There is a transition leaving a choice without a guard. This is not allowed.                                                                                                                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row10&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1009                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;A choice must have exactly one outgoing transition with an ’else’ guard. Check your design!                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row11&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1010                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Found a transition starting from unknown state: “event name”                                                                                                                                                                                                                                 &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row12&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1011                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Outgoing transition from a choice requires a guard definition!                                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row13&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1012                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Transition ending in a choice misses the event definition!                                                                                                                                                                                                                                   &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row14&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1013                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;At least one transition has no event definition.                                                                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row15&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1014                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Event name contains one or more spaces                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row16&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1015                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Transition must not cross state borders!                                                                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row17&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1016                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;State name is empty $\Rightarrow$ check state names                                                                                                                                                                                                                                          &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row18&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1017                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;State name contains one or more spaces                                                                                                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row19&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1018                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Inner transitions are presently not possible if state has children                                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row20&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1019                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;No default state on root level                                                                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row21&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1020                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;More than one default state on root level                                                                                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row22&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1021                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Child state has children. This is not supported.                                                                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row23&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1022                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;A final state cannot have any outgoing transitions                                                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row24&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1023                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;State name already used. State names must be unique.                                                                                                                                                                                                                                         &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row25&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1024                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;State is not reachable - check your design.                                                                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Warning   &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row26&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1025                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Transition must not cross state borders!                                                                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row27&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1026                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Transition must not cross state borders!                                                                                                                                                                                                                                                     &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row28&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1027                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Transitions triggered by same event leave a child and its parent. This is not a problem because transitions have higher priority than another one if its source state is a substate of the source of the other one. Make sure that this is what you want and the definition is unambiguous!  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Info      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row29&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1028                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Transitions triggered from event leave state but some have no guard defined - check your design!                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row30&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1029                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Several transitions triggered from event leave state but have no guard defined $\Rightarrow$ check your design!                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row31&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1030                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Choice state violates naming conventions as defined in codegen.cfg $\Rightarrow$ no name defined                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Info      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row32&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1031                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Choice state name violates naming conventions as defined in codegen.cfg                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Info      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row33&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1032                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;State is not reachable $\Rightarrow$ check your design.                                                                                                                                                                                                                                      &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Info      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row34&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1033                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Simple state violates naming conventions as defined in codegen.cfg                                                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Info      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row35&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1034                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Composite state violates naming conventions as defined in codegen.cfg                                                                                                                                                                                                                        &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Info      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row36&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1035                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Event violates naming conventions as defined in codegen.cfg                                                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Info      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row37&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1036                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Actions and guards of transitions entering a choice are ignored. Place actions and guards on the outgoing transitions.                                                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Warning   &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row38&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1037                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;There is a ’header’ comment which is not linked to the class containing the state machine. It is recommended to link the comment to the correct class.                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Info      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row39&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1038                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;The ’header’ comment is linked to another class than the one that statemachine is in. This note will be ignored.                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Info      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row40&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1039                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;You have set the return type of the state machine function and also want to return if events were processed. This might be ok but usually it is not. Check your codegen.cfg settings.                                                                                                        &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Warning   &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row41&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1040                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;A choice must have at least one incoming transition. Error!                                                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row42&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1042                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;A junction must not have more than one outgoing transition.                                                                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row43&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1043                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;The outgoing transition of a junction must not have an event or guard defined.                                                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row44&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1044                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;A junction should have more than one incoming transitions. Otherwise the junction does not really makes sense.                                                                                                                                                                               &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Info      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row45&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1045                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;The transition leaving a junction pseudostate must not end in another pseudostate (e.g. a choice).                                                                                                                                                                                           &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row46&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1046                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;The transitions entering a junction must not start at another pseudostate (e.g. a choice).                                                                                                                                                                                                   &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row47&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1055                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Found a transition with multiple triggers. Create multiple transitions from it.                                                                                                                                                                                                              &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Info      &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row48&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1058                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;A history state must have at least one incoming transition if extended history state handling is enabled.                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row49&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;1054                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;State has no outgoing transitions. This indicates a dead end in the state model and might be a design flaw.                                                                                                                                                                                  &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Warning   &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row50&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;2008                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;A transition starts or ends in an unknown state. Possible cause: Maybe you started a transition in a history state?                                                                                                                                                                          &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row51&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;2009                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Both EventFirstValue and ValidationCall is set. The validation code requires that events start from zero.                                                                                                                                                                                    &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row52&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;2010                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;A transition from an initial pseudo-state to the initial state crosses state borders.                                                                                                                                                                                                        &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Error     &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row53&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;2011                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;In MD a transtion the action code was defined by name and code attribute. The latter overwrites the first.                                                                                                                                                                                   &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Warning   &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row54&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;2012                &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;Parsing incomplete of a method or a method parameter of a class. Check that all operations, operation parameters and attributes have a name, type etc.                                                                                                                                       &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;Warning   &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row55&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;                    &lt;/td&gt;&lt;td class=&quot;col1 leftalign&quot;&gt;                                                                                                                                                                                                                                                                                             &lt;/td&gt;&lt;td class=&quot;col2 leftalign&quot;&gt;          &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table12&amp;quot;,&amp;quot;secid&amp;quot;:270,&amp;quot;range&amp;quot;:&amp;quot;304145-322076&amp;quot;} --&gt;
&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix J Error, Warning and Info Messages&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_j_error_warning_and_info_messages&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:269,&amp;quot;range&amp;quot;:&amp;quot;303935-322078&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit271&quot; id=&quot;appendix_k_version_history&quot;&gt;Appendix K Version History&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
Version 1.02 now supports the specification of entry and exit actions for outer states. As the modeling tool does not support this directly at the moment a linked note with a special keyword at the beginning is used instead. See section  for more info.
&lt;/p&gt;

&lt;p&gt;
Version 1.2: This version supports the code generation from XMI files. Presently only XMI files generated with Enterprise Architect version 7.1 or Magic Draw version 15.5 are tested. Also the command line options have changed. See section 2 for details.
&lt;/p&gt;

&lt;p&gt;
Version 1.3: Test support is now included. A transition coverage algorithm can print out test routes which ensure that each transition was taken at least once. This greatly simplified test specification.
&lt;/p&gt;

&lt;p&gt;
Version 1.4: In this version several features were added that allow to create more complex state machines. Also the support for testing state machines was increased significantly.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Allowed state hierarchy was increased to three. Transitions between states of the third level must start and end at the third level within the same parent state. This looks like a limitation but in practice it is usually not.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; An interactive simulation was added which is activated with the commandline switch ’-s’. You can type in events and get back the executed code as well as the state the machine is in. See section 3.16 for more details. No coding on your side is required!&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Choice states are now supported for XMI generating tools. See section  for details.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; On larger state charts the size of the generated source code size can be reduced by factoring out the entry and exit code of composite states into separate functions. New config file options were added for this purpose (see section 2.2).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The event definition in *ext.h was changed. Only the event type you specified in ’mydefs.h’ is used now. In several cases variables and functions are now prefixed with the machine name to avoid naming conflicts. This requires small changes in your code using the machine if you regenerate an existing state machine with the new codegen.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Macros were added to support you during debugging. E.g. there are now functions generated that returns the event name and state name.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Macros were added that allows to reset history within a state.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Macros were added that return 0/1 to indicate if the machine is in a certain state or not. This can be used if transitions in one state machine shall be triggered depending on the state a second machine is in (see table 3.2&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 1.4.1: This version supports the code generation from XMI files exported from UModel 2009. See appendix D for more information.
&lt;/p&gt;

&lt;p&gt;
Version 1.5: Generation of C++ code is now supported. See section 3.4.
&lt;/p&gt;

&lt;p&gt;
Version 1.5.1: Option added to either access the instance data by value or by reference. Access by value can be useful if your compiler does not produce optimal code when pointers are used (see section A.6). Furthermore the entry/exit code sequences for composite states were optimized.
&lt;/p&gt;

&lt;p&gt;
Version 1.5.2:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; When running the statemachine multiple times in different threads (tasks) in the context of a real-time operating system no global variables must be used to store thread local data. Therefore it is now possible to specify code that is placed directly at the start of the state machine function body. This allows to create local data in a thread safe manner.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; With EA 7.5 it seems to be not possible anymore to specify transitions without a trigger name (which is in general ok). But for transitions starting from a choice state only guards should to be specified. To ensure a clear design only type in one or more spaces as trigger name. The generator detects this and ignores the trigger name.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Many robustness tests for state machines were added. Due to automated rule checking the effort required for manual code reviews can be reduced. See section 3.15 for more details.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 1.6:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; More robustness tests were added&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Section 3.2.1 explains the execution model of the generated code.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A third level of states and the deep history pseudo-state is now also supported when using the Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; editor.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Possibility to add code that is executed if the statevars are invalid. See section 3.1.6 for more info.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; An experimental graphical simulator is now available. See section 3.17 for more details.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 1.6.1:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Optional tracing of the event flow added. See section 3.20 for more information.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The graphical simulator can be remote controlled by sending events via to a UDP port.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Statemachine optionally returns a flag if an event was processed or not&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Creation of a state table in xls format&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Fixes and Improvements:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; C++ code generation optionally generates virtual ’create-functions’ in the factory class. This allows to provide own factory methods e.g. to initialize state objects.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved error handling and error messages&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Final states must not anymore be placed on top level only.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 1.7:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for Objective-C added (experimental)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for nesC/TinyOS added (experimental)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Separate return codes are now used for normal events and conditional events if the ’ReturnEventProcessed’ flag is set.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Bug fix in choice state code. In choices starting from a root state the wrong action code was taken&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; In the INSTANCEDATA_INIT macro type casts are used now to avoid problems with static code checkers.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New configuration flag ’EventsAreBitCoded’. This flag can be used to instruct the code generator to generate bit-coded events.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Guard evaluation is now separate from event selection code to avoid problems with MISRA rule checkers.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Code to adjust the state variables is now inlined by default. If needed you can still provide your own function.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 1.8:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Ada code generation added.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; C# code generation added.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New command line option ’-U’ to provide config file name&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New parameters for better control of the state handler parameters for the C backend&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Action code from the init pseudostate is used by the codegen for the C/C++/C# backend (see section ).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for the modeling tool ArgoUML added&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Possibility to generate a description of a dot state machine graph in the C/C++ file for the doxygen tool&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; If no ’header comment’ is defined in the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; diagram the minimally required header files and instance/msg variable definitions are automatically generated (for C/C++ only). This makes the start for beginners easier.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 1.8.1:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved parsing of transitions defined in Cadifra&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Zoom function added in the simulator&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Updated C++ section&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.0:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A tree based state diagram editor is available now. This editor follows a different approach compared to the most available &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tools. Instead of drawing diagrams a tree based approach is used. This makes the creation of state machines very efficient (see section 3.17).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for choice states in the Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; editor (see appendix B).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Changes in the C++ backend. Some internal vars are now marked as protected to make them accessible in derived classes. The new key ’CreateOneCppStateHeaderFileOnly’ allows to put all state class code into one cpp/h file. And other improvements …&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Several improvements in different parts of the code&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.0.2:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improvements in the visualization of the editor. E.g. use of choice symbol …&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;HsmFunctionWithEventParameter=yes&lt;/code&gt; and&lt;br/&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;code&gt;HsmFunctionWithInstanceParameters=yes&lt;/code&gt; is now possible at the same time (see section 3.3)
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Wrong missing license message in editor mode fixed.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Wrong handling of flag &lt;code&gt;PrefixMsgWithMachineName&lt;/code&gt; if set to &lt;code&gt;YES&lt;/code&gt; in combination with &lt;code&gt;HsmFunctionWithEventParameter&lt;/code&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New keyword to define the type of the generated destructor of the C++ state machine class. Useful for more dynamic systems.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Events leaving a state are now generated in alphabetical order. See section  “Defining the state processing order”.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.1.4
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Stabilization of the integrated state-chart editor&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Display of entry/do/exit code in the states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New configuration keywords added (DisplayEntryExitDoCode, NumberOf EntryExitDoCodeChars)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Introduction of a new C-backend (-l cx) which supports up to four levels of state nesting without any restrictions. This backend is now the default one.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.21
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Stabilization of the integrated state-chart editor&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New Java backend (see section 3.7)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New C++ backend (see section 3.4)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New configuration key to allow to save the model also if the check was not successful&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New command line switch &lt;code&gt;’-gencfg’&lt;/code&gt; to output the supported configuration keys for the selected language. This allows to quickly generate a config file with all the supported keys and their default values. Example usage:&lt;br/&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;code&gt;java -jar codegen.jar -gencfg -l cx &amp;gt; codegen.cfg&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
Version 2.24
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fixing a problem with drag and drop introduced in the last version&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transitions leaving a choice are now sorted based on their guard definition&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fixing minor issues in the cppx backend&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Update of the ’installation’ and ’getting started sections’&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.25
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Further improvements in the integrated state chart editor. E.g. visualization of modified model properties, changes in properties are not silently discarded anymore if the &lt;code&gt;Apply&lt;/code&gt; button is not pressed …&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; By default -lcx is selected as language backend if nothing else is selected on the command line.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.26
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; modeling tool astah* from ChangeVision added. See section E for details.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fix a problem with the -doxygen option (only occurred in hierarchical diagrams).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fix inconsistencies in the manual around the Java VM option -Djava.ext.dirs&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.37 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Also for flat state machines the handler function can now return if an &lt;em&gt;event/conditional trigger&lt;/em&gt; was processed or not (see ReturnEventProcessed). If no return value is required also the internally used flag is not generated anymore. This is useful for processers with very little RAM.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; It is now possible to add post action code which is executed after the state machine code (in opposite to the action code which is executed before the machine). See section 3.1.6 for details.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A problem with the latest release of ArgoUML was fixed ($\geq$ 0.32) which has changed the XMI export format slightly.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Conditional triggers do now work for astah* input files.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; In case the &lt;code&gt;-Djava.ext.dirs=…&lt;/code&gt; java option was used sometimes the license file location could not be determined.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.38 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Zooming in the built-in editor uses the dot scale feature which results in sharper images.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A validation function is now supported for the C-backend. This helps to detect serious errors happening outside the state machine code but effecting the correct execution of the the state machine. See section  for more details.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fix a problem with empty entry/exit/do actions in Enterprise Architect&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Print report if two final states have the same name&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fix problem with tab handling&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fix problem with prefix of main ChangeToState declaration&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; ResetHistory and Change to state function declaration are from now on only included in the header if needed.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.40 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; By default the C-backend now uses the types from stdint.h for simple data types. In the case other types must be used they can be changed in the configuration file.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The *isIn* and *resetHistory* code are now provided as functions (not only macros). You can decide now if the instanceVar in these functions is accessed via pointer or variable. Use the UseInstancePointer parameter for configuration. This option addresses very memory constraint systems where pointer accesses shall be avoided where possible.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The state machine image in the built in editor can now be copied to the clipboard (right click)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The rank of the state machine layout in the built-in editor can be changed (right click). Depending on the state machine the top-down or left-right layout direction is better.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.41 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for Visual Paradigm added&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New feature to define events or states with a given hamming distance. This feature is only available for the CX backend.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; UModel: Fix a line-end problem with multiline actions&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.5 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; In the simulation and trace mode the achieved transition coverage is displayed as progressbar (0% …100%). The tooltip shows the open transtions left to be taken to achieve 100% transition coverage.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; It is now possible to generate an Excel file with testcases to reach 100% transition coverage. The Excel file contains a sheet per route. Each line in a route represents a test step.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The new keyword ’Constraints’ allows to specify the expected output of a state. These constraints are listed in the Excel workbook as well and help testers to check if the test was sucessful. See section 3.19.4 for more info.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; C++ backend now generates const methods where possible (e.g. isIn()).&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Astah* backend has ignored inner events in previous versions.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.6 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A second test path generation algorithm added (-c1). This breadth-first tree search algorithm returns more but shorter tests routes.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A reset command can be sent to the online visualization to indicate a restarted target.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Entry/Exit/Do code can now be defined in a better way using Enterprise Architect. Multiline code pieces are supported now. The old way does still work.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Problem when moving states in the built-in editor fixed.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Robustness of the online visualization improved when receiving unknown events.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; XMI export of EA 9.2 has changed slightly but enough to stop the codegen from working. This is fixed again.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.7 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support of a new key-word to make the generated Java code &lt;em&gt;Java 1.4 compatible&lt;/em&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for sub-machine states in Enterprise architect. See section G.11 for more details.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt; -
&lt;/p&gt;

&lt;p&gt;
Version 2.8 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Junctions are available now (details see )&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for nested namespaces added for the cppx backend&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; In some cases empty ’if/else if’ blocks were generated which can be problematic in some very resource constraint systems. Empty blocks are now avoided where possible.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; When using the cppx backend the factory and state class were generated in the wrong folder if the parameter of -o contained a path and filename.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improving code block indentation&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A missing empty ’else/* left empty */’ was added in a specific case to satisfy static code checkers.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.8.1 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for multiple incoming transitions into a choice. See section  for more details.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; In previous versions the code for transitions leaving a state with flat history was not correctly generated under some circumstances.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.8.2 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for entry and exit points in diagrams modeled with EA. This allows to make better use of sub-machines. See section G.12&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New helper function available to return the innermost active state. This function is useful for debugging or tracing tasks and available for CX, CPPX and Java backends.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Switching over to the new jdom2.jar version. Replace the existing jdom.jar file with the latest version coming with the codegen.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.8.3 &lt;em&gt;Bug fixes:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fixing a problem when using the internal editor/simulator with a model containing a junction.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 2.9 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for entry and exit points and sub-machines in diagrams modeled with MD. See section C.9 and section C.9.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A new editor component is used in the built–in state machine editor / simulator. The new editor supports folding, line numbers and other nice features. Thanks to Robert Futrell for his very nice component (see section copyright for more information).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The $isIn()$ methods returns a $bool$ now instead an $int$ in C++.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; $getInnermostActiveState()$ is now a public method in Java&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Visual representation of $innerEvents$ in the built–in editor improved. They are now clearly represented in the graphics as well as in the tree view.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Visualization of states in the built–in editor improved.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Issue when simulating state machines with a history state fixed.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.0 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The Modelio &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; modeling tool is supported now. Modelio is an open source modeling environment based on Eclipse. See &lt;a href=&quot;http://www.modelio.org&quot; class=&quot;urlextern&quot; title=&quot;http://www.modelio.org&quot; rel=&quot;ugc nofollow&quot;&gt;www.modelio.org&lt;/a&gt; for more information about the tool.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; In this version only the following language back-ends are available anymore: CX, CPPX, Java. If you use one of the other language back-ends you have to stick with the previous codegen version.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for regions in the CX language back-end&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt; —
&lt;/p&gt;

&lt;p&gt;
Version 3.1
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The C++ language back-end now fully support the code generation from state machines with regions.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Two new parameters for the C back-end were added. They help to avoid naming conflicts when calling multiple state machines from within one file or when using the same state names within different parent states. See section 2.2 parameters &lt;em&gt;PrefixStateNamesWithMachineName&lt;/em&gt; and &lt;em&gt;PrefixStateNamesWithParentName&lt;/em&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.11 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The simulator can now be used to simulate also state machines with regions.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved visualization of state machines using Graphviz in the simulator&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fix of some problems in the simulator&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Bug fixes:&lt;/em&gt; —
&lt;/p&gt;

&lt;p&gt;
Version 3.2 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial support for Metamill added&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.3 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for C# added again&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Documenting &lt;code&gt;-L&lt;/code&gt;&lt;em&gt;events&lt;/em&gt; an &lt;code&gt;-L&lt;/code&gt;&lt;em&gt;states&lt;/em&gt; command line options&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.31 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for “regions in regions” supported by the code generator in the C/C++ backend&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.5
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fixes a problem with transitions leaving a state which contains regions in regions.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Handbook improvements especially in the Enterprise Architecture section.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.51 &lt;em&gt;New features and improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fully support of test case generation for state machines with regions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved visual simulation and other smaller fixes related to regions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fully support of transitions from an initial pseudo-state to a choice state.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6, 3.6.1 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Model checker improved to detect further problems on model level which led to null pointer exceptions before.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial support for activity diagrams added. Only EA and C so far.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improvements in the Java backend (initial state to choice state added)&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.2 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; In the case the initial transition ended in a choice the generated initialization code was not always correct.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; UModel activity diagram support added. See section 4.5 for details.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.3 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Model checker of activity diagrams improved&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fix a problem that leads to a crash of the integrated state-chart editor&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Astah activity diagram support added. See section 4.6 for details.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.4 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial code was eventually wrong in the c++ backend in the case the initial transition ended in a choice pseudostate.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Visual editor and simulator did not start on some systems because of missing icons.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; -&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.5 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The code generator performs some optimizations before generating code from an activity diagram (see section 4.3.2).&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; -&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.6 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; In some cases the entry code was not executed. This problem was fixed.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Region Support for Astah*&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Possibility to define events in comments attached to transitions (only Astah*)&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.7 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fixing a problem in the drag &amp;amp; drop function of the built-in editor.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fixing a problem that two or more exactly same triggers that have triggered a transition on different hierarchy levels of a state diagram could have lead to endless loops in the simulator engine (codegen threw an out of memory exception).&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial support for the new language Swift (see section 3.8).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Undo/Redo feature added into the built-in editor. This is a great usability improvement!&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New parameter for the C++ backend &lt;code&gt;BackrefToMachineInStateClasses&lt;/code&gt;. Now it is possible to automatically generate and set a reference to the state machine in the state classes during initialization of the machine. This makes it possible to easily access code of the state machine class (or its base class) from within state classes.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.8 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Compatibility problem with export format of Visual Paradigm fixed.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New configuration file parameter to suppress the generation date in generated files. See section 2 parameter &lt;code&gt;IncludeDateFileHeaders&lt;/code&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.9 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Fix a problem with XMI files exported from EA12 using sub-machines.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; –&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.10 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; –&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Added the new &lt;code&gt;OptimizeExitCode&lt;/code&gt; parameter which if set to yes generates exit code only once even if there are multiple transitions leaving a state.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.11 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Problem with Modelio 3.3 fixed.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Activity diagrams can now be generated using Modelio.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.12 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Update to latest version of &lt;code&gt;rsyntaxtextarea.jar&lt;/code&gt; which is the text filed library used for the built-in editor. It now supports folding and contains several bug-fixes. Replace the old jar with the new one installed on your computer.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Increased number of transitions / states in the demo mode to allow for better testing before taking a decisions.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.13 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; -&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New command line parameter &lt;code&gt;-L&lt;/code&gt; to define the path to the license file.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.6.14 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for astah SysML added&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; – file.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.7 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; -&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Python code generation added&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.7.1 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; C# now supports init to choice transitions. A transition from an initial pseudostate can now end in a choice pseudostate. The real init state is then evaluated at runtime depending on the guard conditions. See section 3.11 for more information.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New &lt;em&gt;Fontname&lt;/em&gt; keyword to define font in the built in editor and simulator.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; -&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.7.2 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; C++ backend bugfix (initialize code)&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; -&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.7.2.2 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Maintenance release&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; -&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.7.3 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Changed layout of integrated editor to better use space on wide screen displays&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Bug fix related to redo/undo of integrated editor&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; -&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 3.7.4 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved Python backend&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved visual diagram representation in the built-in editor&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved C++ backend&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; For the Cadifra tool connectors can now be used to make complex state diagrams more readable.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 4.0 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Several new configuration parameters for the CPPX backend added. With the new parameters there is much more flexibility to adjust the generated code towards own needs. See table 2.2 for details.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 4.1 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Lua added as new back-end 3.10&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 4.2 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Trace and validate code was reworked to improve type safety in C/C++&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Usage of const where possible in the C-backend&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Region handlers defined static. Not included in state machine header anymore.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New config file parameter &lt;em&gt;IncludeTransitionsIntoStatesTheyStartFrom&lt;/em&gt; to export the state machine in a hierarchical manner from the internal state machine editor.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Introduction of &lt;em&gt;partial&lt;/em&gt; keyword for the C# backend&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 4.3 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Update of the c-section in the manual to better explain the various parameters relevant for C-code generation.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New config file parameter &lt;em&gt;HsmFunctionUserDefinedEventParameter&lt;/em&gt;. This parameter allows to define a user defined type as parameter for the state machine handler. This is useful if you want to hand over data in addition to the event. E.g. data received from a communication interface or the like. See section 3.3 for details and examples.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 4.3.1 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Bug fix in the activity generator backend for C. A problem occurred if the output contained a path and not just the output file name.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; -&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 5.0.2 &lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Bug fix in the Lua backend&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Completely rewritten built in state diagram editor. The new version is much more user friendly and allows to create state machines and generate code from them within minutes.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; UnknownEventHandler: Allows to define code that is executed if an event could not processed in a state. Can be used for debug purposes for example&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 5.1
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Initial support for regions in the built-in editor&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Several improvements and bug fixes of the built-in editor&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 5.2 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Region support in the built in visual editor&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for displaying regions in separate graph windows. This provides a better overview in bigger state machines&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Tree / graphics relation. Clicking on a state in the state tree shows the related diagram. Clicing on a state in a diagram shows the state in the state tree.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Several bug fixes and improvements in the built-in editor&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Bug fix in the validate code of the C-backend&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Bug fix in the activity generator&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 5.3 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; State/region notes can be displayed in graphical editor. A configuration parameter can be used to enable / disable the visualization of state/region notes&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Export / import of parts of the state diagram into another instance of the graphical editor or the clipboard. This allows to save parts of the state machine model into a text file and to create a library of pre-defined state diagram solutions (library of solutions)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Create *.bak file each time the model is saved&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Code generation to ssc xml in obfuscated format. I.e. removing real state name, event names, … This allows to share models for bug tracking or other purposes without giving away confidential information. A configuration parameter is available for that purpose.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improvement of the simulation engine to avoid deadlocks in special situations&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Prevent usage of already used state names without loosing the changed state details&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improvements when working with separate tabs per region in the built-in graphical editor&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Bugfix in the C-backend related to validation code (wrong order of state names)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improvement in the code generation backend related to new Java features&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Changes in the scc xml parser related to Final States and Choice States. This may create inconsitencies with existing ssc xml files. Request details on how to fix your xml model file in case you run into this issue.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; General bugfixes and improvements&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 5.4.1 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Windows and Mac installer that allows to open a state diagram file created with the built-in editor with a double-click or a right-click (open with). This makes life easier for users who are not at ease with the command line - esp. when using the built-in state machine editor.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; ValidationCall parameter now also supported by the C++ backend. The validation code itself has to be provided by the user.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; codegen.cfg file can be stored in the users home folder to make general settings valid for all project (e.g. dot path)&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;Improvements:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; General bugfixes and improvements&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 5.4.2 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Attributes added to the class will be considered in the code generation and added to the instance data (only for Enterprise Architect/UModel and C backend). Details see section G.10 and D.8&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; For all other tools the possibility exists to add attributes in the configuration file. They are added to the instance data (only C backend). See table 2.2 row INSTANCE_ATTRIBUTE_x etc.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Operations added to the class will be considered in the code generation and mapped to functions in the generated state machine C - and header file. It is also possible to enter the function body code (only for Enterprise Architect and C backend). Details see section G.10. If no body is given the function is only generated in the state machine header file and can be implemented separately.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 5.5.4 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Added a template parameter option for the state handler method in C++. Various possiblities exist now for the state handler signature. See section 3.4.4.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Added the option to pass an object to the state handler method in C# that can contain any data but also the event to be handled.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Added validation code to C# if enabled&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved MagicDraw XMI parser.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 5.5.5.2 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved region handling for own instance data types. Recommended update for all C backend users.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved XMI parser for the various supported &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tools&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 5.5.5.3 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Simulation of timers was added to the integrated state machine editor. See online manual for more information.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 5.5.6.3515 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Rust code can now be generated from &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state machines. See chapter 3.11.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improved code window in the built-in state diagram editor&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Many detail improvements of the integrated state diagram editor&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 6.0.2
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Additional parameters &lt;code&gt;NotUseRedundantVoidArgument&lt;/code&gt; and &lt;code&gt;EnableTrailingReturnType&lt;/code&gt; to modernize the generated c++ code and pass clang-tidy with &lt;code&gt;modernize-*&lt;/code&gt; test enabled.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Python generator calls init of a specified base class.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Many detail improvements in the integrated state diagram editor&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for Eclipse Papyrus&lt;sup&gt;a&lt;/sup&gt;dded. See details in section I.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Verison 6.1
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Bugfixes and improvements in the built in state-diagram editor&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Use of a project specific configuration file in the graphical editor&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; New C-backend related parameters to generate code following the opaque object pattern to hide the state machine implementation from other user code and thereof reduce dependencies.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improvements in the section about the c-backend and reorganisation of the examples folder in the download.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Experimental parsing for the DrawIO Editor added&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Events marked &lt;em&gt;external&lt;/em&gt; are now exported in a separate file to allow further external processing. This allows to generate one file containing all state machine events (only with events as defines possible).&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 6.2 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support of the GO language as new code generator backend&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for the GO language in the integrated state diagram editor&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 6.2.1 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support of the JavaScript language as new code generator backend&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for the JavaScript language in the integrated state diagram editor&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 6.2.2 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improvements in the JS backend. &lt;code&gt;IsIn()&lt;/code&gt; and &lt;code&gt;getInnermostActiveStates()&lt;/code&gt; works now with regions.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Improvements in the &lt;code&gt;C++&lt;/code&gt; backend. &lt;code&gt;IsIn()&lt;/code&gt; and &lt;code&gt;getInnermostActiveStates()&lt;/code&gt; works now with regions.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 6.2.3 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Python backend now uses enums for states / events and function annotations.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Bugfix in the C Sharp backend.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 6.3.4 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Added option to return a bool value from the &lt;code&gt;processEvent()&lt;/code&gt; method in C++&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Other minor changes to improve the robustness and clarity of the console messages&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 6.4 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Extended history state handling added. It is now possible to end a transition at a history state. Only if a transition ends in a history state will the previous history be considered when entering the state set. Otherwise the default entry chain is used. The new &lt;code&gt;TransitionsCanEndInHistoryStates&lt;/code&gt; parameter has been added to enable this feature. Section  describes the new history state handling in more detail.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 6.5 &lt;em&gt;New features:&lt;/em&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Bugfixes and improvements in the built in state-diagram editor&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; General improvements&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Version 6.5.1
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Added support for additional command-line parameters when using &lt;code&gt;&amp;#039;-l cppx&amp;#039;&lt;/code&gt;. You can now optionally specify &lt;code&gt;&amp;#039;-std c++11&amp;#039;&lt;/code&gt; or &lt;code&gt;&amp;#039;-std c++14&amp;#039;&lt;/code&gt; to enable all necessary parameters for the corresponding C++ language features. This simplifies configuration for new users. For more details, see section “Generating C++ Code” 3.4.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
99 Martin Gomez, &lt;em&gt;&lt;a href=&quot;http://www.embedded.com//&quot; class=&quot;urlextern&quot; title=&quot;http://www.embedded.com//&quot; rel=&quot;ugc nofollow&quot;&gt;www.embedded.com//&lt;/a&gt;, 12/2008 Object Management Group, &lt;/em&gt;Unified Modelling Language (&lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt;) 1.3 specification&lt;em&gt;, 2000 Object Management Group, &lt;/em&gt;&lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; Superstructure Specification, v2.4.1&lt;em&gt;, 2014 Graphviz is open source graph visualization software, http://&lt;a href=&quot;http://www.graphviz.org/&quot; class=&quot;urlextern&quot; title=&quot;http://www.graphviz.org/&quot; rel=&quot;ugc nofollow&quot;&gt;www.graphviz.org/&lt;/a&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Appendix K Version History&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;appendix_k_version_history&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:82,&amp;quot;secid&amp;quot;:271,&amp;quot;range&amp;quot;:&amp;quot;322079-&amp;quot;} --&gt;&lt;div class=&quot;footnotes&quot;&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__1&quot; id=&quot;fn__1&quot; class=&quot;fn_bot&quot;&gt;1)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;only for state machines
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__2&quot; id=&quot;fn__2&quot; class=&quot;fn_bot&quot;&gt;2)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;Use &lt;code&gt;sim.bat&lt;/code&gt; or &lt;code&gt;sim.sh&lt;/code&gt; depending of your system and set the &lt;em&gt;CLASSPATH&lt;/em&gt; before. It must include to the parent folder of the codegen.jar. An example how to do this is shown in the &lt;em&gt;bat/sh&lt;/em&gt; files.
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__3&quot; id=&quot;fn__3&quot; class=&quot;fn_bot&quot;&gt;3)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;Inner events are presently only supported on the innermost states of hierarchical states and on top level states if they have no children.
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__4&quot; id=&quot;fn__4&quot; class=&quot;fn_bot&quot;&gt;4)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;see http://en.wikipedia.org/wiki/Stdint.h
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__5&quot; id=&quot;fn__5&quot; class=&quot;fn_bot&quot;&gt;5)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;See http://mspgcc.sourceforge.net/manual/x918.html&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__6&quot; id=&quot;fn__6&quot; class=&quot;fn_bot&quot;&gt;6)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;Please consider the limitations if the model contains regions as described in section 1.3
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__7&quot; id=&quot;fn__7&quot; class=&quot;fn_bot&quot;&gt;7)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;Under some circumstances the generator will not be able to generate routes for a 100% coverage
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__8&quot; id=&quot;fn__8&quot; class=&quot;fn_bot&quot;&gt;8)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;Please note that also a Java class is generated. This class provides the same definitions than the header file but allows you to write a Java application to evaluate the trace data.
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__9&quot; id=&quot;fn__9&quot; class=&quot;fn_bot&quot;&gt;9)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;You can change to UDP port in the codegen config file.
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__10&quot; id=&quot;fn__10&quot; class=&quot;fn_bot&quot;&gt;10)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;For more info goto http://&lt;a href=&quot;http://www.rtems.org&quot; class=&quot;urlextern&quot; title=&quot;http://www.rtems.org&quot; rel=&quot;ugc nofollow&quot;&gt;www.rtems.org&lt;/a&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Sat, 03 May 2025 13:36:41 +0000</pubDate>
        </item>
        <item>
            <title>State Diagram Editor Introduction Part I</title>
            <link>https://sinelabore.com/doku.php/wiki/manual/editor</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;state_diagram_editor_introduction_part_i&quot;&gt;State Diagram Editor Introduction Part I&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;State Diagram Editor Introduction Part I&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;state_diagram_editor_introduction_part_i&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;221-275&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit2&quot; id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
In this guideline you learn how use the Sinelabore&lt;em&gt;RT&lt;/em&gt; graphical editor based on the following state diagram and generate code from it.
&lt;/p&gt;

&lt;p&gt;
&lt;em&gt;State machines&lt;/em&gt; show the dynamic behaviour of an application.
It is a graph of states and transitions describing the response to events
depending on the current state. State machines are used for decades in hardware
design. And during the last years also more and more in the area of software development. 
Especially in the embedded real-time domain the use of state machines is popular 
because the behaviour of devices in this domain can be often very well described with state machines.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/manual-parti.gif&quot; class=&quot;media&quot; title=&quot;wiki:manual:manual-parti.gif&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/manual-parti.gif&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot; The first diagram with an init state, a normal state, a final state and a choice. The tutorial below shows step by step how to create this diagram.&quot; alt=&quot; The first diagram with an init state, a normal state, a final state and a choice. The tutorial below shows step by step how to create this diagram.&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
An important aspect of state machines is that the design can be directly
transformed into executable code. This means that there is no break between the
design and the implementation.
&lt;/p&gt;

&lt;p&gt;
The Sinelabore&lt;em&gt;RT&lt;/em&gt; state machine editor is part of the code generator and not an extra package. Depending on the command line options either the editor, the simulator or the code generator is started.
&lt;/p&gt;

&lt;p&gt;
Like the code generator the visual editor can be used across most platforms like Windows, Linux and Mac.
&lt;/p&gt;

&lt;p&gt;
&lt;strong&gt;The state machine editor was designed to allow to create state machine designs within minutes. Compared to other general purpose &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tools the number of required clicks and time is significant lower.&lt;/strong&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Overview&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;overview&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;276-1825&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit3&quot; id=&quot;installation&quot;&gt;Installation&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
To use the visual editor the following software is required:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Sinelabore&lt;em&gt;RT&lt;/em&gt; software itself: For Sinelabore&lt;em&gt;RT&lt;/em&gt;  no installation is needed. The ZIP-file contains a &lt;em&gt;&amp;#039;bin&amp;#039;&lt;/em&gt; folder with the packed Java program (jar file).&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Java runtime environment: The editor is entirely written in Java. It can run on different operating systems such as Windows, Linux or MacOS therefore. The required Java runtime environment is available for download here: &lt;a href=&quot;http://jdk.java.net&quot; class=&quot;urlextern&quot; title=&quot;http://jdk.java.net&quot; rel=&quot;ugc nofollow&quot;&gt;http://jdk.java.net&lt;/a&gt;. LTS version 11 is recommended.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Graphviz layout engine: The Graphviz layout engine is used internally. Install the version for your operating system from here: &lt;a href=&quot;http://www.graphviz.org/&quot; class=&quot;urlextern&quot; title=&quot;http://www.graphviz.org/&quot; rel=&quot;ugc nofollow&quot;&gt;http://www.graphviz.org/&lt;/a&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
We assume in this manual that you installed all tools directly under &lt;em&gt;C:&lt;/em&gt; (for Windows). 
Your output should be similar to the one below (version numbers might differ). If you selected different installation paths adjust the examples in the coming sections accordingly.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;C:\&amp;gt;dir
...
16.01.2021  16:39    &amp;lt;DIR&amp;gt;          Graphviz-2.44.1
16.01.2021  20:46    &amp;lt;DIR&amp;gt;          jdk-11
24.01.2021  17:35    &amp;lt;DIR&amp;gt;          sinelaboreRT5.2
...&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Installation&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;installation&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;1826-2969&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit4&quot; id=&quot;state_machine_editor&quot;&gt;State Machine Editor&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;State Machine Editor&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;state_machine_editor&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:1,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;2970-3004&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit5&quot; id=&quot;overview1&quot;&gt;Overview&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The state machine editor was developed to efficiently create state charts. Therefore it uses a tree based creation approach and not a graphical based approach that is normally used by &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tools. The graphical representation of the model is generated automatically. No time needs to be wasted to move graphical elements around to create a nice looking drawings. State and transition details can be provided with view clicks. Dedicated code entry fields provide syntax highlighting and allow definition of guards, actions and entry/do/exit code.
&lt;/p&gt;

&lt;p&gt;
Once the diagram is ready it is possible to directly generate code form it. Or alternatively save the model file and call the code generator on the command line to generate code separately (e.g. in your make file).
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Overview&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;overview1&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:1,&amp;quot;secid&amp;quot;:5,&amp;quot;range&amp;quot;:&amp;quot;3005-3786&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit6&quot; id=&quot;starting_the_editor_the_very_first_time&quot;&gt;Starting the editor the very first time&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Open a Command window on Windows (or a terminal on MacOS/Linux) and start the editor as follows.
&lt;/p&gt;

&lt;p&gt;
&lt;code&gt;c:\jdk-11\bin\javaw.exe -cp “c:/sinelaboreRT5.2/bin/*” codegen.Main -p ssc -E&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
Using the command line flag &lt;code&gt;-E&lt;/code&gt; starts the state chart editor. &lt;code&gt;-p ssc&lt;/code&gt; defines the model file format (the native editor format which is XML based and human readable). The path to Java executable must match your installation. 
&lt;/p&gt;

&lt;p&gt;
Most probably you have not yet created a configuration file so far. Within the configuration file you can influence the code generation and adjust other parameters. Therefore the editor asks you to point to the &lt;code&gt;dot.exe&lt;/code&gt; file. To avoid this step next time create a file called &lt;code&gt;codegen.cfg&lt;/code&gt; with the following content. The concrete file path to the dot.exe depends on your system. Adjust the path accordingly.
&lt;/p&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:7,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;wrap_center wrap_round wrap_tip plugin_wrap&quot; style=&quot;width: 60%;&quot;&gt;
&lt;p&gt;
Store the &lt;code&gt;codegen.cfg&lt;/code&gt; file with just the dot path in it at the users home directory. Then the codegen automatically finds the dot program for all further projects.
If you bought a license add the path to the license file too. 
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:8,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;pre class=&quot;code&quot;&gt;DotPathWin=&amp;quot;c:\\Graphviz-2.44.1\\bin\\dot.exe&amp;quot;
#Use this on Linux/MacOS
#DotPath=&amp;quot;/usr/local/bin/dot&amp;quot;
LicensePath=...&lt;/pre&gt;

&lt;p&gt;
After the dot.exe was found the editor window will appear and everything is ready for creating your first state diagram. So far there is only an empty workspace as shown in the next figure 
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/empty_diagram.png?id=wiki%3Amanual%3Aeditor&quot; class=&quot;media&quot; title=&quot;wiki:manual:empty_diagram.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/empty_diagram.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Visual editor after startup&quot; alt=&quot; Visual editor after startup&quot; /&gt;&lt;/a&gt;
Figure 1: Visual editor after startup. 
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Starting the editor the very first time&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;starting_the_editor_the_very_first_time&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:1,&amp;quot;secid&amp;quot;:6,&amp;quot;range&amp;quot;:&amp;quot;3787-5368&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit9&quot; id=&quot;creating_a_state_diagram&quot;&gt;Creating a state diagram&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
In this section we create a diagram as shown in figure 4. 
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Creating a state diagram&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;creating_a_state_diagram&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:2,&amp;quot;secid&amp;quot;:9,&amp;quot;range&amp;quot;:&amp;quot;5369-5465&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit10&quot; id=&quot;adding_states&quot;&gt;Adding states&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To add a new state select the root node and right click to bring up the context menu. Then select &lt;code&gt;Insert state&lt;/code&gt;. At minimum a unique state name must be specified. Also add some entry and exit code as shown in final diagram (see figure 4). This will help you to follow the state flow in our demo application later on. Once done click &lt;code&gt;OK&lt;/code&gt; to close the dialog.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/create_edit_state.png?id=wiki%3Amanual%3Aeditor&quot; class=&quot;media&quot; title=&quot;wiki:manual:create_edit_state.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/create_edit_state.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure 2: Create/Edit a state. All relevant properties can be directly provided.
&lt;/p&gt;

&lt;p&gt;
The new state was created and shown as graphical diagram. There was no init state yet so it was created automatically for you too.
&lt;/p&gt;

&lt;p&gt;
Add state S2 as shown in figure 4.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Adding states&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;adding_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:2,&amp;quot;secid&amp;quot;:10,&amp;quot;range&amp;quot;:&amp;quot;5466-6147&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit11&quot; id=&quot;adding_transitions&quot;&gt;Adding transitions&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
To add transitions right click on the state &lt;em class=&quot;u&quot;&gt;in the state tree&lt;/em&gt; where a transition should start from (here the initial state). Select &lt;code&gt;Insert transition&lt;/code&gt; in the context menu. A window is shown where all transition related properties can be set. Select the transition&amp;#039;s target state. Here please select S1. Also add a triggering event, guard and action code as needed. Then click &lt;code&gt;OK&lt;/code&gt;. Transitions are represented with an arrow in the state tree. Note: For the transition from an init state to the default state no triggering event is needed.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/create_transition.png?id=wiki%3Amanual%3Aeditor&quot; class=&quot;media&quot; title=&quot;wiki:manual:create_transition.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/create_transition.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure 3: Creating a transition with triggering event, guard, action and other properties.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Adding transitions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;adding_transitions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:2,&amp;quot;secid&amp;quot;:11,&amp;quot;range&amp;quot;:&amp;quot;6148-6859&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit12&quot; id=&quot;adding_a_final_state&quot;&gt;Adding a final state&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
As a next step add a final state. This works like adding a normal state but no properties can be entered. State names for final states are automatically assigned. Right click on the topmost root state and add a final state.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Adding a final state&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;adding_a_final_state&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:2,&amp;quot;secid&amp;quot;:12,&amp;quot;range&amp;quot;:&amp;quot;6860-7115&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit13&quot; id=&quot;adding_a_choice&quot;&gt;Adding a choice&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Choices realise a dynamic conditional branch. They enable splitting of transitions into multiple outgoing paths such that the decision on which path to take is defined by the provided guards. A choice must have one incoming transition, and two or more outgoing transitions. Each outgoing transition must have a guard. One of the guards must be defined as &amp;#039;else&amp;#039; (default path). This ensures that always on of the outgoing transitions can be taken. For more details see the code generator manual.
&lt;/p&gt;

&lt;p&gt;
Adding a choice works like adding a normal state but no properties can be entered. State names for choices are automatically assigned. Right click on the topmost root state and add a choice.
&lt;/p&gt;

&lt;p&gt;
Then add  tree transitions. One entering the choice. Define the triggering event here. Next two transitions leaving the choice. Specify a guard for each transition that leaves the choice. One guard must be &amp;#039;else&amp;#039;. Add the action code as shown in figure 4.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Adding a choice&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;adding_a_choice&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:2,&amp;quot;secid&amp;quot;:13,&amp;quot;range&amp;quot;:&amp;quot;7116-8088&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit14&quot; id=&quot;first_diagram_done&quot;&gt;First diagram done&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Congratulations! You finished your first state machine diagram now. It  should now look like figure 4.
&lt;/p&gt;

&lt;p&gt;
The status output window shows that there are no errors in the model. Therefore it is possible to save it now. To save the diagram use the &amp;#039;Save As&amp;#039; button. Once saved, you can find the project name in the info bar at the bottom of the editor window. Use &lt;code&gt;manual.xml&lt;/code&gt; as file name.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/initial_diagram_with_choice.png?id=wiki%3Amanual%3Aeditor&quot; class=&quot;media&quot; title=&quot;wiki:manual:initial_diagram_with_choice.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/initial_diagram_with_choice.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; The first diagram with an init state, a normal state, a final state and a choice.&quot; alt=&quot; The first diagram with an init state, a normal state, a final state and a choice.&quot; /&gt;&lt;/a&gt;
Figure 4: The first diagram with an init state, a normal state, a final state and a choice.
&lt;/p&gt;

&lt;p&gt;
Exit the editor now. 
&lt;/p&gt;

&lt;p&gt;
To start the editor again and directly load your project, provide the project file name as last parameter on the command line. Example:
&lt;/p&gt;

&lt;p&gt;
&lt;code&gt;c:\jdk-11\bin\javaw.exe -cp “c:/sinelaboreRT5.0/bin/*” codegen.Main -p ssc -E manual.xml&lt;/code&gt;
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;First diagram done&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;first_diagram_done&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:2,&amp;quot;secid&amp;quot;:14,&amp;quot;range&amp;quot;:&amp;quot;8089-8988&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit15&quot; id=&quot;generating_code_from_your_first_state_diagram&quot;&gt;Generating code from your first state diagram&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
In opposite to typical &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; modelling tools the editor allows only to draw valid diagrams. E.g. it insists that a transition has always a trigger. Or a state name is always present and unique. In case you deleted a state or transitions and there are inconsistencies the built-in model checker warns you. Before not all problems are fixed it is not possible to save the diagram or generate code.
&lt;/p&gt;

&lt;p&gt;
Before you actually can generate code you need to do the following steps:
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Click the &amp;#039;Code&amp;#039; button in the menu bar. First define the target programming language and other user defined code. This brings up the following window which allows you to make all relevant adjustments. Insert the required include files and an external variable which we will define in &lt;code&gt;main.c&lt;/code&gt; later on.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Define the signature of the event handler function. We want to have a parameter for the instance data and another one for the event. Click on the “Handler Signature” button to open a dialog that allows you to select what you want. And as a result you get a list of configuration parameter that you can copy to your configuration file. &lt;pre class=&quot;code&quot;&gt;HsmFunctionWithInstanceParameters=yes
HsmFunctionWithEventParameter=yes&lt;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Add additional variables to the instance data if needed. To do so click on the button “Attributes” and add the required fields.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/code_window.png?id=wiki%3Amanual%3Aeditor&quot; class=&quot;media&quot; title=&quot;wiki:manual:code_window.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/code_window.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; The code window allows to select the programming language and the various code sections inserted into the generated code.&quot; alt=&quot; The code window allows to select the programming language and the various code sections inserted into the generated code.&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Figure 5: The code window allows to select the programming language and the various code sections inserted into the generated code.
g
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Header Code: For example include files or other code like function definitions and variables copied at the very beginning of the generated state machine code implementation file.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Action code: Code executed at the begin of the state machine function.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Post action code: Code executed at the very end of the state machine just before it returns.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
In case the state diagram has no errors (check performed without any faults) you can press the generate button. Otherwise look in the status output window what the problem is and fix it. The code is generated to the same folder where the project file is located.
&lt;/p&gt;

&lt;p&gt;
The following files were generated:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;D:\&amp;gt;dir
 Verzeichnis von D:\

30.01.2021  17:37               137 codegen.cfg
30.01.2021  17:51             2.209 manual.c
30.01.2021  17:51               650 manual_ext.h
30.01.2021  17:51             2.232 manual.h
30.01.2021  17:51             1.990 manual_dbg.h&lt;/pre&gt;

&lt;p&gt;
Content of the files:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;manual.c&lt;/code&gt;  file containing the state machine implementation&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;manual_ext.h&lt;/code&gt; file containing the events that can be processed from the machine&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;manual.h&lt;/code&gt;  header file of the state machine&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;code&gt;manual_dbg.h&lt;/code&gt; Support code for debugging the machine if needed&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Generating code from your first state diagram&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_code_from_your_first_state_diagram&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:2,&amp;quot;secid&amp;quot;:15,&amp;quot;range&amp;quot;:&amp;quot;8989-11918&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit16&quot; id=&quot;compiling_the_first_application&quot;&gt;Compiling the first application&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
To built the first application we need a small main program to call and stimulate the generated state code.
&lt;/p&gt;

&lt;p&gt;
Here is a simple main.c that you can use.
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;lt;stdint.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;manual_ext.h&amp;quot;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;manual.h&amp;quot;&lt;/span&gt;
&amp;nbsp;
MANUAL_INSTANCEDATA_T instData &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; MANUAL_INSTANCEDATA_INIT&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;uint8_t&lt;/span&gt; i&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw4&quot;&gt;int&lt;/span&gt; main&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
	manual&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instData&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; MANUAL_NO_MSG&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
	&lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;--&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
	manual&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instData&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; ev1&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
	&lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;--&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
	manual&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instData&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; ev2&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Now we set i&amp;gt;0&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
	i&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
	manual&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instData&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; ev2&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span class=&quot;co1&quot;&gt;// From now on no reaction is possible anymore because&lt;/span&gt;
	&lt;span class=&quot;co1&quot;&gt;// the machine is in a final state&lt;/span&gt;
	manual&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instData&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; ev2&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
	manual&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;instData&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; ev1&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
This simple code can be compiled with basically any compiler. I installed gcc for windows on my PC.
To compile the code use the following command. If you had no typos you should see no compiler errors.
&lt;/p&gt;

&lt;p&gt;
&lt;code&gt;D:\&amp;gt;g++ -Wall -pedantic main.c manual.c -o manual.exe&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
Now call the manual.exe. The output is like follows:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;D:\&amp;gt;manual.exe
Entry S1
--
Exit S1
ev1
Entry S2
--
Exit S2
ev2
Entry S2
Now we set i&amp;gt;0
Exit S2
ev2
i&amp;gt;0

D:\&amp;gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Compiling the first application&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;compiling_the_first_application&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:4,&amp;quot;secid&amp;quot;:16,&amp;quot;range&amp;quot;:&amp;quot;11919-13088&amp;quot;} --&gt;
&lt;h1 class=&quot;sectionedit17&quot; id=&quot;wrapping_up&quot;&gt;Wrapping up&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
In this manual you learned how to install the Sinelabore&lt;em&gt;RT&lt;/em&gt; tool and how to use it to model a state machine. We also generated fully automatically the state machine code from your model and executed it. Hope you are convinced how easy it is to create state diagrams and generate code from it once you set-up the required tools.
&lt;/p&gt;

&lt;p&gt;
As next step I recommend you to modify the state diagram, recreate the code and understand more and more the possibility you have. Have a look into the code generator manual about supported configuration options and further command line parameters.
&lt;/p&gt;

&lt;p&gt;
Have fun!!!
&lt;/p&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:18,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;wrap_center wrap_round wrap_box plugin_wrap&quot; style=&quot;width: 60%;&quot;&gt;
&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/doku.php/wiki/manual/editorii&quot; class=&quot;wikilink1&quot; title=&quot;wiki:manual:editorii&quot; data-wiki-id=&quot;wiki:manual:editorii&quot;&gt; Go to part II&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:19,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;hr /&gt;

&lt;p&gt;
*) All the details are described in the code generator &lt;a href=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/downloads/sinelaborert.pdf&quot; class=&quot;media mediafile mf_pdf&quot; title=&quot;wiki:downloads:sinelaborert.pdf (6.9 MB)&quot;&gt;Manual&lt;/a&gt;.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Wrapping up&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;wrapping_up&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:6,&amp;quot;secid&amp;quot;:17,&amp;quot;range&amp;quot;:&amp;quot;13089-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 03 May 2024 20:39:12 +0000</pubDate>
        </item>
        <item>
            <title>State Diagram Editor Introduction Part II</title>
            <link>https://sinelabore.com/doku.php/wiki/manual/editorii</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;state_diagram_editor_introduction_part_ii&quot;&gt;State Diagram Editor Introduction Part II&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;State Diagram Editor Introduction Part II&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;state_diagram_editor_introduction_part_ii&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;14-69&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit2&quot; id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
In the &lt;a href=&quot;https://sinelabore.com/doku.php/wiki/manual/editor&quot; class=&quot;wikilink1&quot; title=&quot;wiki:manual:editor&quot; data-wiki-id=&quot;wiki:manual:editor&quot;&gt;first part&lt;/a&gt; of the tutorial you learned to create the first state diagrams and to generate code from them. In this part you will get to know other features of the graphical editor. In particular regarding the handling of regions.
&lt;/p&gt;

&lt;p&gt;
In state diagrams usually only one state is active at a time. In &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state diagrams regions allow to model concurrency – i.e. more than one state can be active at a time (AND states).
A &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state may be divided into regions (one or more). Each region contains a state diagram again. Regions are executed in parallel. You can think of regions as independent state machines displayed in one diagram.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Overview&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;overview&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;70-753&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit3&quot; id=&quot;adding_regions&quot;&gt;Adding regions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Let&amp;#039;s add some regions to the diagram we created in part I of this tutorial. Therefore right click on state S1 and add a region. Then add another region. A default name is defined but you can change it during creation or later at any time. Then add a state to each region entering some entry and exit code. Create a transition from the init states to the just created states. Your image should look like similar to the one just below.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/manual_with_regions.png?id=wiki%3Amanual%3Aeditorii&quot; class=&quot;media&quot; title=&quot;wiki:manual:manual_with_regions.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/manual_with_regions.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Extended state diagram with two regions inside state S1.&quot; alt=&quot; Extended state diagram with two regions inside state S1.&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
You have probably noticed that it was not possible to select other states as transition target than those that are within a region. That is normal. Transitions cannot cross regional boundaries.
&lt;/p&gt;

&lt;p&gt;
If a state contains only one region it is basically equivalent to a hierarchical state. But to to be able to visualise the states in a separate diagram it might be still wanted to model just on region within a state. 
&lt;/p&gt;

&lt;p&gt;
To convert hierarchical states into a region can be done using the context menu “Convert State into new Region”. This creates a new region and moves previous children of the state into the new region.
&lt;/p&gt;

&lt;p&gt;
The opposite is also possible. Select “Convert to State with Children”.
&lt;/p&gt;

&lt;p&gt;
Regions can be displayed into a single big diagram as done here, or in separate diagrams. To display a region in a separate diagram right click on a region and select “Display Region in separate Tab”. Then a new tab with the region diagram is shown. This is useful if the state diagram becomes and more space is needed.
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/model_region_separate_window.png?id=wiki%3Amanual%3Aeditorii&quot; class=&quot;media&quot; title=&quot;wiki:manual:model_region_separate_window.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/model_region_separate_window.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Regions can be displayed in separate windows.&quot; alt=&quot; Regions can be displayed in separate windows.&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Like last time check your design, save it and generate code from it.
&lt;/p&gt;

&lt;p&gt;
Compile again and execute the code. the output looks as follows:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;D:\&amp;gt;manual
Entry S1
Entry R1S1
Entry R2S1
--
Exit R1S1
Exit R2S1
Exit S1
ev1
Entry S2
--
Exit S2
ev2
Entry S2
Now we set i&amp;gt;0
Exit S2
ev2
i&amp;gt;0

D:\&amp;gt;&lt;/pre&gt;

&lt;p&gt;
As you can see the entry and exit code of both regions inside S1 is executed when entering or leaving S1. I.e. they run “in parallel” if the machine is in state S1.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Adding regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;adding_regions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;754-2894&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit4&quot; id=&quot;exporting_parts_of_your_diagram&quot;&gt;Exporting parts of your diagram&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
If you want to export parts of your diagram to the clipboard for later use in another diagram select right click on the state that you want to export and select the export command. The exported diagram is copied in XML format to the clipboard. It can be imported right away in another diagram. Or saved in a text file for later reuse. This allows to build a library of reusable state machine diagrams.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Exporting parts of your diagram&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;exporting_parts_of_your_diagram&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:1,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;2895-3341&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit5&quot; id=&quot;wrapping_up&quot;&gt;Wrapping Up&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Regions are a powerful mechanism for modeling whether a machine is in more than one state at the same time. E.g. a microwave oven “turns the motor” AND “the light is on” AND “the door must be closed.” Such situations can be modeled well with regions.
&lt;/p&gt;

&lt;p&gt;
The example folder contains the example of a microwave oven as a hierarchical &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; model. And once modeled with the help of regions.
&lt;/p&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:6,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;wrap_center wrap_round wrap_box plugin_wrap&quot; style=&quot;width: 60%;&quot;&gt;
&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/doku.php/wiki/manual/editor&quot; class=&quot;wikilink1&quot; title=&quot;wiki:manual:editor&quot; data-wiki-id=&quot;wiki:manual:editor&quot;&gt; Go back to part I&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/doku.php/wiki/manual/editoriii&quot; class=&quot;wikilink1&quot; title=&quot;wiki:manual:editoriii&quot; data-wiki-id=&quot;wiki:manual:editoriii&quot;&gt;Got to part III&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:7,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;
&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Wrapping Up&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;wrapping_up&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:1,&amp;quot;secid&amp;quot;:5,&amp;quot;range&amp;quot;:&amp;quot;3342-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 03 May 2024 20:39:24 +0000</pubDate>
        </item>
        <item>
            <title>State Diagram Editor Introduction Part III</title>
            <link>https://sinelabore.com/doku.php/wiki/manual/editoriii</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;state_diagram_editor_introduction_part_iii&quot;&gt;State Diagram Editor Introduction Part III&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
In the &lt;a href=&quot;https://sinelabore.com/doku.php/wiki/manual/editor&quot; class=&quot;wikilink1&quot; title=&quot;wiki:manual:editor&quot; data-wiki-id=&quot;wiki:manual:editor&quot;&gt;first part&lt;/a&gt; of the tutorial you learned how to create a first state diagram and to generate code from it. Then in the &lt;a href=&quot;https://sinelabore.com/doku.php/wiki/manual/editorii&quot; class=&quot;wikilink1&quot; title=&quot;wiki:manual:editorii&quot; data-wiki-id=&quot;wiki:manual:editorii&quot;&gt;second part&lt;/a&gt; you learned the use of regions and what can be done with them.
&lt;/p&gt;

&lt;p&gt;
In this third part of the tutorial you will learn how to simulate a created model to see for yourself if the machine does what it is supposed to do. Or to run through a model with colleagues or customers and confirm that the behavior is as expected.
&lt;/p&gt;

&lt;p&gt;
A model can only be simulated if it is error free. The absence of errors can be checked with the check button in the button bar. If there are no errors, the simulation is possible in the Tree View (see Figure 1).
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/simulation_without_timers.png?id=wiki%3Amanual%3Aeditoriii&quot; class=&quot;media&quot; title=&quot;wiki:manual:simulation_without_timers.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/simulation_without_timers.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;Simulation window with manual timer simulation.&quot; alt=&quot;Simulation window with manual timer simulation.&quot; /&gt;&lt;/a&gt;
Note: press pause where needed to better follow what&amp;#039;s going on.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;State Diagram Editor Introduction Part III&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;state_diagram_editor_introduction_part_iii&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;14-947&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit2&quot; id=&quot;simulation_without_timer&quot;&gt;Simulation without timer&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The simulation can be started with the button “&lt;em&gt;Start&lt;/em&gt;”. Once the simulation has been started, the events processed by the currently active state (in red) and its parents (also in red) are displayed. A click on an event triggers the state change. Afterwards, the possible events that originate from the new state are displayed. Events of a timer have to be triggered by a click just like all other events. A click on the “&lt;em&gt;Stop&lt;/em&gt;” button ends the simulation. 
&lt;/p&gt;

&lt;p&gt;
The code “executed” in the actions is recorded in the output window. This makes it possible to track which actions are executed when the state changes. 
&lt;/p&gt;

&lt;p&gt;
Note: Actions refer to the code that you have entered as Entry/Exit/Do code or for transitions.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Simulation without timer&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;simulation_without_timer&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;948-1699&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit3&quot; id=&quot;simulation_with_timer&quot;&gt;Simulation with timer&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
In statemachines, one or more timers are very often used to trigger time-controlled actions. Timers send a user defined event to the machine at timeout. To simulate this semi-automatically, it is possible to specify timer commands in the comment of actions in a predefined notation. The timer commands are introduced by a special sequence, by default these are three “&lt;code&gt;@@@&lt;/code&gt;”. Then the timer command follows in XML syntax. This makes it possible to create, start or stop timers and thus make the simulation more realistic. 
&lt;/p&gt;

&lt;p&gt;
To activate the timer simulation, check the “&lt;em&gt;Activate Timers&lt;/em&gt;” option before starting the simulation. If timers fire faster than approx. 200ms (depending on the computer a little more or less), a reduction should be set at “&lt;em&gt;Timer Ratio&lt;/em&gt;”, otherwise the real-time image build-up is no longer possible. Or other events can no longer be clicked. By default the “Timer Ratio” is 1:1.
&lt;/p&gt;
&lt;iframe src=&quot;//www.youtube-nocookie.com/embed/wh2DgdOyfwg?normal=&quot; width=&quot;425&quot; height=&quot;239&quot; style=&quot;width:425px;height:239px;&quot; class=&quot;vshare vshare__none&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; data-domain=&quot;www.youtube-nocookie.com&quot; loading=&quot;lazy&quot;&gt;&lt;h3&gt;Link to a Youtube video showing Timer simulation in action&lt;/h3&gt;&lt;/iframe&gt;
&lt;p&gt;
The following functions are available. Times are always specified in &lt;em&gt;ms&lt;/em&gt;. A unique timer ID is required in each case. When creating a timer, the event must be specified (in the example &lt;code&gt;evTimeout&lt;/code&gt;), which is injected into the simulator when the time expires. Timers can fire cyclically or once.
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;TimerCreate timeout_ms=&amp;quot;400&amp;quot; id=&amp;quot;T1&amp;quot; event=&amp;quot;evTimeout/&amp;gt;
&amp;lt;TimerIncrement value_ms=&amp;quot;100&amp;quot; id=&amp;quot;T1&amp;quot;/&amp;gt;
&amp;lt;TimerDecrement value_ms=&amp;quot;100&amp;quot; id=&amp;quot;T1&amp;quot;/&amp;gt;
&amp;lt;TimerSetTimeout timeout_ms=&amp;quot;400&amp;quot; id=&amp;quot;T1&amp;quot; /&amp;gt;
&amp;lt;TimerStartAcyclic id=&amp;quot;T1&amp;quot; /&amp;gt;&amp;quot;
&amp;lt;TimerStartOnce id=&amp;quot;T1&amp;quot;/&amp;gt;
&amp;lt;TimerStop id=&amp;quot;T1&amp;quot; /&amp;gt;&lt;/pre&gt;

&lt;p&gt;
In the following video you can see how to work with the simulation. After switching on the microwave oven the timer T1 was created. The user can now increase or decrease the time via &lt;code&gt;evDec/evInc&lt;/code&gt;. If he closes the door, the timer T1 starts running. After the time has elapsed, the sent evTimeout event automatically switches to the Completet state. In between, the time can still be changed via &lt;code&gt;evDec/evInc&lt;/code&gt;.
&lt;/p&gt;

&lt;p&gt;
Note: It is important to pay attention to the fact that the entered program code with the timer later e.g. in C or C++ are realized, agrees with the simulation code in the comment! Since this takes place however in the same input field this is not difficult (it in the picture above at the example of a transition).
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Simulation with timer&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;simulation_with_timer&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;1700-4052&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit4&quot; id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
With the simulation of your design you can easily understand its function and check if transitions etc. have been forgotten. By using the timer simulation this is further simplified and the simulation is more realistic.
&lt;/p&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:5,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;wrap_center wrap_round wrap_box plugin_wrap&quot; style=&quot;width: 60%;&quot;&gt;
&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/doku.php/wiki/manual/editorii&quot; class=&quot;wikilink1&quot; title=&quot;wiki:manual:editorii&quot; data-wiki-id=&quot;wiki:manual:editorii&quot;&gt;Got back to part II&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/doku.php/wiki/manual/msp430_tl_tutorial&quot; class=&quot;wikilink1&quot; title=&quot;wiki:manual:msp430_tl_tutorial&quot; data-wiki-id=&quot;wiki:manual:msp430_tl_tutorial&quot;&gt;Go to next part IV&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:6,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;
&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Summary&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;summary&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:1,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;4053-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 03 May 2024 20:39:32 +0000</pubDate>
        </item>
        <item>
            <title>State Diagram Editor Part IV - Traffic Lights example on MSP430</title>
            <link>https://sinelabore.com/doku.php/wiki/manual/msp430_tl_tutorial</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;state_diagram_editor_part_iv_-_traffic_lights_example_on_msp430&quot;&gt;State Diagram Editor Part IV - Traffic Lights example on MSP430&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
In this forth part of the step by step tutorial you get a head-start on how to use state machines to solve a practical problem using a microcontroller board (here a MSP430 from Texas Instruments). All code is easy to understand and can be simply extended. We develop a basic traffic light as you for sure know from your daily experience. 
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/news/tl_board.jpeg?id=wiki%3Amanual%3Amsp430_tl_tutorial&quot; class=&quot;media&quot; title=&quot;wiki:news:tl_board.jpeg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/news/tl_board.jpeg?w=200&amp;amp;tok=543b53&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;Traffic Lights example on MSP430 evaluation board from Texas Instruments&quot; alt=&quot;Traffic Lights example on MSP430 evaluation board from Texas Instruments&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
For this tutorial we use the MSP430FR2355 developers kit which is available on the TI homepage. The software is based on a simple foreground/background architecture where the MSP430 waits in low-power mode for events to be processed by our state machine.
&lt;/p&gt;

&lt;p&gt;
Preconditions:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Code Composer Studio (&lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;) from TI installed on your PC / MSP430FR2355 kit available&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Java installation&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Installation of the Sinelabore Codegen. You can download it here. We installed it on &lt;code&gt;C:\sinelaboreRT4.0&lt;/code&gt; If you use the same path there is no need to modify the batch file further below.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; If you want to modify the state machine yourself and for step 2 you need also Graphiz (Graph visualisation tool). We installed version 2.38 at &lt;code&gt;C:\Graphviz2.28&lt;/code&gt;. &lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;State Diagram Editor Part IV - Traffic Lights example on MSP430&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;state_diagram_editor_part_iv_-_traffic_lights_example_on_msp430&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;14-1288&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit2&quot; id=&quot;step_agetting_familiar_with_the_setup&quot;&gt;Step A: Getting familiar with the setup&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Import our sample project &lt;code&gt;step1s.zip&lt;/code&gt; available &lt;a href=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/news/tl_sm/traffic_light_application_note.zip&quot; class=&quot;media mediafile mf_zip&quot; title=&quot;wiki:news:tl_sm:traffic_light_application_note.zip (807.3 KB)&quot;&gt;here&lt;/a&gt; into the &lt;abbr title=&quot;Cascading Style Sheets&quot;&gt;CSS&lt;/abbr&gt;. It is a ready made project already implementing the following boilerplate code for you:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; hardware initialisation including clock system of the MSP&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; definition/initialisation of the software timer and fifo&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; setup of a hardware timer that cyclically calls the software timer code&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; setup of an interrupt linked to the “fault button”&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; setup of a simple serial interface for debugging / tracing purposes&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Implementing a main loop that wakes up in case events are available and processes them with the help of the generated state machine.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
This template project can be reused and can serve as quick start for further projects too. In the folder “state machine” just an empty state machine definition file called &lt;code&gt;tl_sm.xml&lt;/code&gt; is available.
&lt;/p&gt;

&lt;p&gt;
For our little embedded system we also need “software timers” and “fifos” as no &lt;abbr title=&quot;Real-Time Operating System&quot;&gt;RTOS&lt;/abbr&gt; is in use. Therefore the lib folder contains a software timer module and a fifo module.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/mainloop_ext.png?id=wiki%3Amanual%3Amsp430_tl_tutorial&quot; class=&quot;media&quot; title=&quot;wiki:mainloop_ext.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/mainloop_ext.png?w=400&amp;amp;tok=59ea17&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;Mainloop system design with state machines and timers&quot; alt=&quot;Mainloop system design with state machines and timers&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
The imported project could already be compiled, downloaded and executed but nothing will happen because the state machine is still empty. The following picture shows the general architecture of this application and the empty state machine. Go on reading to understand how to build a more complete application based on that framework.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Step A: Getting familiar with the setup&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;step_agetting_familiar_with_the_setup&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;1289-2829&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit3&quot; id=&quot;step_bfill_the_empty_state_machine_with_life&quot;&gt;Step B: Fill the empty state machine with life&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Typically it is an iterative process to design a state machine. Start thinking of the events that the machine has to react on. Then define the states and the state transitions triggered from the events you found. In our simple example there are just few events: timeouts from a software timers to provide timing, a button event to indicate a hardware fault and another timer event indicating the end of the start-up phase.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/news/tl_sm/step_b.jpg?id=wiki%3Amanual%3Amsp430_tl_tutorial&quot; class=&quot;media&quot; title=&quot;wiki:news:tl_sm:step_b.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/news/tl_sm/step_b.jpg?w=400&amp;amp;tok=3aed3d&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;State machine model of the traffic light&quot; alt=&quot;State machine model of the traffic light&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
From the downloaded code copy file &lt;code&gt;tl_sm.xml&lt;/code&gt; (for traffic light state machine) into the &lt;code&gt;state machine&lt;/code&gt; folder overwriting the existing file. Also copy the &lt;code&gt;led.h/c&lt;/code&gt; files into the project (beside main.c) that allows to switch on/off the traffic lights. Finally also update the &lt;code&gt;main.c&lt;/code&gt; file to have all needed headers included all files from step1b folder).
&lt;/p&gt;

&lt;p&gt;
Open the state machine editor by starting the &lt;code&gt;edit.bat&lt;/code&gt; file in a console window. There should be no error as long as the path was used (as described in the preconditions). Otherwise check the path in &lt;code&gt;edit.bat&lt;/code&gt; and &lt;code&gt;codegen.config&lt;/code&gt; and change it according to your installation.
&lt;/p&gt;

&lt;p&gt;
In case all is fine the state machine editor pops up. It is intended for not too complex diagrams and uses Graphviz for automatic layout. 
&lt;/p&gt;

&lt;p&gt;
The Sinelabore Codegen can process input from other powerful &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; modelling tools. In practise this means you are free to define your own tool chain depending on your needs. Eventually you might want a tool that also runs on Linux or there is already a tool available in your company. You have the choice - most probably the sinelabore code generator supports these tools. The supported tools are listed &lt;a href=&quot;https://sinelabore.com/doku.php/wiki/tools/supported_uml_tools&quot; class=&quot;wikilink1&quot; title=&quot;wiki:tools:supported_uml_tools&quot; data-wiki-id=&quot;wiki:tools:supported_uml_tools&quot;&gt;here&lt;/a&gt; on the homepage and details on how to work with them is provided in the manual.
&lt;/p&gt;

&lt;p&gt;
Don’t modify the state machine for now. Just close the tool again and execute “build.bat” in the command window to generate code from the model. The following files gets re-created:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; tm_sm.c/h	These files contain the generated state machine based on nested switch/case statements.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; tm_sm_ext.h	 This file contains the events that can be sent to the state machine&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; tm_sm_debug.h This file contains helper code for debugging purposes&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; tm_sm_trace.h This file contains helper code for tracing purposes (will be used in part 2).&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Compile and download the code to the target now. If you start the program you will notice that nothing happens beside 1Hz flashing of the red led on the eval board. It  indicates the heart beat of our app and is only used for debugging purposes. Go on reading to understand why.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Step B: Fill the empty state machine with life&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;step_bfill_the_empty_state_machine_with_life&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;2830-5535&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit4&quot; id=&quot;step_cfill_in_action_code&quot;&gt;Step C: Fill in action code&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Right now just the state machine enters the default state. But no triggers come in like timer timeout events nor is there any action code. This means we have to add some action code to our state machine. Action code is nothing else than code executed for example at the time when a state is entered or exited. Or when a transition was taken. Action code must be valid C-code (or any other programming language you use in your project)
&lt;/p&gt;

&lt;p&gt;
Copy the &lt;code&gt;tl_sm.xml&lt;/code&gt; (from folder step1c) that include now all action code and put it into the &lt;code&gt;generated&lt;/code&gt;state machine“ folder. Also copy the updated &lt;code&gt;main.c&lt;/code&gt; again into your project. In &lt;code&gt;main.c&lt;/code&gt; we basically added an interrupt service handler for the push-button.
&lt;/p&gt;

&lt;p&gt;
Open the state machine editor by starting the “edit.bat” file in a console window again. Now you will see that some action code was added. There is code to start our software time either in single shot or repetitive mode. And there is code to switch the traffic lights on or off. Try to understand what the state-machine will do.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/news/tl_sm/step3c.gif?id=wiki%3Amanual%3Amsp430_tl_tutorial&quot; class=&quot;media&quot; title=&quot;wiki:news:tl_sm:step3c.gif&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/news/tl_sm/step3c.gif&quot; class=&quot;mediaright&quot; align=&quot;right&quot; loading=&quot;lazy&quot; title=&quot;Image of the built-in editor and simulator of the sinelabore code generator&quot; alt=&quot;Image of the built-in editor and simulator of the sinelabore code generator&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Don’t modify the state machine. Just close the tool again and execute &lt;code&gt;build.bat&lt;/code&gt; in the command window to generate code from the updated model. Compile and download the code and execute it. Now you will see that first the yellow light is blinking for a while after power on. Then the normal sequence of a traffic light starts and goes on forever. Until you press the push-button. Then the machine enters an endless yellow blinking sequence. I.e. a service technician is required to eventually fix a hardware problem in the traffic light &lt;img src=&quot;https://sinelabore.com/lib/images/smileys/smile.svg&quot; class=&quot;icon smiley&quot; alt=&quot;:-)&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
Maybe open the state machine editor again to understand what happens. The timing is faster than it should be in real life. This is just to make watching the machine not too boring.
&lt;/p&gt;

&lt;p&gt;
Take a look in main.c line 127. You can see how to send an event from an interrupt service routine into the state machine queue. The machine simply processes event by event that is available in the fifo. This makes it very easy to understand and debug state machines designed in such a way.
&lt;/p&gt;

&lt;p&gt;
Finally the result looks like this:
&lt;/p&gt;
&lt;iframe src=&quot;//www.youtube-nocookie.com/embed/TBlobDwIRW4?&quot; width=&quot;425&quot; height=&quot;239&quot; style=&quot;width:425px;height:239px;&quot; class=&quot;vshare vshare__none&quot; allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; scrolling=&quot;no&quot; data-domain=&quot;www.youtube-nocookie.com&quot; loading=&quot;lazy&quot;&gt;&lt;h3&gt;Link to a Youtube video showing the traffic light in action&lt;/h3&gt;&lt;/iframe&gt;
&lt;p&gt;
&lt;strong&gt;What have we done so far:&lt;/strong&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; used a template project using timers, fifo and an empty state machine as quick start&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; modified the state machine by adding states and events&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; iteratively modify the state machine by adding action code until the full functionality is available.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
As you see the usually somehow teditious coding work of the actual state machine is 100% taken over from the state machine code generator. You can fully focus on the application logic and don’t need to worry about all the rest. Beside that the generator performs model checks and warns you about typical design flaws like states without exit etc.
&lt;/p&gt;

&lt;p&gt;
In part two it is shown how to add trace code and monitor the state machine in action.
&lt;/p&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_start&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:5,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;&lt;div class=&quot;wrap_center wrap_round wrap_box plugin_wrap&quot; style=&quot;width: 60%;&quot;&gt;
&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/doku.php/wiki/manual/editoriii&quot; class=&quot;wikilink1&quot; title=&quot;wiki:manual:editoriii&quot; data-wiki-id=&quot;wiki:manual:editoriii&quot;&gt;Go back to part III&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;plugin_wrap_end&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;secid&amp;quot;:6,&amp;quot;range&amp;quot;:&amp;quot;0-&amp;quot;} --&gt;
&lt;p&gt;
~~DISCUSSION:closed|Leave your comments~~
&lt;/p&gt;
&lt;div class=&quot;tags&quot;&gt;&lt;span&gt;
	&lt;a href=&quot;https://sinelabore.com/doku.php/tag/msp430?do=showtag&amp;amp;tag=%5BMSP430&quot; class=&quot;wikilink1&quot; title=&quot;tag:msp430&quot; rel=&quot;tag&quot;&gt;[MSP430&lt;/a&gt;,
	&lt;a href=&quot;https://sinelabore.com/doku.php/tag/tl?do=showtag&amp;amp;tag=TL&quot; class=&quot;wikilink1&quot; title=&quot;tag:tl&quot; rel=&quot;tag&quot;&gt;TL&lt;/a&gt;,
	&lt;a href=&quot;https://sinelabore.com/doku.php/tag/application_example?do=showtag&amp;amp;tag=Application_Example&quot; class=&quot;wikilink1&quot; title=&quot;tag:application_example&quot; rel=&quot;tag&quot;&gt;Application Example&lt;/a&gt;,
	&lt;a href=&quot;https://sinelabore.com/doku.php/tag/part?do=showtag&amp;amp;tag=Part&quot; class=&quot;wikilink1&quot; title=&quot;tag:part&quot; rel=&quot;tag&quot;&gt;Part&lt;/a&gt;,
	&lt;a href=&quot;https://sinelabore.com/doku.php/tag/1?do=showtag&amp;amp;tag=1%5D&quot; class=&quot;wikilink1&quot; title=&quot;tag:1&quot; rel=&quot;tag&quot;&gt;1]&lt;/a&gt;
&lt;/span&gt;&lt;/div&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Step C: Fill in action code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;step_cfill_in_action_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;5536-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 03 May 2024 20:39:40 +0000</pubDate>
        </item>
        <item>
            <title>How to generate state machine code from UML</title>
            <link>https://sinelabore.com/doku.php/wiki/manual/state_machine_generate</link>
            <description>
&lt;h1 class=&quot;sectionedit1&quot; id=&quot;how_to_generate_state_machine_code_from_uml&quot;&gt;How to generate state machine code from UML&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
Once the state machine has been modelled, you can generate state machine code from that model. The Code Generator can be fully controlled by a number of command line flags and parameters and a configuration file. 
&lt;/p&gt;

&lt;p&gt;
Example: Generate C code from Cadifra modelling tool 
&lt;/p&gt;
&lt;pre class=&quot;code Dos&quot;&gt;C:\&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;c:\jdk-11\bin\java.exe -cp &amp;quot;c:\sinelaboreRT5.0\bin\*&amp;quot; codegen.Main -p CADIFRA -l cx -o oven first_example_step3.cdd&lt;/pre&gt;

&lt;p&gt;
Example: Generate CPP code from Enterprise Architect modelling tool 
&lt;/p&gt;
&lt;pre class=&quot;code Bash&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;java&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;&lt;span class=&quot;es4&quot;&gt;$(CODEGEN_PATH)&lt;/span&gt;/*&amp;quot;&lt;/span&gt; codegen.Main &lt;span class=&quot;re5&quot;&gt;-l&lt;/span&gt; cppx &lt;span class=&quot;re5&quot;&gt;-p&lt;/span&gt; EA &lt;span class=&quot;re5&quot;&gt;-t&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Model:implementation:oven&amp;quot;&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-o&lt;/span&gt; oven  oven.xml&lt;/pre&gt;

&lt;p&gt;
Here is a list of all supported command line flags and parameters:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;&lt;span class=&quot;kw2&quot;&gt;java&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-cp&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;path_to_jar_file/*&amp;quot;&lt;/span&gt; codegen.Main
Usage: &lt;span class=&quot;kw2&quot;&gt;java&lt;/span&gt; &lt;span class=&quot;re5&quot;&gt;-cp&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;PATH-TO-JAR/*&amp;quot;&lt;/span&gt; codegen.Main &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-xls&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-gencfg&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-doxygen&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-Trace&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-verbose&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-U configfile&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-t route:to:class&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-Lstates&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-Levents&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-l cppx&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;cx&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;SSC&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;java&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;swift&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;csharp&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;lua&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;python&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;rust&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;go&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-A&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-s&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;-S&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;-E&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-c&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;-c1&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-p EA&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;MD&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;CADIFRA&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;UMODEL&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;ARGOUML&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;SSC&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;ASTAH&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;VP&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;Modelio&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;MM&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;PlantUML&lt;span class=&quot;sy0&quot;&gt;|&lt;/span&gt;DrawIO&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;-o outfilename&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; modelfilname&lt;/pre&gt;
&lt;div class=&quot;table sectionedit2&quot;&gt;&lt;table class=&quot;inline&quot;&gt;
	&lt;thead&gt;
	&lt;tr class=&quot;row0&quot;&gt;
		&lt;th class=&quot;col0 leftalign&quot;&gt; Flag         &lt;/th&gt;&lt;th class=&quot;col1 leftalign&quot;&gt; Description            &lt;/th&gt;
	&lt;/tr&gt;
	&lt;/thead&gt;
	&lt;tr class=&quot;row1&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-t            &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; In case a XMI file shall be parsed the path to the class that contains the state machine definition must be specified. This option allows you to model more than one state-based class and then generate one after the other by calling the code-generator with the corresponding path. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row2&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-p            &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Defines the used input format e.g. EA for Enterprise Architect. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row3&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-o &amp;lt;file&amp;gt;     &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Output filename (excluding file extension. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row4&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-l            &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Target language -l cx or -l cppx for example.&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row5&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-Trace        &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Activates the generation of trace code. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row6&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-gencfg       &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Prints out all configuration options for a specific lan- guage (use -l to define the language).&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row7&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-verbose      &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Enables the output of information messages during parsing and code generation &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row8&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-c or c1      &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Print transition coverage information and creates an Excel sheet with test routes. &lt;code&gt;-c&lt;/code&gt; uses a depth-first tree search algorithm which produces fewer but longer test routes. &lt;code&gt;-c1&lt;/code&gt; uses a breadth first algorithm which creates more but shorter test routes.&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row9&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-U &amp;lt;file&amp;gt;     &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Path and name of the codegen configuration file. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row10&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-L &amp;lt;file&amp;gt;     &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Path and name of the license file &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row11&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-Lstates      &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; List the states in the model on the console. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row12&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-Levents      &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; List the events in the model on the console. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row13&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-xls          &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Creates a state table in Excel format &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row14&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-doxygen      &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Creates a dot based description of the state diagram as part of the C/CPP file. This allows Doxygen to add a state machine diagram to the software documentation.&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row15&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-s            &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Start in interactive simulation mode. Also consider to use the -v flag in addition which enables the printout of the executed C-code per simulation step. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row16&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-S            &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Start simulation in graphical interactive mode. &lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr class=&quot;row17&quot;&gt;
		&lt;td class=&quot;col0 leftalign&quot;&gt;-E            &lt;/td&gt;&lt;td class=&quot;col1&quot;&gt; Start the integrated state diagram editor. &lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;table&amp;quot;,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;1126-3010&amp;quot;} --&gt;
&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 15 Dec 2023 10:11:37 +0000</pubDate>
        </item>
        <item>
            <title>What is a State Machine?</title>
            <link>https://sinelabore.com/doku.php/wiki/manual/state_machine_intro</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;what_is_a_state_machine&quot;&gt;What is a State Machine?&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
On this page you will learn what state diagrams are, what they consist of and how to create them.
&lt;/p&gt;

&lt;p&gt;
A state machine shows the dynamic behavior of an application.
It is a graph of states and transitions that describe the response to events
depending on the current state. State machines are used for
decades in hardware design. And during the last years also more and more in the
area of software development. &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state machines have some significant improvements compared to 
classical Moore or Mealy state machines. They support hierarchical designs, it is possible to
model parallel execution (and states) and several pseudo states were added to further improve
expressiveness.
&lt;/p&gt;

&lt;p&gt;
Especially in the embedded real-time domain the use of state machines is popular
because the behavior of devices in this domain can be often very well described
with state machines.
&lt;/p&gt;

&lt;p&gt;
An important aspect of state machines is that the design can be directly
transformed into executable code. This means that there is no break between the
design and the implementation. This is all the more important if the device
under development has to be certified &lt;em&gt;(e.g. according to  IEC61508)&lt;/em&gt;. 
&lt;/p&gt;

&lt;p&gt;
The following picture shows a hierarchical state machine that is used through out this introduction.
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/complex.png?id=wiki%3Amanual%3Astate_machine_intro&quot; class=&quot;media&quot; title=&quot;wiki:manual:complex.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/complex.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure: This state diagram example shows many of the features supported by the code generator. It was created using the Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; editor.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;What is a State Machine?&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;what_is_a_state_machine&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;256-1738&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit2&quot; id=&quot;state_machines_are_trees&quot;&gt;State Machines are Trees&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Basically a state machine can be represented as a tree of states. A transition e13
connects the two states S12 and S22. If the transition is triggered you have to walk upwards in the tree starting from S12 until you reach a common parent of S12 and S22. Then walk downwards in the tree until the target state (in this case S22) is reached. On the way all the entry and exit code of the visited states has to be executed.
&lt;/p&gt;

&lt;p&gt;
In case the starting state is a composite state it has to be determined which child state to exit in addition. If the target state is a composite state it also has to be determined which child state to enter if too. If history states are used their history has to be considered when entering states.
&lt;/p&gt;

&lt;p&gt;
Luckily the code generator takes care of all these conditions in the generated code. So you don’t have to worry about all the details involved in implementing state machines in a specific language.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/complex_tree.jpg?id=wiki%3Amanual%3Astate_machine_intro&quot; class=&quot;media&quot; title=&quot;wiki:manual:complex_tree.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/complex_tree.jpg?w=400&amp;amp;tok=4937da&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
Figure: The code generator internally creates a tree from a state diagram. Here the state tree of the example state machine is shown.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;State Machines are Trees&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;state_machines_are_trees&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;1739-2876&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit3&quot; id=&quot;states&quot;&gt;States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
State machines can be &lt;em&gt;hierarchical&lt;/em&gt; or &lt;em&gt;flat&lt;/em&gt;. A machine with sub-states within states is called a hierarchical state machine. States can have &lt;em&gt;entry code&lt;/em&gt; that is always executed if a state is entered. &lt;em&gt;Exit code&lt;/em&gt; is executed whenever the state is left. Note that the entry and exit code is also executed if a self transition takes place (e.g. e4 or e8 in the example machine). If events shall be processed without triggering the entry and exit actions so called inner events can be used &lt;sup&gt;&lt;a href=&quot;#fn__1&quot; id=&quot;fnt__1&quot; class=&quot;fn_top&quot;&gt;1)&lt;/a&gt;&lt;/sup&gt;. If for a state no entry and exit actions were declared an inner event behaves exactly like a self transition.
&lt;/p&gt;

&lt;p&gt;
A state can also have a &lt;em&gt;do&lt;/em&gt; activity. The do activity code is executed whenever the state is active just before event transitions are evaluated. This means that calculation results from the action code can be used as triggers for state transitions. Every state must have a unique state name.
&lt;/p&gt;

&lt;p&gt;
&lt;em&gt;Actions&lt;/em&gt; (i.e. entry/do/exit code) within states shall be non-blocking and short regarding their execution time. On every hierarchy level a default state must be specified. A final state is a state that can’t be left anymore. I.e. the state machine must be re-initialized to be reactive again.
&lt;/p&gt;

&lt;p&gt;
Some &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tools makes it difficult to define action code (e.g. a few C-statements). Therefore it is possible to specify inner events, entry and exit code … for a state by linking a note to a state. See next figure on the right side for an example. The note must start with the text &lt;em&gt;compartment:&lt;/em&gt;. Sometimes it is useful to use this option despite the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tool allows to specify entry/action/exit code directly. As the ’&lt;em&gt;constraints:&lt;/em&gt;’ is not supported by any &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; tool it must be always defined within an attached comment note (see section 3.6 in the PDF manual for more about using constraints).
In principle states can be nested again and again. The code generator was intensively tested with up to four hierarchy levels. If you use more levels reconsider your design!
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/entry_exit_action.jpg?id=wiki%3Amanual%3Astate_machine_intro&quot; class=&quot;media&quot; title=&quot;wiki:manual:entry_exit_action.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/entry_exit_action.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure: Left: A state with entry-, exit-, action code and inner events. Right: Complex state with entry- and exit code specified in a linked note.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;2877-5215&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit4&quot; id=&quot;transitions&quot;&gt;Transitions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
There are two types of transitions supported from the code generator. a) event based transitions and b) conditional triggered transitions. An event based transition has the following syntax &lt;code&gt;eventName[guardExpression]/action&lt;/code&gt;. The transition is only taken if the guard expression evaluates to true and the event was sent to the state machine. Only in this case the action code is executed. 
From a transition like
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;evDoorClosed[timer_preset()&amp;gt;0]/timer_start();&lt;/pre&gt;

&lt;p&gt;
the code generator generates the following C code:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;OVEN_EVENT_T&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;evDoorClosed&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;timer_preset&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span class=&quot;coMULTI&quot;&gt;/*Transition from Idle to Cooking*/&lt;/span&gt;
  evConsumed &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; 1U&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;coMULTI&quot;&gt;/*Action code for transition */&lt;/span&gt;
  timer_start&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
  ...&lt;/pre&gt;

&lt;p&gt;
A conditional (or guard) transition is not triggered from an outside event but when a guard expression is evaluated to true. It has the syntax: &lt;em&gt;#condition/action&lt;/em&gt;. Please note that the hash character &lt;strong&gt;#&lt;/strong&gt; must be typed in (i.e. prefix your code statement) to indicate this special type of trigger. From a transition like this:
&lt;/p&gt;

&lt;p&gt;
&lt;code&gt;#i==1/printf(“i==1\n”);&lt;/code&gt; the code generator generates the following C code:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;i&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
   ...
   &lt;span class=&quot;coMULTI&quot;&gt;/*Action code for transition*/&lt;/span&gt;
   &lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/printf.html&quot;&gt;&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;i==1&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
   ...&lt;/pre&gt;

&lt;p&gt;
&lt;strong&gt;Externally defined events:&lt;/strong&gt; Usually for all events used in a state machine diagram, the required event definitions are generated in the header file &lt;code&gt;*_ext.h&lt;/code&gt;. And only these events can be handled from the state machine.
&lt;/p&gt;

&lt;p&gt;
But sometimes it is required to react on events defined externally from the state machine diagram (e.g. existing code is re-used defining own events or the operating system sends predefined events e.g. in case of a timer timeout). 
&lt;/p&gt;

&lt;p&gt;
The code generator needs to know that a specific event should be or shouldn’t be included in the event definition process. Therefore such events can be prefixed with an exclamation mark (!). In all other areas of the generation process (state machine handler code, debug helpers etc.) they are included as any other event. &lt;sup&gt;&lt;a href=&quot;#fn__2&quot; id=&quot;fnt__2&quot; class=&quot;fn_top&quot;&gt;2)&lt;/a&gt;&lt;/sup&gt;
&lt;/p&gt;

&lt;p&gt;
Action code defined in transitions must be non-blocking! The next figure shows examples for all types of supported transitions. Action code from an initial pseudo state is only used if the target state of the transition is not in a parent state with history. In history states the usage of actions on the init transition is often misapplied and therefore ignored!
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/transitions.png?id=wiki%3Amanual%3Astate_machine_intro&quot; class=&quot;media&quot; title=&quot;wiki:manual:transitions.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/transitions.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Image showing the transitions supported by the code generator&quot; alt=&quot; Image showing the transitions supported by the code generator&quot; /&gt;&lt;/a&gt;
Figure: Examples of possible transitions supported by the code generator.
&lt;/p&gt;

&lt;p&gt;
From top to bottom:
&lt;/p&gt;
&lt;ol&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Ordered List ItemTransition from an init pseudostate. Only an action expression is allowed here.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Simple event with no guard and no action&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;  Event with guard. The guard expression enclosed in brackets( [] ) is denoting that this expression must be true for the transition to take place.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Event with guard and action. If the transition takes place the action code is executed. The action code must be one or more lines of valid C code.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Conditional transition. The transition takes place if the variable i is zero.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Conditional transition with action. The transition takes place if the variable i is zero. Additionally the action code is executed.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Transitions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;transitions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;5216-8555&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit5&quot; id=&quot;choices&quot;&gt;Choices&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The &lt;abbr title=&quot;Object Management Group&quot;&gt;OMG&lt;/abbr&gt; &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; specification states: &lt;em&gt;“…choice vertices which, when reached, result in the dynamic evaluation of the guards of the triggers of its outgoing transitions. This realizes a dynamic conditional branch. It enables splitting of transitions into multiple outgoing paths such that the decision on which path to take may be a function of the results of prior actions performed in the same run-to-completion step. If more than one of the guards evaluates to true, an arbitrary one is selected. If none of the guards evaluates to true, then the model is considered ill-formed. (To avoid this, it is recommended to define one outgoing transition with the predefined ’else’ guard for every choice vertex.”&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
The state chart in the next figure shows different options how choices can be used. Choices are represented as &lt;strong&gt;diamonds&lt;/strong&gt;. They can be placed within a composite state or at root level. A choice must have at least one incoming transition. Guards specified at the incoming transition(s) are ignored from the code-generator. Actions are simply copied to the outgoing transitions. Place them at the outgoing transitions.
&lt;/p&gt;

&lt;p&gt;
Usually choices can have only one incoming transition and multiple outgoing transitions (at least two). But the code–generator also allows more than one incoming transition. This is a convenient function to allow the compact specification of complex structures. Internally this construct is handled like two choices with one incoming transition each and the same outgoing transitions.
&lt;/p&gt;

&lt;p&gt;
In case more than one incoming transition is found the choice is doubled for each incoming transition. I.e. it is like modeling two choices with one transition each, and having the same outgoing transitions. At least two outgoing transitions each one with a guard must be defined. One of the guards must be an else statement as described above. Depending of the target state of each outgoing transition the related entry/exit code is generated. Creating chains of choices is not supported.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/choice_basic.jpg?id=wiki%3Amanual%3Astate_machine_intro&quot; class=&quot;media&quot; title=&quot;wiki:manual:choice_basic.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/choice_basic.jpg?w=400&amp;amp;tok=bcfe41&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Image showing different options to use choices&quot; alt=&quot; Image showing different options to use choices&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
Figure: Different options to use choices. A default path marked with
&lt;em&gt;else&lt;/em&gt; must always exist.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Choices&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;choices&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:5,&amp;quot;range&amp;quot;:&amp;quot;8556-10779&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit6&quot; id=&quot;determining_the_default_state_dynamically_init_to_choice&quot;&gt;Determining the default state dynamically (Init to Choice)&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Sometimes the initial state of a state machine or sub–machine shall be determined during run–time and not design–time. Examples:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; If the hardware self-test of a device fails the machine should enter an error state and not a normal operation state&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Depending on a parameter (for example set by a user) a specific state shall be entered&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
In such cases it is possible to connect the initial pseudo–state with the input side of a choice and connect the outgoing transitions with the target states. It is important that there exists one else path to ensure that there is always one option that can be taken by default. Several examples are shown in the following figure. Note that it is possible to define an action on the incoming transition of a choice that reads a value or performs a check and use the result of that function as guard for the outgoing transitions of a choice.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/init2choice_basic.jpg?id=wiki%3Amanual%3Astate_machine_intro&quot; class=&quot;media&quot; title=&quot;wiki:manual:init2choice_basic.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/init2choice_basic.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Figure shows the init to choice feature to dynamically determine the init state&quot; alt=&quot; Figure shows the init to choice feature to dynamically determine the init state&quot; /&gt;&lt;/a&gt;
Figure: Choices can be used to determine the initial state at run-time.
The figure shows several possibilities how to use this feature.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Determining the default state dynamically (Init to Choice)&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;determining_the_default_state_dynamically_init_to_choice&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:6,&amp;quot;range&amp;quot;:&amp;quot;10780-12001&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit7&quot; id=&quot;junctions&quot;&gt;Junctions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The &lt;abbr title=&quot;Object Management Group&quot;&gt;OMG&lt;/abbr&gt; &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; specification states: &lt;em&gt;… junction vertices are semantic-free vertices that are used to chain together multiple transitions. They are used to construct compound transition paths between states. For example, a junction can be used to converge multiple incoming transitions into a single outgoing transition representing a shared transition path (this is known as a merge).&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
The &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; specification also discusses the possibility of multiple outgoing transitions. This is not supported by the code generator!
&lt;/p&gt;

&lt;p&gt;
The junctions can be seen as a kind of drawing helper in the case you have several transitions ending all in the same state and all of these transitions share some common action. In such a case place the different triggers, guards and action code to the incoming transitions and the common part the the outgoing transition.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/cadifra_junction.png?id=wiki%3Amanual%3Astate_machine_intro&quot; class=&quot;media&quot; title=&quot;wiki:manual:cadifra_junction.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/cadifra_junction.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Figure shows junctions&quot; alt=&quot; Figure shows junctions&quot; /&gt;&lt;/a&gt;
Figure: Junction example drawn with Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt;. There is no junction symbol available in Cadifra &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt;. The shown (J) state is the supported replacement.
&lt;/p&gt;

&lt;p&gt;
The code-generator creates two separate transitions out of this model. The first one from S1 to S3. The second one from S2 to S3.
&lt;/p&gt;

&lt;p&gt;
Limitations and rules:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A junction should have at least two incoming transitions&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A junction must have exactly one outgoing transition.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; On the outgoing transition no guard and trigger must be defined.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The action in the outgoing path is appended to actions defined on the incoming paths.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Incoming transitions must not start from a pseudo state e.g. another junction, choice, …&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The outgoing transition must not end in a pseudo state e.g. another junction, choice, …&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Junctions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;junctions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:7,&amp;quot;range&amp;quot;:&amp;quot;12002-13711&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit8&quot; id=&quot;final_states&quot;&gt;Final States&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Final states have only incoming transitions. Once a state machine enters a final state it will not react on any other event. Exceptions are final states inside a hierarchical state machine. Transitions leaving the
parent state of a final state can still be taken. In the next figure the state &lt;code&gt;Final&lt;/code&gt; can be left via ev3 or evRealEnd
while state Final1 can’t be left anymore.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/final.png?id=wiki%3Amanual%3Astate_machine_intro&quot; class=&quot;media&quot; title=&quot;wiki:manual:final.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/final.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Image shows the use of final states in state machines.&quot; alt=&quot; Image shows the use of final states in state machines.&quot; /&gt;&lt;/a&gt;
Figure: Example usage of final states. Once the machine is in state &lt;code&gt;Final1&lt;/code&gt; it can&amp;#039;t be left anymore. State &lt;code&gt;Final&lt;/code&gt; can be left via event.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Final States&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;final_states&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:8,&amp;quot;range&amp;quot;:&amp;quot;13712-14349&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit9&quot; id=&quot;regions&quot;&gt;Regions&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
In state diagrams usually only one state is active at a time. In &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state diagrams regions also allow to model concurrency – i.e. more than one state is active at a time (AND states).
&lt;/p&gt;

&lt;p&gt;
A &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state may be divided into regions. Each region contains sub-states. Regions are executed in parallel. You can think of regions as independent state machines displayed in one diagram. The state machine in the next figure shows the well known microwave oven example designed using regions. Several regions each running in parallel in the state Active. Dashed lines are used to divide a state into regions.
&lt;/p&gt;

&lt;p&gt;
The power setting, light and microwave radiator are be considered as independent (concurrent) parts of the oven, each with its own states. The door and timer as the main external trigger are used in the regions to trigger state transitions. For example the radiator is switched on if the door gets closed and the timer is &amp;gt; zero.
&lt;/p&gt;

&lt;p&gt;
As you can see multiple concurrent regions can be used to explicitly visualise different parts of a device. And all the states in the one diagram.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/regions_basic.jpg?id=wiki%3Amanual%3Astate_machine_intro&quot; class=&quot;media&quot; title=&quot;wiki:manual:regions_basic.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/regions_basic.jpg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;
Figure: State S1 contains two regions.
&lt;/p&gt;

&lt;p&gt;
&lt;strong&gt;Points to consider with regions&lt;/strong&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Transitions must not cross region boundaries: In the next figure state transitions do not cross region boundaries and therefore the modellers’ intention is clear. But look at the next diagram. Now it is not clear anymore what the modeller had in mind. And it is also not very obvious what a code generator should generate. For that reason the following constraints were defined.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Regions must work on the same instance data: State diagrams follow the run-to- completion concept. Transitions that fire are fully executed and the state machine reaches a stable state configuration until it returns and can respond to the next event. To ensure this a copy of the instance data is kept and state changes are only performed on that copy. In practice this means that changes in one region does not influence other regions.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Regions&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;regions&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:9,&amp;quot;range&amp;quot;:&amp;quot;14350-16393&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit10&quot; id=&quot;adapting_the_generated_code&quot;&gt;Adapting the Generated Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
To adapt the generated code to your needs you can add notes to your design that have to start with either ’&lt;code&gt;header:&lt;/code&gt;’ or ’&lt;code&gt;postAction:&lt;/code&gt;’ or ’&lt;code&gt;action:&lt;/code&gt;’ or ’&lt;code&gt;unknownStateHandler:&lt;/code&gt;’.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/class_with_header_comment.png?id=wiki%3Amanual%3Astate_machine_intro&quot; class=&quot;media&quot; title=&quot;wiki:manual:class_with_header_comment.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/class_with_header_comment.png?w=600&amp;amp;tok=a2d60c&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Image shows the use of a header comment.&quot; alt=&quot; Image shows the use of a header comment.&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
Figure: It is possible to define own code inserted on top of the generated file.
This allows to specify own include files or other required local code in the state machine file.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; All code following the ’header:’ keyword is added at the begin of the generated state machine code. This allows to include required header files or the definition of local variables needed within the state machine.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Code following the ’action:’ keyword is inserted at the begin of the state machine function. This allows to execute own code whenever the state machine is called just before event processing starts.  This can be used to receive events from a message queue.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Code following the ’postAction:’ keyword is inserted at the end of the statem achine function. This allows to execute own code after the state machine code was processed e.g. to enable an interrupt at the end of an interrupt handler function implemented as state machine. Please note that this generator keyword is only available for the following backends: cx, cppx, java, ssc.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Code following the ’unknownStateHandler:’ keyword is inserted between every default/break pair of the generated code. The given code is executed if the state variables do not hold a valid state. This should never happen and indicates a serious problem in the system (e.g. memory is corrupt due to stack overflow). Alternatively it is also possible to define the code to insert in the codegen.cfg file.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/manual/unknownstatecode.jpg?id=wiki%3Amanual%3Astate_machine_intro&quot; class=&quot;media&quot; title=&quot;wiki:manual:unknownstatecode.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/manual/unknownstatecode.jpg?w=200&amp;amp;tok=6fbae8&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; This image shows the use of the unknown state handler.&quot; alt=&quot; This image shows the use of the unknown state handler.&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;
Figure: A message is printed whenever an invalid statevar was found.
&lt;/p&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Adapting the Generated Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;adapting_the_generated_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:10,&amp;quot;range&amp;quot;:&amp;quot;16394-18369&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit11&quot; id=&quot;what_next&quot;&gt;What next&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
For a quick start into state machines play with the toy example which is available in the examples folder other_examples/guisim_client_server. Start the code generator in simulation mode (see sim.run batch file on how to do it) and type in events used in the state diagram (e.g. &lt;em&gt;e13&lt;/em&gt; or &lt;em&gt;e2&lt;/em&gt; followed by a return). Then the simulation performs the state change and calls the related entry / exit and other action code. You can follow what is going on by watching the printouts. Observe especially:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The order the entry and exit actions are executed in case of event e13&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; When e1 triggers a state change to S2 and when it triggers a self-transition to S11&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Understand what happens if transitions start or end at composite states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Understand the effect of the history marker in S2&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Example output of the simulation:
&lt;/p&gt;
&lt;pre class=&quot;code bash&quot;&gt;....
Enter event name and press &lt;span class=&quot;kw3&quot;&gt;return&lt;/span&gt;
e14
msg: e14
&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;S12 Action&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;S12Exit&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;e14&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;S11Entry&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
&lt;span class=&quot;re5&quot;&gt;----------------------&lt;/span&gt;
E1
msg: E1
&lt;span class=&quot;kw3&quot;&gt;printf&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;S11 Action&lt;span class=&quot;es1&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
&lt;span class=&quot;re5&quot;&gt;----------------------&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;What next&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;what_next&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:11,&amp;quot;range&amp;quot;:&amp;quot;18370-&amp;quot;} --&gt;&lt;div class=&quot;footnotes&quot;&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__1&quot; id=&quot;fn__1&quot; class=&quot;fn_bot&quot;&gt;1)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;Inner events are presently only supported on the innermost states of hierarchical states and on top level states if they have no children.&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;fn&quot;&gt;&lt;sup&gt;&lt;a href=&quot;#fnt__2&quot; id=&quot;fn__2&quot; class=&quot;fn_bot&quot;&gt;2)&lt;/a&gt;&lt;/sup&gt; 
&lt;div class=&quot;content&quot;&gt;Note: Only the C/C++ backend consider externally marked events.&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 03 May 2024 20:38:01 +0000</pubDate>
        </item>
    </channel>
</rss>
