-
Notifications
You must be signed in to change notification settings - Fork 0
/
machine.scxml
47 lines (44 loc) · 1.39 KB
/
machine.scxml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?xml version="1.0" encoding="UTF-8"?>
<scxml name="MicroWave"
xmlns="http://www.w3.org/2005/07/scxml" version="1.0" datamodel="ecmascript" initial="off">
<datamodel>
<data id="cook_time" expr="5" />
<data id="door_closed" expr="true" />
<data id="timer" expr="0" />
</datamodel>
<state id="off">
<transition event="turn.on" target="on" />
</state>
<state id="on">
<initial>
<transition target="idle" />
</initial>
<!-- on/pause state -->
<transition event="turn.off" target="off" />
<transition cond="timer >= cook_time" target="off" />
<state id="idle">
<!-- default immediate transition if door is shut -->
<transition cond="door_closed" target="cooking" />
<transition event="door.close" target="cooking">
<assign location="door_closed" expr="true" />
<!-- start cooking -->
</transition>
</state>
<state id="cooking">
<onentry>
<script src="entry action"/>
</onentry>
<onexit>
<script src="exit action"/>
</onexit>
<invoke src="timerService"/>
<transition event="door.open" target="idle">
<assign location="door_closed" expr="false" />
</transition>
<!-- a 'time' event is seen once a second -->
<transition event="time">
<assign location="timer" expr="timer + 1" />
</transition>
</state>
</state>
</scxml>