... | ... |
@@ -1,6 +1,35 @@ |
1 | 1 |
var PFD = nil; |
2 | 2 |
var MFD = nil; |
3 | 3 |
|
4 |
+data = { # set of data common to all devices |
|
5 |
+ roll : 0, |
|
6 |
+ pitch : 0, |
|
7 |
+ vsi : 0, |
|
8 |
+ ias : 0, |
|
9 |
+ alt : 0, |
|
10 |
+ hdg : 0, |
|
11 |
+ wow : 1, |
|
12 |
+ timers : { |
|
13 |
+ '20Hz': maketimer ( |
|
14 |
+ 0.05, |
|
15 |
+ func { |
|
16 |
+ data.roll = getprop('/orientation/roll-deg'); |
|
17 |
+ data.pitch = getprop('orientation/pitch-deg'); |
|
18 |
+ data.vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm'); |
|
19 |
+ data.ias = getprop('/velocities/airspeed-kt'); |
|
20 |
+ data.alt = getprop('/instrumentation/altimeter/indicated-altitude-ft'); |
|
21 |
+ data.hdg = getprop('/orientation/heading-deg'); |
|
22 |
+ } |
|
23 |
+ ), |
|
24 |
+ '1Hz': maketimer ( |
|
25 |
+ 1, |
|
26 |
+ func { |
|
27 |
+ data.wow = getprop('/gear/gear/wow'); |
|
28 |
+ } |
|
29 |
+ ), |
|
30 |
+ }, |
|
31 |
+}; |
|
32 |
+ |
|
4 | 33 |
# les listeners triggent en permanence sur les fréquences... |
5 | 34 |
var setListeners = func { |
6 | 35 |
setlistener('/instrumentation/nav/nav-id', |
... | ... |
@@ -195,9 +195,10 @@ var displayClass = { |
195 | 195 |
|
196 | 196 |
me.loadGroup(groups); |
197 | 197 |
|
198 |
+ foreach (var freq; keys(data.timers)) |
|
199 |
+ data.timers[freq].start(); |
|
200 |
+ |
|
198 | 201 |
if (me.role == 'PFD') { |
199 |
- me.update20Hz(); |
|
200 |
- me.update1Hz(); |
|
201 | 202 |
me.updateAI(); |
202 | 203 |
me.updateVSI(); |
203 | 204 |
me.updateIAS(); |
... | ... |
@@ -452,36 +453,10 @@ var displayClass = { |
452 | 453 |
}, |
453 | 454 |
#}}} |
454 | 455 |
|
455 |
- update20Hz : func { |
|
456 |
-# 20Hz updates roll, pitch, VSI, IAS, altitude and HDG {{{ |
|
457 |
- me._updated_roll = getprop('/orientation/roll-deg'); |
|
458 |
- me._updated_pitch = getprop('orientation/pitch-deg'); |
|
459 |
- me._updated_vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm'); |
|
460 |
- me._updated_ias = getprop('/velocities/airspeed-kt'); |
|
461 |
- me._updated_alt = getprop('/instrumentation/altimeter/indicated-altitude-ft'); |
|
462 |
- me._updated_hdg = getprop('/orientation/heading-deg'); |
|
463 |
- settimer(func me.update20Hz(), 0.05); |
|
464 |
- }, |
|
465 |
- _updated_roll : 0, |
|
466 |
- _updated_pitch : 0, |
|
467 |
- _updated_vsi : 0, |
|
468 |
- _updated_ias : 0, |
|
469 |
- _updated_alt : 0, |
|
470 |
- _updated_hdg : 0, |
|
471 |
-#}}} |
|
472 |
- |
|
473 |
- update1Hz : func { |
|
474 |
-# 1Hz updates {{{ |
|
475 |
- me._updated_wow = getprop('/gear/gear/wow'); |
|
476 |
- settimer(func me.update20Hz(), 1); |
|
477 |
- }, |
|
478 |
- _updated_wow : 1, |
|
479 |
-#}}} |
|
480 |
- |
|
481 | 456 |
updateAI: func(){ |
482 | 457 |
#{{{ |
483 |
- var pitch = me._updated_pitch; |
|
484 |
- var roll = me._updated_roll; |
|
458 |
+ var pitch = data.pitch; |
|
459 |
+ var roll = data.roll; |
|
485 | 460 |
if (pitch > 80) |
486 | 461 |
pitch = 80; |
487 | 462 |
elsif (pitch < -80) |
... | ... |
@@ -500,7 +475,7 @@ var displayClass = { |
500 | 475 |
|
501 | 476 |
updateVSI: func () { |
502 | 477 |
# animate VSI {{{ |
503 |
- var vsi = me._updated_vsi; |
|
478 |
+ var vsi = data.vsi; |
|
504 | 479 |
me.screenElements.VSIText |
505 | 480 |
.setText(num(math.round(vsi, 10))); |
506 | 481 |
if (vsi > 4500) |
... | ... |
@@ -515,7 +490,7 @@ var displayClass = { |
515 | 490 |
|
516 | 491 |
updateIAS: func () { |
517 | 492 |
# animates the IAS lint (PFD) {{{ |
518 |
- var ias = me._updated_ias; |
|
493 |
+ var ias = data.ias; |
|
519 | 494 |
if (ias >= 10) |
520 | 495 |
me.screenElements.Speed110 |
521 | 496 |
.setText(sprintf("% 2u",num(math.floor(ias/10)))); |
... | ... |
@@ -575,7 +550,7 @@ var displayClass = { |
575 | 550 |
|
576 | 551 |
updateALT: func () { |
577 | 552 |
# animates the altitude lint (PFD) {{{ |
578 |
- var alt = me._updated_alt; |
|
553 |
+ var alt = data.alt; |
|
579 | 554 |
if (alt < 0) |
580 | 555 |
me.screenElements.Alt11100 |
581 | 556 |
.setText(sprintf("% 3i",math.ceil(alt/100))); |
... | ... |
@@ -743,7 +718,7 @@ var displayClass = { |
743 | 718 |
|
744 | 719 |
updateHSI : func () { |
745 | 720 |
# rotates the compass (PFD) {{{ |
746 |
- var hdg = me._updated_hdg; |
|
721 |
+ var hdg = data.hdg; |
|
747 | 722 |
me.screenElements.Rose |
748 | 723 |
.setRotation(-hdg * D2R); |
749 | 724 |
me.screenElements['HDG-text'] |
... | ... |
@@ -796,7 +771,7 @@ var displayClass = { |
796 | 771 |
if (! PFD.display.screenElements['SelectedALT'].getVisible()) |
797 | 772 |
return; |
798 | 773 |
var selected_alt = getprop('/instrumentation/zkv1000/afcs/selected-alt-ft'); |
799 |
- var delta_alt = me._updated_alt - selected_alt; |
|
774 |
+ var delta_alt = data.alt - selected_alt; |
|
800 | 775 |
if (abs(delta_alt) > 300) |
801 | 776 |
delta_alt = 300 * abs(delta_alt)/delta_alt; |
802 | 777 |
me.screenElements['SelectedALT-symbol'] |
... | ... |
@@ -825,7 +800,7 @@ var displayClass = { |
825 | 800 |
} |
826 | 801 |
else { |
827 | 802 |
var course = getprop('/instrumentation/zkv1000/cdi/course'); |
828 |
- var rot = (course - me._updated_hdg) * D2R; |
|
803 |
+ var rot = (course - data.hdg) * D2R; |
|
829 | 804 |
me.screenElements['CDI'] |
830 | 805 |
.setRotation(rot) |
831 | 806 |
.show(); |
... | ... |
@@ -1037,12 +1012,12 @@ var displayClass = { |
1037 | 1012 |
# update the window text and arrows for OPTN1/2 {{{ |
1038 | 1013 |
if (me._winddata_optn == 0) |
1039 | 1014 |
return; |
1040 |
- if (me._updated_ias < 30) { |
|
1015 |
+ if (data.ias < 30) { |
|
1041 | 1016 |
me.screenElements['WindData-NODATA'] |
1042 | 1017 |
.hide(); |
1043 | 1018 |
var wind_hdg = getprop('/environment/wind-from-heading-deg'); |
1044 | 1019 |
var wind_spd = getprop('/environment/wind-speed-kt'); |
1045 |
- var alpha = wind_hdg - me._updated_hdg; |
|
1020 |
+ var alpha = wind_hdg - data.hdg; |
|
1046 | 1021 |
if (me._winddata_optn == 1) { |
1047 | 1022 |
me.screenElements['WindData-OPTN1-HDG'] |
1048 | 1023 |
.setRotation((alpha + 180) * D2R) |
... | ... |
@@ -1140,7 +1115,7 @@ var displayClass = { |
1140 | 1115 |
|
1141 | 1116 |
if (info.pointer) |
1142 | 1117 |
me.screenElements[el ~ '-pointer'] |
1143 |
- .setRotation(-info.hdg-me._updated_hdg * D2R) |
|
1118 |
+ .setRotation(-info.hdg - data.hdg * D2R) |
|
1144 | 1119 |
.show(); |
1145 | 1120 |
else |
1146 | 1121 |
me.screenElements[el ~ '-pointer'] |