navd_page.nas 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. # include some helper functions for the NAVD page if not already loaded
  7. var ROSER=175;
  8. # check if the function lib is already loaded
  9. if (!defined("ROSENUMS"))
  10. io.include(HELIONIXPATH ~ "Nasal/fnd_func.nas");
  11. adc["symfilter"] = Sensor.new({prop: datafltr});
  12. page_setup["navd"] = func (i) {
  13. p = mfd[i].add_page("navd", HELIONIXPATH~"svg/navd.svg");
  14. # MFD top row button labels
  15. # ============================
  16. p.add_cond("fndBtn", {offset: isin("fnd", mfd[i].pages) > -1 } );
  17. p.add_cond("vmdBtn", {offset: isin("vmd", mfd[i].pages) > -1 } );
  18. p.add_cond("navdBtn", {offset: 0 } );
  19. p.add_cond("dmapBtn", {offset: isin("dmap", mfd[i].pages) > -1 } );
  20. p.add_cond("miscBtn", {offset: isin("misc", mfd[i].pages) > -1 } );
  21. p.add_cond("efbBtn", {offset: isin("efb", mfd[i].pages) > -1 } );
  22. # Rose transformations
  23. # Bearing Needles for NAV1 and NAV2
  24. # ============================
  25. p.add_trans("bear1Needle", "rotation", {sensor: adc.add({function: func navSrcBear(adc.bearsrc0[i].val), timer: FAST}) });
  26. p.add_cond("bear1Needle", {sensor: adc.add({function: func navSrcInrange(adc.bearsrc0[i].val), timer: SLOW}) });
  27. p.add_trans("bear2Needle", "rotation", {sensor: adc.add({function: func navSrcBear(adc.bearsrc1[i].val), timer: FAST}) });
  28. p.add_cond("bear2Needle", {sensor: adc.add({function: func navSrcInrange(adc.bearsrc1[i].val), timer: SLOW}) });
  29. # course and CDI
  30. # ============================
  31. p.add_trans("hdgBug", "rotation", {sensor: adc.headbug});
  32. p.add_trans("Cdi_Group", "rotation", {sensor: adc.add({function: func navSrcCrs(adc.navsrc[i].val), timer:FAST}) });
  33. p.add_trans("Rose_Group", "rotation", {sensor: adc.heading, scale: -1});
  34. p.add_cond_grp(["cdiNeedle", "toFrom", "cdiScale"], {offset:0}); # CDI not used in NAVD
  35. #p.add_trans("cdiNeedle", "x-shift", {function: func {return (adc.navsrc[i].val == "NAV1") ? adc.nav0defl.val : adc.nav1defl.val }, scale: 8, timer:FAST});
  36. #p.add_trans("toFrom", "rotation", {function: func {return (adc.navsrc[i].val == "NAV1") ? adc.nav0from.val : adc.nav1from.val }, scale: 180, timer:SLOW});
  37. # lots of text
  38. # for nav aids to update
  39. # ============================
  40. p.add_text("navSrctop", {sensor: adc.add({function: func navSrcType(adc.navsrc[i].val), timer:SLOW, type:"STRING" }) });
  41. p.add_text("navDMEtop", {sensor: adc.add({function: func navSrcDist(adc.navsrc[i].val), timer: SLOW, type:"STRING" }) });
  42. p.add_text("navIDtop", {sensor: adc.add({function: func navSrcId(adc.navsrc[i].val), timer: SLOW, type:"STRING"}) });
  43. p.add_text("navBrgtop", {sensor: adc.add({function: func navSrcBear(adc.navsrc[i].val), timer: SLOW}), format: "%3.0f°" });
  44. p.add_text("crs", {sensor: adc.add({function: func navSrcCrs(adc.navsrc[i].val), timer:SLOW }), format: "%3.0f" });
  45. p.add_text("rngNum", {sensor: adc.add({prop: rngprop }), format: "%3.0f" });
  46. p.add_cond_grp(["navDMEtop","navIDtop","navBrgtop"], {sensor: adc.add({function: func navSrcInrange(adc.navsrc[i].val), timer: SLOW}) });
  47. # FMS col
  48. p.add_text("navSrc", {offset: "FMS"});
  49. p.add_text("navBrg", {sensor: adc.add( {function: func navSrcBear("FMS"), timer:SLOW }), format: "%3.0f°" });
  50. p.add_text("fmsToID", {sensor: adc.fmstoid }); # for FMS from nav ID
  51. p.add_text("fmsFromID", {sensor: adc.fmsfromid }); # for FMS to nav ID
  52. p.add_text("navTTG", {sensor: adc.fmsttg, scale: 1/60, format: "%i min"});
  53. p.add_cond("navTTG", {sensor: adc.fmsttg, between: [60,10000] });
  54. p.add_text("navDME", {sensor: adc.add( {function: func navSrcDist("FMS"), timer: SLOW, type:"STRING" }) });
  55. p.add_cond("navDME", {sensor: adc.add( {function: func navSrcInrange("FMS"), timer: SLOW, type:"BOOL"}) });
  56. p.add_text("gsNum", {sensor: adc.gs, format: "%3.0i"});
  57. p.add_text("tasNum", {sensor: adc.tas, format: "%3.0i"});
  58. # NAV1 and NAV2 cols
  59. p.add_text("bearingSrc1", {sensor: adc.add( {function: func navSrcType("NAV1"), timer:SLOW, type:"STRING"}) });
  60. p.add_text("bearingSrc2", {sensor: adc.add( {function: func navSrcType("NAV2"), timer:SLOW, type:"STRING"}) });
  61. p.add_text("bearingFrq1", {sensor: adc.add( {function: func navSrcFrq("NAV1"), timer: SLOW, type:"STRING"}) });
  62. p.add_text("bearingFrq2", {sensor: adc.add( {function: func navSrcFrq("NAV2"), timer: SLOW, type:"STRING"}) });
  63. p.add_text("bearingDME1", {sensor: adc.add( {function: func DME_format(adc.nav0dist.val), timer: SLOW, type:"STRING"}) });
  64. p.add_cond("bearingDME1", {sensor: adc.nav0inrange });
  65. p.add_text("bearingDME2", {sensor: adc.add( {function: func DME_format(adc.nav1dist.val), timer: SLOW, type:"STRING"}) });
  66. p.add_cond("bearingDME2", {sensor: adc.nav1inrange });
  67. p.add_text("bearingTTG1", {sensor: adc.nav0ttg, scale: 1/60, format: "%i min" });
  68. p.add_text("bearingTTG2", {sensor: adc.nav1ttg, scale: 1/60, format: "%i min" });
  69. p.add_cond("bearingTTG1", {sensor: adc.nav0ttg, between: [60, 10000]});
  70. p.add_cond("bearingTTG2", {sensor: adc.nav1ttg, between: [60, 10000]});
  71. p.add_cond("txtNav", {sensor: adc.symfilter, equals: 1 });
  72. p.add_cond("txtAirp", {sensor: adc.symfilter, equals: 3 });
  73. p.add_cond("txtRte", {sensor: adc.symfilter, equals: 2 });
  74. p.add_text("bearing1", {sensor: adc.nav0bear, format: "%3.0f°"});
  75. p.add_text("brg1Id1", {sensor: adc.add({function: func substr(navSrcType( adc.bearsrc0[i].val ),0,1), timer:SLOW, type:"STRING"}) });
  76. p.add_text("brg1Id2", {sensor: adc.add({function: func substr(navSrcType( adc.bearsrc0[i].val ),1,1), timer:SLOW, type:"STRING"}) });
  77. p.add_text("brg1Id3", {sensor: adc.add({function: func substr(navSrcType( adc.bearsrc0[i].val ),2,1), timer:SLOW, type:"STRING"}) });
  78. p.add_text("brg1Id4", {sensor: adc.add({function: func substr(navSrcType( adc.bearsrc0[i].val ),3,1), timer:SLOW, type:"STRING"}) });
  79. p.add_text("bearing2", {sensor: adc.nav1bear, format: "%3.0f°"});
  80. p.add_text("brg2Id1", {sensor: adc.add({function: func substr(navSrcType( adc.bearsrc1[i].val ),0,1), timer:SLOW, type:"STRING"}) });
  81. p.add_text("brg2Id2", {sensor: adc.add({function: func substr(navSrcType( adc.bearsrc1[i].val ),1,1), timer:SLOW, type:"STRING"}) });
  82. p.add_text("brg2Id3", {sensor: adc.add({function: func substr(navSrcType( adc.bearsrc1[i].val ),2,1), timer:SLOW, type:"STRING"}) });
  83. p.add_text("brg2Id4", {sensor: adc.add({function: func substr(navSrcType( adc.bearsrc1[i].val ),3,1), timer:SLOW, type:"STRING"}) });
  84. # /instrumentation/nav[0]/has-gs --> navSrc VOR1/ILS1
  85. #p.add_cond("navETE", {offset:0}); # hide ETE
  86. # GPS
  87. #
  88. # ======================================
  89. p.add_text("gpsLatNum", {sensor: adc.gpslat, trunc:"abs", format: "%8.4f°"});
  90. p.add_text("gpsLonNum", {sensor: adc.gpslon, trunc:"abs", format: "%08.4f°"});
  91. p.add_text("gpsLat", {sensor: adc.gpsLatNS});
  92. p.add_text("gpsLon", {sensor: adc.gpsLonWE});
  93. # translate rose numerals in round orbit
  94. # around center of compass rose
  95. # ======================================
  96. GenerateRosenumerals(p, ROSER);
  97. Generatewindbarb(p);
  98. # setup the navigation symbols
  99. # animations
  100. # ======================================
  101. for (var sym=0; sym<20; sym += 1) {
  102. adc["navsym_id"~sym] = Sensor.new({prop: mfdroot~"navd/sym[" ~ sym ~ "]/id", "type": "STRING" } );
  103. adc["navsym_sym"~sym] = Sensor.new({prop: mfdroot ~ "navd/sym[" ~ sym ~ "]/sym", "timer": SLOW });
  104. adc["navsym_dst"~sym] = Sensor.new({prop: mfdroot ~ "navd/sym[" ~ sym ~ "]/distance-norm" });
  105. adc["navsym_brg"~sym] = Sensor.new({prop: mfdroot ~ "navd/sym[" ~ sym ~ "]/rel-bearing" });
  106. };
  107. for (var sym=0; sym<20; sym += 1) {
  108. var thissym = "symbol_"~sym;
  109. p.copy_element("symbol","_"~sym);
  110. p[thissym].show();
  111. p.add_trans(thissym, "rotation", {sensor: adc.add({prop: mfdroot~"navd/sym[" ~ sym ~ "]/rel-bearing" }), scale:-1 });
  112. p.add_trans(thissym, "y-shift", {sensor: adc.add( {prop: mfdroot~"navd/sym[" ~ sym ~ "]/distance-norm"}), scale: -330/2 });
  113. p.add_trans(thissym, "rotation", {sensor: adc.add({prop: mfdroot~"navd/sym[" ~ sym ~ "]/rel-bearing" }) });
  114. p.add_by_id("symbol_vor_"~sym);
  115. p.add_by_id("symbol_wayp_"~sym);
  116. p.add_by_id("symbol_ndb_"~sym);
  117. p.add_by_id("symbol_airp_"~sym);
  118. p.add_by_id("symbol_nextwayp_"~sym);
  119. p.add_by_id("symbol_fix_"~sym);
  120. # use only a single callback function for all nav symbol types to reduce
  121. # callback overhead. pass the page object and the symbol number
  122. adc["navsym_sym"~sym]._register_(
  123. {o: p,
  124. c: sym,
  125. f: func(x,c) {
  126. if (adc["navsym_sym"~c].val > -1) {
  127. x["symbol_"~c].setVisible(1);
  128. x["symbol_vor_"~c].setVisible( adc["navsym_sym"~c].val == 0 );
  129. x["symbol_wayp_"~c].setVisible( adc["navsym_sym"~c].val == 1 );
  130. x["symbol_ndb_"~c].setVisible( adc["navsym_sym"~c].val == 2 );
  131. x["symbol_airp_"~c].setVisible( adc["navsym_sym"~c].val == 3 );
  132. x["symbol_nextwayp_"~c].setVisible( adc["navsym_sym"~c].val == 4 );
  133. x["symbol_fix_"~c].setVisible( adc["navsym_sym"~c].val == 6 );
  134. } else {
  135. x["symbol_"~c].setVisible(0);
  136. }
  137. }
  138. },
  139. p
  140. );
  141. p.add_text("symbol_id_"~sym, {sensor: adc["navsym_id"~sym] });
  142. }
  143. # hide the template symbol
  144. p["symbol"].hide();
  145. }; # func