helionix_mfd_control.nas 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. # mfd.nas to drive gauges of the VMD MFD #
  2. ### Eucopter MFD panel control class ###
  3. # Bezel Button Numbers
  4. # 2 3 4 5 6 7
  5. #[1]<pwr
  6. # 25 8
  7. # 24 9
  8. # 23 10
  9. # 22 11
  10. # 21 12
  11. # 20 13
  12. # 19 18 17 16 15 14
  13. var EUcoptermfd = {
  14. new: func(i) {
  15. var m = { parents: [Timerloop.new(), EUcoptermfd] };
  16. m.id = i;
  17. m.idx = 0;
  18. m.pwr_state = 0;
  19. #split the modes list
  20. m.list = split(",", getprop("/instrumentation/mfd["~i~"]/mode-list"));
  21. #handle empty mode list, no pages return nil
  22. if (m.list[0] == "")
  23. return nil;
  24. m.l = size(m.list);
  25. m.supply = getprop("instrumentation/mfd["~i~"]/supply");
  26. m.supply = m.supply == nil ? "systems/electrical/volts" : m.supply;
  27. m.pwr_sw = "instrumentation/mfd["~i~"]/pwr-sw-pos";
  28. m.mode = "instrumentation/mfd["~i~"]/mode";
  29. m.initstep = "instrumentation/mfd["~i~"]/initstep";
  30. m.navsrprop = "instrumentation/mfd["~i~"]/nav-source";
  31. m.bear0prop = "instrumentation/mfd["~i~"]/bearing-source[0]";
  32. m.bear1prop = "instrumentation/mfd["~i~"]/bearing-source[1]";
  33. m.efbpageprop = "instrumentation/efis/efb/page";
  34. m.numprop = adc.vmdnum.path;
  35. m.volt = 21; # mfd min. voltage demand (just a guess)
  36. setprop(m.mode, m.list[0] );
  37. #setprop(m.navsrprop, "NAV1");
  38. setprop(m.initstep, 1 );
  39. return m;
  40. },
  41. update: func() {
  42. var v = getprop(me.supply);
  43. v = v == nil ? 0 : v;
  44. if (!me.pwr_state and getprop(me.pwr_sw) and v >= me.volt) {
  45. # start with the first page mode in list
  46. setprop(me.mode, me.list[0]);
  47. me.idx = 0;
  48. me.pwr_state = 1;
  49. } else if (!getprop(me.pwr_sw) or v < me.volt) {
  50. me.pwr_state=0;
  51. setprop(me.mode, "off"); # show blank screen
  52. }
  53. # special procedure for the init screen animation
  54. if (getprop(me.mode) == "init" and me.idx==0) {
  55. me.idx = 1;
  56. #show the 2nd test pattern, 1.5 sec later
  57. settimer(func {setprop(me.initstep,2)}, 1.5 );
  58. if (me.list[1]=="fnd") {
  59. # timers to show the FND AI Alignment screen
  60. settimer(func {setprop(me.initstep,3)}, 3.0 );
  61. settimer(func {me.modeprop(); }, 8.0 );
  62. settimer(func {setprop(me.initstep,1)}, 9.0 );
  63. } else {
  64. settimer(func {me.modeprop(); }, 3.0 );
  65. settimer(func {setprop(me.initstep,1)}, 4.0 );
  66. }
  67. }
  68. # show/hide canvas
  69. foreach(var m; me.list)
  70. if (me.getmode() == m)
  71. mfd[me.id][m].show();
  72. else
  73. mfd[me.id][m].hide();
  74. },
  75. modeprop: func () setprop(me.mode, me.list[me.idx]),
  76. setmode: func (modestr) {
  77. i = isin(modestr, me.list);
  78. if (i>=0) { me.idx=i; me.modeprop();}
  79. },
  80. getmode: func () {
  81. return getprop(me.mode);
  82. },
  83. pwr_on: func () {
  84. setprop(me.pwr_sw, 1);
  85. },
  86. pwr_off: func () {
  87. setprop(me.pwr_sw, 0);
  88. },
  89. clickon: func (n) {
  90. var mymode = me.getmode();
  91. if (me.pwr_state) {
  92. if (n==2) me.setmode("fnd");
  93. if (n==3) me.setmode("navd");
  94. if (n==4) me.setmode("vmd");
  95. if (n==5) me.setmode("dmap");
  96. if (n==7) me.setmode("efb");
  97. if (n==9) {
  98. if (mymode=="dmap") toggleprop(planprop);
  99. }
  100. if (n==10) {
  101. if (mymode=="navd") cycleprop(me.bear0prop, ["NAV1", "ADF1", "FMS"]);
  102. if (mymode=="vmd") toggleprop(me.numprop);
  103. }
  104. if (n==11) {
  105. if (mymode=="fnd") cycleprop(me.bear0prop, ["NAV1", "ADF1", "FMS"]);
  106. if (mymode=="navd") cycleprop(me.bear1prop, ["NAV2", "ADF1", "FMS"]);
  107. }
  108. if (n==12) {
  109. if (mymode=="fnd") cycleprop(me.bear1prop, ["NAV2", "ADF1", "FMS"]);
  110. }
  111. if (n==13) {
  112. #if (mymode=="dmap") cycleprop(databpage, [0,1,2]);
  113. }
  114. if (n==16) {
  115. #if (mymode=="DMAP") cycleprop(databpage, [0,1,2]);
  116. }
  117. if (n==19) {
  118. if (mymode=="navd" or mymode=="fnd") {
  119. # set AP source and activate AP heading mode
  120. var s = getprop(me.navsrprop);
  121. #setprop("instrumentation/efis/nav-source", (s=="NAV1") ? "" : s);
  122. setprop("instrumentation/efis/fnd/nav-source", s);
  123. cycleprop("autopilot/locks/heading", ["nav1-hold", ""]);
  124. }
  125. if (mymode=="efb") setprop(me.efbpageprop,0);
  126. }
  127. if (n==20) {
  128. if (mymode=="fnd") cycleprop(me.navsrprop, ["NAV1", "NAV2", "FMS"]);
  129. if (mymode=="navd") cycleprop(me.navsrprop, ["NAV1", "NAV2", "FMS"]);
  130. }
  131. if (n==21) {
  132. if (mymode=="vmd") cycleprop(datapageprop, [0,1,2]);
  133. }
  134. if (n==22) {
  135. if (mymode=="navd") cycleprop(datafltr, [1,2,3] );
  136. }
  137. if (n==24) {
  138. if (mymode=="navd" or mymode=="dmap") cycleprop(rngprop, [5, 10, 20, 40]);
  139. if (mymode=="efb") {
  140. if (getprop(me.efbpageprop)==0)
  141. setprop(me.efbpageprop,20)
  142. else
  143. decrprop(me.efbpageprop);
  144. }
  145. }
  146. if (n==25) {
  147. if (mymode=="navd") cycleprop(me.navsrprop, ["NAV1", "NAV2", "FMS"]);
  148. if (mymode=="dmap") toggleprop(mapprop);
  149. if (mymode=="efb") {
  150. if (getprop(me.efbpageprop)==0)
  151. setprop(me.efbpageprop,1)
  152. else
  153. incrprop(me.efbpageprop);
  154. }
  155. }
  156. if (n==99) {
  157. cycleprop(me.mode, me.list);
  158. }
  159. }
  160. if (n==1) toggleprop(me.pwr_sw); # toggle power property !!!
  161. }
  162. };