Showing 5 changed files with 158 additions and 67 deletions
+6 -42
Nasal/core.nas
... ...
@@ -27,62 +27,26 @@ data = { # set of data common to all devices
27 27
     },
28 28
 };
29 29
 
30
-# les listeners triggent en permanence sur les fréquences...
31 30
 var setListeners = func {
32 31
     setlistener('/instrumentation/nav/nav-id',
33 32
             func (n) {
34 33
                 var val = n.getValue();
35 34
                 foreach (var c; keys(flightdeck))
36
-                    if (flightdeck[c] != nil)
37
-                        flightdeck[c].display.updateNAV({'nav-id': 1, val: val});
35
+                    flightdeck[c].display.updateNAV({'nav-id': 1, val: val});
38 36
             }, 1, 2);
39 37
     setlistener('/instrumentation/nav[1]/nav-id',
40 38
             func (n) {
41 39
                 var val = n.getValue();
42 40
                 foreach (var c; keys(flightdeck))
43
-                    if (flightdeck[c] != nil)
44
-                        flightdeck[c].display.updateNAV({'nav-id': 2, val: val});
41
+                    flightdeck[c].display.updateNAV({'nav-id': 2, val: val});
45 42
             }, 1, 2);
46
-    setlistener('/instrumentation/zkv1000/radios/nav-tune',
47
-            func (n) {
48
-                var val = n.getValue();
49
-                setNavTune();
50
-                foreach (var c; keys(flightdeck))
51
-                    if (flightdeck[c] != nil)
52
-                        flightdeck[c].display.updateNAV({tune: val});
53
-            }, 1, 2);
54
-    setlistener('/instrumentation/zkv1000/radios/comm-tune',
55
-            func (n) {
56
-                var val = n.getValue();
57
-                setCommTune();
58
-                foreach (var c; keys(flightdeck))
59
-                    if (flightdeck[c] != nil)
60
-                        flightdeck[c].display.updateCOMM({tune: val});
61
-            }, 1, 2);
62
-    setlistener('/instrumentation/zkv1000/afcs/heading-bug-deg',
63
-            func (n) {
64
-                var val = n.getValue();
65
-                if (val != nil) {
66
-                    foreach (var c; keys(flightdeck))
67
-                        if (flightdeck[c] != nil and flightdeck[c].role == 'PFD')
68
-                            flightdeck[c].display.updateHDG(val);
69
-                }
70
-            }, 0, 2);
71
-    setlistener('/instrumentation/zkv1000/PFD/knobs/CRS',
72
-            func (n) {
73
-                var val = n.getValue();
74
-                if (val != nil) {
75
-                    foreach (var c; keys(flightdeck))
76
-                        if (flightdeck[c] != nil and flightdeck[c].role == 'PFD')
77
-                            flightdeck[c].display.updateCRS();
78
-                }
79
-            }, 0, 2);
43
+   # keep this listener as long as the code is to heavy to be modified in multiple places
80 44
     setlistener('/instrumentation/zkv1000/afcs/selected-alt-ft',
81 45
             func (n) {
82 46
                 var val = n.getValue();
83 47
                 if (val != nil)
84 48
                     foreach (var c; keys(flightdeck))
85
-                        if (flightdeck[c] != nil and flightdeck[c].role == 'PFD') {
49
+                        if (flightdeck[c].role == 'PFD') {
86 50
                             if (! flightdeck[c].display.screenElements['SelectedALT'].getVisible()) {
87 51
                                 flightdeck[c].display.screenElements['SelectedALT'].show();
88 52
                                 flightdeck[c].display.screenElements['SelectedALT-text'].show();
... ...
@@ -95,12 +59,12 @@ var setListeners = func {
95 59
             }, 0, 2);
96 60
     setlistener('/gear/gear/wow',
97 61
             func foreach (var c; keys(flightdeck))
98
-                if (flightdeck[c] != nil and flightdeck[c].role == 'PFD')
62
+                if (flightdeck[c].role == 'PFD')
99 63
                     flightdeck[c].display.updateXPDR(),
100 64
             0, 0);
101 65
     setlistener('/instrumentation/altimeter/setting-inhg',
102 66
             func foreach (var c; keys(flightdeck))
103
-                if (flightdeck[c] != nil and flightdeck[c].role == 'PFD')
67
+                if (flightdeck[c].role == 'PFD')
104 68
                     flightdeck[c].display.updateBARO(), 0, 2);
105 69
 }
106 70
 
+2 -1
Nasal/display.nas
... ...
@@ -727,10 +727,11 @@ var displayClass = {
727 727
     },
728 728
 #}}}
729 729
 
730
-    updateHDG : func (hdg) {
730
+    updateHDG : func () {
731 731
 # moves the heading bug and display heading-deg for 3 seconds (PFD) {{{
732 732
         if (me.role == 'MFD')
733 733
             return;
734
+        var hdg = getprop('/instrumentation/zkv1000/afcs/heading-bug-deg');
734 735
         me.screenElements['Heading-bug']
735 736
             .setRotation(hdg * D2R);
736 737
         me.screenElements['SelectedHDG-bg']
+50 -8
pfd-copilot.xml
... ...
@@ -221,6 +221,18 @@
221 221
         <command>property-toggle</command>
222 222
         <property>/instrumentation/zkv1000/radios/nav-tune</property>
223 223
       </binding>
224
+      <binding>
225
+        <condition>
226
+          <property>/instrumentation/zkv1000/PFD-copilot/status</property>
227
+        </condition>
228
+       <command>nasal</command>
229
+        <script>
230
+          zkv1000.setNavTune();
231
+          var n = getprop('/instrumentation/zkv1000/radios/nav-tune');
232
+          foreach (var c; keys(zkv1000.flightdeck))
233
+            zkv1000.flightdeck[c].display.updateNAV({tune:n});
234
+        </script>
235
+      </binding>
224 236
     </action>
225 237
   </animation>
226 238
   <animation>
... ...
@@ -245,8 +257,7 @@
245 257
         <command>nasal</command>
246 258
         <script>
247 259
           foreach (var c; keys(zkv1000.flightdeck))
248
-            if (zkv1000.flightdeck[c] != nil)
249
-              zkv1000.flightdeck[c].display.updateNAV({set:1});
260
+            zkv1000.flightdeck[c].display.updateNAV({set:1});
250 261
         </script>
251 262
       </binding>
252 263
     </action>
... ...
@@ -266,8 +277,7 @@
266 277
         <command>nasal</command>
267 278
         <script>
268 279
           foreach (var c; keys(zkv1000.flightdeck))
269
-            if (zkv1000.flightdeck[c] != nil)
270
-              zkv1000.flightdeck[c].display.updateNAV({set:1});
280
+            zkv1000.flightdeck[c].display.updateNAV({set:1});
271 281
         </script>
272 282
       </binding>
273 283
     </shift-action>
... ...
@@ -322,6 +332,17 @@
322 332
        <max>359</max>
323 333
        <wrap>true</wrap>
324 334
       </binding>
335
+      <binding>
336
+        <condition>
337
+          <property>/instrumentation/zkv1000/PFD-copilot/status</property>
338
+        </condition>
339
+        <command>nasal</command>
340
+        <script>
341
+          foreach (var c; keys(zkv1000.flightdeck))
342
+            if (zkv1000.flightdeck[c].role == 'PFD')
343
+              zkv1000.flightdeck[c].display.updateHDG();
344
+        </script>
345
+      </binding>
325 346
     </action>
326 347
   </animation>
327 348
 
... ...
@@ -435,6 +456,18 @@
435 456
         <command>property-toggle</command>
436 457
         <property>/instrumentation/zkv1000/radios/comm-tune</property>
437 458
       </binding>
459
+      <binding>
460
+        <condition>
461
+          <property>/instrumentation/zkv1000/PFD-copilot/status</property>
462
+        </condition>
463
+       <command>nasal</command>
464
+        <script>
465
+          zkv1000.setCommTune();
466
+          var n = getprop('/instrumentation/zkv1000/radios/comm-tune');
467
+          foreach (var c; keys(zkv1000.flightdeck))
468
+            zkv1000.flightdeck[c].display.updateCOMM({tune:n});
469
+        </script>
470
+      </binding>
438 471
     </action>
439 472
   </animation>
440 473
   <animation>
... ...
@@ -459,8 +492,7 @@
459 492
         <command>nasal</command>
460 493
         <script>
461 494
           foreach (var c; keys(zkv1000.flightdeck))
462
-            if (zkv1000.flightdeck[c] != nil)
463
-              zkv1000.flightdeck[c].display.updateCOMM({set:1});
495
+            zkv1000.flightdeck[c].display.updateCOMM({set:1});
464 496
         </script>
465 497
       </binding>
466 498
     </action>
... ...
@@ -480,8 +512,7 @@
480 512
         <command>nasal</command>
481 513
         <script>
482 514
           foreach (var c; keys(zkv1000.flightdeck))
483
-            if (zkv1000.flightdeck[c] != nil)
484
-              zkv1000.flightdeck[c].display.updateCOMM({set:1});
515
+            zkv1000.flightdeck[c].display.updateCOMM({set:1});
485 516
         </script>
486 517
       </binding>
487 518
     </shift-action>
... ...
@@ -521,6 +552,17 @@
521 552
         <max>359</max>
522 553
         <wrap>true</wrap>
523 554
       </binding>
555
+      <binding>
556
+        <condition>
557
+          <property>/instrumentation/zkv1000/PFD-copilot/status</property>
558
+        </condition>
559
+        <command>nasal</command>
560
+        <script>
561
+          foreach (var c; keys(zkv1000.flightdeck))
562
+            if (zkv1000.flightdeck[c].role == 'PFD')
563
+              flightdeck[c].display.updateCRS();
564
+        </script>
565
+      </binding>
524 566
     </action>
525 567
   </animation>
526 568
 
+50 -8
pfd-pilot.xml
... ...
@@ -221,6 +221,18 @@
221 221
         <command>property-toggle</command>
222 222
         <property>/instrumentation/zkv1000/radios/nav-tune</property>
223 223
       </binding>
224
+      <binding>
225
+        <condition>
226
+          <property>/instrumentation/zkv1000/PFD-pilot/status</property>
227
+        </condition>
228
+       <command>nasal</command>
229
+        <script>
230
+          zkv1000.setNavTune();
231
+          var n = getprop('/instrumentation/zkv1000/radios/nav-tune');
232
+          foreach (var c; keys(zkv1000.flightdeck))
233
+            zkv1000.flightdeck[c].display.updateNAV({tune:n});
234
+        </script>
235
+      </binding>
224 236
     </action>
225 237
   </animation>
226 238
   <animation>
... ...
@@ -245,8 +257,7 @@
245 257
         <command>nasal</command>
246 258
         <script>
247 259
           foreach (var c; keys(zkv1000.flightdeck))
248
-            if (zkv1000.flightdeck[c] != nil)
249
-              zkv1000.flightdeck[c].display.updateNAV({set:1});
260
+            zkv1000.flightdeck[c].display.updateNAV({set:1});
250 261
         </script>
251 262
       </binding>
252 263
     </action>
... ...
@@ -266,8 +277,7 @@
266 277
         <command>nasal</command>
267 278
         <script>
268 279
           foreach (var c; keys(zkv1000.flightdeck))
269
-            if (zkv1000.flightdeck[c] != nil)
270
-              zkv1000.flightdeck[c].display.updateNAV({set:1});
280
+            zkv1000.flightdeck[c].display.updateNAV({set:1});
271 281
         </script>
272 282
       </binding>
273 283
     </shift-action>
... ...
@@ -322,6 +332,17 @@
322 332
        <max>359</max>
323 333
        <wrap>true</wrap>
324 334
       </binding>
335
+      <binding>
336
+        <condition>
337
+          <property>/instrumentation/zkv1000/PFD-pilot/status</property>
338
+        </condition>
339
+        <command>nasal</command>
340
+        <script>
341
+          foreach (var c; keys(zkv1000.flightdeck))
342
+            if (zkv1000.flightdeck[c].role == 'PFD')
343
+              zkv1000.flightdeck[c].display.updateHDG();
344
+        </script>
345
+      </binding>
325 346
     </action>
326 347
   </animation>
327 348
 
... ...
@@ -435,6 +456,18 @@
435 456
         <command>property-toggle</command>
436 457
         <property>/instrumentation/zkv1000/radios/comm-tune</property>
437 458
       </binding>
459
+      <binding>
460
+        <condition>
461
+          <property>/instrumentation/zkv1000/PFD-pilot/status</property>
462
+        </condition>
463
+       <command>nasal</command>
464
+        <script>
465
+          zkv1000.setCommTune();
466
+          var n = getprop('/instrumentation/zkv1000/radios/comm-tune');
467
+          foreach (var c; keys(zkv1000.flightdeck))
468
+            zkv1000.flightdeck[c].display.updateCOMM({tune:n});
469
+        </script>
470
+      </binding>
438 471
     </action>
439 472
   </animation>
440 473
   <animation>
... ...
@@ -459,8 +492,7 @@
459 492
         <command>nasal</command>
460 493
         <script>
461 494
           foreach (var c; keys(zkv1000.flightdeck))
462
-            if (zkv1000.flightdeck[c] != nil)
463
-              zkv1000.flightdeck[c].display.updateCOMM({set:1});
495
+            zkv1000.flightdeck[c].display.updateCOMM({set:1});
464 496
         </script>
465 497
       </binding>
466 498
     </action>
... ...
@@ -480,8 +512,7 @@
480 512
         <command>nasal</command>
481 513
         <script>
482 514
           foreach (var c; keys(zkv1000.flightdeck))
483
-            if (zkv1000.flightdeck[c] != nil)
484
-              zkv1000.flightdeck[c].display.updateCOMM({set:1});
515
+            zkv1000.flightdeck[c].display.updateCOMM({set:1});
485 516
         </script>
486 517
       </binding>
487 518
     </shift-action>
... ...
@@ -521,6 +552,17 @@
521 552
         <max>359</max>
522 553
         <wrap>true</wrap>
523 554
       </binding>
555
+      <binding>
556
+        <condition>
557
+          <property>/instrumentation/zkv1000/PFD-pilot/status</property>
558
+        </condition>
559
+        <command>nasal</command>
560
+        <script>
561
+          foreach (var c; keys(zkv1000.flightdeck))
562
+            if (zkv1000.flightdeck[c].role == 'PFD')
563
+              flightdeck[c].display.updateCRS();
564
+        </script>
565
+      </binding>
524 566
     </action>
525 567
   </animation>
526 568
 
+50 -8
pfd.xml
... ...
@@ -221,6 +221,18 @@
221 221
         <command>property-toggle</command>
222 222
         <property>/instrumentation/zkv1000/radios/nav-tune</property>
223 223
       </binding>
224
+      <binding>
225
+        <condition>
226
+          <property>/instrumentation/zkv1000/PFD/status</property>
227
+        </condition>
228
+       <command>nasal</command>
229
+        <script>
230
+          zkv1000.setNavTune();
231
+          var n = getprop('/instrumentation/zkv1000/radios/nav-tune');
232
+          foreach (var c; keys(zkv1000.flightdeck))
233
+            zkv1000.flightdeck[c].display.updateNAV({tune:n});
234
+        </script>
235
+      </binding>
224 236
     </action>
225 237
   </animation>
226 238
   <animation>
... ...
@@ -245,8 +257,7 @@
245 257
         <command>nasal</command>
246 258
         <script>
247 259
           foreach (var c; keys(zkv1000.flightdeck))
248
-            if (zkv1000.flightdeck[c] != nil)
249
-              zkv1000.flightdeck[c].display.updateNAV({set:1});
260
+            zkv1000.flightdeck[c].display.updateNAV({set:1});
250 261
         </script>
251 262
       </binding>
252 263
     </action>
... ...
@@ -266,8 +277,7 @@
266 277
         <command>nasal</command>
267 278
         <script>
268 279
           foreach (var c; keys(zkv1000.flightdeck))
269
-            if (zkv1000.flightdeck[c] != nil)
270
-              zkv1000.flightdeck[c].display.updateNAV({set:1});
280
+            zkv1000.flightdeck[c].display.updateNAV({set:1});
271 281
         </script>
272 282
       </binding>
273 283
     </shift-action>
... ...
@@ -322,6 +332,17 @@
322 332
        <max>359</max>
323 333
        <wrap>true</wrap>
324 334
       </binding>
335
+      <binding>
336
+        <condition>
337
+          <property>/instrumentation/zkv1000/PFD/status</property>
338
+        </condition>
339
+        <command>nasal</command>
340
+        <script>
341
+          foreach (var c; keys(zkv1000.flightdeck))
342
+            if (zkv1000.flightdeck[c].role == 'PFD')
343
+              zkv1000.flightdeck[c].display.updateHDG();
344
+        </script>
345
+      </binding>
325 346
     </action>
326 347
   </animation>
327 348
 
... ...
@@ -435,6 +456,18 @@
435 456
         <command>property-toggle</command>
436 457
         <property>/instrumentation/zkv1000/radios/comm-tune</property>
437 458
       </binding>
459
+      <binding>
460
+        <condition>
461
+          <property>/instrumentation/zkv1000/PFD/status</property>
462
+        </condition>
463
+       <command>nasal</command>
464
+        <script>
465
+          zkv1000.setCommTune();
466
+          var n = getprop('/instrumentation/zkv1000/radios/comm-tune');
467
+          foreach (var c; keys(zkv1000.flightdeck))
468
+            zkv1000.flightdeck[c].display.updateCOMM({tune:n});
469
+        </script>
470
+      </binding>
438 471
     </action>
439 472
   </animation>
440 473
   <animation>
... ...
@@ -459,8 +492,7 @@
459 492
         <command>nasal</command>
460 493
         <script>
461 494
           foreach (var c; keys(zkv1000.flightdeck))
462
-            if (zkv1000.flightdeck[c] != nil)
463
-              zkv1000.flightdeck[c].display.updateCOMM({set:1});
495
+            zkv1000.flightdeck[c].display.updateCOMM({set:1});
464 496
         </script>
465 497
       </binding>
466 498
     </action>
... ...
@@ -480,8 +512,7 @@
480 512
         <command>nasal</command>
481 513
         <script>
482 514
           foreach (var c; keys(zkv1000.flightdeck))
483
-            if (zkv1000.flightdeck[c] != nil)
484
-              zkv1000.flightdeck[c].display.updateCOMM({set:1});
515
+            zkv1000.flightdeck[c].display.updateCOMM({set:1});
485 516
         </script>
486 517
       </binding>
487 518
     </shift-action>
... ...
@@ -521,6 +552,17 @@
521 552
         <max>359</max>
522 553
         <wrap>true</wrap>
523 554
       </binding>
555
+      <binding>
556
+        <condition>
557
+          <property>/instrumentation/zkv1000/PFD/status</property>
558
+        </condition>
559
+        <command>nasal</command>
560
+        <script>
561
+          foreach (var c; keys(zkv1000.flightdeck))
562
+            if (zkv1000.flightdeck[c].role == 'PFD')
563
+              flightdeck[c].display.updateCRS();
564
+        </script>
565
+      </binding>
524 566
     </action>
525 567
   </animation>
526 568