Debian Codegraph @

gui/dialogs/gps.xml

raw symbols SCIP
1 <?xml version="1.0"?>
2 <PropertyList>
3 <!-- mhab improve layout
4 <width>620</width>
5 <height>430</height>
6 -->
7 <modal>false</modal>
8 <nasal>
9 <open><![CDATA[
10
11 if (!defined("_gps_dialog_search_results")) {
12 globals._gps_dialog_search_results = [];
13 }
14
15 var gps = props.globals.getNode("/instrumentation/gps/", 1);
16 var dlg = props.globals.getNode("/sim/gui/dialogs/gps", 1);
17 var cmd = gps.getNode("command", 1);
18
19 var scratch = gps.getNode("scratch", 1);
20 var scratchValid = dlg.getNode("scratch/valid", 1);
21 var searchIsWaypoints = 0;
22 var anySpec = 'vor,airport,heliport,ils,seaport,fix,ndb,waypoint,tacan,city,town';
23 dlg.getNode("search-type", 1).setValue("airport");
24
25 var updateSearchResults = func(isWpts, index = 0)
26 {
27 searchIsWaypoints = isWpts;
28 dlg.getNode("scratch-index", 1).setValue(index);
29
30 var lastIndex = size(globals._gps_dialog_search_results) - 1;
31 dlg.getNode("scratch-has-next", 1).setValue((index + 1) < lastIndex);
32
33 if (size(globals._gps_dialog_search_results) < 1) {
34 scratchValid.setBoolValue(0);
35 return;
36 }
37
38 updateScratch();
39 }
40
41 var updateScratch = func
42 {
43 var index = dlg.getNode("scratch-index").getValue();
44 var result = globals._gps_dialog_search_results[index];
45 if (result == nil) {
46 scratchValid.setBoolValue(0);
47 return;
48 }
49
50 scratchValid.setBoolValue(1);
51 scratch.getNode("latitude-deg", 1).setValue(result.lat);
52 scratch.getNode("longitude-deg", 1).setValue(result.lon);
53 scratch.getNode("ident", 1).setValue(result.id);
54 var cd = nil;
55
56 if (searchIsWaypoints) {
57 scratch.getNode("type", 1).setValue('WPT');
58
59 cd = result.courseAndDistanceFrom(geo.aircraft_position());
60 } else {
61 var ty = result.type;
62 scratch.getNode("type", 1).setValue(ty);
63 scratch.getNode("name", 1).setValue(result.name);
64 scratch.getNode("altitude-ft", 1).setValue(result.elevation*M2FT);
65
66 if (ty == 'vor') {
67 scratch.getNode("frequency-mhz", 1).setValue(result.frequency);
68 } elsif (ty == 'ndb') {
69 scratch.getNode("frequency-khz", 1).setValue(result.frequency);
70 }
71
72 cd = positioned.courseAndDistance(result);
73 }
74
75
76 dlg.getNode("scratch-mag-bearing-deg", 1).setValue(geo.normdeg(cd[0] - magvar()));
77 dlg.getNode("scratch-distance-nm", 1).setValue(cd[1]);
78
79 gui.dialog_update("gps");
80 }
81
82 var doSearch = func()
83 {
84 var ty = dlg.getNode("search-type").getValue();
85 if (ty == 'any') ty = anySpec;
86
87 var query = dlg.getNode("search-query").getValue();
88 globals._gps_dialog_search_results = positioned.sortByRange(positioned.findByIdent(query, ty));
89 updateSearchResults(0);
90 }
91
92 var doSearchNames = func
93 {
94 var ty = dlg.getNode("search-type").getValue();
95 if (ty == 'any') ty = anySpec;
96 var query = dlg.getNode("search-query").getValue();
97 globals._gps_dialog_search_results = positioned.sortByRange(positioned.findByName(query, ty));
98 updateSearchResults(0);
99 }
100
101 var doSearchNearest = func
102 {
103 var ty = dlg.getNode("search-type").getValue();
104 if (ty == 'any') ty = anySpec;
105
106 globals._gps_dialog_search_results = positioned.findWithinRange(200.0, ty);
107 updateSearchResults(0);
108 }
109
110 var doLoadRouteWaypoint = func
111 {
112 var fp = flightplan();
113 var wps = [];
114 for (var i=0; i < fp.getPlanSize(); i+=1) {
115 append(wps, fp.getWP(i));
116 }
117 globals._gps_dialog_search_results = wps;
118 updateSearchResults(1, fp.current);
119 }
120
121 var doScratchPrevious = func
122 {
123 var index = dlg.getNode("scratch-index").getValue();
124 if (index == 0) return;
125 dlg.getNode("scratch-index").setValue(index - 1);
126 dlg.getNode("scratch-has-next", 1).setValue(size(globals._gps_dialog_search_results) > 1);
127 updateScratch();
128 }
129
130 var doScratchNext = func
131 {
132 var index = dlg.getNode("scratch-index").getValue();
133 var lastIndex = size(globals._gps_dialog_search_results) - 1;
134 if (index == lastIndex) return;
135
136 dlg.getNode("scratch-has-next", 1).setValue((index + 1) < lastIndex);
137 dlg.getNode("scratch-index").setValue(index + 1);
138 updateScratch();
139 }
140
141 # restore state from previous time the dialog was open
142 # default to 0 if no prior value
143 var curIndex = dlg.getNode("scratch-index", 1).getValue() or 0;
144 updateSearchResults(0, curIndex);
145
146 var slaved = props.globals.getNode("/instrumentation/nav[0]/slaved-to-gps", 1);
147 ]]></open>
148
149 </nasal>
150 <name>gps</name>
151 <layout>vbox</layout>
152 <group>
153 <layout>hbox</layout>
154
155 <text>
156 <label>GPS</label>
157 </text>
158
159 <empty><stretch>1</stretch></empty>
160
161 <button>
162 <legend>X</legend>
163 <key>Esc</key>
164 <pref-width>20</pref-width>
165 <pref-height>20</pref-height>
166 <binding>
167 <command>dialog-close</command>
168 </binding>
169 </button>
170 </group>
171 <hrule/>
172 <!-- show current state -->
173 <group>
174 <layout>table</layout>
175
176 <!-- only to get a gap to left border -->
177 <text>
178 <row>0</row>
179 <col>0</col>
180 <label> </label>
181 <halign>left</halign>
182 </text>
183
184 <!-- only to get a gap between row 1-3 -->
185 <text>
186 <row>0</row>
187 <col>2</col>
188 <label> </label>
189 <halign>left</halign>
190 </text>
191
192 <!-- only to get a gap between row 3-5 -->
193 <text>
194 <row>0</row>
195 <col>4</col>
196 <label> </label>
197 <halign>left</halign>
198 </text>
199
200 <text>
201 <row>0</row>
202 <col>1</col>
203 <halign>left</halign>
204 <label>MMMM</label>
205 <format>Mode: %s</format>
206 <property>/instrumentation/gps/mode</property>
207 <live>true</live>
208 </text>
209 <text>
210 <visible>
211 <equals>
212 <property>/instrumentation/gps/mode</property>
213 <value>leg</value>
214 </equals>
215 </visible>
216 <row>0</row>
217 <col>2</col>
218 <label>MMM</label>
219 <halign>left</halign>
220 <format>Current Route Wp: %03d</format>
221 <property>/autopilot/route-manager/current-wp</property>
222 <live>true</live>
223 </text>
224 <text>
225 <visible>
226 <not>
227 <equals>
228 <property>/instrumentation/gps/mode</property>
229 <value>leg</value>
230 </equals>
231 </not>
232 </visible>
233 <row>0</row>
234 <col>3</col>
235 <label>MMM</label>
236 <halign>left</halign>
237 <format>Desired course: %5.1f*</format>
238 <property>/instrumentation/gps/desired-course-deg</property>
239 <live>true</live>
240 </text>
241 <text>
242 <row>0</row>
243 <col>5</col>
244 <label>MMM</label>
245 <halign>left</halign>
246 <format>Xtrack: %5.2fnm</format>
247 <property>/instrumentation/gps/wp/wp[1]/course-error-nm</property>
248 <live>true</live>
249 </text>
250 <text>
251 <row>1</row>
252 <col>1</col>
253 <label>MMMMMM</label>
254 <halign>left</halign>
255 <format>Longitude: %6.3f</format>
256 <property>/instrumentation/gps/indicated-longitude-deg</property>
257 <live>true</live>
258 </text>
259 <text>
260 <row>1</row>
261 <col>3</col>
262 <label>MMMMMM</label>
263 <halign>left</halign>
264 <format>Latitude: %6.3f</format>
265 <property>/instrumentation/gps/indicated-latitude-deg</property>
266 <live>true</live>
267 </text>
268 <text>
269 <row>1</row>
270 <col>5</col>
271 <label>MMMMMM</label>
272 <halign>left</halign>
273 <format>Altitude: %6.0fft</format>
274 <property>/instrumentation/gps/indicated-altitude-ft</property>
275 <live>true</live>
276 </text>
277 <text>
278 <row>2</row>
279 <col>1</col>
280 <label>MMMM</label>
281 <halign>left</halign>
282 <format>Groundspeed: %4.0fkts</format>
283 <property>/instrumentation/gps/indicated-ground-speed-kt</property>
284 <live>true</live>
285 </text>
286 <text>
287 <row>2</row>
288 <col>3</col>
289 <label>MMM</label>
290 <halign>left</halign>
291 <format>Track: %3.0f*</format>
292 <property>/instrumentation/gps/indicated-track-magnetic-deg</property>
293 <live>true</live>
294 </text>
295 <text>
296 <row>2</row>
297 <col>5</col>
298 <label>MMMMMM</label>
299 <halign>left</halign>
300 <format>VS: %4.0ffpm</format>
301 <property>/instrumentation/gps/indicated-vertical-speed</property>
302 <live>true</live>
303 </text>
304 <text>
305 <row>3</row>
306 <col>1</col>
307 <label>MMMM</label>
308 <halign>left</halign>
309 <format>Odometer: %4.1fnm</format>
310 <property>/instrumentation/gps/odometer</property>
311 <live>true</live>
312 </text>
313 <text>
314 <row>3</row>
315 <col>3</col>
316 <label>MMMM</label>
317 <halign>left</halign>
318 <format>RAIM: %3.2f</format>
319 <property>/instrumentation/gps/raim</property>
320 <live>true</live>
321 </text>
322 <!-- mode dependent properties -->
323 <text>
324 <row>4</row>
325 <col>1</col>
326 <label>MMMMMM</label>
327 <halign>left</halign>
328 <format>Ident: %s</format>
329 <property>/instrumentation/gps/wp/wp[1]/ID</property>
330 <live>true</live>
331 </text>
332 <text>
333 <row>4</row>
334 <col>3</col>
335 <colspan>2</colspan>
336 <label>MMMMMMMMMMM</label>
337 <halign>left</halign>
338 <format>Name: %s</format>
339 <property>/instrumentation/gps/wp/wp[1]/name</property>
340 <live>true</live>
341 </text>
342 <text>
343 <row>5</row>
344 <col>1</col>
345 <label>MMMMMM</label>
346 <halign>left</halign>
347 <format>Longitude: %6.3f</format>
348 <property>/instrumentation/gps/wp/wp[1]/longitude-deg</property>
349 <live>true</live>
350 </text>
351 <text>
352 <row>5</row>
353 <col>3</col>
354 <label>MMMMMM</label>
355 <halign>left</halign>
356 <format>Latitude: %6.3f</format>
357 <property>/instrumentation/gps/wp/wp[1]/latitude-deg</property>
358 <live>true</live>
359 </text>
360 <text>
361 <row>5</row>
362 <col>5</col>
363 <label>MMMMMM</label>
364 <halign>left</halign>
365 <format>Altitude: %6.0fft</format>
366 <property>/instrumentation/gps/wp/wp[1]/altitude-ft</property>
367 <live>true</live>
368 </text>
369 <!-- distance / bearing info -->
370 <text>
371 <row>6</row>
372 <col>1</col>
373 <label>MMMMMM</label>
374 <halign>left</halign>
375 <format>Bearing: %3.0f</format>
376 <property>/instrumentation/gps/wp/wp[1]/bearing-mag-deg</property>
377 <live>true</live>
378 </text>
379 <text>
380 <row>6</row>
381 <col>3</col>
382 <label>MMMMMM</label>
383 <halign>left</halign>
384 <format>Distance: %5.2fnm</format>
385 <property>/instrumentation/gps/wp/wp[1]/distance-nm</property>
386 <live>true</live>
387 </text>
388 <text>
389 <row>6</row>
390 <col>5</col>
391 <label>MMMMMMMM</label>
392 <halign>left</halign>
393 <format>TTW: %s</format>
394 <property>/instrumentation/gps/wp/wp[1]/TTW</property>
395 <live>true</live>
396 </text>
397 <text>
398 <visible>
399 <equals>
400 <property>/instrumentation/gps/mode</property>
401 <value>leg</value>
402 </equals>
403 </visible>
404 <row>7</row>
405 <col>1</col>
406 <label>MMMMMM</label>
407 <halign>left</halign>
408 <format>Leg Course: %3.0f</format>
409 <property>/instrumentation/gps/wp/leg-mag-course-deg</property>
410 <live>true</live>
411 </text>
412 <text>
413 <visible>
414 <equals>
415 <property>/instrumentation/gps/mode</property>
416 <value>leg</value>
417 </equals>
418 </visible>
419 <row>7</row>
420 <col>3</col>
421 <label>MMMMMM</label>
422 <halign>left</halign>
423 <format>Leg Distance: %5.1fnm</format>
424 <property>/instrumentation/gps/wp/leg-distance-nm</property>
425 <live>true</live>
426 </text>
427 <text>
428 <visible>
429 <equals>
430 <property>/instrumentation/gps/mode</property>
431 <value>obs</value>
432 </equals>
433 <property>/instrumentation/gps/to-flag</property>
434 </visible>
435 <row>7</row>
436 <col>1</col>
437 <label>TO</label>
438 <halign>left</halign>
439 </text>
440 <text>
441 <visible>
442 <equals>
443 <property>/instrumentation/gps/mode</property>
444 <value>obs</value>
445 </equals>
446 <property>/instrumentation/gps/from-flag</property>
447 </visible>
448 <row>7</row>
449 <col>1</col>
450 <label>FROM</label>
451 <halign>left</halign>
452 </text>
453
454 <!-- only to get a gap to right border -->
455 <text>
456 <row>0</row>
457 <col>6</col>
458 <label> </label>
459 <halign>left</halign>
460 </text>
461
462 </group>
463
464 <hrule/>
465
466 <!-- ident text field, type combo, next/prev paging buttons
467 nearest and search buttons
468 -->
469 <group>
470 <layout>hbox</layout>
471 <valign>fill</valign>
472 <group>
473 <layout>vbox</layout>
474 <group>
475 <layout>hbox</layout>
476 <valign>fill</valign>
477 <halign>left</halign>
478 <text>
479 <label> Type:</label>
480 <halign>left</halign>
481 <!--
482 <pref-width>80</pref-width>
483 -->
484 </text>
485 <combo>
486 <pref-width>100</pref-width>
487 <name>searchType</name>
488 <property>/sim/gui/dialogs/gps/search-type</property>
489 <value>any</value>
490 <value>airport</value>
491 <value>vor</value>
492 <value>ndb</value>
493 <value>fix</value>
494 <value>wpt</value>
495 <value>city</value>
496 <value>town</value>
497 <live>true</live>
498 <binding>
499 <command>dialog-apply</command>
500 </binding>
501 </combo>
502 </group>
503 <group>
504 <layout>hbox</layout>
505 <valign>fill</valign>
506 <text>
507 <label> Search:</label>
508 <halign>left</halign>
509 <!--
510 <pref-width>80</pref-width>
511 -->
512 </text>
513 <input>
514 <name>search-query</name>
515 <halign>fill</halign>
516 <stretch>true</stretch>
517 <pref-width>150</pref-width>
518 <live>true</live>
519 <property>/sim/gui/dialogs/gps/search-query</property>
520 <binding>
521 <command>dialog-apply</command>
522 </binding>
523 </input>
524 <!-- only to get a gap -->
525 <text>
526 <label> </label>
527 <halign>left</halign>
528 </text>
529 </group>
530 <group>
531 <layout>hbox</layout>
532 <valign>fill</valign>
533 <!-- only to get a gap -->
534 <text>
535 <label> </label>
536 <halign>left</halign>
537 </text>
538 <button>
539 <legend>Search</legend>
540 <binding>
541 <command>nasal</command>
542 <script>doSearch()</script>
543 </binding>
544 </button>
545 <button>
546 <legend>Search Names</legend>
547 <binding>
548 <command>nasal</command>
549 <script>doSearchNames()</script>
550 </binding>
551 </button>
552 <button>
553 <legend>Nrst</legend>
554 <binding>
555 <command>nasal</command>
556 <script>doSearchNearest()</script>
557 </binding>
558 </button>
559 <button>
560 <enable>
561 <property>/autopilot/route-manager/active</property>
562 </enable>
563 <legend>Actv RTE WPT</legend>
564 <binding>
565 <command>nasal</command>
566 <script>doLoadRouteWaypoint()</script>
567 </binding>
568 </button>
569 <empty>
570 <stretch>true</stretch>
571 </empty>
572 </group>
573 </group>
574
575 <vrule/>
576
577 <group>
578 <visible>
579 <property>/sim/gui/dialogs/gps/scratch/valid</property>
580 </visible>
581 <layout>vbox</layout>
582
583 <group>
584 <visible>
585 <property>/sim/gui/dialogs/gps/scratch/valid</property>
586 </visible>
587 <layout>table</layout>
588 <text>
589 <row>0</row>
590 <col>0</col>
591 <halign>left</halign>
592 <label>MMMMMM</label>
593 <format>Ident: %s</format>
594 <property>/instrumentation/gps/scratch/ident</property>
595 <live>true</live>
596 </text>
597 <text>
598 <row>0</row>
599 <col>1</col>
600 <pref-width>250</pref-width>
601 <colspan>2</colspan>
602 <halign>left</halign>
603 <label>MMMMMM</label>
604 <format>Name: %s</format>
605 <property>/instrumentation/gps/scratch/name</property>
606 <live>true</live>
607 </text>
608 <text>
609 <row>1</row>
610 <col>0</col>
611 <halign>left</halign>
612 <label>MMMMMMMM</label>
613 <format>Lon: %6.3f</format>
614 <property>/instrumentation/gps/scratch/longitude-deg</property>
615 <live>true</live>
616 </text>
617 <text>
618 <row>1</row>
619 <col>1</col>
620 <halign>left</halign>
621 <label>MMMMMMM</label>
622 <format>Lat: %6.3f</format>
623 <property>/instrumentation/gps/scratch/latitude-deg</property>
624 <live>true</live>
625 </text>
626 <text>
627 <row>1</row>
628 <col>2</col>
629 <halign>left</halign>
630 <label>MMMMMM</label>
631 <format>Alt: %6.0fft</format>
632 <property>/instrumentation/gps/scratch/altitude-ft</property>
633 <live>true</live>
634 </text>
635 <!-- gap -->
636 <text>
637 <row>1</row>
638 <col>3</col>
639 <halign>left</halign>
640 <label> </label>
641 </text>
642 <!-- distance / bearing info -->
643 <text>
644 <row>2</row>
645 <col>0</col>
646 <halign>left</halign>
647 <label>MMMMMM</label>
648 <format>Bearing: %3.0f</format>
649 <property>/sim/gui/dialogs/gps/scratch-mag-bearing-deg</property>
650 <live>true</live>
651 </text>
652 <text>
653 <row>2</row>
654 <col>1</col>
655 <halign>left</halign>
656 <label>MMMMMM</label>
657 <format>Distance: %5.1fnm</format>
658 <property>/sim/gui/dialogs/gps/scratch-distance-nm</property>
659 <live>true</live>
660 </text>
661 <!-- navaid info -->
662 <text>
663 <visible>
664 <equals>
665 <property>/instrumentation/gps/scratch/type</property>
666 <value>vor</value>
667 </equals>
668 </visible>
669 <row>3</row>
670 <col>0</col>
671 <halign>left</halign>
672 <label>MMMMMMMMMM</label>
673 <format>Frequency: %5.1fMhz</format>
674 <property>/instrumentation/gps/scratch/frequency-mhz</property>
675 <live>true</live>
676 </text>
677 <text>
678 <visible>
679 <equals>
680 <property>/instrumentation/gps/scratch/type</property>
681 <value>ndb</value>
682 </equals>
683 </visible>
684 <row>3</row>
685 <col>0</col>
686 <halign>left</halign>
687 <label>MMMMMMMMM</label>
688 <format>Frequency: %5.1fKhz</format>
689 <property>/instrumentation/gps/scratch/frequency-khz</property>
690 <live>true</live>
691 </text>
692 </group>
693 <group>
694 <visible>
695 <property>/sim/gui/dialogs/gps/scratch/valid</property>
696 </visible>
697 <layout>hbox</layout>
698 <!-- prev/next buttons -->
699 <button>
700 <enable>
701 <greater-than>
702 <property>/sim/gui/dialogs/gps/scratch-index</property>
703 <value>0</value>
704 </greater-than>
705 </enable>
706 <halign>left</halign>
707 <legend>Prev</legend>
708 <key>left</key>
709 <binding>
710 <command>nasal</command>
711 <script>doScratchPrevious()</script>
712 </binding>
713 </button>
714 <button>
715 <enable>
716 <property>/sim/gui/dialogs/gps/scratch-has-next</property>
717 </enable>
718 <halign>left</halign>
719 <legend>Next</legend>
720 <key>right</key>
721 <binding>
722 <command>nasal</command>
723 <script>doScratchNext()</script>
724 </binding>
725 </button>
726 </group>
727 </group>
728 </group>
729 <hrule/>
730 <group>
731 <layout>hbox</layout>
732 <halign>fill</halign>
733 <default-padding>6</default-padding>
734 <button>
735 <legend>LEG</legend>
736 <equal>true</equal>
737 <binding>
738 <command>nasal</command>
739 <script>cmd.setValue("leg")</script>
740 </binding>
741 </button>
742 <button>
743 <legend>DTO</legend>
744 <binding>
745 <command>nasal</command>
746 <script>cmd.setValue("direct")</script>
747 </binding>
748 </button>
749 <button>
750 <legend>OBS</legend>
751 <binding>
752 <command>nasal</command>
753 <script>cmd.setValue("obs")</script>
754 </binding>
755 </button>
756 <text>
757 <visible>
758 <equals>
759 <property>/instrumentation/gps/mode</property>
760 <value>obs</value>
761 </equals>
762 </visible>
763 <!--
764 <pref-width>100</pref-width>
765 -->
766 <label>MMMMMMMMMMM</label>
767 <format>Selected Course: %03d*</format>
768 <property>/instrumentation/gps/selected-course-deg</property>
769 <live>true</live>
770 </text>
771 <dial>
772 <visible>
773 <equals>
774 <property>/instrumentation/gps/mode</property>
775 <value>obs</value>
776 </equals>
777 </visible>
778 <pref-width>30</pref-width>
779 <pref-height>30</pref-height>
780 <wrap>true</wrap>
781 <min>0</min>
782 <max>359</max>
783 <stretch>true</stretch>
784 <property>/instrumentation/gps/selected-course-deg</property>
785 <binding>
786 <command>dialog-apply</command>
787 </binding>
788 </dial>
789 <empty>
790 <stretch>true</stretch>
791 </empty>
792 <checkbox>
793 <halign>left</halign>
794 <label>Link NAV1 to GPS</label>
795 <property>/instrumentation/nav[0]/slaved-to-gps</property>
796 <binding>
797 <command>dialog-apply</command>
798 </binding>
799 </checkbox>
800 <button>
801 <legend>Close</legend>
802 <default>true</default>
803 <key>Esc</key>
804 <binding>
805 <command>dialog-close</command>
806 </binding>
807 </button>
808 </group>
809 </PropertyList>