airdata.nas 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. # add sensor elements to air data computer. to avoid repeated readout of the same
  7. # property values we define sensors (originally seen in Thorstens Zivko Edge)
  8. #
  9. # properties that change very frequently will be polled
  10. # to avoid listener overhead (see 'timer:') or
  11. # which are tied properties and don't work with listeners
  12. # the vital parameters are update with 30Hz
  13. # =========================
  14. adc["roll"] = Sensor.new({prop:"orientation/roll-deg", thres:0.1, timer:1/30, name:"proll"});
  15. adc["pitch"] = Sensor.new({prop: "orientation/pitch-deg", thres:0.1, timer:1/30});
  16. adc["ias"] = Sensor.new({prop: "instrumentation/airspeed-indicator/indicated-speed-kt", thres:0.1, timer:1/30});
  17. adc["tas"] = Sensor.new({prop: "velocities/airspeed-kt", thres:0.1,timer:FAST});
  18. adc["gs"] = Sensor.new({prop: "velocities/groundspeed-kt", thres:0.1,timer:FAST});
  19. adc["iasTrend"] = Sensor.new({prop: "velocities/airspeed-delta-kt-sec", thres: 0.5, timer: FAST});
  20. adc["alt"] = Sensor.new({prop: "instrumentation/altimeter/indicated-altitude-ft", thres: 0.1, name:"alt", timer:1/30});
  21. adc["vs"] = Sensor.new({prop: "velocities/vertical-speed-fps", timer: 1/30, thres:0.01});
  22. adc["agl"] = Sensor.new({prop: "position/altitude-agl-ft", thres:0.1, timer: FAST});
  23. adc["heading"] = Sensor.new({prop: "orientation/heading-magnetic-deg", thres:0.1, timer: 1/30});
  24. adc["qnh"] = Sensor.new({prop: "instrumentation/altimeter/setting-inhg"});
  25. adc["slipskid"] = Sensor.new({prop: "instrumentation/slip-skid-ball/indicated-slip-skid", timer:FAST, thres:0.05});
  26. adc["qnhDisplay"] = Sensor.new( {function: func {(adc.qnh.val == 29.92) ? "STD" : sprintf("%4.0f", adc.qnh.val*33.8639)}, timer: SLOW, type:"STRING" });
  27. adc["winddir"] = Sensor.new({prop: "/environment/wind-from-heading-deg", timer: SLOW, thres:1} );
  28. adc["relwinddir"] = Sensor.new({function: func {adc.winddir.val-adc.heading.val}, timer: SLOW, thres:1});
  29. adc["windspeed"] = Sensor.new({prop: "/environment/wind-speed-kt", timer: SLOW, thres:1} );
  30. adc["oat"] = Sensor.new({prop: "environment/temperature-degc", timer: SLOW, thres:0.5 });
  31. adc["vsiNumVis"] = Sensor.new({ function: func { (adc.vs.val > 0) * -35 } });
  32. ## Engines and FLI
  33. adc["nr"] = Sensor.new({prop: "rotors/main/rpm-pct", timer:FAST, thres:0.1});
  34. adc["n2_1"] = Sensor.new({prop: "engines/engine[0]/n2-pct", timer:FAST, thres:0.1});
  35. adc["n2_2"] = Sensor.new({prop: "engines/engine[1]/n2-pct", timer:FAST, thres:0.1});
  36. adc["n1_1"] = Sensor.new({prop: "engines/engine[0]/n1-pct", timer:FAST, thres:0.1});
  37. adc["n1_2"] = Sensor.new({prop: "engines/engine[1]/n1-pct", timer:FAST, thres:0.1});
  38. adc["trq_1"] = Sensor.new({prop: "engines/engine[0]/torque-pct", timer:FAST, thres:0.1});
  39. adc["trq_2"] = Sensor.new({prop: "engines/engine[1]/torque-pct", timer:FAST, thres:0.1});
  40. adc["tot_1"] = Sensor.new({prop: "engines/engine[0]/tot-degc", timer:FAST, thres:1});
  41. adc["tot_2"] = Sensor.new({prop: "engines/engine[1]/tot-degc", timer:FAST, thres:1});
  42. adc["nr_lut"] = LUT.new([[0,0], [80,90], [100,180], [120,270]]);
  43. #adc["nrlut"] = Sensor.new({"function": func {return adc.nr_lut.get(adc.nr.get())} });
  44. adc["oil_t1"] = Sensor.new({prop: "engines/engine/oil-temperature-degc", timer:SLOW, thres:1});
  45. adc["oil_t2"] = Sensor.new({prop: "engines/engine[1]/oil-temperature-degc", timer:SLOW, thres:1});
  46. adc["mgb_t"] = Sensor.new({prop: "rotors/gear/mgb-oil-temperature-degc", timer:SLOW, thres:1});
  47. adc["oil_p1"] = Sensor.new({prop: "engines/engine/oil-pressure-bar", timer:FAST, thres:0.1});
  48. adc["oil_p2"] = Sensor.new({prop: "engines/engine[1]/oil-pressure-bar", timer:FAST, thres:0.1});
  49. adc["mgb_p"] = Sensor.new({prop: "rotors/gear/mgb-oil-pressure-bar", timer:FAST, thres:0.1});
  50. adc["hydr1"] = Sensor.new({prop: "systems/hydraulic/sys[0]/hyd-press-bar", timer:FAST, thres:1});
  51. adc["hydr2"] = Sensor.new({prop: "systems/hydraulic/sys[1]/hyd-press-bar", timer:FAST, thres:1});
  52. adc["fli"] = Sensor.new({prop: "instrumentation/efis/fnd/fli-tape", timer:FAST, thres:0.01 });
  53. adc["fliSync"] = Sensor.new({prop: "instrumentation/efis/fnd/fli-sync", timer:FAST, thres:0.01});
  54. adc["fliTtop"] = Sensor.new({prop: "instrumentation/efis/fnd/fli-ttop", timer:FAST, thres:0.01});
  55. adc["fliMcp"] = Sensor.new({prop: "instrumentation/efis/fnd/fli-mcp", timer:FAST, thres:0.01});
  56. adc["vmdnum"] = Sensor.new({prop: "instrumentation/efis/vmd/num", type:"BOOL",timer:SLOW});
  57. ## Navigation
  58. adc["navsrc"] = {};
  59. adc["bearsrc0"] = {};
  60. adc["bearsrc1"] = {};
  61. #activate only for 3 screens.
  62. foreach(var j; [0,1,2]) {
  63. adc["navsrc"][j] = Sensor.new({prop: "instrumentation/mfd["~j~"]/nav-source", type:"STRING", timer:SLOW});
  64. adc["bearsrc0"][j] = Sensor.new({prop: "instrumentation/mfd["~j~"]/bearing-source[0]", type:"STRING"});
  65. adc["bearsrc1"][j] = Sensor.new({prop: "instrumentation/mfd["~j~"]/bearing-source[1]", type:"STRING"});
  66. }
  67. adc["comm0frq"] = Sensor.new({prop: "instrumentation/comm[0]/frequencies/selected-mhz"});
  68. adc["comm0stb"] = Sensor.new({prop: "instrumentation/comm[0]/frequencies/standby-mhz"});
  69. adc["nav0frq"] = Sensor.new({prop: "instrumentation/nav[0]/frequencies/selected-mhz"});
  70. adc["nav0stb"] = Sensor.new({prop: "instrumentation/nav[0]/frequencies/standby-mhz"});
  71. adc["nav0id"] = Sensor.new({prop: "instrumentation/nav[0]/nav-id",type:"STRING", timer:SLOW});
  72. adc["nav0bear"] = Sensor.new({prop: "instrumentation/nav[0]/heading-deg", thres:0.01});
  73. adc["nav0crs"] = Sensor.new({prop: "instrumentation/nav[0]/radials/selected-deg", timer:SLOW });
  74. adc["nav0inrange"] = Sensor.new({prop: "instrumentation/nav[0]/in-range", type:"BOOL", timer:SLOW});
  75. adc["nav0hasgs"] = Sensor.new({prop: "instrumentation/nav[0]/has-gs", type:"BOOL", timer:SLOW});
  76. adc["nav0gsinrange"] = Sensor.new({prop: "instrumentation/nav[0]/gs-in-range", type:"BOOL", timer:SLOW});
  77. adc["nav0gsdef"] = Sensor.new({prop: "instrumentation/nav[0]/gs-needle-deflection-norm", thres:0.01, timer:FAST});
  78. adc["nav0from"] = Sensor.new({prop: "instrumentation/nav[0]/from-flag",timer:SLOW});
  79. adc["nav0defl"] = Sensor.new({prop: "instrumentation/nav[0]/heading-needle-deflection", thres:0.01, timer:FAST});
  80. adc["nav0dmeinrange"] = Sensor.new({prop: "instrumentation/nav[0]/dme-in-range", type:"BOOL", timer:SLOW});
  81. adc["nav0dist"] = Sensor.new({prop: "instrumentation/nav[0]/nav-distance",timer:SLOW});
  82. adc["nav0ttg"] = Sensor.new({prop: "instrumentation/nav[0]/time-to-intercept-sec",timer:SLOW});
  83. adc["comm1frq"] = Sensor.new({prop: "instrumentation/comm[1]/frequencies/selected-mhz"});
  84. adc["comm1stb"] = Sensor.new({prop: "instrumentation/comm[1]/frequencies/standby-mhz"});
  85. adc["nav1frq"] = Sensor.new({prop: "instrumentation/nav[1]/frequencies/selected-mhz", timer:SLOW});
  86. adc["nav1stb"] = Sensor.new({prop: "instrumentation/nav[1]/frequencies/standby-mhz", timer:SLOW});
  87. adc["nav1id"] = Sensor.new({prop: "instrumentation/nav[1]/nav-id",type:"STRING", timer:SLOW});
  88. adc["nav1bear"] = Sensor.new({prop: "instrumentation/nav[1]/heading-deg", thres:0.01});
  89. adc["nav1crs"] = Sensor.new({prop: "instrumentation/nav[1]/radials/selected-deg"});
  90. adc["nav1dmeinrange"] = Sensor.new({prop: "instrumentation/nav[1]/dme-in-range", type:"BOOL",timer:SLOW});
  91. adc["nav1inrange"] = Sensor.new({prop: "instrumentation/nav[1]/in-range", type:"BOOL",timer:SLOW});
  92. adc["nav1hasgs"] = Sensor.new({prop: "instrumentation/nav[1]/has-gs", type:"BOOL",timer:SLOW});
  93. adc["nav1gsinrange"] = Sensor.new({prop: "instrumentation/nav[1]/gs-in-range", type:"BOOL",timer:SLOW});
  94. adc["nav1gsdef"] = Sensor.new({prop: "instrumentation/nav[1]/gs-needle-deflection-norm", thres:0.01, timer:FAST});
  95. adc["nav1from"] = Sensor.new({prop: "instrumentation/nav[1]/from-flag",timer:SLOW});
  96. adc["nav1defl"] = Sensor.new({prop: "instrumentation/nav[1]/heading-needle-deflection", thres:0.01, timer:FAST});
  97. adc["nav1dist"] = Sensor.new({prop: "instrumentation/nav[1]/nav-distance", timer:SLOW});
  98. adc["nav1ttg"] = Sensor.new({prop: "instrumentation/nav[1]/time-to-intercept-sec", timer:SLOW});
  99. adc["ilsin"] = Sensor.new({prop: "instrumentation/marker-beacon/inner", timer:0.1});
  100. adc["ilsmid"] = Sensor.new({prop: "instrumentation/marker-beacon/middle", timer:0.1});
  101. adc["ilsout"] = Sensor.new({prop: "instrumentation/marker-beacon/outer", timer:0.1});
  102. adc["ilsmarker"] = Sensor.new({function: func { (adc.ilsin.val or adc.ilsmid.val or adc.ilsout.val) }, timer: 0.2 });
  103. adc["adf0frq"] = Sensor.new({prop: "instrumentation/adf[0]/frequencies/selected-khz", timer:SLOW});
  104. adc["adf0inrange"] = Sensor.new({prop:"instrumentation/adf[0]/in-range", type:"BOOL", timer:SLOW});
  105. adc["adf0bear"] = Sensor.new({function: func {return getprop("instrumentation/adf[0]/indicated-bearing-deg") + adc.heading.val;}, timer:FAST });
  106. adc["gpslat"] = Sensor.new({prop: "position/latitude-deg",timer:SLOW});
  107. adc["gpslon"] = Sensor.new({prop: "position/longitude-deg",timer:SLOW});
  108. adc["gpsgs"] = Sensor.new({prop: "instrumentation/gps/indicated-ground-speed-kt",timer:SLOW});
  109. adc["gpstrk"] = Sensor.new({prop: "instrumentation/gps/indicated-track-true-deg",timer:SLOW});
  110. ## Navigation FMS
  111. adc["fmsinrange"] = Sensor.new({"prop": "instrumentation/gps/wp/wp[1]/valid", "type":"BOOL","timer":SLOW});
  112. adc["fmsfrom"] = Sensor.new({"prop": "instrumentation/gps/wp/wp[1]/from-flag", "type":"BOOL","timer":SLOW});
  113. adc["fmscrs"] = Sensor.new({"prop": "instrumentation/gps/wp/wp[1]/desired-course-deg","timer":SLOW});
  114. adc["fmstoid"] = Sensor.new({"prop": "instrumentation/gps/wp/wp[1]/ID","type":"STRING","timer":SLOW});
  115. adc["fmsfromid"] = Sensor.new({"prop": "instrumentation/gps/wp/wp[0]/ID","type":"STRING","timer":SLOW});
  116. adc["fmsbear"] = Sensor.new({"prop": "instrumentation/gps/wp/wp[1]/bearing-mag-deg","timer":SLOW});
  117. adc["fmsdist"] = Sensor.new({"prop": "instrumentation/gps/wp/wp[1]/distance-nm","timer":SLOW});
  118. adc["fmsdefl"] = Sensor.new({"prop": "instrumentation/gps/wp/wp[1]/course-error-nm","timer":SLOW});
  119. adc["fmsttg"] = Sensor.new({"prop": "instrumentation/gps/wp/wp[1]/TTW-sec","timer":SLOW});
  120. adc["gpsLatNS"] = Sensor.new({function: func {adc.gpslat.val>0 ? "N" : "S"}, timer:SLOW, type:"STRING"});
  121. adc["gpsLonWE"] = Sensor.new({function: func {adc.gpslon.val>0 ? "E" : "W"}, timer:SLOW, type:"STRING"});
  122. ## Autopilot
  123. adc["headbug"] = Sensor.new({prop: "autopilot/settings/heading-bug-deg", timer:FAST});
  124. adc["aptargetAlt"] = Sensor.new({prop: "autopilot/settings/target-altitude-ft", timer:FAST});
  125. adc["aptargetSpeed"] = Sensor.new({prop: "autopilot/settings/target-speed-kt", timer:FAST});
  126. adc["aptargetRoc"] = Sensor.new({prop: "autopilot/internal/target-climb-rate-fps", timer:FAST});
  127. adc["aptargetAgl"] = Sensor.new({prop: "autopilot/settings/target-agl-ft", timer:FAST});
  128. adc["aproll"] = Sensor.new({prop: "autopilot/locks/heading", type: "STRING", timer:SLOW });
  129. adc["apalt"] = Sensor.new({prop: "autopilot/locks/altitude", type: "STRING", timer:SLOW });
  130. adc["aprollarm"] = Sensor.new({prop: "autopilot/locks/heading-arm", type: "STRING", timer:SLOW});
  131. adc["apaltarm"] = Sensor.new({prop: "autopilot/locks/altitude-arm", type: "STRING", timer:SLOW});
  132. adc["apspeed"] = Sensor.new({prop: "autopilot/locks/speed", type: "STRING", timer:SLOW});
  133. adc["apcoll"] = Sensor.new({prop: "autopilot/internal/use-collective-for-alt", timer:SLOW});
  134. adc["apnavsrc"] = Sensor.new({prop: "instrumentation/efis/fnd/nav-source", timer:SLOW, type: "STRING"});
  135. adc["vsBugVis"] = Sensor.new({function: func { (adc.apalt.val == "vertical-speed-hold" or adc.apalt.val == "altitude-hold") }, timer: SLOW });
  136. adc["aglTargetVis"] = Sensor.new({function: func { (adc.apalt.val == "agl-hold" or adc.apaltarm.val == "agl-hold") } });
  137. adc["altTargetVis"] = Sensor.new({function: func { (adc.apalt.val == "altitude-hold" or adc.apaltarm.val == "altitude-hold") } });
  138. adc["apLockRoll"] = Sensor.new({function: func {
  139. var r = adc.aproll.val;
  140. if (r == "wing-leveler") return "SAS";
  141. elsif (r == "dg-heading-hold") return "HDG";
  142. elsif (r == "nav1-hold") {
  143. if (adc.apnavsrc.val == "FMS")
  144. return "NAV";
  145. elsif (adc.apnavsrc.val == "NAV2")
  146. return (adc.nav1hasgs.val) ? "LOC2" : "VOR2";
  147. else
  148. return (adc.nav0hasgs.val) ? "LOC1" : "VOR1";
  149. } else
  150. return "";
  151. },
  152. timer: SLOW,
  153. type: "STRING"
  154. });
  155. adc["apArmRoll"] = Sensor.new( {function: func {
  156. var r = adc.aprollarm.val;
  157. if (r == "nav1-hold") return "VOR1";
  158. elsif (r == "nav2-hold") return "VOR2";
  159. else return "";
  160. },
  161. timer: SLOW,
  162. type: "STRING"
  163. });
  164. adc["apLockPitch"] = Sensor.new( {name:"aplp", function: func {
  165. var a = adc.apalt.val;
  166. var s = adc.apspeed.val;
  167. var c = adc.apcoll.val;
  168. if (a == "pitch-hold") return "SAS";
  169. elsif (a == "altitude-hold" and !c) return "ALT";
  170. elsif (a == "agl-hold" and !c) return "CR.HT";
  171. elsif (a == "vertical-speed-hold" and !c) return "V/S";
  172. elsif (s == "speed-with-pitch-trim") return "IAS";
  173. elsif (a == "gs1-hold" and !c) return "G/S1";
  174. elsif (s == "go-around") return "GA";
  175. else return "";
  176. },
  177. timer: SLOW,
  178. type: "STRING"
  179. });
  180. adc["apArmPitch"] = Sensor.new( {function: func {
  181. var a = adc.apaltarm.val;
  182. var c = adc.apcoll.val;
  183. if (a == "altitude-hold" and !c) return "ALT.A";
  184. elsif (a == "gs1-hold" and !c) return "G/S1";
  185. else return "";
  186. },
  187. timer: SLOW,
  188. type: "STRING"
  189. });
  190. adc["apLockColl"] = Sensor.new( {function: func {
  191. var a = adc.apalt.val;
  192. var c = adc.apcoll.val;
  193. if (getprop("controls/flight/fcs/sas-enabled")==0) return " AFCS DISENGAGED";
  194. elsif (a == "altitude-hold" and c) return "ALT";
  195. elsif (a == "agl-hold" and c) return "CR.HT";
  196. elsif (a == "go-around") return "GA";
  197. elsif (a == "vertical-speed-hold" and c) return "V/S";
  198. elsif (a == "gs1-hold" and c) return "G/S1";
  199. elsif (a == "fpa-hold" and c) return "FPA";
  200. else return "";
  201. },
  202. timer: SLOW,
  203. type: "STRING"
  204. });
  205. adc["apArmColl"] = Sensor.new( {function: func {
  206. var a = adc.apaltarm.val;
  207. var c = adc.apcoll.val;
  208. if (a == "altitude-hold" and c) return "ALT.A";
  209. elsif (a == "gs1-hold" and c) return "G/S1";
  210. elsif (a == "agl-hold" and c) return "CR.HT";
  211. else return "";
  212. },
  213. timer: SLOW,
  214. type: "STRING"
  215. });
  216. ## Fuel
  217. adc["tank0"] = Sensor.new({prop: "consumables/fuel/tank[0]/level-norm", timer: SLOW, thres:0.01} );
  218. adc["tank1"] = Sensor.new({prop: "consumables/fuel/tank[1]/level-norm", timer: SLOW, thres:0.01} );
  219. adc["tank2"] = Sensor.new({prop: "consumables/fuel/tank[2]/level-norm", timer: SLOW, thres:0.01} );
  220. adc["tank_total"] = Sensor.new({prop: "consumables/fuel/total-fuel-lbs", timer: SLOW, thres:1} );
  221. adc["tank0lbs"] = Sensor.new({prop: "/consumables/fuel/tank[0]/level-lbs", timer: SLOW, thres:1} );
  222. adc["tank1lbs"] = Sensor.new({prop: "/consumables/fuel/tank[1]/level-lbs", timer: SLOW, thres:1} );
  223. adc["tank2lbs"] = Sensor.new({prop: "/consumables/fuel/tank[2]/level-lbs", timer: SLOW, thres:1} );
  224. adc["endurance"] = Sensor.new({prop: "/consumables/fuel/endurance-sec", timer: SLOW, thres:60} );
  225. adc["ff_1"] = Sensor.new({prop: "/engines/engine/fuel-flow_pph", timer: SLOW, thres:1 } );
  226. adc["ff_2"] = Sensor.new({prop: "/engines/engine[1]/fuel-flow_pph", timer: SLOW, thres:1 } );
  227. adc["grossweight"] = Sensor.new({prop: "/yasim/gross-weight-lbs", timer: SLOW, thres:1} );
  228. ## Electrical
  229. adc["batteryload"] = Sensor.new({prop: "/systems/electrical/loads/battery", timer: SLOW, thres:0.5} );
  230. adc["batterycharge"] = Sensor.new({prop: "/systems/electrical/loads/battery-charge", timer: SLOW, thres:0.5} );
  231. adc["elecBus0"] = Sensor.new({prop: "systems/electrical/outputs/bus[0]",timer:SLOW});
  232. adc["elecBus1"] = Sensor.new({prop: "systems/electrical/outputs/bus[1]",timer:SLOW});
  233. adc["elecAlt0"] = Sensor.new({prop: "/systems/electrical/loads/alternator[0]",timer:SLOW});
  234. adc["elecAlt1"] = Sensor.new({prop: "/systems/electrical/loads/alternator[1]",timer:SLOW});
  235. #unused
  236. #adc.initUpdateItems(1/25);