summaryrefslogtreecommitdiff
path: root/server/xml/macros/example.xml
blob: eafcf3341b9927a2b40cc00a77385f8032eb60d4 (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
<?xml version='1.0' encoding='UTF-8'?>
<macro name="example" version="1.0" resume="Axis: ${axis}\nCylinder: ${cyl}\nSphere: ${sphere}\n">
  <queries>
    <query class="lensmeter" ttl="10000" automap="true"/>
  </queries>
  <maps>
    <map name="axis">
      -- LUA program
      return math.pi, 1234567890
    </map>
    <map name="cyl">
      -- Returning 0, 0 invalidates the result
      value = 0
      timestamp = 0

      -- Check for the existence of each level.
      if( lensmeter and
          lensmeter.right and
          lensmeter.right.cyl and
          lensmeter.right.cyl.value and 
          lensmeter.right.cyl.timestamp )
      then
        timestamp = lensmeter.right.cyl.value
        value = lensmeter.right.cyl.value
      end
            
      return value, timestamp
    </map>
  </maps>
  <luaprograms>
    <luaprogram name="theanswer">
      sphere = tonumber(getValue('sphere'))
      axis = tonumber(getValue('axis'))
      if( sphere == axis )
      then
        setValue('cyl', name)
        return true
      else
        return false
      end
    </luaprogram>
  </luaprograms>
  <window name="mainwindow"
          caption="Example Window"
          width="300"
          height="500"
          layout="vbox">
    <frame name="linse_frame" caption="Linser:" layout="vbox">
      <frame name="linse_framea" layout="hbox">
        <label name="a" width="100" caption="Akse rotation:"/>
        <lineedit name="axis" regexp="[24]*" map="axis" lua="theanswer" value="244"/>
      </frame>
      <frame name="linse_frameb" layout="hbox">
        <label name="b" width="100" caption="Sphere:"/>
        <lineedit name="sphere" regexp="[24]*" lua="theanswer" value="42"/>
      </frame>
      <frame name="linse_framec" layout="hbox">
        <label name="c" width="100" caption="Cyl:"/>
        <lineedit name="cyl" regexp="[24]*" map="cyl" value=""/>
      </frame>
    </frame>
    <frame name="linse_frame" caption="FlereLinser:" layout="vbox">
      <multilist name="multilisttest" layout="hbox">
        <items layout="hbox">
          <item value="Pillemigselvinavlen"/>
          <item value="Øffegøj"/>
        </items>
        <input>
          <label name="c" width="100" caption="Cyl2:"/>
          <lineedit name="cyl2" regexp="[24]*" map="cyl" value=""/>
        </input>
      </multilist>
    </frame>
    <frame name="buttons" layout="hbox">
      <button name="cancel" caption="Annuller" action="cancel"/>
      <button name="commit" caption="Godkend" action="commit"/>
    </frame>
  </window>
</macro>