summaryrefslogtreecommitdiffstats
path: root/test/samples/uscxml/applications/spoken-map-ticker.scxml
blob: 5a1c0b2d05329f19645e54076c0856902814bad4 (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<scxml datamodel="ecmascript" name="mapticker"
	xmlns:html="http://www.w3.org/1999/xhtml"
  xmlns:vxml="http://www.w3.org/2001/vxml" 
	xmlns="http://www.w3.org/2005/07/scxml">

	<script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js" />

	<state id="start">
		<!--
			Invoke an external HTML browser
		-->
		<invoke type="xhtml" id="xhtml1">
			<content src="spoken-map-ticker.xhtml" />
			<finalize>
				<!-- <script>dump(_event);</script> -->
			</finalize>
		</invoke>
		
		<!--
			Invoke a VoiceXML browser
		-->
		<invoke type="vxml" id="vxml" />
		
		<!--
			Invoke a uMundo component for pub/sub ticker subscription
		-->
		<invoke type="umundo" id="umundo">
			<param name="channel" expr="'map/tick'" />
			<finalize>
				<!-- <script>dump(_event);</script> -->
			</finalize>
		</invoke>
		
		<invoke type="openal" id="audio"></invoke>
		
		<state id="idle">
			<!--
				Map in XHTML invoker was moved -> update OpenAL listener position
			-->
			<transition event="map.center" target="idle">
				<send event="move.listener" target="#_audio">
					<param name="x" expr="_event.data.lon" />
					<param name="y" expr="1" />
					<param name="z" expr="_event.data.lat" />
				</send>
			</transition>

			<!--
				Ticker message was received
				-> Send to XHTML invoker to display
				-> Play clicking noise from respective direction
				-> Speak content if severity exceeds a given threshold
			-->
			<transition target="idle" event="umundo.rcvd">
				<send target="#_xhtml1">
					<content>${_event.data}</content>
				</send>
				<send target="#_audio" event="play" delay="0ms">
					<param name="src" expr="'click.wav'" />
					<param name="x" expr="_event.data.lon" />
					<param name="y" expr="0" />
					<param name="z" expr="_event.data.lat" />
				</send>

				<if cond="_event.data.message &amp;&amp; _event.data.severity &gt; 8">
					<send target="#_vxml">
						<content>
							<vxml:prompt>
								${_event.data.message}
							</vxml:prompt>
						</content>
					</send>
				</if>
				
			</transition>
		</state>		
	</state>
</scxml>