Debian Codegraph @

scripts/perl/examples/autopilot.pl

raw
1 #!/usr/bin/perl
2 #
3 # autopilot.pl - Handle autopilot functions
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
21 sub autopilot_off {
22 my( $fgfs ) = shift;
23
24 &set_prop( $fgfs, "/autopilot/locks/heading", "" );
25 &set_prop( $fgfs, "/autopilot/locks/altitude", "" );
26 &set_prop( $fgfs, "/autopilot/locks/speed", "" );
27 }
28
29
30 sub wing_leveler {
31 my( $fgfs ) = shift;
32 my( $state ) = shift;
33
34 if ( $state ) {
35 &set_prop( $fgfs, "/autopilot/locks/heading", "wing-leveler" );
36 } else {
37 &set_prop( $fgfs, "/autopilot/locks/heading", "" );
38 }
39 }
40
41
42 sub bank_hold {
43 my( $fgfs ) = shift;
44 my( $state ) = shift;
45 my( $bank_deg ) = shift;
46
47 if ( $state ) {
48 &set_prop( $fgfs, "/autopilot/locks/heading", "bank-hold" );
49 &set_prop( $fgfs, "/autopilot/settings/target-bank-deg", $bank_deg );
50 } else {
51 &set_prop( $fgfs, "/autopilot/locks/heading", "" );
52 }
53 }
54
55
56 sub heading_hold {
57 my( $fgfs ) = shift;
58 my( $state ) = shift;
59 my( $hdg_deg ) = shift;
60
61 if ( $state ) {
62 &set_prop( $fgfs, "/autopilot/locks/heading", "dg-heading-hold" );
63 &set_prop( $fgfs, "/autopilot/settings/heading-bug-deg", $hdg_deg );
64 } else {
65 &set_prop( $fgfs, "/autopilot/locks/heading", "" );
66 }
67 }
68
69
70 sub pitch_hold_trim {
71 my( $fgfs ) = shift;
72 my( $state ) = shift;
73 my( $pitch_deg ) = shift;
74
75 if ( $state ) {
76 &set_prop( $fgfs, "/autopilot/locks/altitude", "pitch-hold" );
77 &set_prop( $fgfs, "/autopilot/settings/target-pitch-deg", $pitch_deg );
78 } else {
79 &set_prop( $fgfs, "/autopilot/locks/altitude", "" );
80 }
81 }
82
83
84 sub pitch_hold_yoke {
85 my( $fgfs ) = shift;
86 my( $state ) = shift;
87 my( $pitch_deg ) = shift;
88
89 if ( $state ) {
90 &set_prop( $fgfs, "/autopilot/locks/altitude", "pitch-hold-yoke" );
91 &set_prop( $fgfs, "/autopilot/settings/target-pitch-deg", $pitch_deg );
92 } else {
93 &set_prop( $fgfs, "/autopilot/locks/altitude", "" );
94 }
95 }
96
97
98 sub altitude_hold {
99 my( $fgfs ) = shift;
100 my( $state ) = shift;
101 my( $alt_ft ) = shift;
102
103 if ( $state ) {
104 &set_prop( $fgfs, "/autopilot/locks/altitude", "altitude-hold" );
105 &set_prop( $fgfs, "/autopilot/settings/target-altitude-ft", $alt_ft );
106 } else {
107 &set_prop( $fgfs, "/autopilot/locks/altitude", "" );
108 }
109 }
110
111
112 sub auto_speed_throttle {
113 my( $fgfs ) = shift;
114 my( $state ) = shift;
115 my( $kts ) = shift;
116
117 if ( $state ) {
118 &set_prop( $fgfs, "/autopilot/locks/speed", "speed-with-throttle" );
119 &set_prop( $fgfs, "/autopilot/settings/target-speed-kt", $kts );
120 } else {
121 &set_prop( $fgfs, "/autopilot/locks/speed", "" );
122 }
123 }
124
125
126 sub auto_speed_pitch_trim {
127 my( $fgfs ) = shift;
128 my( $state ) = shift;
129 my( $kts ) = shift;
130
131 if ( $state ) {
132 &set_prop( $fgfs, "/autopilot/locks/speed", "speed-with-pitch-trim" );
133 &set_prop( $fgfs, "/autopilot/settings/target-speed-kt", $kts );
134 } else {
135 &set_prop( $fgfs, "/autopilot/locks/speed", "" );
136 }
137 }
138
139 sub auto_speed_pitch_yoke {
140 my( $fgfs ) = shift;
141 my( $state ) = shift;
142 my( $kts ) = shift;
143
144 if ( $state ) {
145 &set_prop( $fgfs, "/autopilot/locks/speed", "speed-with-pitch-yoke" );
146 &set_prop( $fgfs, "/autopilot/settings/target-speed-kt", $kts );
147 } else {
148 &set_prop( $fgfs, "/autopilot/locks/speed", "" );
149 }
150 }
151
152
153
154