File: position.pl

package info (click to toggle)
flightgear 0.9.6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 9,948 kB
  • ctags: 17,555
  • sloc: cpp: 90,696; ansic: 5,266; sh: 3,488; makefile: 840; perl: 680; python: 106
file content (107 lines) | stat: -rwxr-xr-x 3,063 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/perl
#
# position.pl - Handle repositioning aircraft (in air/on ground)
#
# Written by Curtis L. Olson, started January 2004
#
# Copyright (C) 2004  Curtis L. Olson - curt@flightgear.org
#
# This code is placed in the public domain by Curtis L. Olson.
# There is no warranty, etc. etc. etc.
#
# $Id: position.pl,v 1.2 2004/02/12 20:28:19 curt Exp $
# ----------------------------------------------------------------------------


require "telnet.pl";

use strict;

my( $airport_id ) = "KSNA";
my( $rwy_no ) = "19R";
my( $reset_sec ) = 300;

my( $server ) = "localhost";
my( $port ) = 5401;
my( $timeout ) = 5;


sub reset_in_air {
    my( $fgfs ) = shift;
    my( $aptid ) = shift;
    my( $rwy ) = shift;
    my( $offset_dist ) = shift;
    my( $glideslope_deg ) = shift;
    my( $altitude_ft ) = shift;
    my( $airspeed_kt ) = shift;

    my( $prop, $value );
    my( %HASH ) = ();

    $HASH{ "/sim/presets/airport-id" } = $aptid;
    $HASH{ "/sim/presets/runway" } = $rwy;
    $HASH{ "/sim/presets/offset-distance" } = $offset_dist;
    if ( $glideslope_deg > 0 ) {
        $HASH{ "/sim/presets/glideslope-deg" } = $glideslope_deg;
        $HASH{ "/sim/presets/altitude-ft" } = "";
    } else {
        $HASH{ "/sim/presets/glideslope-deg" } = "";
        $HASH{ "/sim/presets/altitude-ft" } = $altitude_ft;
    }

    $HASH{ "/sim/presets/airspeed-kt" } = $airspeed_kt;
    $HASH{ "/sim/presets/vor-id" } = "";
    $HASH{ "/sim/presets/vor-freq" } = "";
    $HASH{ "/sim/presets/ndb-id" } = "";
    $HASH{ "/sim/presets/ndb-freq" } = "";
    $HASH{ "/sim/presets/fix" } = "";
    $HASH{ "/sim/presets/longitude-deg" } = "-9999.0";
    $HASH{ "/sim/presets/latitude-deg" } = "-9999.0";
    $HASH{ "/sim/presets/offset-azimuth" } = "";
    $HASH{ "/sim/presets/heading-deg" } = "-9999.0";

    foreach $prop ( keys(%HASH) ) {
        $value = $HASH{$prop};
        print "setting $prop = $value\n";
        &set_prop( $fgfs, $prop, $value );
    }

    &send( $fgfs, "run presets-commit" );
}


sub reset_on_ground {
    my( $fgfs ) = shift;
    my( $aptid ) = shift;
    my( $rwy ) = shift;

    my( $prop, $value );
    my( %HASH ) = ();

    $HASH{ "/sim/presets/airport-id" } = $aptid;
    $HASH{ "/sim/presets/runway" } = $rwy;
    $HASH{ "/sim/presets/offset-distance" } = "";
    $HASH{ "/sim/presets/glideslope-deg" } = "";
    $HASH{ "/sim/presets/altitude-ft" } = "";
    $HASH{ "/sim/presets/airspeed-kt" } = "";
    $HASH{ "/sim/presets/vor-id" } = "";
    $HASH{ "/sim/presets/vor-freq" } = "";
    $HASH{ "/sim/presets/ndb-id" } = "";
    $HASH{ "/sim/presets/ndb-freq" } = "";
    $HASH{ "/sim/presets/fix" } = "";
    $HASH{ "/sim/presets/longitude-deg" } = "-9999.0";
    $HASH{ "/sim/presets/latitude-deg" } = "-9999.0";
    $HASH{ "/sim/presets/offset-azimuth" } = "";
    $HASH{ "/sim/presets/heading-deg" } = "-9999.0";

    foreach $prop ( keys(%HASH) ) {
        $value = $HASH{$prop};
        print "setting $prop = $value\n";
        &set_prop( $fgfs, $prop, $value );
    }

    &send( $fgfs, "run presets-commit" );
}