mfd_control.nas 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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.volt=15; # mfd voltage demand (just a guess)
  32. setprop(m.mode, m.list[0] );
  33. setprop(m.navsrprop, "NAV1");
  34. setprop(m.initstep, 1 );
  35. return m;
  36. },
  37. update: func() {
  38. var v = getprop(me.supply);
  39. v = v == nil ? 0 : v;
  40. if (!me.pwr_state and getprop(me.pwr_sw) and v >= me.volt) {
  41. # start with the first page mode in list
  42. setprop(me.mode, me.list[0]);
  43. me.idx = 0;
  44. me.pwr_state = 1;
  45. } else if (!getprop(me.pwr_sw) or v < me.volt) {
  46. me.pwr_state=0;
  47. setprop(me.mode, "off"); # show blank screen
  48. }
  49. # special procedure for the init screen animation
  50. if (getprop(me.mode) == "init" and me.idx==0) {
  51. me.idx = 1;
  52. #show the 2nd test pattern, 1.5 sec later
  53. settimer(func {setprop(me.initstep,2)}, 1.5 );
  54. if (me.list[1]=="fnd") {
  55. # timers to show the FND AI Alignment screen
  56. settimer(func {setprop(me.initstep,3)}, 3.0 );
  57. settimer(func {me.modeprop(); }, 8.0 );
  58. settimer(func {setprop(me.initstep,1)}, 9.0 );
  59. } else {
  60. settimer(func {me.modeprop(); }, 3.0 );
  61. settimer(func {setprop(me.initstep,1)}, 4.0 );
  62. }
  63. }
  64. # show/hide canvas
  65. foreach(var m; me.list)
  66. if (me.getmode() == m)
  67. mfd[me.id][m].show();
  68. else
  69. mfd[me.id][m].hide();
  70. },
  71. modeprop: func () setprop(me.mode, me.list[me.idx]),
  72. setmode: func (modestr) {
  73. i = isin(modestr, me.list);
  74. if (i>=0) { me.idx=i; me.modeprop();}
  75. },
  76. getmode: func () {
  77. return getprop(me.mode);
  78. },
  79. pwr_on: func () {
  80. setprop(me.pwr_sw, 1);
  81. },
  82. pwr_off: func () {
  83. setprop(me.pwr_sw, 0);
  84. },
  85. clickon: func (n) {
  86. var mymode = me.getmode();
  87. if (me.pwr_state) {
  88. if (n==2) me.setmode("fnd");
  89. if (n==3) me.setmode("navd");
  90. if (n==4) me.setmode("vmd");
  91. if (n==5) me.setmode("dmap");
  92. if (n==9) {
  93. if (mymode=="dmap") toggleprop(planprop);
  94. }
  95. if (n==10) {
  96. if (mymode=="navd") cycleprop(bear0prop, ["NAV1", "ADF1", "FMS"]);
  97. if (mymode=="dmap") toggleprop(dataprop);
  98. if (mymode=="vmd") toggleprop(numprop);
  99. }
  100. if (n==11) {
  101. if (mymode=="fnd") cycleprop(bear0prop, ["NAV1", "ADF1", "FMS"]);
  102. if (mymode=="navd") cycleprop(bear1prop, ["NAV2", "ADF1", "FMS"]);
  103. }
  104. if (n==12) {
  105. if (mymode=="fnd") cycleprop(bear1prop, ["NAV2", "ADF1", "FMS"]);
  106. if (mymode=="dmap") cycleprop(datafltr, [1,3,4] );
  107. }
  108. if (n==13) {
  109. if (mymode=="dmap") cycleprop(databpage, [0,1,2]);
  110. }
  111. if (n==16) {
  112. #if (mymode=="DMAP") cycleprop(databpage, [0,1,2]);
  113. }
  114. if (n==19) {
  115. if (mymode=="navd" or mymode=="fnd") {
  116. # set AP source and activate AP heading mode
  117. var s = getprop(me.navsrprop);
  118. #setprop("instrumentation/efis/nav-source", (s=="NAV1") ? "" : s);
  119. setprop("instrumentation/efis/fnd/nav-source", s);
  120. cycleprop("autopilot/locks/heading", ["nav1-hold", ""]);
  121. }
  122. }
  123. if (n==20) {
  124. if (mymode=="fnd") cycleprop(me.navsrprop, ["NAV1", "NAV2", "FMS"]);
  125. if (mymode=="navd") cycleprop(me.navsrprop, ["NAV1", "NAV2", "FMS"]);
  126. }
  127. if (n==21) {
  128. if (mymode=="vmd") cycleprop(datapageprop, [0,1,2]);
  129. }
  130. if (n==24) {
  131. if (mymode=="navd" or mymode=="dmap") cycleprop(rngprop, [10, 20, 30]);
  132. }
  133. if (n==25) {
  134. if (mymode=="navd") cycleprop(me.navsrprop, ["NAV1", "NAV2", "FMS"]);
  135. if (mymode=="dmap") toggleprop(mapprop);
  136. }
  137. if (n==99) {
  138. cycleprop(me.mode, me.list);
  139. }
  140. }
  141. if (n==1) toggleprop(me.pwr_sw); # toggle power property !!!
  142. }
  143. };