Showing 2 changed files with 16 additions and 6 deletions
+15 -6
Nasal/core.nas
... ...
@@ -1,18 +1,23 @@
1 1
 var setListeners = func {
2
-    setlistener('/instrumentation/nav/nav-id',
2
+    var prop = '/instrumentation/nav/nav-id';
3
+    data.listeners[prop] = setlistener(prop,
3 4
             func (n) {
4 5
                 var val = n.getValue();
5 6
                 foreach (var c; keys(flightdeck))
6 7
                     flightdeck[c].display.updateNAV({'nav-id': 1, val: val});
7 8
             }, 1, 2);
8
-    setlistener('/instrumentation/nav[1]/nav-id',
9
+
10
+    prop = '/instrumentation/nav[1]/nav-id';
11
+    data.listeners[prop] = setlistener(prop,
9 12
             func (n) {
10 13
                 var val = n.getValue();
11 14
                 foreach (var c; keys(flightdeck))
12 15
                     flightdeck[c].display.updateNAV({'nav-id': 2, val: val});
13 16
             }, 1, 2);
14
-   # keep this listener as long as the code is to heavy to be modified in multiple places
15
-    setlistener('/instrumentation/zkv1000/afcs/selected-alt-ft',
17
+
18
+    # keep this listener as long as the code is to heavy to be modified in multiple places
19
+    prop = '/instrumentation/zkv1000/afcs/selected-alt-ft';
20
+    data.listeners[prop] = setlistener(prop,
16 21
             func (n) {
17 22
                 var val = n.getValue();
18 23
                 if (val != nil)
... ...
@@ -28,12 +33,16 @@ var setListeners = func {
28 33
                             flightdeck[c].display.updateSelectedALT();
29 34
                         }
30 35
             }, 0, 2);
31
-    setlistener('/gear/gear/wow',
36
+
37
+    prop = '/gear/gear/wow';
38
+    data.listeners[prop] = setlistener(prop,
32 39
             func foreach (var c; keys(flightdeck))
33 40
                 if (flightdeck[c].role == 'PFD')
34 41
                     flightdeck[c].display.updateXPDR(),
35 42
             0, 0);
36
-    setlistener('/instrumentation/altimeter/setting-inhg',
43
+
44
+    prop = '/instrumentation/altimeter/setting-inhg';
45
+    data.listeners[prop] = setlistener(prop,
37 46
             func foreach (var c; keys(flightdeck))
38 47
                 if (flightdeck[c].role == 'PFD')
39 48
                     flightdeck[c].display.updateBARO(), 0, 2);
+1
zkv1000.nas
... ...
@@ -53,6 +53,7 @@ var data = { # set of data common to all devices
53 53
             }
54 54
         ),
55 55
     },
56
+    listeners : {},
56 57
 };
57 58
 
58 59
 var zkv = cdi = radios = alerts = infos = cursors = afcs = eis = nil;