Debian Codegraph @

gui/dialogs/route-manager.xml

raw symbols SCIP
1 <?xml version="1.0"?>
2
3 <!--
4 command interface /autopilot/route-manager/input:
5
6 @clear ... clear route
7 @pop ... remove first entry
8 @delete3 ... delete 4th entry
9 @insert2:ksfo@900 ... insert "ksfo@900" as 3rd entry
10 ksfo@900 ... append "ksfo@900"
11
12 -->
13
14 <PropertyList>
15 <name>route-manager</name>
16 <layout>vbox</layout>
17 <resizable>true</resizable>
18
19 <nasal>
20 <open><![CDATA[
21 var ft = getprop("/sim/startup/units") == "feet";
22 var dlg = props.globals.getNode("/sim/gui/dialogs/route-manager", 1);
23 var selection = dlg.getNode("selection", 1);
24 var input = dlg.getNode("input", 1);
25
26 var routem = props.globals.getNode("/autopilot/route-manager", 1);
27
28 selection.setIntValue(-1);
29 input.setValue("");
30
31 var list = cmdarg().getNode("list");
32 var cmd = routem.getNode("input", 1);
33 var route = routem.getNode("route", 1);
34 var dep = routem.getNode("departure", 1);
35 var dest = routem.getNode("destination", 1);
36
37 var sel_index = func {
38 return int(selection.getValue());
39 }
40
41 var clear = func {
42 flightplan().clearAll();
43 selection.setIntValue(-1);
44 gui.dialog_update("route-manager");
45 }
46
47 var insert = func {
48 var insertIndex = sel_index();
49 var appending = (insertIndex < 0);
50
51 # Input is a list of space-separated waypoint specifications
52 var argv = split(" ", input.getValue());
53 foreach (var arg; argv) {
54 # When argument is not empty (caused by multiple space
55 # separators) insert *after* waypoint
56 if (size(arg) > 0) {
57 if (appending) {
58 cmd.setValue(arg);
59 } else {
60 insertIndex += 1;
61 cmd.setValue("@insert" ~ insertIndex ~ ":" ~ arg);
62 }
63 }
64 }
65
66 input.setValue("");
67 selection.setValue(insertIndex);
68 gui.dialog_update("route-manager");
69 }
70
71 var remove = func {
72 flightplan().deleteWP(sel_index());
73 }
74
75 var route = func {
76 var fp = flightplan();
77 var from = fp.getWP(sel_index() - 1);
78 var to = fp.getWP(sel_index());
79
80 if ((from == nil ) or (to == nil)) {
81 logprint(LOG_INFO, 'unable to route, invalid start ad end points');
82 return;
83 }
84
85 var route = airwaysRoute(from, to);
86 fp.insertWaypoints(route, sel_index());
87 }
88
89 var jump_to = func {
90 flightplan().current = sel_index();
91 }
92
93 var load_route = func(path) {
94 routem.getNode("file-path", 1).setValue(path.getValue());
95 cmd.setValue("@load");
96 }
97
98 var save_route = func(path) {
99 routem.getNode("file-path", 1).setValue(path.getValue());
100 cmd.setValue("@save");
101 gui.dialog_update("route-manager");
102 }
103
104 var defaultDirInFileSelector = 'DOCUMENTS';
105
106 var file_selector = gui.FileSelector.new(
107 callback: load_route, title: "Load flight-plan", button: "Load",
108 location: defaultDirInFileSelector, dotfiles: 0);
109 var save_selector = gui.FileSelector.new(
110 callback: save_route, title: "Save flight-plan", button: "Save",
111 location: defaultDirInFileSelector, dotfiles: 0);
112
113 var activate_fp = func {
114 fgcommand("activate-flightplan", props.Node.new({"activate": 1}));
115 }
116
117 var departureRunways = dlg.getNode("departure-runways", 1);
118 var destRunways = dlg.getNode("destination-runways", 1);
119 var sids = dlg.getNode("sids", 1);
120 var stars = dlg.getNode("stars", 1);
121 var approaches = dlg.getNode("approaches", 1);
122
123 var updateDepartureRunways = func {
124 departureRunways.removeChildren("value");
125 apt = flightplan().departure;
126 if (apt != nil) {
127 var i=0;
128 foreach (var rwy; keys(apt.runways)) {
129 departureRunways.getNode("value[" ~ i ~ "]", 1).setValue(rwy);
130 i += 1;
131 }
132 }
133
134 gui.dialog_update("route-manager", "departure-runway");
135 }
136
137 var updateArrivalRunways = func {
138 destRunways.removeChildren("value");
139 var apt = flightplan().destination;
140 if (apt != nil) {
141 var i=0;
142 foreach (var rwy; keys(apt.runways)) {
143 destRunways.getNode("value[" ~ i ~ "]", 1).setValue(rwy);
144 i += 1;
145 }
146 }
147
148 gui.dialog_update("route-manager", "destination-runway");
149 }
150
151 var updateSIDs = func {
152 sids.removeChildren("value");
153
154 var apt = flightplan().departure;
155 var rwy = flightplan().departure_runway;
156 if (apt == nil) {
157 return;
158 }
159
160 if (size(apt.sids(rwy)) == 0) {
161 sids.getNode("value[0]", 1).setValue("DEFAULT");
162 sids.getNode("value[1]", 1).setValue("(none)");
163 gui.dialog_update("route-manager", "sid");
164 return;
165 }
166
167 var i=1;
168 sids.getNode("value[0]", 1).setValue("(none)");
169 foreach (var s; apt.sids(rwy)) {
170 var sid = apt.getSid(s);
171 var transVec = sid.transitions;
172
173 if (size(transVec) > 0) {
174 # list each transition of the SID
175 foreach (var trans; transVec) {
176 sids.getNode("value[" ~ i ~ "]", 1).setValue(s ~ "-" ~ trans);
177 i += 1;
178 }
179 } else {
180 # no transitions defined, simple case
181 sids.getNode("value[" ~ i ~ "]", 1).setValue(s);
182 i += 1;
183 }
184 }
185
186 gui.dialog_update("route-manager", "sid");
187 }
188
189 var updateSTARs = func {
190 stars.removeChildren("value");
191 var apt = flightplan().destination;
192 var rwy = flightplan().destination_runway;
193 if (apt == nil or apt.stars(rwy) == nil) {
194 return;
195 }
196
197 var i=1;
198 stars.getNode("value[0]", 1).setValue("(none)");
199 foreach (var s; apt.stars(rwy)) {
200 var star = apt.getStar(s);
201 var transVec = star.transitions;
202
203 if (size(transVec) > 0) {
204 # list each transition of the STAR
205 foreach (var trans; transVec) {
206 stars.getNode("value[" ~ i ~ "]", 1).setValue(s ~ "-" ~ trans);
207 i += 1;
208 }
209 } else {
210 # no transitions defined, simple case
211 stars.getNode("value[" ~ i ~ "]", 1).setValue(s);
212 i += 1;
213 }
214 }
215
216 gui.dialog_update("route-manager", "star");
217 }
218
219 var updateApproaches = func {
220 approaches.removeChildren("value");
221 var apt = flightplan().destination;
222 var rwy = flightplan().destination_runway;
223
224 if (apt == nil) {
225 return;
226 }
227
228 if (size(apt.getApproachList(rwy)) == 0) {
229 approaches.getNode("value[0]", 1).setValue("DEFAULT");
230 approaches.getNode("value[1]", 1).setValue("(none)");
231 gui.dialog_update("route-manager", "approach");
232 return;
233 }
234
235 if (rwy == nil) {
236 logprint(LOG_INFO, "no destination runway selected");
237 } else {
238 logprint(LOG_INFO, "updateApproaches: destinatiom runway is:" ~ rwy.id);
239 }
240
241 var i=1;
242 approaches.getNode("value[0]", 1).setValue("(none)");
243 foreach (var s; apt.getApproachList(rwy)) {
244 approaches.getNode("value[" ~ i ~ "]", 1).setValue(s);
245 i += 1;
246 }
247
248 gui.dialog_update("route-manager", "approach");
249 }
250
251 var initPosition = func {
252 var routeActive = routem.getNode("active").getValue();
253 if (routeActive) return;
254
255 # FIXME have user waypoints check
256 var fp = flightplan();
257
258 var airborne = getprop('/gear/gear[0]/wow') == 0;
259 if (airborne) {
260 logprint(LOG_INFO, 'route-manager dialog, init in-air, clearing departure settings');
261 fp.departure = nil;
262 return;
263 }
264
265 # we're on the ground, find the nearest airport to start from
266 if (fp.departure == nil) {
267 var apts = findAirportsWithinRange(25.0);
268 if (size(apts) == 0) return; # no airports nearby
269 fp.departure = apts[0]; # use the closest one
270 }
271
272 if (fp.departure_runway == nil) {
273 var rwy = fp.departure.findBestRunwayForPos( geo.aircraft_position() );
274 fp.departure_runway = rwy;
275 logprint(LOG_INFO, "Selected runway:", rwy.id);
276 }
277 }
278
279 # initialise departure values based on current position
280 initPosition();
281
282 updateDepartureRunways();
283 updateArrivalRunways();
284 updateSIDs();
285 updateApproaches();
286 updateSTARs();
287 ]]></open>
288
289 <close>
290 file_selector.del();
291 save_selector.del();
292 </close>
293
294 <departure-changed><![CDATA[
295 logprint(LOG_INFO, "dialog updating departure info");
296 updateDepartureRunways();
297 updateSIDs();
298 ]]></departure-changed>
299
300 <arrival-changed><![CDATA[
301 logprint(LOG_INFO, "dialog updating arrival info");
302 updateArrivalRunways();
303 updateApproaches();
304 updateSTARs();
305 ]]></arrival-changed>
306
307 </nasal>
308
309 <group>
310 <layout>hbox</layout>
311
312 <text>
313 <label>Route Manager</label>
314 </text>
315
316 <empty><stretch>1</stretch></empty>
317
318 <button>
319 <legend>X</legend>
320 <key>Esc</key>
321 <pref-width>20</pref-width>
322 <pref-height>20</pref-height>
323 <binding>
324 <command>dialog-close</command>
325 </binding>
326 </button>
327 </group>
328 <hrule/>
329 <!-- departure / arrival airport information -->
330
331 <group>
332 <layout>table</layout>
333 <text>
334 <row>0</row>
335 <col>0</col>
336 <halign>right</halign>
337 <label> Departure:</label>
338 </text>
339 <input>
340 <row>0</row>
341 <col>1</col>
342 <halign>left</halign>
343 <name>departure-airport</name>
344 <pref-width>70</pref-width>
345 <property>/autopilot/route-manager/departure/airport</property>
346 <live>true</live>
347 <binding>
348 <command>dialog-apply</command>
349 <object-name>departure-airport</object-name>
350 </binding>
351 </input>
352
353 <text>
354 <row>0</row>
355 <col>2</col>
356 <format>%s</format>
357 <property>/autopilot/route-manager/departure/name</property>
358 <live>true</live>
359 <stretch>true</stretch>
360 <halign>fill</halign>
361 </text>
362
363 <text>
364 <row>0</row>
365 <col>3</col>
366 <halign>right</halign>
367 <label>Rwy:</label>
368 </text>
369 <combo>
370 <row>0</row>
371 <col>4</col>
372 <halign>left</halign>
373 <name>departure-runway</name>
374 <property>/autopilot/route-manager/departure/runway</property>
375 <editable>false</editable>
376 <properties>/sim/gui/dialogs/route-manager/departure-runways</properties>
377
378 <binding>
379 <command>dialog-apply</command>
380 <object-name>departure-runway</object-name>
381 </binding>
382 </combo>
383
384 <text>
385 <row>0</row>
386 <col>7</col>
387 <halign>right</halign>
388 <label>SID:</label>
389 </text>
390 <combo>
391 <row>0</row>
392 <col>8</col>
393 <halign>left</halign>
394 <name>sid</name>
395 <property>/autopilot/route-manager/departure/sid-with-trans</property>
396 <editable>false</editable>
397 <properties>/sim/gui/dialogs/route-manager/sids</properties>
398
399 <binding>
400 <command>dialog-apply</command>
401 <object-name>sid</object-name>
402 </binding>
403 </combo>
404
405 <text>
406 <row>1</row>
407 <col>0</col>
408 <halign>right</halign>
409 <label>Arrival:</label>
410 </text>
411 <input>
412 <row>1</row>
413 <col>1</col>
414 <halign>left</halign>
415 <pref-width>70</pref-width>
416 <name>destination-airport</name>
417 <property>/autopilot/route-manager/destination/airport</property>
418 <live>true</live>
419 <binding>
420 <command>dialog-apply</command>
421 <object-name>destination-airport</object-name>
422 </binding>
423 </input>
424 <text>
425 <row>1</row>
426 <col>2</col>
427 <stretch>true</stretch>
428 <pref-width>200</pref-width>
429 <format>%s</format>
430 <property>/autopilot/route-manager/destination/name</property>
431 <live>true</live>
432 <halign>fill</halign>
433 </text>
434
435 <text>
436 <row>1</row>
437 <col>3</col>
438 <halign>right</halign>
439 <label>Rwy:</label>
440 </text>
441 <combo>
442 <row>1</row>
443 <col>4</col>
444 <halign>left</halign>
445 <name>destination-runway</name>
446 <property>/autopilot/route-manager/destination/runway</property>
447 <editable>false</editable>
448 <properties>/sim/gui/dialogs/route-manager/destination-runways</properties>
449
450 <binding>
451 <command>dialog-apply</command>
452 <object-name>destination-runway</object-name>
453 </binding>
454 </combo>
455
456 <text>
457 <row>1</row>
458 <col>5</col>
459 <halign>right</halign>
460 <label>Approach:</label>
461 </text>
462 <combo>
463 <row>1</row>
464 <col>6</col>
465 <pref-width>120</pref-width>
466 <halign>left</halign>
467 <name>approach</name>
468 <property>/autopilot/route-manager/destination/approach-with-trans</property>
469 <editable>false</editable>
470 <properties>/sim/gui/dialogs/route-manager/approaches</properties>
471
472 <binding>
473 <command>dialog-apply</command>
474 <object-name>approach</object-name>
475 </binding>
476 </combo>
477
478
479 <text>
480 <row>1</row>
481 <col>7</col>
482 <halign>right</halign>
483 <label>STAR:</label>
484 </text>
485 <combo>
486 <row>1</row>
487 <col>8</col>
488 <halign>left</halign>
489 <name>star</name>
490 <property>/autopilot/route-manager/destination/star-with-trans</property>
491 <editable>false</editable>
492 <properties>/sim/gui/dialogs/route-manager/stars</properties>
493
494 <binding>
495 <command>dialog-apply</command>
496 <object-name>star</object-name>
497 </binding>
498 </combo>
499 </group>
500 <!--
501 <group>
502 <layout>hbox</layout>
503 <text>
504 <label>Alternate:</label>
505 <pref-width>80</pref-width>
506 </text>
507 <input>
508 <name>alt-airport</name>
509 <halign>fill</halign>
510 <stretch>true</stretch>
511 <pref-width>150</pref-width>
512 <property>/autopilot/route-manager/alternate/airport</property>
513 </input>
514
515 </group>
516 -->
517 <group>
518 <layout>hbox</layout>
519 <text>
520 <halign>right</halign>
521 <label> Cruise Speed (kts):</label>
522 </text>
523 <input>
524 <name>cruise-speed</name>
525 <live>true</live>
526 <halign>left</halign>
527 <stretch>true</stretch>
528 <pref-width>100</pref-width>
529 <property>/autopilot/route-manager/cruise/speed-kts</property>
530 <binding>
531 <command>dialog-apply</command>
532 <object-name>cruise-speed</object-name>
533 </binding>
534 </input>
535
536 <text>
537 <label>Cruise Altitude (ft/FL):</label>
538 <halign>right</halign>
539 </text>
540 <input>
541 <name>cruise-alt</name>
542 <live>true</live>
543 <halign>left</halign>
544 <stretch>true</stretch>
545 <pref-width>100</pref-width>
546 <property>/autopilot/route-manager/cruise/altitude-ft</property>
547 <binding>
548 <command>dialog-apply</command>
549 <object-name>cruise-alt</object-name>
550 </binding>
551 </input>
552 </group>
553
554 <hrule/>
555
556 <group>
557 <layout>hbox</layout>
558 <default-padding>2</default-padding>
559 <text>
560 <label>MMMMMMMMMMMMM</label>
561 <format>Total Dist: %.2f nm</format>
562 <property>/autopilot/route-manager/total-distance</property>
563 <live>true</live>
564 </text>
565 <text>
566 <label>MMMMMMMMMMMMMMMMM</label>
567 <format>Dist Remaining: %.2f nm</format>
568 <property>/autopilot/route-manager/distance-remaining-nm</property>
569 <live>true</live>
570 </text>
571 <text>
572 <label>MMMMMMMMMMMMMM</label>
573 <format>ETE: %s</format>
574 <property>/autopilot/route-manager/ete-string</property>
575 <live>true</live>
576 </text>
577 <text>
578 <label>MMMMMMMMMMMMMMMM</label>
579 <format>Flight Time: %s</format>
580 <property>/autopilot/route-manager/flight-time-string</property>
581 <live>true</live>
582 </text>
583 </group>
584 <group>
585 <layout>hbox</layout>
586 <default-padding>2</default-padding>
587
588 <text>
589 <label>MMMMMMMMMMMMMMMM</label>
590 <format>Target: %s</format>
591 <property>/autopilot/route-manager/wp[0]/id</property>
592 <live>true</live>
593 </text>
594
595 <text>
596 <label>MMMMMMMMM</label>
597 <format>Dist: %.2f nm</format>
598 <property>/autopilot/route-manager/wp[0]/dist</property>
599 <live>true</live>
600 </text>
601
602 <text>
603 <label>MMMMMMMMM</label>
604 <format>ETA: %s</format>
605 <property>/autopilot/route-manager/wp[0]/eta</property>
606 <live>true</live>
607 </text>
608 </group>
609
610 <group>
611 <layout>hbox</layout>
612 <default-padding>2</default-padding>
613 <stretch>true</stretch>
614 <halign>fill</halign>
615 <valign>fill</valign>
616
617 <!-- gap -->
618 <text>
619 <label> </label>
620 </text>
621
622 <waypointlist>
623 <name>list</name>
624 <halign>fill</halign>
625 <valign>fill</valign>
626 <stretch>true</stretch>
627 <pref-height>150</pref-height>
628 <property>/sim/gui/dialogs/route-manager/selection</property>
629 <binding>
630 <command>dialog-apply</command>
631 <object-name>list</object-name>
632 </binding>
633 </waypointlist>
634
635 <!-- gap -->
636 <text>
637 <label> </label>
638 </text>
639
640 </group>
641
642 <group>
643 <layout>hbox</layout>
644 <default-padding>4</default-padding>
645
646 <text>
647 <label> Waypoint:</label>
648 <!--
649 <pref-width>60</pref-width>
650 -->
651 </text>
652
653 <input>
654 <name>input</name>
655 <halign>fill</halign>
656 <stretch>true</stretch>
657 <pref-width>220</pref-width>
658 <property>/sim/gui/dialogs/route-manager/input</property>
659 </input>
660
661 <button>
662 <legend>Add</legend>
663 <default>true</default>
664 <!--
665 <pref-width>70</pref-width>
666 -->
667 <binding>
668 <command>dialog-apply</command>
669 <object-name>input</object-name>
670 </binding>
671 <binding>
672 <command>nasal</command>
673 <script>insert()</script>
674 </binding>
675 <binding>
676 <command>dialog-update</command>
677 </binding>
678 </button>
679
680 <!-- gap -->
681 <text>
682 <label></label>
683 </text>
684 </group>
685
686 <text>
687 <padding>1</padding>
688 <label>Format: list of (airport|fix|nav|lon,lat) with optional @alt -- e.g. "KSFO@900", "SAHEY CIITY@6000"</label>
689 </text>
690 <text>
691 <padding>1</padding>
692 <label>Lon,lat can be entered signed, with NSEW, or as degrees and minutes, e.g. "-2.5,51.3", "2.5W,51.3N", "11*47.17'E,48*21.23'N"</label>
693 </text>
694 <text>
695 <padding>1</padding>
696 <label>Any location can be be offset by a radial and distance in Nm, e.g. DCS/45/10 or 18.5E,33.9S/290/4.5</label>
697 </text>
698
699 <!-- button field -->
700 <group>
701 <layout>hbox</layout>
702 <halign>fill</halign>
703 <default-padding>8</default-padding>
704
705 <button>
706 <legend>Clear All</legend>
707 <equal>true</equal>
708 <binding>
709 <command>nasal</command>
710 <script>clear()</script>
711 </binding>
712 </button>
713
714 <button>
715 <legend>Remove</legend>
716 <equal>true</equal>
717 <enable>
718 <greater-than>
719 <property>/sim/gui/dialogs/route-manager/selection</property>
720 <value>-1</value>
721 </greater-than>
722 </enable>
723 <binding>
724 <command>nasal</command>
725 <script>remove()</script>
726 </binding>
727 </button>
728
729 <button>
730 <legend>Route</legend>
731 <equal>true</equal>
732 <binding>
733 <command>nasal</command>
734 <script>route()</script>
735 </binding>
736 </button>
737 <!--
738 <button>
739 <legend>Auto-route</legend>
740 <equal>true</equal>
741 <binding>
742 <command>nasal</command>
743 <script>auto_route()</script>
744 </binding>
745 </button>
746 -->
747 <button>
748 <legend>Jump To</legend>
749 <enable>
750 <greater-than>
751 <property>/sim/gui/dialogs/route-manager/selection</property>
752 <value>-1</value>
753 </greater-than>
754 </enable>
755 <binding>
756 <command>nasal</command>
757 <script>jump_to()</script>
758 </binding>
759 </button>
760
761 <button>
762 <legend>Activate</legend>
763 <equal>true</equal>
764 <enable>
765 <not><property>/autopilot/route-manager/active</property></not>
766 </enable>
767 <binding>
768 <command>dialog-apply</command>
769 </binding>
770 <binding>
771 <command>nasal</command>
772 <script>activate_fp()</script>
773 </binding>
774 </button>
775
776 <empty><stretch>true</stretch></empty>
777 <!-- gap -->
778 <text>
779 <label></label>
780 </text>
781
782 <button>
783 <legend>Load ...</legend>
784 <equal>true</equal>
785 <enable>
786 <not><property>/autopilot/route-manager/active</property></not>
787 </enable>
788 <binding>
789 <command>nasal</command>
790 <script>file_selector.open()</script>
791 </binding>
792 </button>
793 <button>
794 <legend>Save ...</legend>
795 <equal>true</equal>
796 <binding>
797 <command>nasal</command>
798 <script>save_selector.open();</script>
799 </binding>
800 </button>
801 <button>
802 <legend>Close</legend>
803 <equal>true</equal>
804 <key>Esc</key>
805 <binding>
806 <command>dialog-close</command>
807 </binding>
808 </button>
809 </group>
810 </PropertyList>