ソースを参照

Microwave example: add more variants

Joeri Exelmans 4 年 前
コミット
131ec796f1

+ 1 - 2
examples/microwave/models/model_01_flat_nodoor.xml

@@ -1,12 +1,11 @@
 <single_instance_cd>
+  <!-- "Take Many"-variant -->
   <delta>1 ms</delta>
   <statechart>
     <semantics
       big_step_maximality="take_many"
       combo_step_maximality="take_one"
       input_event_lifeline="first_combo_step"
-      hierarchical_priority="source_parent"
-      orthogonal_priority="explicit"
       same_source_priority="explicit"
       />
     <datamodel>

+ 76 - 0
examples/microwave/models/model_01b_flat_nodoor.xml

@@ -0,0 +1,76 @@
+<single_instance_cd>
+  <!-- "Take One"-variant with 2 after-transitions -->
+  <delta>1 ms</delta>
+  <statechart>
+    <semantics
+      big_step_maximality="take_one"
+      input_event_lifeline="whole"
+      hierarchical_priority="source_parent"
+      same_source_priority="explicit"
+      />
+    <datamodel>
+      time = 0;
+      checkStartTime = func {
+        if (time == 0) time = 30;
+      };
+    </datamodel>
+    <inport name="in">
+      <event name="start"/>
+      <event name="stop"/>
+      <event name="increase_time"/>
+      <event name="door_opened"/>
+      <event name="door_closed"/>
+    </inport>
+    <outport name="out">
+      <event name="micro_on"/>
+      <event name="micro_off"/>
+      <event name="set_time"/>
+      <event name="ping"/>
+    </outport>
+    <root initial="NotRunning">
+      <state id="Running">
+        <onentry> <raise port="out" event="micro_on"/> </onentry>
+        <onexit> <raise port="out" event="micro_off"/> </onexit>
+        <transition port="in" event="stop" target="../NotRunning"/>
+        <transition after="1 s" cond="time > 1" target=".">
+          <code> time -= 1; </code>
+          <raise port="out" event="set_time">
+            <param expr="time"/>
+          </raise>
+        </transition>
+        <transition port="in" event="increase_time" target=".">
+          <code> time += 10; </code>
+            <raise port="out" event="set_time">
+              <param expr="time"/>
+            </raise>
+        </transition>
+        <transition after="1 s" cond="time == 1" target="../NotRunning">
+          <code> time -= 1; </code>
+          <raise port="out" event="set_time">
+            <param expr="time"/>
+          </raise>
+        </transition>
+      </state>
+      <state id="NotRunning">
+        <transition port="in" event="start" target="../Running">
+          <code> checkStartTime(); </code>
+          <raise port="out" event="set_time">
+            <param expr="time"/>
+          </raise>
+        </transition>
+        <transition port="in" event="stop" target=".">
+          <code> time = 0; </code>
+          <raise port="out" event="set_time">
+            <param expr="time"/>
+          </raise>
+        </transition>
+        <transition port="in" event="increase_time" target=".">
+          <code> time += 10; </code>
+            <raise port="out" event="set_time">
+              <param expr="time"/>
+            </raise>
+        </transition>
+      </state>
+    </root>
+  </statechart>
+</single_instance_cd>

+ 85 - 0
examples/microwave/models/model_01b_flat_nodoor_priorities.svg

