Debian Codegraph @

scripts/perl/examples/position.pl

raw
1 #!/usr/bin/perl
2 #
3 # position.pl - Handle repositioning aircraft (in air/on ground)
4 #
5 # Written by Curtis L. Olson, started January 2004
6 #
7 # Copyright (C) 2004 Curtis L. Olson - http://www.flightgear.org/~curt
8 #
9 # This code is placed in the public domain by Curtis L. Olson.
10 # There is no warranty, etc. etc. etc.
11 #
12 # $Id$
13 # ----------------------------------------------------------------------------
14
15
16 require "telnet.pl";
17
18 use strict;
19
20 my( $airport_id ) = "KSNA";
21 my( $rwy_no ) = "19R";
22 my( $reset_sec ) = 300;
23
24 my( $server ) = "localhost";
25 my( $port ) = 5401;
26 my( $timeout ) = 5;
27
28
29 sub reset_in_air {
30 my( $fgfs ) = shift;
31 my( $aptid ) = shift;
32 my( $rwy ) = shift;
33 my( $offset_dist ) = shift;
34 my( $glideslope_deg ) = shift;
35 my( $altitude_ft ) = shift;
36 my( $airspeed_kt ) = shift;
37
38 my( $prop, $value );
39 my( %HASH ) = ();
40
41 $HASH{ "/sim/presets/airport-id" } = $aptid;
42 $HASH{ "/sim/presets/runway" } = $rwy;
43 $HASH{ "/sim/presets/offset-distance" } = $offset_dist;
44 if ( $glideslope_deg > 0 ) {
45 $HASH{ "/sim/presets/glideslope-deg" } = $glideslope_deg;
46 $HASH{ "/sim/presets/altitude-ft" } = "";
47 } else {
48 $HASH{ "/sim/presets/glideslope-deg" } = "";
49 $HASH{ "/sim/presets/altitude-ft" } = $altitude_ft;
50 }
51
52 $HASH{ "/sim/presets/airspeed-kt" } = $airspeed_kt;
53 $HASH{ "/sim/presets/vor-id" } = "";
54 $HASH{ "/sim/presets/vor-freq" } = "";
55 $HASH{ "/sim/presets/ndb-id" } = "";
56 $HASH{ "/sim/presets/ndb-freq" } = "";
57 $HASH{ "/sim/presets/fix" } = "";
58 $HASH{ "/sim/presets/longitude-deg" } = "-9999.0";
59 $HASH{ "/sim/presets/latitude-deg" } = "-9999.0";
60 $HASH{ "/sim/presets/offset-azimuth" } = "";
61 $HASH{ "/sim/presets/heading-deg" } = "-9999.0";
62
63 foreach $prop ( keys(%HASH) ) {
64 $value = $HASH{$prop};
65 print "setting $prop = $value\n";
66 &set_prop( $fgfs, $prop, $value );
67 }
68
69 &send( $fgfs, "run presets-commit" );
70 }
71
72
73 sub reset_on_ground {
74 my( $fgfs ) = shift;
75 my( $aptid ) = shift;
76 my( $rwy ) = shift;
77
78 my( $prop, $value );
79 my( %HASH ) = ();
80
81 $HASH{ "/sim/presets/airport-id" } = $aptid;
82 $HASH{ "/sim/presets/runway" } = $rwy;
83 $HASH{ "/sim/presets/offset-distance" } = "";
84 $HASH{ "/sim/presets/glideslope-deg" } = "";
85 $HASH{ "/sim/presets/altitude-ft" } = "";
86 $HASH{ "/sim/presets/airspeed-kt" } = "";
87 $HASH{ "/sim/presets/vor-id" } = "";
88 $HASH{ "/sim/presets/vor-freq" } = "";
89 $HASH{ "/sim/presets/ndb-id" } = "";
90 $HASH{ "/sim/presets/ndb-freq" } = "";
91 $HASH{ "/sim/presets/fix" } = "";
92 $HASH{ "/sim/presets/longitude-deg" } = "-9999.0";
93 $HASH{ "/sim/presets/latitude-deg" } = "-9999.0";
94 $HASH{ "/sim/presets/offset-azimuth" } = "";
95 $HASH{ "/sim/presets/heading-deg" } = "-9999.0";
96
97 foreach $prop ( keys(%HASH) ) {
98 $value = $HASH{$prop};
99 print "setting $prop = $value\n";
100 &set_prop( $fgfs, $prop, $value );
101 }
102
103 &send( $fgfs, "run presets-commit" );
104 }
105
106
107