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