<?xml version="1.0"?>
<scxml xmlns="http://www.w3.org/2005/07/scxml">
	<script>
		from random import random
	</script>
	<state>
		<initial>
			<transition target="process">
				<send event="pause" delayexpr="str(int(random()*2)+1) + 's'" />
			</transition>
		</initial>
		<state id="process" initial="s1">
			<history id="h" type="shallow">
				<transition target="process" />
			</history>
			
			<state id="s1">
				<onentry>
					<send event="e1" delay="500ms" />
				</onentry>
				<transition target="s2" event="e1" />
			</state>
			
			<state id="s2">
				<onentry>
					<send event="e2" delay="500ms" />
				</onentry>
				<transition event="e2" target="s1" />
			</state>
			<transition event="pause" target="interrupted" />
		</state>
	
		<state id="interrupted">
			<onentry>
				<raise event="resume"/>
			</onentry>
			<transition event="resume" target="h" />
			<onexit>
				<send event="terminate" delay="500ms" />
			</onexit>
		</state>

		<transition event="terminate" target="terminated" />
	</state>

	<final id="terminated" />
</scxml>

