meghas_mfd_control.nas 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # mfd.nas to drive gauges of the VMD MFD #
  2. ### Eucopter MFD panel control class ###
  3. var EUcoptermfd = {
  4. new: func(i) {
  5. var m = { parents: [Timerloop.new(), EUcoptermfd] };
  6. m.id = i;
  7. m.idx = 0;
  8. m.pwr_state = 0;
  9. #split the modes list
  10. m.list = split(",", getprop("/instrumentation/mfd["~i~"]/mode-list"));
  11. #handle empty mode list, no pages return nil
  12. if (m.list[0] == "")
  13. return nil;
  14. m.l = size(m.list);
  15. m.supply = getprop("instrumentation/mfd["~i~"]/supply");
  16. m.supply = m.supply == nil ? "systems/electrical/volts" : m.supply;
  17. m.pwr_sw = "instrumentation/mfd["~i~"]/pwr-sw-pos";
  18. m.mode = "instrumentation/mfd["~i~"]/mode";
  19. m.initstep = "instrumentation/mfd["~i~"]/initstep";
  20. m.navsrprop = "instrumentation/mfd["~i~"]/nav-source";
  21. m.volt=15; # mfd voltage demand (just a guess)
  22. setprop(m.mode, m.list[0] );
  23. #setprop(m.navsrprop, "NAV1");
  24. setprop(m.initstep, 1 );
  25. return m;
  26. },
  27. update: func() {
  28. var v = getprop(me.supply);
  29. v = v == nil ? 0 : v;
  30. if (!me.pwr_state and getprop(me.pwr_sw) and v >= me.volt) {
  31. # start with the first page mode in list
  32. setprop(me.mode, me.list[0]);
  33. me.idx = 0;
  34. me.pwr_state = 1;
  35. } else if (!getprop(me.pwr_sw) or v < me.volt) {
  36. me.pwr_state=0;
  37. setprop(me.mode, "off"); # show blank screen
  38. }
  39. # special procedure for the init screen animation
  40. if (getprop(me.mode) == "init2" and me.idx==0) {
  41. me.idx = 1;
  42. #show the 2nd test pattern, 1.5 sec later
  43. settimer(func {setprop(me.initstep,2)}, 1.5 );
  44. if (me.list[1]=="pfd") {
  45. # timers to show the FND AI Alignment screen
  46. settimer(func {setprop(me.initstep,3)}, 3.0 );
  47. settimer(func {me.modeprop(); }, 8.0 );
  48. settimer(func {setprop(me.initstep,1)}, 9.0 );
  49. } else {
  50. settimer(func {me.modeprop(); }, 3.0 );
  51. settimer(func {setprop(me.initstep,1)}, 4.0 );
  52. }
  53. }
  54. # show/hide canvas
  55. foreach(var m; me.list)
  56. if (me.getmode() == m)
  57. mfd[me.id][m].show();
  58. else
  59. mfd[me.id][m].hide();
  60. },
  61. modeprop: func () setprop(me.mode, me.list[me.idx]),
  62. setmode: func (modestr) {
  63. i = isin(modestr, me.list);
  64. if (i>=0) { me.idx=i; me.modeprop();}
  65. },
  66. getmode: func () {
  67. return getprop(me.mode);
  68. },
  69. pwr_on: func () {
  70. setprop(me.pwr_sw, 1);
  71. },
  72. pwr_off: func () {
  73. setprop(me.pwr_sw, 0);
  74. },
  75. clickon: func (n) {
  76. var mymode = me.getmode();
  77. if (me.pwr_state) {
  78. # add button actions here..
  79. }
  80. if (n==1) toggleprop(me.pwr_sw); # toggle power property !!!
  81. }
  82. };