blob: f48008c54c1f0e1e2a714bbffbe6376a676b4460 (
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
79
80
81
82
83
84
85
86
87
88
89
|
<scxml datamodel="ecmascript" name="vrml">
<script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js" />
<script>
var files = {};
</script>
<state 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>
<!-- Stop processing if an error occurred -->
<transition target="final" event="error">
<log expr="'An error occured:'" />
<script>dump(_event);</script>
</transition>
<!-- 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" />
<!-- Remember every file -->
<finalize>
<script>
dump(_event);
// use filename without directory as the key
var key = _event.data.file.name.substr(_event.data.file.dir.length + 1);
files[key] = _event.data;
</script>
</finalize>
</invoke>
<!-- Start the osgconvert invoker to transform 3D files -->
<invoke type="osgconvert" id="osgvonvert.osgb">
<param name="threads" expr="2" />
</invoke>
<!-- Idle here -->
<state id="idle">
<!-- request for a specific format -->
<transition event="http" target="idle" cond="
_event.data.pathComponent.length == 3 &&
_event.data.pathComponent[0] == 'vrml' &&
_event.data.pathComponent[1] in files">
<script>dump(_event);</script>
<if cond="_event.data.pathComponent[2] in files[_event.data.pathComponent[1]]">
<response status="200" requestexpr="_event.origin">
<content expr="files[_event.data.pathComponent[1]][_event.data.pathComponent[2]]" />
</response>
<else>
<send target="#_osgvonvert.osgb">
<param name="source" expr="files[_event.data.pathComponent[1]].path" />
<param name="dest" expr="files[_event.data.pathComponent[1]].path + '.png'" />
<param name="format" expr="'png'" />
</send>
<postpone until="_event.data.pathComponent[2] in files[_event.data.pathComponent[1]]" />
</else>
</if>
</transition>
<!-- request for info on a special file -->
<transition event="http" target="idle" cond="
_event.data.pathComponent.length == 2 &&
_event.data.pathComponent[0] == 'vrml' &&
_event.data.pathComponent[1] in files">
<script>dump(_event);</script>
<response status="200" requestexpr="_event.origin">
<content expr="files[_event.data.pathComponent[1]]" />
</response>
</transition>
<!-- request for topmost list of all files -->
<transition event="http" target="idle" cond="
_event.data.pathComponent.length == 1 &&
_event.data.pathComponent[0] == 'vrml'
">
<script>dump(_event);</script>
<response status="200" requestexpr="_event.origin">
<content expr="files" />
</response>
</transition>
</state>
</state>
<state id="final" final="true" />
</scxml>
|