<?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:backends</title>
        <description>Productivity for embedded software development</description>
        <link>https://sinelabore.com/</link>
        <lastBuildDate>Wed, 08 Apr 2026 09:13:00 +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>Generating C code</title>
            <link>https://sinelabore.com/doku.php/wiki/backends/c_lang</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;generating_c_code&quot;&gt;Generating C code&lt;/h1&gt;
&lt;div class=&quot;level1&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; state charts. There are a number of different ways in which the generated code can be fine-tuned through the setting of configuration parameters. This allows generation to follow known patterns, which are illustrated with examples below.
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;em class=&quot;u&quot;&gt;Object pattern&lt;/em&gt;: Instance related data is always grouped in a struct. All state machine related functions operate on this data struct. The advantage is that the data flow is easy to follow, the code is re-entrant because there is no global manipulated state, and multiple instances are easy to realise. &lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; &lt;em class=&quot;u&quot;&gt;Opaque object pattern&lt;/em&gt;: This is similar to the object pattern, but hides the implementation from the outside of the generating state machine code. This further reduces dependencies between the state machine implementation and other code. See also &lt;a href=&quot;https://en.wikipedia.org/wiki/Opaque_pointer&quot; class=&quot;urlextern&quot; title=&quot;https://en.wikipedia.org/wiki/Opaque_pointer&quot; rel=&quot;ugc nofollow&quot;&gt;https://en.wikipedia.org/wiki/Opaque_pointer&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 class=&quot;u&quot;&gt;Single instance pattern&lt;/em&gt;: Typically there is only one instance and no instance pointer is needed. For example, implementing an IRQ handler as a state machine, or using a hardware module in the state machine that exists only once.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
In the generated code, state hierarchies are mapped to nested switch/case code. Event handling code is mapped to if/else-if/else structures. The various configuration parameters allow you to generate code that is optimal for your system. See section 2.2 of the PDF manual for a list of all available options. To generate C code call the code generator with the command line flag ’-l cx’.
To generate a configuration file with all parameters related to the C code generation call the code generator as follows once:
&lt;code&gt;java −cp path_to_bin_folder/∗ codegen.Main −l cx −gencfg &amp;gt; codegen.cfg&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
There are various configuration options to adjust the generated code:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; usage as interrupt handler without any parameters (e.g. &lt;code&gt;#pragma vector=UART0TX_VECTOR
__interrupt void irq_handler(void)&lt;/code&gt;);&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; having only the event as parameter of the handler&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; having an instance pointer and event as parameter (for running multiple instances of the same machine e.g. &lt;code&gt;void  testcase(TESTCASE_INSTANCEDATA_T *instanceVar, TESTCASE_EVENT_T  msg )&lt;/code&gt;)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; having an own defined parameter containing the event which allow to easily send data with the event (e.g. &lt;code&gt;void  testcase(TESTCASE_INSTANCEDATA_T *instanceVar, USER_EVENT_T *userData)&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for externally defined events (i.e. outside the &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; diagram) to better support reuse of legacy code&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Support for conditional events (i.e. boolean expressions)&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; the C backend has features for high-availability applications where it is desirable to detect serious errors happening outside the state machine code but effecting the correct execution of the state machine. Such errors might come from a runaway pointer overwriting key variables, power brownout corrupting a bit or a bad ram cell losing a bit to name a few. To detect and handle such situations is an overall system design task. But the code generator can help you to detect inconsistencies of the state machine offering different mechanisms described in the manual.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
The code generator supports code generation from models with regions. A region is an orthogonal part of a state. Regions allow to express parallelism within a state. A state can have two or more regions. Region contains states and transitions. 
&lt;/p&gt;

&lt;p&gt;
An example state diagram with regions is shown below. Imagine how much effort it would be to manually write the code for this machine. And even worse how difficult it would be to maintain it over time when new states/events are added.
&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/news/astah_regions.png&quot; class=&quot;medialeft&quot; align=&quot;left&quot; loading=&quot;lazy&quot; alt=&quot;&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
All this allows to generate code that is optimal for your system. See the manual 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;
This results in the following files:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; C-file with the state machine implementation&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; H-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; H-file with the events that can be sent to the machine&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; A file with some code that supports debugging&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
Example code generated from the oven example in the handbook:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;oven_ext.h&amp;quot;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;oven_hlp.h&amp;quot;&lt;/span&gt;
&lt;span class=&quot;co2&quot;&gt;#include &amp;quot;oven.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;kw2&quot;&gt;extern&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;unsigned&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;char&lt;/span&gt; msg&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kw2&quot;&gt;extern&lt;/span&gt; T_PWR pwr&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&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;
&amp;nbsp;
	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;
&amp;nbsp;
	&lt;span class=&quot;coMULTI&quot;&gt;/* Create a copy of the instance data.
	   Changes during the machine execution are done on the copy 
	   while tests (e.g. isIn) must use the unmodified instance data */&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;
&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;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;
&amp;nbsp;
		&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; ovenLight&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; ovenPower&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; ovenRadioator&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;
&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;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;evDec&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 Active to Active */&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;coMULTI&quot;&gt;/* Exit code for regions in state Active */&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;coMULTI&quot;&gt;/* Action code for transition  */&lt;/span&gt;
					timer_dec&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;
&amp;nbsp;
					&lt;span class=&quot;coMULTI&quot;&gt;/* Entry code for regions in state Active */&lt;/span&gt;
					&lt;span class=&quot;coMULTI&quot;&gt;/* entry chain  */&lt;/span&gt;
					&lt;span class=&quot;coMULTI&quot;&gt;/* entry chain  */&lt;/span&gt;
					&lt;span class=&quot;coMULTI&quot;&gt;/* entry chain  */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
					&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&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;instanceVarCopy&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; Active&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;OVEN_EVENT_T&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;evInc&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 Active to Active */&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;coMULTI&quot;&gt;/* Exit code for regions in state Active */&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;coMULTI&quot;&gt;/* Action code for transition  */&lt;/span&gt;
					timer_inc&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;
&amp;nbsp;
					&lt;span class=&quot;coMULTI&quot;&gt;/* Entry code for regions in state Active */&lt;/span&gt;
					&lt;span class=&quot;coMULTI&quot;&gt;/* entry chain  */&lt;/span&gt;
					&lt;span class=&quot;coMULTI&quot;&gt;/* entry chain  */&lt;/span&gt;
					&lt;span class=&quot;coMULTI&quot;&gt;/* entry chain  */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
					&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&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;instanceVarCopy&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; Active&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;/* Intentionally left blank */&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;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 Active  */&lt;/span&gt;
&amp;nbsp;
		&lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; Inactive&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;&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;span class=&quot;coMULTI&quot;&gt;/* Transition from Inactive to Active */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
				&lt;span class=&quot;coMULTI&quot;&gt;/* Entry code for regions in state Active */&lt;/span&gt;
				&lt;span class=&quot;coMULTI&quot;&gt;/* entry chain  */&lt;/span&gt;
				&lt;span class=&quot;coMULTI&quot;&gt;/* entry chain  */&lt;/span&gt;
				&lt;span class=&quot;coMULTI&quot;&gt;/* entry chain  */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
				&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&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;instanceVarCopy&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;stateVar &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; Active&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;/* Intentionally left blank */&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;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 Inactive  */&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;
			&lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&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;&lt;/pre&gt;

&lt;p&gt;
Beside the state machine a &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; class can also contain additional attributes and operations. Attributes are mapped as member variables of the state machine instance data. Operations are mapped to C-functions.
The following example shows a class with an attribute and operation. Operations can be used beneficially to model entry/exit code or other helper functions. Attributes might represent internal variables of the stateful class.
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/backup/class_with_header_comment.png?id=wiki%3Abackends%3Ac_lang&quot; class=&quot;media&quot; title=&quot;wiki:backup:class_with_header_comment.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/backup/class_with_header_comment.png&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;Class with an attribute and operation&quot; alt=&quot;Class with an attribute and operation&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
For more details read section “Generating C Code” of the manual.
&lt;/p&gt;

&lt;p&gt;
~~DISCUSSION|Leave your comments~~
&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;Generating C code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_c_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;14-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 03 May 2024 20:41:46 +0000</pubDate>
        </item>
        <item>
            <title>Generating C++ Code</title>
            <link>https://sinelabore.com/doku.php/wiki/backends/cpp_lang</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;generating_c_code&quot;&gt;Generating C++ Code&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
Sinelabore supports C++ code generation. By default, the code generator uses only a subset of C++ to account for resource-constrained systems. In fact, only classes, public/protected/private member variables and methods are used. For more powerful systems, code generation using features of C++11 is supported if enabled (--std=c++11 for g++ or clang++). The various parameters allow you to customise the generated code to suit your needs. The quality of the generated code has been proven in practice by my many demanding customers using various lint-like tools without any problems.
&lt;/p&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;.
&lt;/p&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 class diagram shows the structure of the generated classes.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/backends/cpp_class_diagram.png?id=wiki%3Abackends%3Acpp_lang&quot; class=&quot;media&quot; title=&quot;wiki:backends:cpp_class_diagram.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/backends/cpp_class_diagram.png?w=600&amp;amp;tok=190bfd&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot;Class diagram that shows the structure of the generated classes.&quot; alt=&quot;Class diagram that shows the structure of the generated classes.&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
The code generator supports code generation from models with regions and all other relevant state machine features. An example of a simplified microwave oven model is shown below. Regions allow the expression of parallelism within a state. A state may have two or more regions. A region contains states and transitions. Imagine how much effort it would be to write the code for this machine by hand. And even worse, how difficult it would be to maintain it over time as new states/events are added.
&lt;/p&gt;

&lt;p&gt;
The signature of the event handler can be adapted to the own needs in a flexible way:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Basic signature: &lt;pre class=&quot;code c&quot;&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;&lt;span class=&quot;kw4&quot;&gt;const&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;/pre&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Using a template parameter that allows elegant and flexible parameter handover: &lt;pre class=&quot;code c&quot;&gt;template &lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;typename T&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&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;&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; TESTCASE_EVENT_T msg&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; T&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt; userdata&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;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Without any parameter: &lt;pre class=&quot;code c&quot;&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;&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;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Command line parameter &lt;code&gt;-Trace&lt;/code&gt; enables  trace code generation&lt;/div&gt;
&lt;/li&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;
All details about the C++ backend are available in section “Generating C++ Code” of the manual.
&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;Generating C++ Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_c_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;24-2274&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit2&quot; id=&quot;model_example_and_generated_code&quot;&gt;Model Example and Generated Code&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
Assume that c++11 features are to be used to generate the code for the oven example shown. The following parameters have been set in the configuration file according to your needs.
&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;
&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/backends/ovenstatemachine.png&quot; class=&quot;medialeft&quot; align=&quot;left&quot; loading=&quot;lazy&quot; title=&quot; State machine of a microwave oven used as example state machine with regions. Below generated code from this machine is listed.&quot; alt=&quot; State machine of a microwave oven used as example state machine with regions. Below generated code from this machine is listed.&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;
An excerpt of the generated code is listed here:
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;oven&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;oven&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  m_initialized&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;static_cast&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;uint16_t&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&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;
  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;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;coMULTI&quot;&gt;/* State names */&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt; stateNames &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;st0&quot;&gt;&amp;quot;Inactive&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Active&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;LightOn&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;LightOff&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;HighPower&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;LowPower&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;CookingPause&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Cooking&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;RadiatorOff&amp;quot;&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;coMULTI&quot;&gt;/* Event names */&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;string&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;&amp;gt;&lt;/span&gt; eventNames &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;st0&quot;&gt;&amp;quot;evPwrLow&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evTimeout&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evDec&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evDoorOpen&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evDoorClosed&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evPwrHigh&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evInc&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;NO_MSG&amp;quot;&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;kw4&quot;&gt;auto&lt;/span&gt; oven&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;getNameByState&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 state&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;sy0&quot;&gt;-&amp;gt;&lt;/span&gt; std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;string&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;br0&quot;&gt;&amp;#40;&lt;/span&gt;static_cast&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;stateNames&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;static_cast&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;uint32_t&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;state&lt;span class=&quot;br0&quot;&gt;&amp;#41;&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;#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;auto&lt;/span&gt; oven&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;getNameByEvent&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; OVEN_EVENT_T evt&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;sy0&quot;&gt;-&amp;gt;&lt;/span&gt; std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;string&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;br0&quot;&gt;&amp;#40;&lt;/span&gt;static_cast&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;const&lt;/span&gt; std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;eventNames&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;static_cast&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;uint16_t&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;evt&lt;span class=&quot;br0&quot;&gt;&amp;#41;&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;#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;co1&quot;&gt;// Initialize method. Must be called once to init the machine&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;void&lt;/span&gt; oven&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span class=&quot;co1&quot;&gt;//call on entry code of default states&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;m_initialized&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;static_cast&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;uint16_t&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&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;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    m_initialized&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;static_cast&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;uint16_t&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;1U&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;//Create copy of statevar&lt;/span&gt;
    stateVarsCopy &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; stateVars&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co1&quot;&gt;// Set state vars to default states&lt;/span&gt;
&amp;nbsp;
    stateVarsCopy.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &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;me2&quot;&gt;Inactive&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* set init state of top state */&lt;/span&gt;
    stateVarsCopy.&lt;span class=&quot;me1&quot;&gt;stateVarLight&lt;/span&gt; &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;me2&quot;&gt;LightOn&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* set init state of Light */&lt;/span&gt;
    stateVarsCopy.&lt;span class=&quot;me1&quot;&gt;stateVarPower&lt;/span&gt; &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;me2&quot;&gt;LowPower&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* set init state of Power */&lt;/span&gt;
    stateVarsCopy.&lt;span class=&quot;me1&quot;&gt;stateVarRadioator&lt;/span&gt; &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;me2&quot;&gt;RadiatorOff&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* set init state of Radioator */&lt;/span&gt;
&amp;nbsp;
    timer.&lt;span class=&quot;me1&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;OVEN_EVENT_T&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;evTimeout&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;uint8_t&lt;/span&gt; testResult &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; hardwareTest&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;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;testResult&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;
      stateVarsCopy.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &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;me2&quot;&gt;Active&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;br0&quot;&gt;&amp;#123;&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; States&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;Inactive&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;co1&quot;&gt;// Copy state variables back&lt;/span&gt;
    stateVars &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; stateVarsCopy&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&lt;span class=&quot;co1&quot;&gt;// State machine event handler&lt;/span&gt;
&lt;span class=&quot;kw4&quot;&gt;auto&lt;/span&gt; oven&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;processEvent&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; OVEN_EVENT_T msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt; std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;uint16_t&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;kw4&quot;&gt;auto&lt;/span&gt; evConsumed &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; static_cast&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;uint16_t&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&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;
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;//Create copy of statevar&lt;/span&gt;
  stateVarsCopy &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; stateVars&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;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;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; States&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;Active&lt;/span&gt;&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; ovenLight&lt;span class=&quot;br0&quot;&gt;&amp;#40;&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; ovenPower&lt;span class=&quot;br0&quot;&gt;&amp;#40;&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; ovenRadioator&lt;span class=&quot;br0&quot;&gt;&amp;#40;&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;static_cast&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;uint16_t&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&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;
&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;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;OVEN_EVENT_T&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;evDec&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 Active to Active */&lt;/span&gt;
          validationHandler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;States&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;Active&lt;/span&gt;&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;me2&quot;&gt;Active&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;coMULTI&quot;&gt;/* Action code for transition  */&lt;/span&gt;
          timer.&lt;span class=&quot;me1&quot;&gt;dec&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;
          &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; States&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;Active&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;OVEN_EVENT_T&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;evInc&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 Active to Active */&lt;/span&gt;
          validationHandler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;States&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;Active&lt;/span&gt;&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;me2&quot;&gt;Active&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;coMULTI&quot;&gt;/* Action code for transition  */&lt;/span&gt;
          timer.&lt;span class=&quot;me1&quot;&gt;inc&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;
          &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; States&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;Active&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&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;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 Active  */&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; States&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;Inactive&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;coMULTI&quot;&gt;/* end of case Inactive  */&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;
      &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&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;co1&quot;&gt;// Copy state variables back&lt;/span&gt;
  stateVars &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; stateVarsCopy&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;br0&quot;&gt;&amp;#40;&lt;/span&gt;evConsumed&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;co1&quot;&gt;// end processEvent&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;coMULTI&quot;&gt;/* Region code for state Light */&lt;/span&gt;
&amp;nbsp;
std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;uint16_t&lt;/span&gt; oven&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;ovenLight&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&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;
&amp;nbsp;
  std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;uint16_t&lt;/span&gt; evConsumed &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; 0U&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;stateVars.&lt;span class=&quot;me1&quot;&gt;stateVarLight&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;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; States&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;LightOff&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;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;OVEN_EVENT_T&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;evDoorClosed&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;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;timer.&lt;span class=&quot;me1&quot;&gt;preset&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;&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;#123;&lt;/span&gt;
          &lt;span class=&quot;coMULTI&quot;&gt;/* Transition from LightOff to LightOn */&lt;/span&gt;
          validationHandler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;States&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;LightOff&lt;/span&gt;&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;me2&quot;&gt;LightOn&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;
          evConsumed&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;static_cast&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;uint16_t&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;1U&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;/* Action code for transition  */&lt;/span&gt;
          switchLight&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;T_LIGHT&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;L_ON&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;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
          stateVarsCopy.&lt;span class=&quot;me1&quot;&gt;stateVarLight&lt;/span&gt; &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;me2&quot;&gt;LightOn&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&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;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 LightOff  */&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; States&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;LightOn&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;msg&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;OVEN_EVENT_T&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;evDoorOpen&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;if&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;timer.&lt;span class=&quot;me1&quot;&gt;preset&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;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 LightOn to LightOff */&lt;/span&gt;
          validationHandler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;States&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;LightOn&lt;/span&gt;&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;me2&quot;&gt;LightOff&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;
          evConsumed&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;static_cast&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;uint16_t&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;1U&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;/* Action code for transition  */&lt;/span&gt;
          switchLight&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;T_LIGHT&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;L_OFF&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;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
          stateVarsCopy.&lt;span class=&quot;me1&quot;&gt;stateVarLight&lt;/span&gt; &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;me2&quot;&gt;LightOff&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&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;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 LightOn  */&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;
      &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&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;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;/pre&gt;

&lt;p&gt;
The complete code is available in the examples folder of the code generator download.
&lt;/p&gt;

&lt;p&gt;
The generated code does not rely on a library. It can be easily integrated into different system designs. An example is shown below. In this case, the state machine runs in a separate thread and receives events via an event queue. This is a typical usage pattern in embedded real-time systems.
&lt;/p&gt;

&lt;p&gt;
&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/backends/c_11_example.svg&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Typical usage pattern of state machines in embedded real-time systems. Machines run in their own thread of control. Communication between machines is realised with queues for decoupling reasons.&quot; alt=&quot; Typical usage pattern of state machines in embedded real-time systems. Machines run in their own thread of control. Communication between machines is realised with queues for decoupling reasons.&quot; /&gt;
&lt;/p&gt;
&lt;pre class=&quot;code c&quot;&gt;std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me2&quot;&gt;thread&lt;/span&gt; eventHandlerThread&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;
  my_oven&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt; machine &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; new my_oven&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;
  machine&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&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;sy0&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;while&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;true&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;
    OVEN_EVENT_T msg&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
    q.&lt;span class=&quot;me1&quot;&gt;waitAndPop&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&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;
    machine&lt;span class=&quot;sy0&quot;&gt;-&amp;gt;&lt;/span&gt;processEvent&lt;span class=&quot;br0&quot;&gt;&amp;#40;&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;
  &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;/div&gt;
&lt;!-- EDIT{&amp;quot;target&amp;quot;:&amp;quot;section&amp;quot;,&amp;quot;name&amp;quot;:&amp;quot;Model Example and Generated Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;model_example_and_generated_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:3,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;2275-8884&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit3&quot; id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The C++ backend has proven itself with many users and guarantees the always consistent code quality through the generator. You can fully concentrate on the respective application. Download the demo and tryout the &lt;code&gt;microwave_ea9_using_regions_cpp11&lt;/code&gt; 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;Summary&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;summary&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:6,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;8885-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 02 May 2025 14:25:20 +0000</pubDate>
        </item>
        <item>
            <title>Generating Java Code</title>
            <link>https://sinelabore.com/doku.php/wiki/backends/java_lang</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;generating_java_code&quot;&gt;Generating Java Code&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
To generate Java code call the code generator with the command line flag &lt;code&gt;’-l java’&lt;/code&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;p&gt;
The following example shows how to use the generated code together with a &lt;abbr title=&quot;Graphical User Interface&quot;&gt;GUI&lt;/abbr&gt; class based on a simple SWING application. Each time a button is pressed an event is sent to the state machine. Which then writes entry/exit code of the current state to the text window.
&lt;/p&gt;

&lt;p&gt;
Class SMBase.java serves as bridge between the java &lt;abbr title=&quot;Graphical User Interface&quot;&gt;GUI&lt;/abbr&gt; code and the generated state machine code.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/backends/java_example.png?id=wiki%3Abackends%3Ajava_lang&quot; class=&quot;media&quot; title=&quot;wiki:backends:java_example.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/backends/java_example.png?w=400&amp;amp;tok=b38e40&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
The state machine that realises the behaviour of the button presses looks as follows:
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/backends/java_example_sm.png?id=wiki%3Abackends%3Ajava_lang&quot; class=&quot;media&quot; title=&quot;wiki:backends:java_example_sm.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/backends/java_example_sm.png?w=400&amp;amp;tok=b7acdf&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; alt=&quot;&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
The complete project file for Apache Netbeans can be downloaded &lt;a href=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/backends/hava_demo.zip&quot; class=&quot;media mediafile mf_zip&quot; title=&quot;wiki:backends:hava_demo.zip (22.7 KB)&quot;&gt;here&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;
More information is available in the manual in section “Generating Java 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;Generating Java Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_java_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;14-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 03 May 2024 20:42:03 +0000</pubDate>
        </item>
        <item>
            <title>Generating JavaScript code from UML state machine models</title>
            <link>https://sinelabore.com/doku.php/wiki/backends/javascript</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;generating_javascript_code_from_uml_state_machine_models&quot;&gt;Generating JavaScript code from UML state machine models&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;
Sinelabore creates compact and clearly readable JavaScript code from &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; state machine diagrams. It has zero dependencies, and is useful for frontend and backend application logic.
&lt;/p&gt;

&lt;p&gt;
Sinelabore enables event-driven programming to handle complex logic in predictable, robust, and visual ways.
&lt;/p&gt;

&lt;p&gt;
To generate JavaScript code, call the code generator with the command line flag &lt;code&gt;-l js&lt;/code&gt; or &lt;code&gt;-l mjs&lt;/code&gt; depending on the file extension wanted. The content of the generated file is the same in both cases.
&lt;/p&gt;

&lt;p&gt;
Example command to generate the oven machine code from a model file called oven.xml:
&lt;/p&gt;

&lt;p&gt;
&lt;code&gt;java -cp “../../*” codegen.Main -l js  -p ssc  -o oven oven.xml&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
By supporting JS code generation, Sinelabore users can now design state machines in &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; and generate JS code from them. Which is undoubtedly a great advantage when thinking about the development of protocols between IoT devices and servers, for example. Or the development of device prototypes where a functioning &lt;abbr title=&quot;Graphical User Interface&quot;&gt;GUI&lt;/abbr&gt; user interface based on &lt;abbr title=&quot;HyperText Markup Language&quot;&gt;HTML&lt;/abbr&gt;/JS can be emulated very easily.
&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;Generating JavaScript code from UML state machine models&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_javascript_code_from_uml_state_machine_models&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;24-1129&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit2&quot; id=&quot;how_can_you_benefit_from_js_code_generation&quot;&gt;How can You benefit from JS code generation?&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;How can You benefit from JS code generation?&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;how_can_you_benefit_from_js_code_generation&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:2,&amp;quot;range&amp;quot;:&amp;quot;1130-1186&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit3&quot; id=&quot;creating_business_logic&quot;&gt;Creating business logic&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Create your business logic as state machines on either the client or server side. Create state machine diagrams without manual coding, allowing rapid prototyping or requirements gathering without worrying about the details of state machine implementation. The built-in model checker ensures that your state machine is always correct. Simulate your design to test and iterate using the built-in simulator. Or create a rapid prototype (see below) to get early feedback from your team and customers on how things should 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;Creating business logic&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;creating_business_logic&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:3,&amp;quot;range&amp;quot;:&amp;quot;1187-1745&amp;quot;} --&gt;
&lt;h3 class=&quot;sectionedit4&quot; id=&quot;creating_hmi_prototypes_for_iot_or_embedded_devices&quot;&gt;Creating HMI prototypes for IoT or embedded devices&lt;/h3&gt;
&lt;div class=&quot;level3&quot;&gt;

&lt;p&gt;
Prototypes are often needed to get quick feedback on design approaches or unclear requirements. This is where JS can play an important role. Thanks to its integration into &lt;abbr title=&quot;HyperText Markup Language&quot;&gt;HTML&lt;/abbr&gt; pages and its simple syntax, it enables the rapid development of functional prototypes. Users can then “play” with them and give direct feedback. This is shown here for a microwave oven. The oven can be controlled via a simple &lt;abbr title=&quot;HyperText Markup Language&quot;&gt;HTML&lt;/abbr&gt; page (the state machine is shown below).
&lt;/p&gt;

&lt;p&gt;
&lt;video class=&quot;mediacenter&quot; title=&quot; Microwave oven GUI simulation based on a website&quot; width=&quot;320&quot; height=&quot;240&quot; controls=&quot;controls&quot;&gt;
&lt;source src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/backends/oven_simulation_js.mp4&quot; type=&quot;video/mp4&quot; /&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/backends/oven_simulation_js.mp4&quot; class=&quot;media mediafile mf_mp4&quot; title=&quot;wiki:backends:oven_simulation_js.mp4 (2.5 MB)&quot;&gt; Microwave oven GUI simulation based on a website&lt;/a&gt;&lt;/video&gt;

&lt;/p&gt;

&lt;p&gt;
The event hander of the generated state machine is called at the appropriate points in the &lt;abbr title=&quot;HyperText Markup Language&quot;&gt;HTML&lt;/abbr&gt; page e.g. to forward the key presses to the generated event handler the following code used:
&lt;/p&gt;
&lt;pre class=&quot;code JavaScript&quot;&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;lt;&lt;/span&gt;script type&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;module&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;&amp;gt;&lt;/span&gt;
         &lt;span class=&quot;kw5&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt; oven &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; from &lt;span class=&quot;st0&quot;&gt;&#039;./oven.mjs&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
         &lt;span class=&quot;kw5&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt; TimerManager &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; from &lt;span class=&quot;st0&quot;&gt;&#039;./TimerManager.mjs&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
         let myOven&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;// Declare my Oven in the outer scope&lt;/span&gt;
         &lt;span class=&quot;kw1&quot;&gt;const&lt;/span&gt; userData&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;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
         window.&lt;span class=&quot;me1&quot;&gt;buttonDecClicked&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
             myOven.&lt;span class=&quot;me1&quot;&gt;processEvent&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;myOven.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evDec&lt;/span&gt;&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;#125;&lt;/span&gt;
&amp;nbsp;
         window.&lt;span class=&quot;me1&quot;&gt;buttonIncClicked&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
             myOven.&lt;span class=&quot;me1&quot;&gt;processEvent&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;myOven.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evInc&lt;/span&gt;&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;#125;&lt;/span&gt;
&amp;nbsp;
         window.&lt;span class=&quot;me1&quot;&gt;buttonOpenDoorClicked&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
             myOven.&lt;span class=&quot;me1&quot;&gt;processEvent&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;myOven.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evDoorOpen&lt;/span&gt;&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;#125;&lt;/span&gt;
&amp;nbsp;
         window.&lt;span class=&quot;me1&quot;&gt;buttonCloseDoorClicked&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
             myOven.&lt;span class=&quot;me1&quot;&gt;processEvent&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;myOven.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evDoorClosed&lt;/span&gt;&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;#125;&lt;/span&gt;
      ...
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;
The machine below realizes the behaviour of the oven. It uses hierarchical states with deep history and actions in various places. Two JS helper classes are used to interact with the &lt;abbr title=&quot;Graphical User Interface&quot;&gt;GUI&lt;/abbr&gt; and to have timers available.
&lt;/p&gt;

&lt;p&gt;
The machine realizes this behaviour:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The light and the oven will only become active when a time has been set and the door is closed&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; If the door is opened in between, the oven will be switched off and the time will stop. After closing the door, the oven continues to run at the old time.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; The time can be changed at any time&lt;/div&gt;
&lt;/li&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;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/backends/oven_sm.png?id=wiki%3Abackends%3Ajavascript&quot; class=&quot;media&quot; title=&quot;wiki:backends:oven_sm.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/backends/oven_sm.png?w=800&amp;amp;tok=ac1070&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; State Machine of a Microwave Oven with Java Script Promo Code&quot; alt=&quot; State Machine of a Microwave Oven with Java Script Promo Code&quot; width=&quot;800&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
A customer can work with this machine and interactively test whether the device really works as intended. For example, should the light stay on after the cooking time has elapsed even though the oven has not yet been opened? Such things can only be determined if you can “play” with your model.
&lt;/p&gt;

&lt;p&gt;
The Sinelabore Code Generator provides all the functions necessary to work with the machine. In addition to the event handler, these are auxiliary functions, for example to find out what state (or states) the machine is in and much more. The complete code is available below:
&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 HMI prototypes for IoT or embedded devices&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;creating_hmi_prototypes_for_iot_or_embedded_devices&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:4,&amp;quot;range&amp;quot;:&amp;quot;1746-4577&amp;quot;} --&gt;
&lt;h2 class=&quot;sectionedit5&quot; id=&quot;features_of_the_javascript_state_machine_code_generator&quot;&gt;Features of the JavaScript State Machine Code Generator&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;

&lt;p&gt;
The code generator supports the following features:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Code generation from flat or hierarchical state machine models with or without regions. A region is an orthogonal part of a state. Regions allow to express parallelism within a state. A state can have two or more regions. Region contains states and transitions.&lt;/div&gt;
&lt;/li&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;  Final states&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Trace code generation with command line parameter &lt;code&gt;-Trace&lt;/code&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; UserData field for user defined variables to be used in the machine &lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
As in the other backends too, code at the beginning of the generated JavaScript file can be specified with the &lt;code&gt;header&lt;/code&gt; linked to the class in a &lt;abbr title=&quot;Unified Modeling Language&quot;&gt;UML&lt;/abbr&gt; diagram. Use this to define your imports or other local code. It is also possible to define pre- and post-action code of the generated state handler (see section &amp;#039;Introduction&amp;#039; in the manual).
&lt;/p&gt;

&lt;p&gt;
The generated code looks as follows for the oven state machine. The complete example is available on the &lt;a href=&quot;https://github.com/sinelabore/examples&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/sinelabore/examples&quot; rel=&quot;ugc nofollow&quot;&gt;sinelabore github site&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;&lt;a class=&quot;folder&quot; href=&quot;#folded_13775c3677f95f14eb47ff4d8b74f320_1&quot;&gt;Generated JavaScript code from the Oven State Machine &lt;/a&gt;&lt;/p&gt;&lt;div class=&quot;folded hidden&quot; id=&quot;folded_13775c3677f95f14eb47ff4d8b74f320_1&quot;&gt;&lt;pre class=&quot;code JavaScript&quot;&gt;&lt;span class=&quot;coMULTI&quot;&gt;/*
 * (c) Sinelabore Software Tools GmbH, 2008 - 2024
 *
 * All rights reserved. Reproduction, modification,
 * use or disclosure to third parties without express
 * authority is forbidden.
 */&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;coMULTI&quot;&gt;/* Command line options: -l mjs -p ssc -o oven oven.xml  */&lt;/span&gt;
&lt;span class=&quot;coMULTI&quot;&gt;/* This file is generated from oven.xml - do not edit manually */&lt;/span&gt;
&lt;span class=&quot;coMULTI&quot;&gt;/* Generated on: Wed Jan 17 19:50:24 CET 2024 / Version 6.2.1B13753*/&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
&lt;span class=&quot;kw5&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt; TimerManager &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; from &lt;span class=&quot;st0&quot;&gt;&#039;./TimerManager.mjs&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;kw5&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt; DisplayInterface &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt; from &lt;span class=&quot;st0&quot;&gt;&#039;./DisplayInterface.mjs&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&lt;span class=&quot;kw5&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt; oven&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;
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;init&lt;/span&gt; &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;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;instId&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;
  &lt;span class=&quot;co1&quot;&gt;// State machine state data&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    stateVar&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
    stateVarMainRegion &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
    stateVarCookingRegion &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;null&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;// States of the state machine &lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;Object&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;freeze&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      none&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;
      Super&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;
      Completed&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;
      Cooking&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
      CookingPause&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
      Idle&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
      TimeNotShown&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
      TimeShown&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;7&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;#41;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;// Events the state machine can process&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;Object&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;freeze&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      none&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;
      evTimeout&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;
      evDec&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;
      evDoorOpen&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
      evDoorClosed&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
      evInc&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
      evPwr&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
      evBlink&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;7&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;#41;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;// Initialize state machine&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;initialize&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;init&lt;/span&gt; &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;sy0&quot;&gt;;&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;// Set state vars to default states&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Super&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* set init state of top state */&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* set init state of MainRegion */&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarCookingRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;TimeShown&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* set init state of CookingRegion */&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tid&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;createTimer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&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;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evTimeout&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;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tidBlink&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;createTimer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evBlink&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;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;display&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;new&lt;/span&gt; DisplayInterface&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;
    console.&lt;span class=&quot;me1&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;Oven Off&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;
&amp;nbsp;
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInSuper&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Super&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;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInTimeNotShown&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarCookingRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;TimeNotShown&lt;/span&gt;&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;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInCooking&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;br0&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInTimeShown&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarCookingRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;TimeShown&lt;/span&gt;&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;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInCooking&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;br0&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInCompleted&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Completed&lt;/span&gt;&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;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInSuper&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;br0&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInCooking&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Cooking&lt;/span&gt;&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;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInSuper&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;br0&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInCookingPause&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;CookingPause&lt;/span&gt;&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;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInSuper&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;br0&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInIdle&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&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;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInSuper&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;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;//Return the state name string based on the state value&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateToString&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;stateValue&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;const&lt;/span&gt; value &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;Object&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;keys&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;key &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;key&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; stateValue&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; value &lt;span class=&quot;sy0&quot;&gt;||&lt;/span&gt; `UnknownState&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;$&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;stateValue&lt;span class=&quot;br0&quot;&gt;&amp;#125;&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;co1&quot;&gt;//Return the event name string based on the event value&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventToString&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;eventValue&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;const&lt;/span&gt; value &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;Object&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;keys&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;key &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;key&lt;span class=&quot;br0&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; eventValue&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; value &lt;span class=&quot;sy0&quot;&gt;||&lt;/span&gt; `UnknownEvent&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;$&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;eventValue&lt;span class=&quot;br0&quot;&gt;&amp;#125;&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;
  &lt;span class=&quot;co1&quot;&gt;// Return of a map with the states in which the state machine is currently in&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;innermostActiveStates&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;var&lt;/span&gt; statesMap &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;new&lt;/span&gt; Map&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;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInCompleted&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;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;statesMap.&lt;span class=&quot;kw1&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Completed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Completed&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;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInTimeShown&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;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;statesMap.&lt;span class=&quot;kw1&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;TimeShown&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;TimeShown&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;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInTimeNotShown&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;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;statesMap.&lt;span class=&quot;kw1&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;TimeNotShown&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;TimeNotShown&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;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInCookingPause&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;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;statesMap.&lt;span class=&quot;kw1&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;CookingPause&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;CookingPause&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;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;isInIdle&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;br0&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;statesMap.&lt;span class=&quot;kw1&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Idle&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;return&lt;/span&gt; statesMap&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;
  &lt;span class=&quot;co1&quot;&gt;// State machine event handler&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;processEvent&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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; 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;var&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;
    &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;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;init&lt;/span&gt; &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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&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;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span class=&quot;co1&quot;&gt;// Copy stateVar to ensure regions have same view on machine&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;Object&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&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;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&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;// Action code &lt;/span&gt;
      &lt;span class=&quot;coMULTI&quot;&gt;/* Action - sample */&lt;/span&gt;
      console.&lt;span class=&quot;me1&quot;&gt;log&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventToString&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;msg&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;
&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;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&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;
&amp;nbsp;
      &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Super&lt;/span&gt;&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; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;processEventMainRegion&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; userData&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;&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;
&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;msg &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evDec&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 Super to Super*/&lt;/span&gt;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Exit code for regions in state Super*/&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;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Cooking&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;
&amp;nbsp;
            &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;/* Intentionally left blank */&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;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Action code for transition */&lt;/span&gt;
            document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;decTimer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tid&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;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;display&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;setTT&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;getPreset&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tid&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;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Entry code for regions in state Super*/&lt;/span&gt;
            console.&lt;span class=&quot;me1&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;Oven Off&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;coMULTI&quot;&gt;/* Default in entry chain */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;coMULTI&quot;&gt;/* Default in entry chain */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Super&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; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evInc&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 Super to Super*/&lt;/span&gt;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Exit code for regions in state Super*/&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;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Cooking&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;
&amp;nbsp;
            &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;/* Intentionally left blank */&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;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Action code for transition */&lt;/span&gt;
            document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;incTimer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tid&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;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;display&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;setTT&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;getPreset&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tid&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;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Entry code for regions in state Super*/&lt;/span&gt;
            console.&lt;span class=&quot;me1&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;Oven Off&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;coMULTI&quot;&gt;/* Default in entry chain */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;coMULTI&quot;&gt;/* Default in entry chain */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Super&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; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evPwr&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 Super to Super*/&lt;/span&gt;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Exit code for regions in state Super*/&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;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Cooking&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;
&amp;nbsp;
            &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;/* Intentionally left blank */&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;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Action code for transition */&lt;/span&gt;
            console.&lt;span class=&quot;me1&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;Set Power&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;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Entry code for regions in state Super*/&lt;/span&gt;
            console.&lt;span class=&quot;me1&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;Oven Off&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;coMULTI&quot;&gt;/* Default in entry chain */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;coMULTI&quot;&gt;/* Default in entry chain */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Super&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank*/&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;break&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* end of case Super */&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;
        &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;
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;// Post Action Code&lt;/span&gt;
    &lt;span class=&quot;coMULTI&quot;&gt;/* Post-Action - sample */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
    &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;Object&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;assign&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&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;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&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; evConsumed
  &lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;// Region code for region CookingRegion&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;processEventCookingRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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; 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;var&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;
&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;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarCookingRegion&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;
&amp;nbsp;
      &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;TimeShown&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;msg &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evBlink&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 TimeShown to TimeNotShown*/&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;/* Action code for transition */&lt;/span&gt;
          &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;display&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;setTT&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;&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;
&amp;nbsp;
          &lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
          &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarCookingRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;TimeNotShown&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank*/&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;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 TimeShown */&lt;/span&gt;
&amp;nbsp;
      &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;TimeNotShown&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;msg &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evBlink&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 TimeNotShown to TimeShown*/&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;/* Action code for transition */&lt;/span&gt;
          &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;display&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;setTT&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;getPreset&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tid&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;
&amp;nbsp;
          &lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
          &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarCookingRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;TimeShown&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank*/&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;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 TimeNotShown */&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;
        &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;
&amp;nbsp;
    &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;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;// Region code for region MainRegion&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;processEventMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;function&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; 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;var&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;
  &lt;span class=&quot;kw1&quot;&gt;var&lt;/span&gt; eventConsumedCookingRegion &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;0&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;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVars&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&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;
&amp;nbsp;
      &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Completed&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;msg &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evDoorOpen&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 Completed to Idle*/&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;/* Action code for transition */&lt;/span&gt;
          document.&lt;span class=&quot;me1&quot;&gt;getElementById&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;myImage&amp;quot;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;src&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;images/oven_open_off.png&amp;quot;&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 Idle*/&lt;/span&gt;
          console.&lt;span class=&quot;me1&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;Oven Off&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;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
          &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Idle&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank*/&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;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 Completed */&lt;/span&gt;
&amp;nbsp;
      &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Cooking&lt;/span&gt;&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; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;processEventCookingRegion&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; userData&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;&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;
&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;msg &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evDoorOpen&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 Cooking to CookingPause*/&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;/* Exit code for regions in state Cooking*/&lt;/span&gt;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Action code for transition */&lt;/span&gt;
            console.&lt;span class=&quot;me1&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;Oven Off&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;
            document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;pauseTimer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tid&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;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;display&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;updateImage&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;images/oven_open_off.png&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;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;CookingPause&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; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evTimeout&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 Cooking to Completed*/&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;/* Exit code for regions in state Cooking*/&lt;/span&gt;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Action code for transition */&lt;/span&gt;
            console.&lt;span class=&quot;me1&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;Oven Off&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;
            document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stopTimer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tid&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;
            document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stopTimer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tidBlink&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;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;display&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;updateImage&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;images/oven_closed_off.png&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;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Completed&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank*/&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;break&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* end of case Cooking */&lt;/span&gt;
&amp;nbsp;
      &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;CookingPause&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;msg &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evDoorClosed&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 CookingPause to Cooking*/&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;/* Action code for transition */&lt;/span&gt;
          document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;continueTimer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tid&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;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;display&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;updateImage&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;images/oven_closed_on.png&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;
&amp;nbsp;
          &lt;span class=&quot;coMULTI&quot;&gt;/* Entry code for regions in state Cooking*/&lt;/span&gt;
          &lt;span class=&quot;coMULTI&quot;&gt;/* Default in entry chain */&lt;/span&gt;
          &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarCookingRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;TimeShown&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;coMULTI&quot;&gt;/* Default in entry chain */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
          &lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
          &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Cooking&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank*/&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;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 CookingPause */&lt;/span&gt;
&amp;nbsp;
      &lt;span class=&quot;kw1&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Idle&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;msg &lt;span class=&quot;sy0&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evDoorClosed&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;if&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;getPreset&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tid&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;&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;/* Action code for transition */&lt;/span&gt;
            document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;startTimer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tid&lt;/span&gt;&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;sy0&quot;&gt;;&lt;/span&gt;
            document.&lt;span class=&quot;me1&quot;&gt;timerMgr&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;startTimer&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tidBlink&lt;/span&gt;&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;#41;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;display&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;updateImage&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;images/oven_closed_on.png&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;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Entry code for regions in state Cooking*/&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Default in entry chain */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarCookingRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;TimeShown&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;coMULTI&quot;&gt;/* Default in entry chain */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
            &lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Cooking&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span class=&quot;coMULTI&quot;&gt;/* Transition from Idle to Idle*/&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;/* Action code for transition */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;display&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;updateImage&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;images/oven_closed_off.png&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;coMULTI&quot;&gt;/* OnEntry code of state Idle*/&lt;/span&gt;
            console.&lt;span class=&quot;me1&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;Oven Off&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;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
            &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Idle&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 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;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;evDoorOpen&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 Idle*/&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;/* Action code for transition */&lt;/span&gt;
          &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;display&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;updateImage&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;images/oven_open_off.png&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;coMULTI&quot;&gt;/* OnEntry code of state Idle*/&lt;/span&gt;
          console.&lt;span class=&quot;me1&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;Oven Off&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;coMULTI&quot;&gt;/* adjust state variables */&lt;/span&gt;
          &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarsCopy&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarMainRegion&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;this&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;states&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;Idle&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
          &lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank*/&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;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 Idle */&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;
        &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;
&amp;nbsp;
    &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;
&amp;nbsp;
&amp;nbsp;
&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&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;Features of the JavaScript State Machine Code Generator&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;features_of_the_javascript_state_machine_code_generator&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:1,&amp;quot;secid&amp;quot;:5,&amp;quot;range&amp;quot;:&amp;quot;4578-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 03 May 2024 20:43:09 +0000</pubDate>
        </item>
        <item>
            <title>Generating Python Code</title>
            <link>https://sinelabore.com/doku.php/wiki/backends/python_lang</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;generating_python_code&quot;&gt;Generating Python Code&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

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

&lt;p&gt;
The generator generates just a Python class which implements the complete state machine.
This has the benefit that your Python project does not become bloated with all kinds of helper classes. If required an optional base class can be specified in the configuration file.
To get started the microwave oven project from the introduction section is is available on &lt;a href=&quot;https://github.com/sinelabore/examples/tree/master/OS_neutral/microwave_python&quot; class=&quot;urlextern&quot; title=&quot;https://github.com/sinelabore/examples/tree/master/OS_neutral/microwave_python&quot; rel=&quot;ugc nofollow&quot;&gt;GitHub&lt;/a&gt;. It is a fully running example. A &lt;abbr title=&quot;Graphical User Interface&quot;&gt;GUI&lt;/abbr&gt; realized with Tkinker allows you to send events to the state machine and observe the state machine reaction.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/backends/tkinker_oven.png?id=wiki%3Abackends%3Apython_lang&quot; class=&quot;media&quot; title=&quot;wiki:backends:tkinker_oven.png&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/backends/tkinker_oven.png?w=800&amp;amp;tok=a9a28f&quot; class=&quot;mediacenter&quot; loading=&quot;lazy&quot; title=&quot; Oven GUI built with Tkinker&quot; alt=&quot; Oven GUI built with Tkinker&quot; width=&quot;800&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Example Code:
&lt;/p&gt;
&lt;pre class=&quot;code python&quot;&gt;&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Command line options: -l PYTHON -p ssc -o oven oven.xml  &#039;&#039;&#039;&lt;/span&gt;
&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; This file is generated from oven.xml - do not edit manually &#039;&#039;&#039;&lt;/span&gt;
&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Generated on: Tue Jan 01 19:08:22 CET 2019 / version 3.7.3&#039;&#039;&#039;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;from&lt;/span&gt; oven_base &lt;span class=&quot;kw1&quot;&gt;import&lt;/span&gt; *
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;class&lt;/span&gt; oven&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;oven_base&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
&amp;nbsp;
	&lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;kw4&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; errorhandler&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;:
&amp;nbsp;
		&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Set state vars to default states &#039;&#039;&#039;&lt;/span&gt;
		&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Super&amp;quot;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;# set init state of top state &lt;/span&gt;
		&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Idle&amp;quot;&lt;/span&gt; &lt;span class=&quot;co1&quot;&gt;# set init state of Super&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
		&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; call on entry code of default states &#039;&#039;&#039;&lt;/span&gt;
		&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOff&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;
&amp;nbsp;
&amp;nbsp;
		&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;events&lt;/span&gt; &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;st0&quot;&gt;&#039;evPwrLow&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;st0&quot;&gt;&#039;evTimeout&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;st0&quot;&gt;&#039;evDec&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;st0&quot;&gt;&#039;evDoorOpen&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;st0&quot;&gt;&#039;evDoorClosed&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;st0&quot;&gt;&#039;evPwrHigh&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;st0&quot;&gt;&#039;evInc&#039;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
			&lt;span class=&quot;st0&quot;&gt;&#039;OVEN_NO_MSG&#039;&lt;/span&gt;
		&lt;span class=&quot;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
		&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;False&lt;/span&gt;
&amp;nbsp;
		&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; errorhandler &lt;span class=&quot;kw1&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;None&lt;/span&gt;:
			&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ehlr&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;errorhandler&lt;/span&gt;
		&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;:
			&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ehlr&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;errorhandler
&amp;nbsp;
&amp;nbsp;
	&lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; errorhandler&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;&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;kw1&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;Error:&amp;quot;&lt;/span&gt;  + msg&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
	&lt;span class=&quot;kw1&quot;&gt;def&lt;/span&gt; processEvent&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;self&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;:
&amp;nbsp;
		&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;False&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
		&lt;span class=&quot;co1&quot;&gt;# action code&lt;/span&gt;
		&lt;span class=&quot;co1&quot;&gt;# just a comment&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
		&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Super&amp;quot;&lt;/span&gt;:
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Completed&amp;quot;&lt;/span&gt;:
				&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; event&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evDoorOpen&amp;quot;&lt;/span&gt;:
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Transition from Completed to Idle&#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;True&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; OnEntry code of state Idle&#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOff&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;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; adjust state variables &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Idle&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
				&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;:
					&lt;span class=&quot;kw1&quot;&gt;pass&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;#Intentionally left blank&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Cooking&amp;quot;&lt;/span&gt;:
				&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; event&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evDoorOpen&amp;quot;&lt;/span&gt;:
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Transition from Cooking to CookingPause&#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;True&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Action code for transition &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOff&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;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tm&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;pause&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;
&amp;nbsp;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; adjust state variables &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;CookingPause&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
				&lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; event&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evTimeout&amp;quot;&lt;/span&gt;:
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Transition from Cooking to Completed&#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;True&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Action code for transition &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOff&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;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tm&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;clear&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;
&amp;nbsp;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; adjust state variables &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Completed&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
				&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;:
					&lt;span class=&quot;kw1&quot;&gt;pass&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;#Intentionally left blank&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;CookingPause&amp;quot;&lt;/span&gt;:
				&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; event&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evDoorClosed&amp;quot;&lt;/span&gt;:
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Transition from CookingPause to Cooking&#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;True&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Action code for transition &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tm&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;cont&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;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; OnEntry code of state Cooking&#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOn&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;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; adjust state variables &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Cooking&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
				&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;:
					&lt;span class=&quot;kw1&quot;&gt;pass&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;#Intentionally left blank&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Idle&amp;quot;&lt;/span&gt;:
				&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; event&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evDoorClosed&amp;quot;&lt;/span&gt;:
					&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tm&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;preset&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;&amp;gt;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;0&lt;/span&gt;:
						&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Transition from Idle to Cooking&#039;&#039;&#039;&lt;/span&gt;
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;True&lt;/span&gt;
&amp;nbsp;
						&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Action code for transition &#039;&#039;&#039;&lt;/span&gt;
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tm&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;start&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;
						&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; OnEntry code of state Cooking&#039;&#039;&#039;&lt;/span&gt;
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOn&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;
						&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; adjust state variables &#039;&#039;&#039;&lt;/span&gt;
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Cooking&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
					&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;:
						&lt;span class=&quot;kw1&quot;&gt;pass&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;#Intentionally left blank&lt;/span&gt;
&amp;nbsp;
				&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;:
					&lt;span class=&quot;kw1&quot;&gt;pass&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;#Intentionally left blank&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Check if event was already processed &#039;&#039;&#039;&lt;/span&gt;
			&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;!=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;True&lt;/span&gt;:
&amp;nbsp;
				&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; event&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evDec&amp;quot;&lt;/span&gt;:
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Transition from Super to Super&#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;True&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Action code for transition &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tm&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;dec&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;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Super&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; entry chain &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Cooking&amp;quot;&lt;/span&gt;:
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOn&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;
					&lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Idle&amp;quot;&lt;/span&gt;:
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOff&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;
					&lt;span class=&quot;co1&quot;&gt;###&lt;/span&gt;
&amp;nbsp;
				&lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; event&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evInc&amp;quot;&lt;/span&gt;:
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Transition from Super to Super&#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;True&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Action code for transition &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;tm&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;inc&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;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Super&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; entry chain &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Cooking&amp;quot;&lt;/span&gt;:
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOn&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;
					&lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Idle&amp;quot;&lt;/span&gt;:
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOff&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;
					&lt;span class=&quot;co1&quot;&gt;###&lt;/span&gt;
&amp;nbsp;
				&lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; event&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evPwrHigh&amp;quot;&lt;/span&gt;:
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Transition from Super to Super&#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;True&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Action code for transition &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenSetPwrHigh&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;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Super&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; entry chain &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Cooking&amp;quot;&lt;/span&gt;:
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOn&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;
					&lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Idle&amp;quot;&lt;/span&gt;:
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOff&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;
					&lt;span class=&quot;co1&quot;&gt;###&lt;/span&gt;
&amp;nbsp;
				&lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; event&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&amp;quot;evPwrLow&amp;quot;&lt;/span&gt;:
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Transition from Super to Super&#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kw2&quot;&gt;True&lt;/span&gt;
&amp;nbsp;
					&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; Action code for transition &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenSetPwrLow&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;
					&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVar&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Super&amp;quot;&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;st0&quot;&gt;&#039;&#039;&#039; entry chain &#039;&#039;&#039;&lt;/span&gt;
					&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Cooking&amp;quot;&lt;/span&gt;:
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOn&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;
					&lt;span class=&quot;kw1&quot;&gt;elif&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;stateVarSuper&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Idle&amp;quot;&lt;/span&gt;:
						&lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;radiator&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;ovenOff&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;
					&lt;span class=&quot;co1&quot;&gt;###&lt;/span&gt;
&amp;nbsp;
				&lt;span class=&quot;kw1&quot;&gt;else&lt;/span&gt;:
					&lt;span class=&quot;kw1&quot;&gt;pass&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;#Intentionally left blank&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
		&lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;kw2&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;me1&quot;&gt;eventConsumed&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;Generating Python Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_python_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;14-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Sat, 15 Jun 2024 18:08:13 +0000</pubDate>
        </item>
        <item>
            <title>Generating Rust Code</title>
            <link>https://sinelabore.com/doku.php/wiki/backends/rust_lang</link>
            <description>


&lt;h1 class=&quot;sectionedit1&quot; id=&quot;generating_rust_code&quot;&gt;Generating Rust Code&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&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 &lt;a href=&quot;https://www.rust-lang.org&quot; class=&quot;urlextern&quot; title=&quot;https://www.rust-lang.org&quot; rel=&quot;ugc nofollow&quot;&gt;https://www.rust-lang.org&lt;/a&gt;
To generate Rust code call the code generator with the following commandline flag &lt;code&gt;−l Rust&lt;/code&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 &lt;code&gt;-o test&lt;/code&gt; 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 following image shows a simple microwave oven in the integrated state machine editor.
&lt;/p&gt;

&lt;p&gt;
&lt;a href=&quot;https://sinelabore.com/lib/exe/detail.php/wiki/examples/rust_oven.jpg?id=wiki%3Abackends%3Arust_lang&quot; class=&quot;media&quot; title=&quot;wiki:examples:rust_oven.jpg&quot;&gt;&lt;img src=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/examples/rust_oven.jpg&quot; class=&quot;media&quot; loading=&quot;lazy&quot; title=&quot; Microwave oven example in the integrated state machine editor.&quot; alt=&quot; Microwave oven example in the integrated state machine editor.&quot; /&gt;&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
Code generation works as follows:
&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 installation/bin/*&amp;quot;&lt;/span&gt; codegen.Main &lt;span class=&quot;re5&quot;&gt;-l&lt;/span&gt; rust &lt;span class=&quot;re5&quot;&gt;-p&lt;/span&gt; ssc &lt;span class=&quot;re5&quot;&gt;-o&lt;/span&gt; oven oven.xml&lt;/pre&gt;
&lt;div class=&quot;hiddenGlobal  hiddenActive&quot;&gt;&lt;div class=&quot;hiddenElements&quot;&gt;&lt;/div&gt;&lt;div class=&quot;hiddenHead  hiddenSinceBeginning&quot;&gt;&lt;div class=&quot;hiddenOnHidden&quot;&gt;
&lt;p&gt;
The fully generated Rust code from the oven state machine looks as follows:
&lt;/p&gt;
&lt;/div&gt;&lt;div class=&quot;hiddenOnVisible&quot;&gt;
&lt;p&gt;
The fully generated Rust code from the oven state machine looks as follows:
&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt; &lt;!-- .hiddenHead --&gt;&lt;div class=&quot;hiddenBody&quot;&gt;&lt;pre class=&quot;code Rust&quot;&gt;&lt;span class=&quot;coMULTI&quot;&gt;/* Command line options: -Trace -l rust -p ssc -o oven oven.xml   */&lt;/span&gt;
&lt;span class=&quot;coMULTI&quot;&gt;/* This file is generated from oven.xml - do not edit manually  */&lt;/span&gt;
&lt;span class=&quot;coMULTI&quot;&gt;/* Generated on: Mon Nov 28 17:57:40 CET 2022 / Version 5.5.5.5 */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;use&lt;/span&gt; std&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;fmt&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&lt;span class=&quot;co0&quot;&gt;/// States in which the state machine can be&lt;/span&gt;
#&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;derive&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Debug&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;PartialEq&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;Copy&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;Clone&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&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; OvenStates&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
	Super&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
	Completed&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
	Cooking&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
	CookingPause&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
	Idle&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;impl&lt;/span&gt; fmt&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;kw3&quot;&gt;Display&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; OvenStates &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span class=&quot;kw1&quot;&gt;fn&lt;/span&gt; fmt&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; f&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; fmt&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;kw3&quot;&gt;Formatter&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; fmt&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;Result&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span class=&quot;kw1&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
			OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Super&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Super&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;
			OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Completed&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Completed&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;
			OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Cooking&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Cooking&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;
			OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;CookingPause&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;CookingPause&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;
			OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Idle&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;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;co0&quot;&gt;/// Events that can be sent to the state machine&lt;/span&gt;
#&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;derive&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Debug&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;PartialEq&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;Copy&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;Clone&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&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; OvenEvents &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
	EvDec&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
	EvTimeout&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
	EvDoorClosed&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
	EvDoorOpen&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
	EvPowerLow&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
	EvPowerHigh&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
	EvInc&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
	OvenNoMsg&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;
&lt;span class=&quot;kw1&quot;&gt;impl&lt;/span&gt; fmt&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;kw3&quot;&gt;Display&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;for&lt;/span&gt; OvenEvents &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span class=&quot;kw1&quot;&gt;fn&lt;/span&gt; fmt&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; f&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; fmt&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;kw3&quot;&gt;Formatter&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; fmt&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;kw4&quot;&gt;Result&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
		&lt;span class=&quot;kw1&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
			OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvDec&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;EvDec&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;
			OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvTimeout&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;EvTimeout&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;
			OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvDoorClosed&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;EvDoorClosed&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;
			OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvDoorOpen&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;EvDoorOpen&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;
			OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvPowerLow&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;EvPowerLow&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;
			OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvPowerHigh&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;EvPowerHigh&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;
			OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvInc&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;EvInc&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;
			OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;OvenNoMsg&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; write&lt;span class=&quot;sy0&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;f&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;st0&quot;&gt;&amp;quot;OvenNoMsg&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;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;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;coMULTI&quot;&gt;/* State machine struct
	 * is_init flag indicates whether the machine event handler was called the first time 
	 * state_var is the top level state variable 
	 * StateXXX are the state variables for hierachical or regions 
	 */&lt;/span&gt;
	#&lt;span class=&quot;br0&quot;&gt;&amp;#91;&lt;/span&gt;derive&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;Debug&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;Copy&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;Clone&lt;span class=&quot;br0&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#93;&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; Oven &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; OvenStates&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;
		&lt;span class=&quot;kw1&quot;&gt;pub&lt;/span&gt; state_varmain_region&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; OvenStates&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; Oven &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;
			Oven &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; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Super&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;
				state_varmain_region &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* set init state of main_region */&lt;/span&gt;
&amp;nbsp;
				&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; Oven&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; OvenEvents&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;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;let&lt;/span&gt; ev_consumed &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; usize&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
			&lt;span class=&quot;co0&quot;&gt;// Create copy of statevar&lt;/span&gt;
			&lt;span class=&quot;kw1&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; fsm_clone &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; Oven &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.clone&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;
			&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
				fsm_clone.is_init &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;sy0&quot;&gt;;&lt;/span&gt;
				fsm_clone.initialize&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;data&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; timer_service&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;co0&quot;&gt;// Action code&lt;/span&gt;
			&lt;span class=&quot;coMULTI&quot;&gt;/* just a comment */&lt;/span&gt;
&amp;nbsp;
			ev_consumed &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; fsm_clone.oven_main_machine&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;ev&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; data&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; timer_service&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;// Copy state variables back&lt;/span&gt;
			&lt;span class=&quot;sy0&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt; &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; fsm_clone&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; ev_consumed&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;
&amp;nbsp;
		&lt;span class=&quot;coMULTI&quot;&gt;/* Region code for state main_region */&lt;/span&gt;
&amp;nbsp;
		&lt;span class=&quot;kw1&quot;&gt;fn&lt;/span&gt; oven_main_region&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; OvenEvents&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;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; ev_consumed &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; usize &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;match&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_varmain_region &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
				OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Completed&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;
					&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; ev &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvDoorOpen&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
						&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from Completed to Idle */&lt;/span&gt;
						ev_consumed&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 Idle */&lt;/span&gt;
						data.oven_off&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;
						&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
						&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_varmain_region &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&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;Completed&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;Idle&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;EvDoorOpen&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;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;/* Intentionally left blank */&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;coMULTI&quot;&gt;/* end of match Completed  */&lt;/span&gt;
&amp;nbsp;
				OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Cooking&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;
					&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; ev &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvDoorOpen&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
						&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from Cooking to CookingPause */&lt;/span&gt;
						ev_consumed&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;/* Action code for transition  */&lt;/span&gt;
						data.oven_off&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;
						timer_service.pause&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.timer_id&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;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
						&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_varmain_region &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;CookingPause&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&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;Cooking&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;CookingPause&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;EvDoorOpen&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;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; ev &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvTimeout&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
						&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from Cooking to Completed */&lt;/span&gt;
						ev_consumed&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;/* Action code for transition  */&lt;/span&gt;
						data.oven_off&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;
						timer_service.stop&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.timer_id&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;/* OnEntry code of state Completed */&lt;/span&gt;
						&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.time&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;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
						&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_varmain_region &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Completed&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&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;Cooking&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;Completed&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;EvTimeout&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;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;/* Intentionally left blank */&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;coMULTI&quot;&gt;/* end of match Cooking  */&lt;/span&gt;
&amp;nbsp;
				OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;CookingPause&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;
					&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; ev &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvDoorClosed&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
						&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from CookingPause to Cooking */&lt;/span&gt;
						ev_consumed&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;/* Action code for transition  */&lt;/span&gt;
						timer_service.cont&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.timer_id&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;/* OnEntry code of state Cooking */&lt;/span&gt;
						data.oven_on&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;
						&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
						&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_varmain_region &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Cooking&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&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;CookingPause&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;Cooking&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;EvDoorClosed&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;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;/* Intentionally left blank */&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;coMULTI&quot;&gt;/* end of match CookingPause  */&lt;/span&gt;
&amp;nbsp;
				OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Idle&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;
					&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; ev &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvDoorClosed&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;kw1&quot;&gt;self&lt;/span&gt;.time &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;#123;&lt;/span&gt;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from Idle to Cooking */&lt;/span&gt;
							ev_consumed&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;/* Action code for transition  */&lt;/span&gt;
							timer_service.start&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.timer_id&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.time&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;/* OnEntry code of state Cooking */&lt;/span&gt;
							data.oven_on&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;
							&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
							&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_varmain_region &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Cooking&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&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;Idle&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;Cooking&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;EvDoorClosed[self.time &amp;gt; 0]&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;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;/* Intentionally left blank */&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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
						&lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&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;coMULTI&quot;&gt;/* end of match Idle  */&lt;/span&gt;
&amp;nbsp;
				_ &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
					&lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&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;coMULTI&quot;&gt;/* End match stateVar_root */&lt;/span&gt;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; ev_consumed&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;
		&lt;span class=&quot;kw1&quot;&gt;pub&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;fn&lt;/span&gt; initialize&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; 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;br0&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.is_init &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;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.timer_id &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; timer_service.create&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;TimerType&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;SingleShot&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvTimeout&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;
			data.oven_off&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;br0&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
		&lt;span class=&quot;kw1&quot;&gt;fn&lt;/span&gt; oven_main_machine&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; OvenEvents&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;
&amp;nbsp;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; ev_consumed &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; usize &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;
&amp;nbsp;
			&lt;span class=&quot;kw1&quot;&gt;match&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_var &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
&amp;nbsp;
				OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Super&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;
					&lt;span class=&quot;coMULTI&quot;&gt;/* calling region code */&lt;/span&gt;
					ev_consumed &lt;span class=&quot;sy0&quot;&gt;|=&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.oven_main_region&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;ev&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; data&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt; timer_service&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; ev_consumed&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;#123;&lt;/span&gt;
&amp;nbsp;
						&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; ev &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvDec&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from Super to Super */&lt;/span&gt;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Exit code for regions in state Super */&lt;/span&gt;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Action code for transition  */&lt;/span&gt;
							&lt;span class=&quot;kw1&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.time &lt;span class=&quot;sy0&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.time &lt;span class=&quot;sy0&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1000&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;span class=&quot;coMULTI&quot;&gt;/* Entry code for regions in state Super */&lt;/span&gt;
							data.oven_off&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;coMULTI&quot;&gt;/* Default in entry chain  */&lt;/span&gt;
							&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_varmain_region &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;coMULTI&quot;&gt;/* Default in entry chain  */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
							&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_var &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Super&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&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;Super&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;Super&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;EvDec&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;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; ev &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvInc&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from Super to Super */&lt;/span&gt;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Exit code for regions in state Super */&lt;/span&gt;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Action code for transition  */&lt;/span&gt;
							&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.time &lt;span class=&quot;sy0&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;nu0&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Entry code for regions in state Super */&lt;/span&gt;
							data.oven_off&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;coMULTI&quot;&gt;/* Default in entry chain  */&lt;/span&gt;
							&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_varmain_region &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;coMULTI&quot;&gt;/* Default in entry chain  */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
							&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_var &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Super&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&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;Super&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;Super&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;EvInc&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;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; ev &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvPowerHigh&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from Super to Super */&lt;/span&gt;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Exit code for regions in state Super */&lt;/span&gt;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Action code for transition  */&lt;/span&gt;
							data.oven_set_pwr&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;2000&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;coMULTI&quot;&gt;/* Entry code for regions in state Super */&lt;/span&gt;
							data.oven_off&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;coMULTI&quot;&gt;/* Default in entry chain  */&lt;/span&gt;
							&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_varmain_region &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;coMULTI&quot;&gt;/* Default in entry chain  */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
							&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_var &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Super&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&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;Super&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;Super&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;EvPowerHigh&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;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; ev &lt;span class=&quot;sy0&quot;&gt;==&lt;/span&gt; OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvPowerLow&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Transition from Super to Super */&lt;/span&gt;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Exit code for regions in state Super */&lt;/span&gt;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* Action code for transition  */&lt;/span&gt;
							data.oven_set_pwr&lt;span class=&quot;br0&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;400&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;coMULTI&quot;&gt;/* Entry code for regions in state Super */&lt;/span&gt;
							data.oven_off&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;coMULTI&quot;&gt;/* Default in entry chain  */&lt;/span&gt;
							&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_varmain_region &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Idle&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;coMULTI&quot;&gt;/* Default in entry chain  */&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
							&lt;span class=&quot;coMULTI&quot;&gt;/* adjust state variables  */&lt;/span&gt;
							&lt;span class=&quot;kw1&quot;&gt;self&lt;/span&gt;.state_var &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenStates&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;Super&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;;&lt;/span&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;Super&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;Super&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;EvPowerLow&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;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;/* Intentionally left blank */&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;br0&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span class=&quot;coMULTI&quot;&gt;/* end of match Super  */&lt;/span&gt;
&amp;nbsp;
				_ &lt;span class=&quot;sy0&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;br0&quot;&gt;&amp;#123;&lt;/span&gt;
					&lt;span class=&quot;coMULTI&quot;&gt;/* Intentionally left blank */&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;coMULTI&quot;&gt;/* End match stateVar_root */&lt;/span&gt;
			&lt;span class=&quot;kw1&quot;&gt;return&lt;/span&gt; ev_consumed&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;
	&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;/div&gt;&lt;/div&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; 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;// define state machine&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;&lt;span class=&quot;sy0&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;kw1&quot;&gt;mut&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;OvenEvents&lt;span class=&quot;sy0&quot;&gt;&amp;gt;,&lt;/span&gt; timer_id&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;usize&lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nu0&quot;&gt;99&lt;/span&gt;&lt;span class=&quot;sy0&quot;&gt;,&lt;/span&gt;time&lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;kw3&quot;&gt;u32&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;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; &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; &lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; myfsm &lt;span class=&quot;sy0&quot;&gt;:&lt;/span&gt; Oven &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;
&lt;span class=&quot;kw1&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;mut&lt;/span&gt; msg &lt;span class=&quot;sy0&quot;&gt;=&lt;/span&gt; OvenEvents&lt;span class=&quot;sy0&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;me1&quot;&gt;EvInc&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;msg&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; 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 &lt;em class=&quot;u&quot;&gt;first macro parameter&lt;/em&gt; 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 logger 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;. This allows to trace the state transitions and event flow.
&lt;/p&gt;

&lt;p&gt;
The &lt;em class=&quot;u&quot;&gt;second macro parameter&lt;/em&gt; allows to hand over another user defined type intended to realize a timer service. Whether the state machine needs and uses a  timer service and how it is implemented is 
totally in the user&amp;#039;s hand. A microwave oven example is provided in the samples folder.
It implemets a basic timer service for realizing the timeout for the cooking time. 
&lt;/p&gt;

&lt;p&gt;
Note: presently there is no possibliy 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;p&gt;
The complete example is available &lt;a href=&quot;https://sinelabore.com/lib/exe/fetch.php/wiki/downloads/microwave_handbook_rust.zip&quot; class=&quot;media mediafile mf_zip&quot; title=&quot;wiki:downloads:microwave_handbook_rust.zip (11.7 KB)&quot;&gt;here&lt;/a&gt;. Built it with &lt;code&gt;cargo build&lt;/code&gt; and then run it with &lt;code&gt;cargo run&lt;/code&gt;. In the src folder you will find command line examples how to model the state machine and build the Rust code. If you run the code type in events and send them to the state machine handler by pressing return.
&lt;/p&gt;

&lt;p&gt;
You should see this output on the command line:
&lt;/p&gt;
&lt;pre class=&quot;code&quot;&gt;cargo run
...
Oven demo program written in Rust
Type in one or more commands and then press return to send them to the state machine
Supported commands:
   o to open the door
   c to close the door
   + to increase the cooking time
   - to decrease the door
   P set oven power to high
   p set oven power to low&lt;/pre&gt;

&lt;p&gt;
How to go on from here:
&lt;/p&gt;
&lt;ul&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Download the codegen which includes all the examples&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Modify the state machine model file and re-generate the Rust code again and explore your changes.&lt;/div&gt;
&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt; Read the manual about all the functions the code generator provides&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&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;
Please note that the Rust back-end is work-in-progress. Your feedback is highly welcome!
&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;Generating Rust Code&amp;quot;,&amp;quot;hid&amp;quot;:&amp;quot;generating_rust_code&amp;quot;,&amp;quot;codeblockOffset&amp;quot;:0,&amp;quot;secid&amp;quot;:1,&amp;quot;range&amp;quot;:&amp;quot;14-&amp;quot;} --&gt;</description>
            <author>anonymous@undisclosed.example.com (Anonymous)</author>
            <pubDate>Fri, 03 May 2024 20:42:50 +0000</pubDate>
        </item>
    </channel>
</rss>