@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.40.1 (20161225.0304)
+ -->
+<!-- Title: priorities Pages: 1 -->
+<svg width="698pt" height="260pt"
+ viewBox="0.00 0.00 697.87 260.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 256)">
+<title>priorities</title>
+<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-256 693.8685,-256 693.8685,4 -4,4"/>
+<!-- 0. stop / Running&#45;&gt;NotRunning -->
+<g id="node1" class="node">
+<title>0. stop / Running&#45;&gt;NotRunning</title>
+<ellipse fill="none" stroke="#000000" cx="183.2837" cy="-234" rx="124.2781" ry="18"/>
+<text text-anchor="middle" x="183.2837" y="-230.3" font-family="Times,serif" font-size="14.00" fill="#000000">0. stop / Running&#45;&gt;NotRunning</text>
+</g>
+<!-- 1. after(1 s)[time &gt; 1] / Running&#45;&gt;Running -->
+<g id="node2" class="node">
+<title>1. after(1 s)[time &gt; 1] / Running&#45;&gt;Running</title>
+<ellipse fill="none" stroke="#000000" cx="183.2837" cy="-162" rx="165.1707" ry="18"/>
+<text text-anchor="middle" x="183.2837" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">1. after(1 s)[time &gt; 1] / Running&#45;&gt;Running</text>
+</g>
+<!-- 0. stop / Running&#45;&gt;NotRunning&#45;&gt;1. after(1 s)[time &gt; 1] / Running&#45;&gt;Running -->
+<g id="edge1" class="edge">
+<title>0. stop / Running&#45;&gt;NotRunning&#45;&gt;1. after(1 s)[time &gt; 1] / Running&#45;&gt;Running</title>
+<path fill="none" stroke="#00ff00" d="M183.2837,-215.8314C183.2837,-208.131 183.2837,-198.9743 183.2837,-190.4166"/>
+<polygon fill="#00ff00" stroke="#00ff00" points="186.7838,-190.4132 183.2837,-180.4133 179.7838,-190.4133 186.7838,-190.4132"/>
+</g>
+<!-- 2. increase_time / Running&#45;&gt;Running -->
+<g id="node3" class="node">
+<title>2. increase_time / Running&#45;&gt;Running</title>
+<ellipse fill="none" stroke="#000000" cx="183.2837" cy="-90" rx="145.6742" ry="18"/>
+<text text-anchor="middle" x="183.2837" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">2. increase_time / Running&#45;&gt;Running</text>
+</g>
+<!-- 1. after(1 s)[time &gt; 1] / Running&#45;&gt;Running&#45;&gt;2. increase_time / Running&#45;&gt;Running -->
+<g id="edge2" class="edge">
+<title>1. after(1 s)[time &gt; 1] / Running&#45;&gt;Running&#45;&gt;2. increase_time / Running&#45;&gt;Running</title>
+<path fill="none" stroke="#00ff00" d="M183.2837,-143.8314C183.2837,-136.131 183.2837,-126.9743 183.2837,-118.4166"/>
+<polygon fill="#00ff00" stroke="#00ff00" points="186.7838,-118.4132 183.2837,-108.4133 179.7838,-118.4133 186.7838,-118.4132"/>
+</g>
+<!-- 3. after(1 s)[time == 1] / Running&#45;&gt;NotRunning -->
+<g id="node4" class="node">
+<title>3. after(1 s)[time == 1] / Running&#45;&gt;NotRunning</title>
+<ellipse fill="none" stroke="#000000" cx="183.2837" cy="-18" rx="183.0677" ry="18"/>
+<text text-anchor="middle" x="183.2837" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">3. after(1 s)[time == 1] / Running&#45;&gt;NotRunning</text>
+</g>
+<!-- 2. increase_time / Running&#45;&gt;Running&#45;&gt;3. after(1 s)[time == 1] / Running&#45;&gt;NotRunning -->
+<g id="edge3" class="edge">
+<title>2. increase_time / Running&#45;&gt;Running&#45;&gt;3. after(1 s)[time == 1] / Running&#45;&gt;NotRunning</title>
+<path fill="none" stroke="#00ff00" d="M183.2837,-71.8314C183.2837,-64.131 183.2837,-54.9743 183.2837,-46.4166"/>
+<polygon fill="#00ff00" stroke="#00ff00" points="186.7838,-46.4132 183.2837,-36.4133 179.7838,-46.4133 186.7838,-46.4132"/>
+</g>
+<!-- 4. start / NotRunning&#45;&gt;Running -->
+<g id="node5" class="node">
+<title>4. start / NotRunning&#45;&gt;Running</title>
+<ellipse fill="none" stroke="#000000" cx="518.2837" cy="-234" rx="124.2781" ry="18"/>
+<text text-anchor="middle" x="518.2837" y="-230.3" font-family="Times,serif" font-size="14.00" fill="#000000">4. start / NotRunning&#45;&gt;Running</text>
+</g>
+<!-- 5. stop / NotRunning&#45;&gt;NotRunning -->
+<g id="node6" class="node">
+<title>5. stop / NotRunning&#45;&gt;NotRunning</title>
+<ellipse fill="none" stroke="#000000" cx="518.2837" cy="-162" rx="137.2758" ry="18"/>
+<text text-anchor="middle" x="518.2837" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">5. stop / NotRunning&#45;&gt;NotRunning</text>
+</g>
+<!-- 4. start / NotRunning&#45;&gt;Running&#45;&gt;5. stop / NotRunning&#45;&gt;NotRunning -->
+<g id="edge4" class="edge">
+<title>4. start / NotRunning&#45;&gt;Running&#45;&gt;5. stop / NotRunning&#45;&gt;NotRunning</title>
+<path fill="none" stroke="#00ff00" d="M518.2837,-215.8314C518.2837,-208.131 518.2837,-198.9743 518.2837,-190.4166"/>
+<polygon fill="#00ff00" stroke="#00ff00" points="521.7838,-190.4132 518.2837,-180.4133 514.7838,-190.4133 521.7838,-190.4132"/>
+</g>
+<!-- 6. increase_time / NotRunning&#45;&gt;NotRunning -->
+<g id="node7" class="node">
+<title>6. increase_time / NotRunning&#45;&gt;NotRunning</title>
+<ellipse fill="none" stroke="#000000" cx="518.2837" cy="-90" rx="171.6696" ry="18"/>
+<text text-anchor="middle" x="518.2837" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">6. increase_time / NotRunning&#45;&gt;NotRunning</text>
+</g>
+<!-- 5. stop / NotRunning&#45;&gt;NotRunning&#45;&gt;6. increase_time / NotRunning&#45;&gt;NotRunning -->
+<g id="edge5" class="edge">
+<title>5. stop / NotRunning&#45;&gt;NotRunning&#45;&gt;6. increase_time / NotRunning&#45;&gt;NotRunning</title>
+<path fill="none" stroke="#00ff00" d="M518.2837,-143.8314C518.2837,-136.131 518.2837,-126.9743 518.2837,-118.4166"/>
+<polygon fill="#00ff00" stroke="#00ff00" points="521.7838,-118.4132 518.2837,-108.4133 514.7838,-118.4133 521.7838,-118.4132"/>
+</g>
+</g>
+</svg>

