CWS.nas 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. # init some properties for Nasal's sake
  2. setprop("/systems/hydraulic_servos/servosp", 0);
  3. WarningPanelUpdate = func {
  4. var fuel = props.globals.getValue("/consumables/fuel/tank[0]/level-lbs") or 0;
  5. var fuelp = props.globals.getValue("/controls/fuel/tank/fuellines_filled") or 0;
  6. var fuelf = props.globals.getValue("/controls/fuel/tank/fuelfilter") or 0;
  7. var servo = props.globals.getValue("/systems/hydraulic_servos/servosp") or 0;
  8. var hydr = props.globals.getValue("/systems/hydraulic_servos/servosp") or 0;
  9. var genload = props.globals.getValue("/systems/electrical/gen-load") or 0;
  10. var batt = props.globals.getValue("/systems/electrical/batt-volts") or 0;
  11. var pitot = props.globals.getValue("/controls/anti-ice/pitot-heat") or 0;
  12. var horn = props.globals.getValue("/controls/electric/horn") or 0;
  13. var door = props.globals.getValue("/sim/model/ec130/doors/door-open") or 0;
  14. var instlight1 = props.globals.getValue("/controls/lighting/instrument-lights") or 0;
  15. var instlight2 = props.globals.getValue("/controls/lighting/instrument-lights2") or 0;
  16. var engp = props.globals.getValue("/engines/engine/oil-pressure-bar") or 0;
  17. var oilp = props.globals.getValue("/engines/engine/oil-pressure-bar-filter") or 0;
  18. var mgbp = props.globals.getValue("/rotors/gear/mgb-oil-pressure-bar") or 0;
  19. var twtgrip = props.globals.getValue("/controls/engines/engine/power") or 0;
  20. # var n1 = props.globals.getValue("/engines/engine/n1-pct") or 0;
  21. # var volts = props.globals.getValue("/systems/electrical/volts") or 0;
  22. # var starter = props.globals.getValue("/controls/engines/engine/starter") or 0;
  23. var LaL = props.globals.getValue("/systems/electrical/outputs/landing-light") or 0;
  24. var TxL = props.globals.getValue("/systems/electrical/outputs/taxi-light") or 0;
  25. var servotest = getprop("/controls/electric/servotest");
  26. var firetest = getprop("/controls/electric/firetest");
  27. var test = getprop("/controls/electric/warningtest");
  28. var gov = props.globals.getValue("/controls/engines/engine/governor") or 0;
  29. var gyro = props.globals.getValue("/controls/electric/gyrocompass") or 0;
  30. ###cautions###
  31. if (LaL or TxL or test)
  32. {
  33. setprop("/instrumentation/annunciators/warning/lite",1);
  34. } else {
  35. setprop("/instrumentation/annunciators/warning/lite",0.0);
  36. }
  37. if ((fuel <106) or test)
  38. {
  39. setprop("/instrumentation/annunciators/warning/fuel",1);
  40. } else {
  41. setprop("/instrumentation/annunciators/warning/fuel",0.0);
  42. }
  43. if ((fuelp < 0.99) or test)
  44. {
  45. setprop("/instrumentation/annunciators/warning/fuelp",1);
  46. } else {
  47. setprop("/instrumentation/annunciators/warning/fuelp",0.0);
  48. }
  49. if ((fuelf > 0.2) or test)
  50. {
  51. setprop("/instrumentation/annunciators/warning/fuelf",1);
  52. } else {
  53. setprop("/instrumentation/annunciators/warning/fuelf",0.0);
  54. }
  55. if ((genload<0.3) or test)
  56. {
  57. setprop("/instrumentation/annunciators/warning/gen",1);
  58. } else {
  59. setprop("/instrumentation/annunciators/warning/gen",0.0);
  60. }
  61. if ((batt < 24 ) or test)
  62. {
  63. setprop("/instrumentation/annunciators/warning/batt",1);
  64. } else {
  65. setprop("/instrumentation/annunciators/warning/batt",0.0);
  66. }
  67. # not in real use yet
  68. if (test)
  69. {
  70. setprop("/instrumentation/annunciators/warning/emergxmit",1);
  71. } else {
  72. setprop("/instrumentation/annunciators/warning/emergxmit",0.0);
  73. }
  74. # not in real use yet
  75. if (test)
  76. {
  77. setprop("/instrumentation/annunciators/warning/inv",1);
  78. } else {
  79. setprop("/instrumentation/annunciators/warning/inv",0.0);
  80. }
  81. if ((pitot < 1) or test)
  82. {
  83. setprop("/instrumentation/annunciators/warning/pitot",1);
  84. } else {
  85. setprop("/instrumentation/annunciators/warning/pitot",0.0);
  86. }
  87. if ((horn < 1) or test)
  88. {
  89. setprop("/instrumentation/annunciators/warning/horn",1);
  90. } else {
  91. setprop("/instrumentation/annunciators/warning/horn",0.0);
  92. }
  93. if (door or test)
  94. {
  95. setprop("/instrumentation/annunciators/warning/door",1);
  96. } else {
  97. setprop("/instrumentation/annunciators/warning/door",0.0);
  98. }
  99. if ((!instlight1 and !instlight2) or test)
  100. {
  101. setprop("/instrumentation/annunciators/warning/instlight",1);
  102. } else {
  103. setprop("/instrumentation/annunciators/warning/instlight",0.0);
  104. }
  105. # not in real use yet
  106. if (test)
  107. {
  108. setprop("/instrumentation/annunciators/warning/noideayet",1);
  109. } else {
  110. setprop("/instrumentation/annunciators/warning/noideayet",0.0);
  111. }
  112. # not in real use yet
  113. if (test)
  114. {
  115. setprop("/instrumentation/annunciators/warning/mgbtemp",1);
  116. } else {
  117. setprop("/instrumentation/annunciators/warning/mgbtemp",0.0);
  118. }
  119. # not in real use yet
  120. if (test)
  121. {
  122. setprop("/instrumentation/annunciators/warning/p2ovht",1);
  123. } else {
  124. setprop("/instrumentation/annunciators/warning/p2ovht",0.0);
  125. }
  126. if ( !gov or test)
  127. {
  128. setprop("/instrumentation/annunciators/warning/gov",1);
  129. } else {
  130. setprop("/instrumentation/annunciators/warning/gov",0.0);
  131. }
  132. # not in real use yet
  133. if (test)
  134. {
  135. setprop("/instrumentation/annunciators/warning/engchip",1);
  136. } else {
  137. setprop("/instrumentation/annunciators/warning/engchip",0.0);
  138. }
  139. # not in real use yet
  140. if (test)
  141. {
  142. setprop("/instrumentation/annunciators/warning/mgbchip",1);
  143. } else {
  144. setprop("/instrumentation/annunciators/warning/mgbchip",0.0);
  145. }
  146. # not in real use yet
  147. if (test)
  148. {
  149. setprop("/instrumentation/annunciators/warning/tgbchip",1);
  150. } else {
  151. setprop("/instrumentation/annunciators/warning/tgbchip",0.0);
  152. }
  153. # value unclear, guess only
  154. if ((servo < 10) or servotest or test)
  155. {
  156. setprop("/instrumentation/annunciators/warning/servo",1);
  157. } else {
  158. setprop("/instrumentation/annunciators/warning/servo",0.0);
  159. }
  160. # value unclear, guess only
  161. if ((hydr < 10) or test)
  162. {
  163. setprop("/instrumentation/annunciators/warning/hydr",1);
  164. } else {
  165. setprop("/instrumentation/annunciators/warning/hydr",0.0);
  166. }
  167. # LIMIT is cotrolled via limits.nas
  168. if (test)
  169. {
  170. setprop("/instrumentation/annunciators/warning/limit",1);
  171. }
  172. if ( !gyro or test)
  173. {
  174. setprop("/instrumentation/annunciators/warning/gyro",1);
  175. } else {
  176. setprop("/instrumentation/annunciators/warning/gyro",0.0);
  177. }
  178. # not in real use yet
  179. if (test)
  180. {
  181. setprop("/instrumentation/annunciators/warning/trim",1);
  182. } else {
  183. setprop("/instrumentation/annunciators/warning/trim",0.0);
  184. }
  185. ###warnings###
  186. if ((oilp <1.1) or test)
  187. {
  188. setprop("/instrumentation/annunciators/cautions/engp",1);
  189. setprop("/sim/sound/gong", 1);
  190. } else {
  191. setprop("/instrumentation/annunciators/cautions/engp",0);
  192. }
  193. if ((engp < 1.1) or test)
  194. {
  195. setprop("/instrumentation/annunciators/cautions/engp",1);
  196. setprop("/sim/sound/gong", 1);
  197. } else {
  198. setprop("/instrumentation/annunciators/cautions/engp",0);
  199. }
  200. if ((mgbp < 1) or test)
  201. {
  202. setprop("/instrumentation/annunciators/cautions/mgbp",1);
  203. setprop("/sim/sound/gong", 1);
  204. } else {
  205. setprop("/instrumentation/annunciators/cautions/mgbp",0);
  206. }
  207. if (firetest or test)
  208. {
  209. setprop("/instrumentation/annunciators/warning/engfire",1);
  210. setprop("/sim/sound/gong", 1);
  211. } else {
  212. setprop("/instrumentation/annunciators/warning/engfire",0.0);
  213. }
  214. # not in real use yet
  215. if (test)
  216. {
  217. setprop("/instrumentation/annunciators/warning/battemp",1);
  218. setprop("/sim/sound/gong", 1);
  219. } else {
  220. setprop("/instrumentation/annunciators/warning/battemp",0.0);
  221. }
  222. if ( !gov or test )
  223. {
  224. setprop("/instrumentation/annunciators/warning/redgov",1);
  225. setprop("/sim/sound/gong", 1);
  226. } else {
  227. setprop("/instrumentation/annunciators/warning/redgov",0.0);
  228. }
  229. if ((twtgrip < 0.99) or test)
  230. {
  231. setprop("/instrumentation/annunciators/cautions/twtgrip",1);
  232. setprop("/sim/sound/gong", 1);
  233. } else {
  234. setprop("/instrumentation/annunciators/cautions/twtgrip",0);
  235. }
  236. # not in real use yet
  237. if (test)
  238. {
  239. setprop("/instrumentation/annunciators/warning/pa",1);
  240. setprop("/sim/sound/gong", 1);
  241. } else {
  242. setprop("/instrumentation/annunciators/warning/pa",0.0);
  243. }
  244. # turn off gong
  245. if ( !getprop("/instrumentation/annunciators/warning/engp")
  246. and !getprop("/instrumentation/annunciators/cautions/mgbp")
  247. and !getprop("/instrumentation/annunciators/warning/redgov")
  248. and !getprop("/instrumentation/annunciators/warning/engfire")
  249. and !getprop("/instrumentation/annunciators/warning/battemp")
  250. and !getprop("/instrumentation/annunciators/cautions/twtgrip")
  251. and !getprop("/instrumentation/annunciators/warning/pa") ) {
  252. setprop("/sim/sound/gong", 0);
  253. }
  254. ###
  255. if (test)
  256. {
  257. setprop("/instrumentation/annunciators/test",1);
  258. } else {
  259. setprop("/instrumentation/annunciators/test",0);
  260. }
  261. settimer(WarningPanelUpdate, 0.1);
  262. }
  263. WarningPanelUpdate();