vmd_page.nas 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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 p=nil;
  7. adc["battsym"] = Sensor.new({prop: "/instrumentation/efis/vmd/battery-symbol-color"});
  8. adc["gen1sym"] = Sensor.new({prop: "/instrumentation/efis/vmd/gen1-symbol-color"});
  9. adc["gen2sym"] = Sensor.new({prop: "/instrumentation/efis/vmd/gen2-symbol-color"});
  10. adc["eng1sym"] = Sensor.new({prop: "/instrumentation/efis/vmd/eng1-symbol-color"});
  11. adc["eng2sym"] = Sensor.new({prop: "/instrumentation/efis/vmd/eng2-symbol-color"});
  12. adc["trainsw"] = Sensor.new({prop: "/controls/switches/ecp/trainswitch"});
  13. adc["eng1stat"] = Sensor.new({function:
  14. func { if ( adc.eng1sym.val == 2) return "FAIL";
  15. if ( adc.eng1sym.val == 1 and adc.n1_1.val>50)
  16. return "IDLE";
  17. else return "START";},
  18. timer: SLOW, type: "STRING" });
  19. adc["eng2stat"] = Sensor.new({function:
  20. func { if ( adc.eng2sym.val == 2) return "FAIL";
  21. if ( adc.eng2sym.val == 1 and adc.n1_2.val>50)
  22. return "IDLE";
  23. else return "START";},
  24. timer: SLOW, type: "STRING" });
  25. # include some helper functions for the VMD page
  26. if (!defined("VMD_FUNC_LOADED"))
  27. io.include(HELIONIXPATH ~ "Nasal/vmd_func.nas");
  28. page_setup["vmd"] = func (i) {
  29. p = mfd[i].add_page("vmd", HELIONIXPATH~"svg/vmd.svg");
  30. var DMEFACTOR = 0.0005399;
  31. var ALTFACTOR = (651-464)/400;
  32. var FPS2FPM = 60;
  33. var SHIFT_THRES = 0.5;
  34. var ROT_THRES = 0.1;
  35. # MFD top row button labels
  36. # ============================
  37. p.add_cond("fndBtn", {offset: isin("fnd", mfd[i].pages) > -1 } );
  38. p.add_cond("vmdBtn", {offset: 0 } );
  39. p.add_cond("navdBtn", {offset: isin("navd", mfd[i].pages) > -1 } );
  40. p.add_cond("dmapBtn", {offset: isin("dmap", mfd[i].pages) > -1 } );
  41. p.add_cond("miscBtn", {offset: isin("misc", mfd[i].pages) > -1 } );
  42. p.add_cond("efbBtn", {offset: isin("efb", mfd[i].pages) > -1 } );
  43. # fuel indicators
  44. # and rotor and eng rmp
  45. # ============================
  46. p.add_trans("fuelTotal", "y-scale", {sensor: adc.tank0 });
  47. p.add_trans("fuelL", "y-scale", {sensor: adc.tank1 });
  48. p.add_trans("fuelR", "y-scale", {sensor: adc.tank2 });
  49. p.add_text("fuelNum", {sensor: adc.tank0lbs, scale: LB2KG, format: "%3.0f" });
  50. p.add_text("fuelNum1", {sensor: adc.tank1lbs, scale: LB2KG, format: "%3.0f" });
  51. p.add_text("fuelNum2", {sensor: adc.tank2lbs, scale: LB2KG, format: "%3.0f" });
  52. p.add_text("fuelFlowL", {sensor: adc.ff_1, scale: LB2KG, format: "%3.0f" });
  53. p.add_text("fuelFlowR", {sensor: adc.ff_2, scale: LB2KG, format: "%3.0f" });
  54. p.add_text("Text2", {sensor: adc.grossweight, scale: LB2KG, format: "%4.0f Kg" });
  55. p.add_text("Text3", {offset: "" });
  56. p.add_text("Text4", {offset: "" });
  57. p.add_text("Text5", {offset: "" });
  58. p.add_text("Text6", {offset: "" });
  59. #Fuel endurance time
  60. p.add_text("enduH", {sensor: adc.endurance, scale: 1/3600, "trunc":1, format: "%1i h" });
  61. p.add_text("enduMin", {sensor: adc.endurance, scale: 1/60, "mod":3600, format: "%02i" });
  62. p.add_cond("trainSym", {sensor: adc.trainsw });
  63. p.add_cond("num_grp", {sensor: adc.vmdnum });
  64. p.add_text("GenVoltL", {sensor: adc.elecBus0, format: "%4.1f V" });
  65. p.add_text("GenVoltR", {sensor: adc.elecBus1, format: "%4.1f V" });
  66. p.add_text("GenAmpL", {sensor: adc.elecAlt0, format: "%3.0f A" });
  67. p.add_text("GenAmpR", {sensor: adc.elecAlt1, format: "%3.0f A" });
  68. p.add_text("BattAmp", {sensor: adc.add( {function: func {
  69. if (adc.batteryload.val > 0)
  70. return adc.batteryload.val;
  71. else
  72. return adc.batterycharge.val;
  73. },
  74. timer: SLOW
  75. }),
  76. format: "%3.0f A",
  77. name: "batt"
  78. });
  79. p.copy_element("gauge_0","_1",[450,0]);
  80. p.copy_element("gauge_0","_2",[130,45]);
  81. p.copy_element("gauge_0","_3",[305,45]);
  82. # Engines TOT Gauges
  83. make_Gauge (
  84. adc.tot_1,
  85. _id="",
  86. _min=100,
  87. _max=900,
  88. name="TOT",
  89. );
  90. make_Gauge (
  91. adc.tot_2,
  92. _id="_1",
  93. _min=100,
  94. _max=900,
  95. name="TOT",
  96. );
  97. # Engine 1 N1 Gauge
  98. make_Gauge (
  99. adc.n1_1,
  100. _id="_2",
  101. _min=75,
  102. _max=115,
  103. name="N1",
  104. );
  105. # Engine 2 N1 Gauge
  106. make_Gauge (
  107. adc.n1_2,
  108. _id="_3",
  109. _min=75,
  110. _max=115,
  111. name="N1",
  112. );
  113. p.copy_element("TGauge_0","_1",[190,0]);
  114. # Engine 1 TRQ Gauge
  115. make_TGauge (
  116. adc.trq_1,
  117. _id="",
  118. _min=0,
  119. _max=125,
  120. name="TRQ",
  121. );
  122. make_TGauge (
  123. adc.trq_2,
  124. _id="_1",
  125. _min=0,
  126. _max=125,
  127. name="TRQ",
  128. );
  129. # look-up-table nr_lut is defined in airdata
  130. p.add_trans("NRgaugeNeedle", "rotation", {sensor: adc.add( {function: func adc.nr_lut.get((adc.nr.val or 0)) }) });
  131. p.add_trans("n2_1Needle", "rotation", {sensor: adc.add( {function: func adc.nr_lut.get( adc.n2_1.val ) }) });
  132. p.add_trans("n2_2Needle", "rotation", {sensor: adc.add( {function: func adc.nr_lut.get( adc.n2_2.val ) }) });
  133. p.add_cond("NRgaugeCover1", {sensor: adc.nr, lessthan: 80});
  134. p.add_cond("NRgaugeCover2", {sensor: adc.nr, greaterthan: 85 });
  135. p.copy_element("LinGauge_0","_1",[150,0]);
  136. p.copy_element("LinGauge_0","_2",[305,0]);
  137. p.copy_element("LinGauge_0","_3",[-125,0]);
  138. make_LinGauge (
  139. adc.oil_t1,
  140. adc.oil_p1,
  141. _id="",
  142. _min1=-40,
  143. _max1=140,
  144. fmt1="%3.0f",
  145. unit1="gC",
  146. _min2=0,
  147. _max2=8.0,
  148. fmt2="%3.1f",
  149. unit2="BAR",
  150. name="ENG OIL",
  151. l1=0,
  152. h1=100,
  153. l2=1.7,
  154. h2=5
  155. );
  156. make_LinGauge (
  157. adc.oil_t2,
  158. adc.oil_p2,
  159. _id="_1",
  160. _min1=-40,
  161. _max1=140,
  162. fmt1="%3.0f",
  163. unit1="gC",
  164. _min2=0,
  165. _max2=8.0,
  166. fmt2="%3.1f",
  167. unit2="BAR",
  168. name="ENG OIL",
  169. l1=0,
  170. h1=100,
  171. l2=1.7,
  172. h2=5
  173. );
  174. make_LinGauge (
  175. adc.mgb_t,
  176. adc.mgb_p,
  177. _id="_2",
  178. _min1=-40,
  179. _max1=140,
  180. fmt1="%3.0f",
  181. unit1="gC",
  182. _min2=0,
  183. _max2=10,
  184. fmt2="%3.1f",
  185. unit2="BAR",
  186. name="MGB OIL",
  187. l1=0,
  188. h1=100,
  189. l2=1.7,
  190. h2=5
  191. );
  192. make_LinGauge (
  193. adc.hydr1,
  194. adc.hydr2,
  195. _id="_3",
  196. _min1=0,
  197. _max1=140,
  198. fmt1="%3.0f",
  199. unit1="BAR",
  200. _min2=0,
  201. _max2=140,
  202. fmt2="%3.0f",
  203. unit2="BAR",
  204. name="HYD",
  205. l1=70,
  206. h1=120,
  207. l2=70,
  208. h2=120
  209. );
  210. p.copy_element("numeral","_1",[450,0]);
  211. p.copy_element("numeral","_2",[130,45]);
  212. p.copy_element("numeral","_3",[305,45]);
  213. make_numeral (
  214. adc.tot_1,
  215. _id="",
  216. dec=0,
  217. unit="°C",
  218. _amber=845,
  219. _red=900
  220. );
  221. make_numeral (
  222. adc.tot_2,
  223. _id="_1",
  224. dec=0,
  225. unit="°C",
  226. _amber=845,
  227. _red=900
  228. );
  229. make_numeral (
  230. adc.n1_1,
  231. _id="_2",
  232. dec=1,
  233. unit="%",
  234. _amber=95,
  235. _red=104
  236. );
  237. make_numeral (
  238. adc.n1_2,
  239. _id="_3",
  240. dec=1,
  241. unit="%",
  242. _amber=95,
  243. _red=104
  244. );
  245. p.copy_element("numeral","_4",[150,-80]);
  246. p.copy_element("numeral","_5",[150+190,-80]);
  247. make_numeral (
  248. adc.trq_1,
  249. _id="_4",
  250. dec=1,
  251. unit="%",
  252. _amber=74,
  253. _red=95
  254. );
  255. make_numeral (
  256. adc.trq_2,
  257. _id="_5",
  258. dec=1,
  259. unit="%",
  260. _amber=74,
  261. _red=95
  262. );
  263. p.copy_element("numeral","_6",[461-55,609-183]);
  264. make_numeral (
  265. adc.nr,
  266. _id="_6",
  267. dec=1,
  268. unit=""
  269. );
  270. p.copy_element("numeral","_7",[400-77, 609-183+107]);
  271. p.copy_element("numeral","_8",[400+57, 609-183+107]);
  272. make_numeral (
  273. adc.n2_1,
  274. _id="_7",
  275. dec=1,
  276. unit="%",
  277. _amber=-96,
  278. _red=-85
  279. );
  280. make_numeral (
  281. adc.n2_2,
  282. _id="_8",
  283. dec=1,
  284. unit="%",
  285. _amber=-96,
  286. _red=-85
  287. );
  288. # battery symbology red: overheat, green:connected, amber: disconnected
  289. p.add_color_range("battSymb", adc.battsym,
  290. [
  291. [0, [0,1,0]],
  292. [1, [1,0.75,0]],
  293. [2, [1,0,0]]
  294. ]
  295. );
  296. # batt Amp indication color, hidden if connected
  297. p.add_color_range("BattAmpC", adc.battsym,
  298. [
  299. [0, [0,0,0]],
  300. [1, [0.5,0.35,0]],
  301. [2, [1,0,0]]
  302. ]
  303. , fill=1);
  304. # generator symbology green:connected, amber: disconnected&eng runn. , gray:disconnected&eng off
  305. var gensym = [
  306. [0, [0,1,0]],
  307. [1, [0.6,0.6,0.6]],
  308. [2, [1,0.75,0]]
  309. ];
  310. p.add_color_range("gen1Symb", adc.gen1sym, gensym);
  311. p.add_color_range("gen2Symb", adc.gen2sym, gensym);
  312. var gensym2 = [
  313. [0, [0,0,0]],
  314. [1, [0.6,0.6,0.6]],
  315. [2, [0.5,0.35,0]]
  316. ];
  317. p.add_color_range("genAmpLc", adc.gen1sym, gensym2, fill=1);
  318. p.add_color_range("genAmpRc", adc.gen2sym, gensym2, fill=1);
  319. var engsym = [
  320. [0, [0,0,0]],
  321. [1, [1,0.75,0]],
  322. [2, [1,0,0]]
  323. ];
  324. p.add_color_range("statusL", adc.eng1sym, engsym);
  325. p.add_color_range("statusR", adc.eng2sym, engsym);
  326. p.add_text("txtStatusR", {sensor: adc.eng2stat });
  327. p.add_text("txtStatusL", {sensor: adc.eng1stat });
  328. }; # func