+ 73 - 0
examples/microwave/models/model_01c_flat_nodoor.xml

@@ -0,0 +1,73 @@
+<single_instance_cd>
+  <!-- "Syntactic"-variant with "Choice" state, modeled as non-stable state -->
+  <delta>1 ms</delta>
+  <statechart>
+    <semantics
+      big_step_maximality="syntactic"
+      input_event_lifeline="whole"
+      same_source_priority="explicit"
+      />
+    <datamodel>
+      time = 0;
+      checkStartTime = func {
+        if (time == 0) time = 30;
+      };
+    </datamodel>
+    <inport name="in">
+      <event name="start"/>
+      <event name="stop"/>
+      <event name="increase_time"/>
+      <event name="door_opened"/>
+      <event name="door_closed"/>
+    </inport>
+    <outport name="out">
+      <event name="micro_on"/>
+      <event name="micro_off"/>
+      <event name="set_time"/>
+      <event name="ping"/>
+    </outport>
+    <root initial="NotRunning">
+      <state id="Running" stable="true">
+        <onentry> <raise port="out" event="micro_on"/> </onentry>
+        <onexit> <raise port="out" event="micro_off"/> </onexit>
+        <transition port="in" event="stop" target="../NotRunning"/>
+        <transition after="1 s" target="../Choice">
+          <code> time -= 1; </code>
+          <raise port="out" event="set_time">
+            <param expr="time"/>
+          </raise>
+        </transition>
+        <transition port="in" event="increase_time" target=".">
+          <code> time += 10; </code>
+            <raise port="out" event="set_time">
+              <param expr="time"/>
+            </raise>
+        </transition>
+      </state>
+      <state id="Choice">
+        <transition cond="time > 0" target="../Running"/>
+        <transition cond="time == 0" target="../NotRunning"/>
+      </state>
+      <state id="NotRunning" stable="true">
+        <transition port="in" event="start" target="../Running">
+          <code> checkStartTime(); </code>
+          <raise port="out" event="set_time">
+            <param expr="time"/>
+          </raise>
+        </transition>
+        <transition port="in" event="stop" target=".">
+          <code> time = 0; </code>
+          <raise port="out" event="set_time">
+            <param expr="time"/>
+          </raise>
+        </transition>
+        <transition port="in" event="increase_time" target=".">
+          <code> time += 10; </code>
+            <raise port="out" event="set_time">
+              <param expr="time"/>
+            </raise>
+        </transition>
+      </state>
+    </root>
+  </statechart>
+</single_instance_cd>

