autopilot.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <?xml version="1.0"?>
  2. <PropertyList>
  3. <name>autopilot</name>
  4. <layout>vbox</layout>
  5. <!--
  6. /autopilot/locks/altitude
  7. /autopilot/locks/heading
  8. /autopilot/locks/speed
  9. /autopilot/locks/passive-mode
  10. /autopilot/settings/heading-bug-deg
  11. /autopilot/settings/target-agl-ft
  12. /autopilot/settings/target-altitude-ft
  13. /autopilot/settings/target-aoa-deg
  14. /autopilot/settings/target-pitch-deg
  15. /autopilot/settings/target-speed-kt
  16. /autopilot/settings/true-heading-deg
  17. /autopilot/settings/vertical-speed-fpm
  18. -->
  19. <group>
  20. <layout>hbox</layout>
  21. <empty><stretch>1</stretch></empty>
  22. <text>
  23. <label>AS350 Autopilot V3</label>
  24. </text>
  25. <empty><stretch>1</stretch></empty>
  26. <button>
  27. <pref-width>16</pref-width>
  28. <pref-height>16</pref-height>
  29. <legend></legend>
  30. <default>1</default>
  31. <keynum>27</keynum>
  32. <border>2</border>
  33. <binding>
  34. <command>dialog-close</command>
  35. </binding>
  36. <binding>
  37. <command>dialog-apply</command>
  38. </binding>
  39. </button>
  40. </group>
  41. <hrule/>
  42. <nasal>
  43. <open>
  44. ## manage one AP property group with checkbox and radio buttons
  45. #
  46. Group = {
  47. new : func(name, options) {
  48. var m = { parents: [Group] };
  49. m.name = name;
  50. m.enabled = 0;
  51. m.mode = options[0];
  52. m.options = [];
  53. var locks = props.globals.getNode("/autopilot/locks", 1);
  54. if (locks.getNode(name) == nil or locks.getNode(name, 1).getValue() == nil) {
  55. locks.getNode(name, 1).setValue("");
  56. }
  57. m.lock = locks.getNode(name);
  58. m.active = dlg.getNode(name ~ "-active", 1);
  59. foreach (var o; options) {
  60. var node = dlg.getNode(o);
  61. if (node == nil) {
  62. node = dlg.getNode(o, 1);
  63. node.setBoolValue(0);
  64. }
  65. append(m.options, node);
  66. if (m.lock.getValue() == o) {
  67. m.mode = o;
  68. }
  69. }
  70. m.listener = setlistener(m.lock, func(n) { m.update(n.getValue()) }, 1);
  71. return m;
  72. },
  73. del : func {
  74. removelistener(me.listener);
  75. },
  76. ## handle checkbox
  77. #
  78. enable : func {
  79. me.enabled = me.active.getBoolValue();
  80. me.lock.setValue(me.enabled ? me.mode : "");
  81. },
  82. ## handle radiobuttons
  83. #
  84. set : func(mode) {
  85. me.mode = mode;
  86. foreach (var o; me.options) {
  87. o.setBoolValue(o.getName() == mode);
  88. }
  89. if (me.enabled) {
  90. me.lock.setValue(mode);
  91. }
  92. },
  93. ## update checkboxes/radiobuttons state from the AP (listener callback)
  94. #
  95. update : func(mode) {
  96. me.enabled = (mode != "");
  97. me.active.setBoolValue(me.enabled);
  98. if (mode == "") {
  99. mode = me.mode;
  100. }
  101. foreach (var o; me.options) {
  102. o.setBoolValue(o.getName() == mode);
  103. }
  104. },
  105. };
  106. ## create and initialize input field properties if necessary
  107. #
  108. var apset = props.globals.getNode("/autopilot/settings", 1);
  109. foreach (var p; ["heading-bug-deg", "true-heading-deg", "vertical-speed-fpm",
  110. "target-pitch-deg", "target-aoa-deg", "target-altitude-ft",
  111. "target-agl-ft", "target-speed-kt"]) {
  112. if ((var n = apset.getNode(p)) == nil or n.getType() == "NONE") {
  113. apset.getNode(p, 1).setDoubleValue(0);
  114. }
  115. }
  116. var dlg = props.globals.getNode("/sim/gui/dialogs/autopilot", 1);
  117. # - first entry ("heading" etc.) is the target property in /autopilot/locks/ *and*
  118. # the checkbox state property name (with "-active" appended);
  119. # - second entry is a list of available options for the /autopilot/locks/* property
  120. # and used as radio button state property; the first list entry is used as default
  121. #
  122. var hdg = Group.new("heading", ["dg-heading-hold", "wing-leveler", "true-heading-hold", "nav1-hold"]);
  123. var vel = Group.new("speed", ["speed-with-throttle", "speed-with-pitch-trim"]);
  124. var alt = Group.new("altitude", ["altitude-hold", "vertical-speed-hold", "pitch-hold",
  125. "aoa-hold", "agl-hold", "gs1-hold"]);
  126. </open>
  127. <close>
  128. hdg.del();
  129. vel.del();
  130. alt.del();
  131. </close>
  132. </nasal>
  133. <group>
  134. <layout>hbox</layout>
  135. <default-padding>8</default-padding>
  136. <group>
  137. <!-- Heading -->
  138. <layout>vbox</layout>
  139. <group>
  140. <layout>hbox</layout>
  141. <checkbox>
  142. <label>Heading Control</label>
  143. <halign>fill</halign>
  144. <property>/sim/gui/dialogs/autopilot/heading-active</property>
  145. <live>true</live>
  146. <binding>
  147. <command>dialog-apply</command>
  148. </binding>
  149. <binding>
  150. <command>nasal</command>
  151. <script>hdg.enable()</script>
  152. </binding>
  153. </checkbox>
  154. </group>
  155. <group>
  156. <layout>table</layout>
  157. <text>
  158. <label>Heading Bug</label>
  159. <halign>right</halign>
  160. <row>1</row>
  161. <col>0</col>
  162. </text>
  163. <radio>
  164. <row>1</row>
  165. <col>1</col>
  166. <property>/sim/gui/dialogs/autopilot/dg-heading-hold</property>
  167. <live>true</live>
  168. <binding>
  169. <command>nasal</command>
  170. <script>hdg.set("dg-heading-hold")</script>
  171. </binding>
  172. </radio>
  173. <input>
  174. <row>1</row>
  175. <col>2</col>
  176. <property>/autopilot/settings/heading-bug-deg</property>
  177. <live>true</live>
  178. <binding>
  179. <command>dialog-apply</command>
  180. </binding>
  181. </input>
  182. <text>
  183. <label>True Heading</label>
  184. <halign>right</halign>
  185. <row>2</row>
  186. <col>0</col>
  187. <visible>
  188. <not>
  189. <property>/autopilot/settings/gps-driving-true-heading</property>
  190. </not>
  191. </visible>
  192. </text>
  193. <!-- alternate UI for above, when GPS is controlling -->
  194. <text>
  195. <visible>
  196. <property>/autopilot/settings/gps-driving-true-heading</property>
  197. </visible>
  198. <label>GPS/FMS Heading</label>
  199. <halign>right</halign>
  200. <row>2</row>
  201. <col>0</col>
  202. </text>
  203. <radio>
  204. <row>2</row>
  205. <col>1</col>
  206. <property>/sim/gui/dialogs/autopilot/true-heading-hold</property>
  207. <live>true</live>
  208. <binding>
  209. <command>nasal</command>
  210. <script>hdg.set("true-heading-hold")</script>
  211. </binding>
  212. </radio>
  213. <input>
  214. <visible>
  215. <not>
  216. <property>/autopilot/settings/gps-driving-true-heading</property>
  217. </not>
  218. </visible>
  219. <row>2</row>
  220. <col>2</col>
  221. <property>/autopilot/settings/true-heading-deg</property>
  222. <live>true</live>
  223. <binding>
  224. <command>dialog-apply</command>
  225. </binding>
  226. </input>
  227. <!-- alternate UI for above, when GPS is controlling -->
  228. <text>
  229. <visible>
  230. <property>/autopilot/settings/gps-driving-true-heading</property>
  231. </visible>
  232. <halign>right</halign>
  233. <row>2</row>
  234. <col>2</col>
  235. <label>MMMM</label>
  236. <format>%3.0f*</format>
  237. <property>/autopilot/settings/true-heading-deg</property>
  238. <live>true</live>
  239. </text>
  240. <text>
  241. <label>NAV1 CDI Course</label>
  242. <halign>right</halign>
  243. <row>3</row>
  244. <col>0</col>
  245. </text>
  246. <radio>
  247. <row>3</row>
  248. <col>1</col>
  249. <property>/sim/gui/dialogs/autopilot/nav1-hold</property>
  250. <live>true</live>
  251. <binding>
  252. <command>nasal</command>
  253. <script>hdg.set("nav1-hold")</script>
  254. </binding>
  255. </radio>
  256. </group>
  257. <hrule/>
  258. <group>
  259. <layout>hbox</layout>
  260. <checkbox>
  261. <label>Velocity Control ( 30-145 kts IAS. )</label>
  262. <halign>fill</halign>
  263. <property>/sim/gui/dialogs/autopilot/speed-active</property>
  264. <live>true</live>
  265. <binding>
  266. <command>dialog-apply</command>
  267. </binding>
  268. <binding>
  269. <command>nasal</command>
  270. <script>vel.enable()</script>
  271. </binding>
  272. </checkbox>
  273. </group>
  274. <group>
  275. <layout>table</layout>
  276. <input>
  277. <row>0</row>
  278. <col>2</col>
  279. <rowspan>2</rowspan>
  280. <property>/autopilot/settings/target-speed-kt</property>
  281. <live>true</live>
  282. <binding>
  283. <command>dialog-apply</command>
  284. </binding>
  285. </input>
  286. <text>
  287. <label>Speed with Pitch</label>
  288. <halign>right</halign>
  289. <row>1</row>
  290. <col>0</col>
  291. </text>
  292. <radio>
  293. <row>1</row>
  294. <col>1</col>
  295. <property>/sim/gui/dialogs/autopilot/speed-with-pitch-trim</property>
  296. <live>true</live>
  297. <binding>
  298. <command>nasal</command>
  299. <script>vel.set("speed-with-pitch-trim")</script>
  300. </binding>
  301. </radio>
  302. </group>
  303. </group>
  304. <!-- End of Heading/Speed -->
  305. <vrule/>
  306. <group>
  307. <!-- Pitch/Altitude -->
  308. <layout>vbox</layout>
  309. <group>
  310. <layout>hbox</layout>
  311. <checkbox>
  312. <label>Altitude Control via Collective</label>
  313. <halign>fill</halign>
  314. <property>/sim/gui/dialogs/autopilot/altitude-active</property>
  315. <live>true</live>
  316. <binding>
  317. <command>dialog-apply</command>
  318. </binding>
  319. <binding>
  320. <command>nasal</command>
  321. <script>alt.enable()</script>
  322. </binding>
  323. </checkbox>
  324. </group>
  325. <group>
  326. <layout>table</layout>
  327. <text>
  328. <label>Vertical Speed</label>
  329. <halign>right</halign>
  330. <row>0</row>
  331. <col>0</col>
  332. </text>
  333. <radio>
  334. <row>0</row>
  335. <col>1</col>
  336. <property>/sim/gui/dialogs/autopilot/vertical-speed-hold</property>
  337. <live>true</live>
  338. <binding>
  339. <command>nasal</command>
  340. <script>alt.set("vertical-speed-hold")</script>
  341. </binding>
  342. </radio>
  343. <input>
  344. <row>0</row>
  345. <col>2</col>
  346. <property>/autopilot/settings/vertical-speed-fpm</property>
  347. <live>true</live>
  348. <binding>
  349. <command>dialog-apply</command>
  350. </binding>
  351. </input>
  352. <text>
  353. <label>Altitude Hold</label>
  354. <halign>right</halign>
  355. <row>3</row>
  356. <col>0</col>
  357. </text>
  358. <radio>
  359. <row>3</row>
  360. <col>1</col>
  361. <property>/sim/gui/dialogs/autopilot/altitude-hold</property>
  362. <live>true</live>
  363. <binding>
  364. <command>nasal</command>
  365. <script>alt.set("altitude-hold")</script>
  366. </binding>
  367. </radio>
  368. <input>
  369. <row>3</row>
  370. <col>2</col>
  371. <property>/autopilot/settings/target-altitude-ft</property>
  372. <live>true</live>
  373. <binding>
  374. <command>dialog-apply</command>
  375. </binding>
  376. </input>
  377. <text>
  378. <label>NAV1 Glideslope</label>
  379. <halign>right</halign>
  380. <row>5</row>
  381. <col>0</col>
  382. </text>
  383. <radio>
  384. <row>5</row>
  385. <col>1</col>
  386. <property>/sim/gui/dialogs/autopilot/gs1-hold</property>
  387. <live>true</live>
  388. <binding>
  389. <command>nasal</command>
  390. <script>alt.set("gs1-hold")</script>
  391. </binding>
  392. </radio>
  393. </group>
  394. <empty>
  395. <stretch>true</stretch>
  396. </empty>
  397. </group>
  398. <!-- End of Pitch/Altitude VBox -->
  399. </group>
  400. <hrule/>
  401. <group>
  402. <!-- Passive Mode Toggle -->
  403. <layout>hbox</layout>
  404. <checkbox>
  405. <label>FlightDirector Mode</label>
  406. <halign>center</halign>
  407. <property>/autopilot/locks/passive-mode</property>
  408. <live>true</live>
  409. <binding>
  410. <command>dialog-apply</command>
  411. </binding>
  412. <binding>
  413. <command>property-toggle</command>
  414. </binding>
  415. </checkbox>
  416. </group>
  417. <hrule/>
  418. <button>
  419. <legend>Close</legend>
  420. <default>true</default>
  421. <key>Esc</key>
  422. <binding>
  423. <command>dialog-close</command>
  424. </binding>
  425. </button>
  426. </PropertyList>