pfd_page.nas 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. # ==============================================================================
  2. # Original Boeing 747-400 pfd by Gijs de Rooy
  3. # Modified for 737-800 by Michael Soitanen
  4. # Modified for EC145 by litzi
  5. # ==============================================================================
  6. var ROSER = 185;
  7. var DMEFACTOR = 0.0005399;
  8. var ALTFACTOR = (651-464)/400;
  9. var FPS2FPM = 60;
  10. var SHIFT_THRES = 0.5;
  11. var ROT_THRES = 0.1;
  12. # include some helper functions for the FND page if not already loaded
  13. if (!defined("FND_FUNC_LOADED"))
  14. io.include(HELIONIXPATH ~ "Nasal/fnd_func.nas");
  15. if ( contains(adc,"ralt_lut") == 0) {
  16. adc["ralt_lut"] = LUT.new([[0,0], [100,96], [1000,537.7], [2200,929.6], [2500,1500]]);
  17. adc["agllut"] = Sensor.new({"function": func {return adc.ralt_lut.get(adc.agl.val)} });
  18. }
  19. page_setup["pfd"] = func (i) {
  20. p = mfd[i].add_page("pfd", HELIONIXPATH~"svg/pfd.svg");
  21. generateAltLadder(p, pitch=ALTFACTOR*100);
  22. # alt tape elements animation
  23. # ============================
  24. var raltoffset = getprop("/instrumentation/efis/fnd/radar-alt-offset-ft");
  25. p.add_direct("altBug", adc.alt, func(o,c) o.setTranslation(0, -ALTFACTOR*(adc.aptargetAlt.val - adc.alt.val) ) );
  26. p.add_direct("altBack", adc.agl, func(o,c) o.setTranslation(0, math.clamp( adc.agl.val, -280, 280) *130/280 ) );
  27. p.add_direct("radarAlttape", adc.agllut, func(o,c) o.setTranslation(0, clamp(adc.agllut.val-raltoffset, 0, 1100)) );
  28. p.add_direct("aglBug", adc.agl, func(o,c) o.setTranslation(0, adc.agllut.val - adc.ralt_lut.get(getprop("/autopilot/settings/target-agl-ft") or 0) ));
  29. p.add_trans("Alt_Group", "y-shift", {sensor: adc.alt, scale: ALTFACTOR });
  30. # move speed and fli tapes, animate ai elements
  31. # ============================
  32. p.add_direct("iasBug", adc.ias, func(o,c) o.setTranslation(0, (adc.ias.val - adc.aptargetSpeed.val)*3.19));
  33. #TODO Experimental: testbench for property rule transformations
  34. #p.link2rule("speedtape", adc.ias.path, {type:"y-shift", scale:3.19, offset:0, max:350, min:-20, abs:0, mod:nil});
  35. #p.link2rule("Alt_Group", adc.alt.path, {type:"y-shift", scale: ALTFACTOR, offset:0, max:35000, min:-2000, abs:0, mod:nil });
  36. p.add_trans("speedtape", "y-shift", {sensor: adc.ias, scale: 3.19 });
  37. p.add_trans("speedTrend", "y-scale", {sensor: adc.iasTrend, scale: 1/40, max: 40, min:-40});
  38. p.add_trans("speedTrendBar", "y-shift", {sensor: adc.iasTrend, scale: -3.19, max: 40, min:-40});
  39. p.add_trans("horizon", "y-shift", {sensor: adc.pitch, scale: 3.6, max: 90 , min:-90});
  40. p.add_trans("horizon", "rotation", {sensor: adc.roll, scale: -1});
  41. p.add_trans("horizonNums", "y-shift", {sensor: adc.pitch, scale: 3.6, max: 90 , min:-90});
  42. p.add_trans("horizonNums", "rotation", {sensor: adc.roll, scale: -1});
  43. p.add_trans("rollPointer", "rotation", {sensor: adc.roll, scale: -1 });
  44. p.add_text("aglNum", {sensor: adc.agl, format: "%3.0f", offset:-raltoffset, trunc: "abs"});
  45. p.add_cond("aglNum", {sensor: adc.agl, lessthan: 1000 });
  46. # move vsi needle and numerical indication
  47. # ============================
  48. p.add_trans("vsi", "rotation", {sensor: adc.vs, scale:-1.2, max:35, min:-35});
  49. p.add_trans_grp(["vsi", "vsiNum"], "y-shift", {sensor: adc.vs, scale: -84/2000*FPS2FPM, max:35, min:-35 });
  50. p.add_trans("vsBug", "y-shift", {sensor: adc.aptargetRoc, scale: -84/2000*FPS2FPM, max:35, min:-35 });
  51. p.add_trans("vsiNum", "y-shift", {sensor: adc.vsiNumVis });
  52. p.add_text("vsiNum", {sensor: adc.vs, "trunc": "abs", scale: FPS2FPM/100, format: "%2.0f" });
  53. p.add_cond("vsiNum", {sensor: adc.vs, notin: [-3,3] });
  54. # Rose transformations
  55. # Bearing Needles
  56. # ============================
  57. p.add_trans("bear1Needle", "rotation", {sensor: adc.add( {function: func navSrcBear(adc.bearsrc0[i].val), timer:FAST}) });
  58. p.add_cond("bear1Needle", {sensor: adc.add( {function: func navSrcInrange(adc.bearsrc0[i].val), timer:SLOW}) });
  59. p.add_trans("bear2Needle", "rotation", {sensor: adc.add( {function: func navSrcBear(adc.bearsrc1[i].val), timer:FAST}) });
  60. p.add_cond("bear2Needle", {sensor: adc.add( {function: func navSrcInrange(adc.bearsrc1[i].val), timer:SLOW}) });
  61. # course and CDI
  62. # ============================
  63. p.add_trans("hdgBug2", "x-shift", {sensor: adc.headbug, scale: 2.422222222222});
  64. p.add_trans("crsNeedle2", "x-shift", {sensor: adc.add({function: func navSrcCrs(adc.navsrc[i].val), timer:FAST}), scale: 2.422222222222 });
  65. p.add_trans("Compass_Group", "x-shift", {sensor: adc.heading, scale: -2.422222222222});
  66. p.add_trans("Rose_Group", "rotation", {sensor: adc.heading, scale: -1});
  67. p.add_trans("hdgBug", "rotation", {sensor: adc.headbug});
  68. p.add_trans_grp(["cdiNeedle", "cdiNeedle2"], "x-shift", {sensor: adc.add( {function: func navSrcDefl(adc.navsrc[i].val), timer:FAST }), scale: 7.5 });
  69. p.add_cond_grp(["cdiNeedle", "toFrom", "Compass_layer"], {sensor: adc.add( {function: func navSrcInrange(adc.navsrc[i].val), timer: SLOW }) });
  70. p.add_trans("toFrom", "rotation", {sensor: adc.add( {function: func { (adc.navsrc[i].val == "NAV1") ? adc.nav0from.val : adc.nav1from.val }, timer: SLOW}), scale:180});
  71. p.add_trans("Cdi_Group", "rotation", {sensor: adc.add( {function: func navSrcCrs(adc.navsrc[i].val), timer:FAST}) });
  72. p.add_trans_grp(["gsNeedle", "gsNeedle2"], "y-shift", {sensor: adc.add({function: func { (adc.navsrc[i].val == "NAV1") ? adc.nav0gsdef.val : adc.nav1gsdef.val }, timer:FAST}), scale: -65});
  73. p.add_cond_grp(["gsNeedle", "gsScale", "gsNeedle2", "gsScale2"], {sensor: adc.add({function: func { (adc.navsrc[i].val == "NAV1") ? adc.nav0gsinrange.val : adc.nav1gsinrange.val}, timer:SLOW}) });
  74. #p.add_trans("speedTrend", "y-scale", {sensor: adc.iasTrend, scale: 0.02, max: 40, min:-40});
  75. # lots of text
  76. # for nav aids to update
  77. # ============================
  78. # if FMS show "GPS" else show Nav frequency
  79. p.add_text("navFrq", {sensor: adc.add({ function: func navSrcFrq(adc.navsrc[i].val), timer:SLOW, type: "STRING"}) });
  80. p.add_cond("navFrq", {sensor: adc.navsrc[i], notequal: "FMS" });
  81. p.add_text("navID", {sensor: adc.add({function: func navSrcId(adc.navsrc[i].val), timer:SLOW, type:"STRING" }) });
  82. p.add_text("navSrc", {sensor: adc.add({function: func navSrcType(adc.navsrc[i].val), timer:SLOW, type:"STRING" }) });
  83. p.add_text("crs", {sensor: adc.add({function: func navSrcCrs(adc.navsrc[i].val), timer:SLOW, type:"STRING"}), format: "%3.0f"});
  84. p.add_text("hdgNum", {sensor: adc.headbug, format: "%3.0f"});
  85. p.add_text("gsNum", {sensor: adc.gs, format: "%3.0f"});
  86. p.add_text("navDME", {sensor: adc.add( {function: func navSrcDist(adc.navsrc[i].val), timer: SLOW, type: "STRING" }) });
  87. p.add_cond("navDME", {sensor: adc.add( {function: func navSrcInrange(adc.navsrc[i].val), timer: SLOW, type: "BOOL"}) });
  88. p.add_cond("navGPS", {sensor: adc.navsrc[i], equals: "FMS" });
  89. p.add_text("navTTG", {sensor: adc.add( {function: func navSrcTTG(adc.navsrc[i].val), timer: SLOW}), format: "%i" });
  90. p.add_cond("navTTG", {sensor: adc.add( {function: func { (navSrcTTG(adc.navsrc[i].val)>1 and navSrcTTG(adc.navsrc[i].val)<300)}, type:"BOOL", timer:SLOW}) });
  91. p.add_text("bearingSrc1", {sensor: adc.add( {function: func navSrcType(adc.bearsrc0[i].val), timer: SLOW, type: "STRING" }) });
  92. p.add_text("bearingSrc2", {sensor: adc.add( {function: func navSrcType(adc.bearsrc1[i].val), timer: SLOW, type: "STRING" }) });
  93. # p.add_text("bearingFrq1", {sensor: adc.add( {function: func navSrcFrq(adc.bearsrc0[i].val), timer: SLOW, type: "STRING" }) });
  94. # p.add_text("bearingFrq2", {sensor: adc.add( {function: func navSrcFrq(adc.bearsrc1[i].val), timer: SLOW, type: "STRING" }) });
  95. p.add_text("bearingDME1", {sensor: adc.add( {function: func navSrcDist(adc.bearsrc0[i].val), timer: SLOW, type: "STRING" }) });
  96. p.add_cond("bearingDME1", {sensor: adc.add( {function: func navSrcInrange(adc.bearsrc0[i].val), timer: SLOW}) });
  97. p.add_text("bearingDME2", {sensor: adc.add( {function: func navSrcDist(adc.bearsrc1[i].val), timer: SLOW, type: "STRING" }) });
  98. p.add_cond("bearingDME2", {sensor: adc.add( {function: func navSrcInrange(adc.bearsrc1[i].val), timer: SLOW }) });
  99. p.add_cond("Mrk_Group", {sensor: adc.ilsmarker });
  100. p.add_text("MrkLabel", {sensor: adc.add( {function: func { ( adc.ilsin.val ? "I" : (adc.ilsmid.val ? "M" : (adc.ilsout.val ? "O" : "" )))}, timer: SLOW, type: "STRING" }) });
  101. # /instrumentation/nav[0]/has-gs --> navSrc VOR1/ILS1
  102. p.add_text("qnh", {sensor: adc.qnhDisplay });
  103. # AP annunciators text items
  104. #
  105. # ============================
  106. p.add_text("altTarget", {sensor: adc.aptargetAlt, format: "%5.0f"});
  107. p.add_cond_grp(["altTarget", "altBug"], {sensor: adc.altTargetVis });
  108. p.add_text("aglTarget", {sensor: adc.aptargetAgl, format: "%3.0f"});
  109. p.add_cond_grp(["aglTarget", "aglBug"], {sensor: adc.aglTargetVis});
  110. p.add_cond("iasBug", {sensor: adc.apspeed, equals: "speed-with-pitch-trim" });
  111. p.add_cond("vsBug", {sensor: adc.vsBugVis });
  112. p.add_text("apLockRoll", {sensor: adc.apLockRoll });
  113. p.add_text("apArmRoll", {sensor: adc.apArmRoll });
  114. p.add_text("apLockPitch", {sensor: adc.apLockPitch });
  115. p.add_text("apArmPitch", {sensor: adc.apArmPitch });
  116. p.add_text("apLockColl", {sensor: adc.apLockColl });
  117. p.add_text("apArmColl", {sensor: adc.apArmColl });
  118. # translate rose numerals in circular orbit
  119. # around center of compass rose
  120. # ============================
  121. GenerateRosenumerals(p, ROSER);
  122. Generatewindbarb(p);
  123. }; # func