summaryrefslogtreecommitdiffstats
path: root/apps/samples/vrml-server.scxml
blob: e88be4c3cb89f62ac76e10893caa297dd8713a3d (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
<scxml datamodel="ecmascript" name="vrml">
	<script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js" />
	<datamodel>
		<data id="files">
			{
				"foo" : "bar"
			}
		</data>
	</datamodel>
	<parallel id="main">
		<!-- Stop processing if no vrml-path was given on command line -->
		<transition target="final" cond="_x['args']['vrml-path'] == undefined || _x['args']['vrml-path'].length == 0">
			<log expr="'No --vrml-path given'" />
		</transition>
		
		<state id="processHttp">
			<state id="wait">
				<transition event="http" target="wait">
					<script>
						dump(_event);
					</script>
					<response status="200" requestexpr="_event.origin">
						<content expr="files" />
					</response>
				</transition>
			</state>
		</state>
		
		<!-- Stop processing if an error occurred -->
		<transition target="final" event="error">
			<log expr="'An error occured:'" />
			<script>dump(_event);</script>
		</transition>
		
		<!-- Start the osgconvert invoker to transform 3D files -->
		<invoke type="osgconvert" id="osgvonvert.osgb">
			<param name="format" expr="'osgb'" />
			<param name="destDir" expr="_x['args']['vrml-path'] + '/processed'" />
		</invoke>
		
		<!-- Start the directory monitor -->
		<invoke type="dirmon" id="dirmon.vrml">
			<param name="dir" expr="_x['args']['vrml-path']" />
			<param name="recurse" expr="true" />
			<param name="suffix" expr="'.wrl'" />
			<param name="reportExisting" expr="true" />
			<!-- Send every file to the converter -->
			<finalize>
				<send target="#_osgvonvert.osgb" event="convert">
					<param name="file" expr="_event.data.file" />
					<param name="name" expr="_event.data.file.name" />
				</send>
			</finalize>
		</invoke>
		
		<!-- Idle here -->
		<state id="idle">
			<onentry>
				<script>
					dump(_x['args']);
				</script>
			</onentry>
		</state>
	</parallel>
	<state id="final" final="true" />
</scxml>