+ 91 - 0
examples/microwave/models/model_01c_flat_nodoor_priorities.svg

@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.40.1 (20161225.0304)
+ -->
+<!-- Title: priorities Pages: 1 -->
+<svg width="912pt" height="188pt"
+ viewBox="0.00 0.00 912.17 188.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 184)">
+<title>priorities</title>
+<polygon fill="#ffffff" stroke="transparent" points="-4,4 -4,-184 908.1719,-184 908.1719,4 -4,4"/>
+<!-- 0. stop / Running&#45;&gt;NotRunning -->
+<g id="node1" class="node">
+<title>0. stop / Running&#45;&gt;NotRunning</title>
+<ellipse fill="none" stroke="#000000" cx="145.5871" cy="-162" rx="124.2781" ry="18"/>
+<text text-anchor="middle" x="145.5871" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">0. stop / Running&#45;&gt;NotRunning</text>
+</g>
+<!-- 1. after(1 s) / Running&#45;&gt;Choice -->
+<g id="node2" class="node">
+<title>1. after(1 s) / Running&#45;&gt;Choice</title>
+<ellipse fill="none" stroke="#000000" cx="145.5871" cy="-90" rx="122.6784" ry="18"/>
+<text text-anchor="middle" x="145.5871" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">1. after(1 s) / Running&#45;&gt;Choice</text>
+</g>
+<!-- 0. stop / Running&#45;&gt;NotRunning&#45;&gt;1. after(1 s) / Running&#45;&gt;Choice -->
+<g id="edge1" class="edge">
+<title>0. stop / Running&#45;&gt;NotRunning&#45;&gt;1. after(1 s) / Running&#45;&gt;Choice</title>
+<path fill="none" stroke="#00ff00" d="M145.5871,-143.8314C145.5871,-136.131 145.5871,-126.9743 145.5871,-118.4166"/>
+<polygon fill="#00ff00" stroke="#00ff00" points="149.0872,-118.4132 145.5871,-108.4133 142.0872,-118.4133 149.0872,-118.4132"/>
+</g>
+<!-- 2. increase_time / Running&#45;&gt;Running -->
+<g id="node3" class="node">
+<title>2. increase_time / Running&#45;&gt;Running</title>
+<ellipse fill="none" stroke="#000000" cx="145.5871" cy="-18" rx="145.6742" ry="18"/>
+<text text-anchor="middle" x="145.5871" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">2. increase_time / Running&#45;&gt;Running</text>
+</g>
+<!-- 1. after(1 s) / Running&#45;&gt;Choice&#45;&gt;2. increase_time / Running&#45;&gt;Running -->
+<g id="edge2" class="edge">
+<title>1. after(1 s) / Running&#45;&gt;Choice&#45;&gt;2. increase_time / Running&#45;&gt;Running</title>
+<path fill="none" stroke="#00ff00" d="M145.5871,-71.8314C145.5871,-64.131 145.5871,-54.9743 145.5871,-46.4166"/>
+<polygon fill="#00ff00" stroke="#00ff00" points="149.0872,-46.4132 145.5871,-36.4133 142.0872,-46.4133 149.0872,-46.4132"/>
+</g>
+<!-- 3. [time &gt; 0] / Choice&#45;&gt;Running -->
+<g id="node4" class="node">
+<title>3. [time &gt; 0] / Choice&#45;&gt;Running</title>
+<ellipse fill="none" stroke="#000000" cx="431.5871" cy="-162" rx="127.2775" ry="18"/>
+<text text-anchor="middle" x="431.5871" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">3. [time &gt; 0] / Choice&#45;&gt;Running</text>
+</g>
+<!-- 4. [time == 0] / Choice&#45;&gt;NotRunning -->
+<g id="node5" class="node">
+<title>4. [time == 0] / Choice&#45;&gt;NotRunning</title>
+<ellipse fill="none" stroke="#000000" cx="431.5871" cy="-90" rx="145.6742" ry="18"/>
+<text text-anchor="middle" x="431.5871" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">4. [time == 0] / Choice&#45;&gt;NotRunning</text>
+</g>
+<!-- 3. [time &gt; 0] / Choice&#45;&gt;Running&#45;&gt;4. [time == 0] / Choice&#45;&gt;NotRunning -->
+<g id="edge3" class="edge">
+<title>3. [time &gt; 0] / Choice&#45;&gt;Running&#45;&gt;4. [time == 0] / Choice&#45;&gt;NotRunning</title>
+<path fill="none" stroke="#00ff00" d="M431.5871,-143.8314C431.5871,-136.131 431.5871,-126.9743 431.5871,-118.4166"/>
+<polygon fill="#00ff00" stroke="#00ff00" points="435.0872,-118.4132 431.5871,-108.4133 428.0872,-118.4133 435.0872,-118.4132"/>
+</g>
+<!-- 5. start / NotRunning&#45;&gt;Running -->
+<g id="node6" class="node">
+<title>5. start / NotRunning&#45;&gt;Running</title>
+<ellipse fill="none" stroke="#000000" cx="732.5871" cy="-162" rx="124.2781" ry="18"/>
+<text text-anchor="middle" x="732.5871" y="-158.3" font-family="Times,serif" font-size="14.00" fill="#000000">5. start / NotRunning&#45;&gt;Running</text>
+</g>
+<!-- 6. stop / NotRunning&#45;&gt;NotRunning -->
+<g id="node7" class="node">
+<title>6. stop / NotRunning&#45;&gt;NotRunning</title>
+<ellipse fill="none" stroke="#000000" cx="732.5871" cy="-90" rx="137.2758" ry="18"/>
+<text text-anchor="middle" x="732.5871" y="-86.3" font-family="Times,serif" font-size="14.00" fill="#000000">6. stop / NotRunning&#45;&gt;NotRunning</text>
+</g>
+<!-- 5. start / NotRunning&#45;&gt;Running&#45;&gt;6. stop / NotRunning&#45;&gt;NotRunning -->
+<g id="edge4" class="edge">
+<title>5. start / NotRunning&#45;&gt;Running&#45;&gt;6. stop / NotRunning&#45;&gt;NotRunning</title>
+<path fill="none" stroke="#00ff00" d="M732.5871,-143.8314C732.5871,-136.131 732.5871,-126.9743 732.5871,-118.4166"/>
+<polygon fill="#00ff00" stroke="#00ff00" points="736.0872,-118.4132 732.5871,-108.4133 729.0872,-118.4133 736.0872,-118.4132"/>
+</g>
+<!-- 7. increase_time / NotRunning&#45;&gt;NotRunning -->
+<g id="node8" class="node">
+<title>7. increase_time / NotRunning&#45;&gt;NotRunning</title>
+<ellipse fill="none" stroke="#000000" cx="732.5871" cy="-18" rx="171.6696" ry="18"/>
+<text text-anchor="middle" x="732.5871" y="-14.3" font-family="Times,serif" font-size="14.00" fill="#000000">7. increase_time / NotRunning&#45;&gt;NotRunning</text>
+</g>
+<!-- 6. stop / NotRunning&#45;&gt;NotRunning&#45;&gt;7. increase_time / NotRunning&#45;&gt;NotRunning -->
+<g id="edge5" class="edge">
+<title>6. stop / NotRunning&#45;&gt;NotRunning&#45;&gt;7. increase_time / NotRunning&#45;&gt;NotRunning</title>
+<path fill="none" stroke="#00ff00" d="M732.5871,-71.8314C732.5871,-64.131 732.5871,-54.9743 732.5871,-46.4166"/>
+<polygon fill="#00ff00" stroke="#00ff00" points="736.0872,-46.4132 732.5871,-36.4133 729.0872,-46.4133 736.0872,-46.4132"/>
+</g>
+</g>
+</svg>

+ 1 - 0
examples/microwave/models/model_02_hierarchical_door.xml

@@ -1,4 +1,5 @@
 <single_instance_cd>
+  <!-- Safety feature extension through hierarchical state: microwave can't be running while door is open -->
   <delta>1 ms</delta>
   <statechart>
     <semantics

+ 1 - 0
examples/microwave/models/model_03_orthogonal.xml

@@ -1,4 +1,5 @@
 <single_instance_cd>
+  <!-- Cleaner implementation of "time increase" with orthogonal regions -->
   <delta>1 ms</delta>
   <statechart>
     <semantics