]> git.mxchange.org Git - flightgear.git/blob - src/Controls/controls.cxx
Add Nasal Vs. 1.5
[flightgear.git] / src / Controls / controls.cxx
1 // controls.cxx -- defines a standard interface to all flight sim controls
2 //
3 // Written by Curtis Olson, started May 1997.
4 //
5 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #include <simgear/compiler.h>
25 #include <simgear/debug/logstream.hxx>
26 #include <Main/fg_props.hxx>
27
28 #include "controls.hxx"
29
30
31 static const int MAX_NAME_LEN = 128;
32
33 \f
34 ////////////////////////////////////////////////////////////////////////
35 // Inline utility methods.
36 ////////////////////////////////////////////////////////////////////////
37
38 static inline void
39 CLAMP(double *x, double min, double max )
40 {
41   if ( *x < min ) { *x = min; }
42   if ( *x > max ) { *x = max; }
43 }
44
45 static inline void
46 CLAMP(int *i, int min, int max )
47 {
48   if ( *i < min ) { *i = min; }
49   if ( *i > max ) { *i = max; }
50 }
51
52 \f
53 ////////////////////////////////////////////////////////////////////////
54 // Implementation of FGControls.
55 ////////////////////////////////////////////////////////////////////////
56
57 // Constructor
58 FGControls::FGControls() :
59     aileron( 0.0 ),
60     aileron_trim( 0.0 ),
61     elevator( 0.0 ),
62     elevator_trim( 0.0 ),
63     rudder( 0.0 ),
64     rudder_trim( 0.0 ),
65     flaps( 0.0 ),
66     slats( 0.0 ),
67     BLC( false ),
68     spoilers( 0.0 ),
69     speedbrake( 0.0 ),
70     wing_sweep( 0.0 ),
71     wing_fold( false ),
72     drag_chute( false ),
73     throttle_idle( true ),
74     dump_valve( false ),
75     parking_brake( 0.0 ),
76     steering( 0.0 ),
77     gear_down( true ),
78     antiskid( true ),
79     tailhook( false ),
80     tailwheel_lock( false ),
81     wing_heat( false ),
82     pitot_heat( true ),
83     wiper( 0 ),
84     window_heat( false ),
85     battery_switch( true ),
86     external_power( false ),
87     APU_generator( false ),
88     APU_bleed( false ),
89     mode( 0 ),
90     dump( false ),
91     outflow_valve( 0.0 ),
92     taxi_light( false ),
93     logo_lights( false ),
94     nav_lights( false ),
95     beacon( false ),
96     strobe( false ),
97     panel_norm( 0.0 ),
98     instruments_norm( 0.0 ),
99     dome_norm( 0.0 ),
100     master_arm( false ),
101     station_select( 1 ),
102     release_ALL( false ),
103     vertical_adjust( 0.0 ),
104     fore_aft_adjust( 0.0 ),
105     off_start_run( 0 ),
106     APU_fire_switch( false ),
107     autothrottle_arm( false ),
108     autothrottle_engage( false ),
109     heading_select( 0.0 ),
110     altitude_select( 50000.0 ),
111     bank_angle_select( 30.0 ),
112     vertical_speed_select( 0.0 ),
113     speed_select( 0.0 ),
114     mach_select( 0.0 ),
115     vertical_mode( 0 ),
116     lateral_mode( 0 )
117 {
118 }
119
120
121 void FGControls::reset_all()
122 {
123     set_aileron( 0.0 );
124     set_aileron_trim( 0.0 );
125     set_elevator( 0.0 );
126     set_elevator_trim( 0.0 );
127     set_rudder( 0.0 );
128     set_rudder_trim( 0.0 );
129     BLC = false;
130     set_spoilers( 0.0 );
131     set_speedbrake( 0.0 );
132     set_wing_sweep( 0.0 );
133     wing_fold = false;
134     drag_chute = false;
135     set_throttle( ALL_ENGINES, 0.0 );
136     set_starter( ALL_ENGINES, false );
137     set_magnetos( ALL_ENGINES, 0 );
138     set_fuel_pump( ALL_ENGINES, false );
139     set_fire_switch( ALL_ENGINES, false );
140     set_fire_bottle_discharge( ALL_ENGINES, false );
141     set_cutoff( ALL_ENGINES, true );
142     set_nitrous_injection( ALL_ENGINES, false );
143     set_cowl_flaps_norm( ALL_ENGINES, 1.0 );
144     set_feather( ALL_ENGINES, false );
145     set_ignition( ALL_ENGINES, false );
146     set_augmentation( ALL_ENGINES, false );
147     set_reverser( ALL_ENGINES, false );
148     set_water_injection( ALL_ENGINES, false );
149     set_condition( ALL_ENGINES, 0 );
150     throttle_idle = true;
151     set_fuel_selector( ALL_TANKS, true );
152     dump_valve = false;
153     steering =  0.0;
154     gear_down = true;
155     tailhook = false;
156     tailwheel_lock = false;
157     set_carb_heat( ALL_ENGINES, false );
158     set_inlet_heat( ALL_ENGINES, false );
159     wing_heat = false;
160     pitot_heat = true;
161     wiper = 0;
162     window_heat = false;
163     set_engine_pump( ALL_HYD_SYSTEMS, true );
164     set_electric_pump( ALL_HYD_SYSTEMS, true );
165     landing_lights = false;
166     turn_off_lights = false;
167     master_arm = false;
168     set_ejection_seat( ALL_EJECTION_SEATS, false );
169     set_eseat_status( ALL_EJECTION_SEATS, SEAT_SAFED );
170     set_cmd_selector_valve( CMD_SEL_NORM );
171     APU_fire_switch = false;
172     autothrottle_arm = false;
173     autothrottle_engage = false;
174     set_autopilot_engage( ALL_AUTOPILOTS, false );
175 }
176
177
178 // Destructor
179 FGControls::~FGControls() {
180 }
181
182
183 void
184 FGControls::init ()
185 {
186     throttle_idle = true;
187     for ( int engine = 0; engine < MAX_ENGINES; engine++ ) {
188         throttle[engine] = 0.0;
189         mixture[engine] = 1.0;
190         fuel_pump[engine] = false;
191         prop_advance[engine] = 1.0;
192         magnetos[engine] = 0;
193         starter[engine] = false;
194         ignition[engine] = false;
195         fire_switch[engine] = false;
196         cutoff[engine] = true;
197         augmentation[engine] = false;
198         reverser[engine] = false;
199         water_injection[engine] = false;
200         nitrous_injection[engine] = false;
201         cowl_flaps_norm[engine] = 0.0;
202         condition[engine] = 0;
203     }
204
205     for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) {
206         brake[wheel] = 0.0;
207         alternate_extension[wheel] = false;
208     }
209
210     auto_coordination = fgGetNode("/sim/auto-coordination", true);
211 }
212
213
214 void
215 FGControls::bind ()
216 {
217   int index, i;
218
219   // flight controls
220   fgTie("/controls/flight/aileron", this,
221         &FGControls::get_aileron, &FGControls::set_aileron);
222   fgSetArchivable("/controls/flight/aileron");
223
224   fgTie("/controls/flight/aileron-trim", this,
225        &FGControls::get_aileron_trim, &FGControls::set_aileron_trim);
226   fgSetArchivable("/controls/flight/aileron-trim");
227
228   fgTie("/controls/flight/elevator", this,
229        &FGControls::get_elevator, &FGControls::set_elevator);
230   fgSetArchivable("/controls/flight/elevator");
231
232   fgTie("/controls/flight/elevator-trim", this,
233        &FGControls::get_elevator_trim, &FGControls::set_elevator_trim);
234   fgSetArchivable("/controls/flight/elevator-trim");
235
236   fgTie("/controls/flight/rudder", this,
237        &FGControls::get_rudder, &FGControls::set_rudder);
238   fgSetArchivable("/controls/flight/rudder");
239
240   fgTie("/controls/flight/rudder-trim", this,
241        &FGControls::get_rudder_trim, &FGControls::set_rudder_trim);
242   fgSetArchivable("/controls/flight/rudder-trim");
243
244   fgTie("/controls/flight/flaps", this,
245        &FGControls::get_flaps, &FGControls::set_flaps);
246   fgSetArchivable("/controls/flight/flaps");
247
248   fgTie("/controls/flight/slats", this,
249        &FGControls::get_slats, &FGControls::set_slats);
250   fgSetArchivable("/controls/flight/slats");
251
252   fgTie("/controls/flight/BLC", this,
253        &FGControls::get_BLC, &FGControls::set_BLC);
254   fgSetArchivable("/controls/flight/BLC");
255
256   fgTie("/controls/flight/spoilers", this,
257        &FGControls::get_spoilers, &FGControls::set_spoilers);
258   fgSetArchivable("/controls/flight/spoilers");
259
260   fgTie("/controls/flight/speedbrake", this,
261        &FGControls::get_speedbrake, &FGControls::set_speedbrake);
262   fgSetArchivable("/controls/flight/speedbrake");
263
264   fgTie("/controls/flight/wing-sweep", this,
265        &FGControls::get_wing_sweep, &FGControls::set_wing_sweep);
266   fgSetArchivable("/controls/flight/wing-sweep");
267
268   fgTie("/controls/flight/wing-fold", this,
269        &FGControls::get_wing_fold, &FGControls::set_wing_fold);
270   fgSetArchivable("/controls/flight/wing-fold");
271
272   fgTie("/controls/flight/drag-chute", this,
273        &FGControls::get_drag_chute, &FGControls::set_drag_chute);
274   fgSetArchivable("/controls/flight/drag-chute");
275
276   // engines
277   fgTie("/controls/engines/throttle_idle", this,
278        &FGControls::get_throttle_idle, &FGControls::set_throttle_idle);
279   fgSetArchivable("/controls/engines/throttle_idle");
280
281   for (index = 0; index < MAX_ENGINES; index++) {
282     char name[MAX_NAME_LEN];
283     snprintf(name, MAX_NAME_LEN,
284              "/controls/engines/engine[%d]/throttle", index);
285     fgTie(name, this, index,
286           &FGControls::get_throttle, &FGControls::set_throttle);
287     fgSetArchivable(name);
288
289     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/starter", index);
290     fgTie(name, this, index,
291          &FGControls::get_starter, &FGControls::set_starter);
292     fgSetArchivable(name);
293
294     snprintf(name, MAX_NAME_LEN,
295              "/controls/engines/engine[%d]/fuel-pump", index);
296     fgTie(name, this, index,
297          &FGControls::get_fuel_pump, &FGControls::set_fuel_pump);
298     fgSetArchivable(name);
299
300     snprintf(name, MAX_NAME_LEN,
301              "/controls/engines/engine[%d]/fire-switch", index);
302     fgTie(name, this, index,
303          &FGControls::get_fire_switch, &FGControls::set_fire_switch);
304     fgSetArchivable(name);
305
306     snprintf(name, MAX_NAME_LEN, 
307        "/controls/engines/engine[%d]/fire-bottle-discharge", index);
308     fgTie(name, this, index,
309          &FGControls::get_fire_bottle_discharge,
310          &FGControls::set_fire_bottle_discharge);
311     fgSetArchivable(name);
312
313     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
314     fgTie(name, this, index,
315          &FGControls::get_cutoff, &FGControls::set_cutoff);
316     fgSetArchivable(name);
317
318     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
319     fgTie(name, this, index,
320          &FGControls::get_mixture, &FGControls::set_mixture);
321     fgSetArchivable(name);
322
323     snprintf(name, MAX_NAME_LEN, 
324        "/controls/engines/engine[%d]/propeller-pitch", index);
325     fgTie(name, this, index,
326          &FGControls::get_prop_advance, 
327          &FGControls::set_prop_advance);
328     fgSetArchivable(name);
329
330     snprintf(name, MAX_NAME_LEN,
331              "/controls/engines/engine[%d]/magnetos", index);
332     fgTie(name, this, index,
333          &FGControls::get_magnetos, &FGControls::set_magnetos);
334     fgSetArchivable(name);
335
336     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
337     fgTie(name, this, index,
338          &FGControls::get_nitrous_injection,
339          &FGControls::set_nitrous_injection);
340     fgSetArchivable(name);
341
342     snprintf(name, MAX_NAME_LEN, 
343        "/controls/engines/engine[%d]/cowl-flaps-norm", index);
344     fgTie(name, this, index,
345          &FGControls::get_cowl_flaps_norm, 
346          &FGControls::set_cowl_flaps_norm);
347     fgSetArchivable(name);
348
349     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
350     fgTie(name, this, index,
351          &FGControls::get_feather, &FGControls::set_feather);
352     fgSetArchivable(name);
353
354     snprintf(name, MAX_NAME_LEN,
355              "/controls/engines/engine[%d]/ignition", index);
356     fgTie(name, this, index,
357          &FGControls::get_ignition, &FGControls::set_ignition);
358     fgSetArchivable(name);
359
360     snprintf(name, MAX_NAME_LEN,
361              "/controls/engines/engine[%d]/augmentation", index);
362     fgTie(name, this, index,
363          &FGControls::get_augmentation, 
364          &FGControls::set_augmentation);
365     fgSetArchivable(name);
366
367     snprintf(name, MAX_NAME_LEN,
368              "/controls/engines/engine[%d]/reverser", index);
369     fgTie(name, this, index,
370          &FGControls::get_reverser, &FGControls::set_reverser);
371     fgSetArchivable(name);
372
373     snprintf(name, MAX_NAME_LEN, 
374        "/controls/engines/engine[%d]/water-injection", index);
375     fgTie(name, this, index,
376          &FGControls::get_water_injection,
377          &FGControls::set_water_injection);
378     fgSetArchivable(name);
379
380     snprintf(name, MAX_NAME_LEN,
381              "/controls/engines/engine[%d]/condition", index);
382     fgTie(name, this, index,
383          &FGControls::get_condition, &FGControls::set_condition);
384     fgSetArchivable(name);
385   }
386
387   // fuel
388   fgTie("/controls/fuel/dump-valve", this,
389        &FGControls::get_dump_valve, &FGControls::set_dump_valve);
390   fgSetArchivable("/controls/fuel/dump-valve");
391
392   for (index = 0; index < MAX_TANKS; index++) {
393     char name[MAX_NAME_LEN];
394     snprintf(name, MAX_NAME_LEN,
395              "/controls/fuel/tank[%d]/fuel_selector", index);
396     fgTie(name, this, index,
397           &FGControls::get_fuel_selector, 
398           &FGControls::set_fuel_selector);
399     fgSetArchivable(name);  
400
401     snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
402     fgTie(name, this, index,
403           &FGControls::get_to_engine, &FGControls::set_to_engine);
404     fgSetArchivable(name);  
405
406     snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
407     fgTie(name, this, index,
408           &FGControls::get_to_tank, &FGControls::set_to_tank);
409     fgSetArchivable(name);  
410
411     for (i = 0; i < MAX_BOOSTPUMPS; i++) {
412       char name[MAX_NAME_LEN];
413       snprintf(name, MAX_NAME_LEN, 
414          "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
415       fgTie(name, this, index * 2 + i,
416             &FGControls::get_boost_pump, 
417             &FGControls::set_boost_pump);
418       fgSetArchivable(name);  
419     }
420   }
421
422   // gear
423   fgTie("/controls/gear/parking-brake", this,
424         &FGControls::get_parking_brake, 
425         &FGControls::set_parking_brake);
426   fgSetArchivable("/controls/gear/parking-brake");
427
428   fgTie("/controls/gear/steering", this,
429         &FGControls::get_steering, &FGControls::set_steering);
430   fgSetArchivable("/controls/gear/steering");
431
432   fgTie("/controls/gear/gear-down", this,
433         &FGControls::get_gear_down, &FGControls::set_gear_down);
434   fgSetArchivable("/controls/gear/gear-down");
435
436   fgTie("/controls/gear/antiskid", this,
437         &FGControls::get_antiskid, &FGControls::set_antiskid);
438   fgSetArchivable("/controls/gear/antiskid");
439
440   fgTie("/controls/gear/tailhook", this,
441         &FGControls::get_tailhook, &FGControls::set_tailhook);
442   fgSetArchivable("/controls/gear/tailhook");
443
444   fgTie("/controls/gear/tailwheel-lock", this,
445         &FGControls::get_tailwheel_lock, 
446         &FGControls::set_tailwheel_lock);
447   fgSetArchivable("/controls/gear/tailwheel-lock");
448
449   for (index = 0; index < MAX_WHEELS; index++) {
450       char name[MAX_NAME_LEN];
451       snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brake", index);
452       fgTie(name, this, index,
453             &FGControls::get_brake, &FGControls::set_brake);
454       fgSetArchivable(name);
455
456       snprintf(name, MAX_NAME_LEN,
457                "/controls/gear/wheel[%d]/alternate-extension", index);
458       fgTie(name, this, index,
459             &FGControls::get_alternate_extension, 
460             &FGControls::set_alternate_extension);
461       fgSetArchivable(name);
462   }
463
464   // anti-ice
465   fgTie("/controls/anti-ice/wing-heat", this,
466         &FGControls::get_wing_heat, &FGControls::set_wing_heat);
467   fgSetArchivable("/controls/anti-ice/wing-heat");
468
469   fgTie("/controls/anti-ice/pitot-heat", this,
470         &FGControls::get_pitot_heat, &FGControls::set_pitot_heat);
471   fgSetArchivable("/controls/anti-ice/pitot-heat");
472
473   fgTie("/controls/anti-ice/wiper", this,
474         &FGControls::get_wiper, &FGControls::set_wiper);
475   fgSetArchivable("/controls/anti-ice/wiper");
476
477   fgTie("/controls/anti-ice/window-heat", this,
478         &FGControls::get_window_heat, &FGControls::set_window_heat);
479   fgSetArchivable("/controls/anti-ice/window-heat");
480
481   for (index = 0; index < MAX_ENGINES; index++) {
482       char name[MAX_NAME_LEN];
483       snprintf(name, MAX_NAME_LEN,
484                "/controls/anti-ice/engine[%d]/carb-heat", index);  
485       fgTie(name, this, index,
486         &FGControls::get_carb_heat, &FGControls::set_carb_heat);
487       fgSetArchivable(name);
488
489       snprintf(name, MAX_NAME_LEN,
490                "/controls/anti-ice/engine[%d]/inlet-heat", index);  
491       fgTie(name, this, index,
492         &FGControls::get_inlet_heat, &FGControls::set_inlet_heat);
493       fgSetArchivable(name);
494   }
495
496   // hydraulics
497   for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
498       char name[MAX_NAME_LEN];
499       snprintf(name, MAX_NAME_LEN, 
500          "/controls/hydraulic/system[%d]/engine-pump", index);  
501       fgTie(name, this, index,
502         &FGControls::get_engine_pump, &FGControls::set_engine_pump);
503       fgSetArchivable(name);
504
505       snprintf(name, MAX_NAME_LEN, 
506          "/controls/hydraulic/system[%d]/electric-pump", index);  
507       fgTie(name, this, index,
508         &FGControls::get_electric_pump, 
509         &FGControls::set_electric_pump);
510       fgSetArchivable(name);
511   }  
512
513   // electric
514   fgTie("/controls/electric/battery-switch", this,
515         &FGControls::get_battery_switch, 
516         &FGControls::set_battery_switch);
517   fgSetArchivable("/controls/electric/battery-switch");
518   
519   fgTie("/controls/electric/external-power", this,
520         &FGControls::get_external_power, 
521         &FGControls::set_external_power);
522   fgSetArchivable("/controls/electric/external-power");
523
524   fgTie("/controls/electric/APU-generator", this,
525         &FGControls::get_APU_generator, 
526         &FGControls::set_APU_generator);
527   fgSetArchivable("/controls/electric/APU-generator");
528
529   for (index = 0; index < MAX_ENGINES; index++) {
530       char name[MAX_NAME_LEN];
531       snprintf(name, MAX_NAME_LEN, 
532          "/controls/electric/engine[%d]/generator", index);  
533       fgTie(name, this, index,
534         &FGControls::get_generator_breaker, 
535         &FGControls::set_generator_breaker);
536       fgSetArchivable(name);
537
538       snprintf(name, MAX_NAME_LEN,
539                "/controls/electric/engine[%d]/bus-tie", index);  
540       fgTie(name, this, index,
541         &FGControls::get_bus_tie, 
542         &FGControls::set_bus_tie);
543       fgSetArchivable(name);
544   }  
545
546   // pneumatic
547   fgTie("/controls/pneumatic/APU-bleed", this,
548         &FGControls::get_APU_bleed, 
549         &FGControls::set_APU_bleed);
550   fgSetArchivable("/controls/pneumatic/APU-bleed");
551
552   for (index = 0; index < MAX_ENGINES; index++) {
553       char name[MAX_NAME_LEN];
554       snprintf(name, MAX_NAME_LEN, 
555          "/controls/pneumatic/engine[%d]/bleed", index);  
556       fgTie(name, this, index,
557         &FGControls::get_engine_bleed, 
558         &FGControls::set_engine_bleed);
559       fgSetArchivable(name);
560   }
561
562   // pressurization
563   fgTie("/controls/pressurization/mode", this,
564         &FGControls::get_mode, &FGControls::set_mode);
565   fgSetArchivable("/controls/pressurization/mode");
566
567   fgTie("/controls/pressurization/dump", this,
568         &FGControls::get_dump, &FGControls::set_dump);
569   fgSetArchivable("/controls/pressurization/dump");
570
571   fgTie("/controls/pressurization/outflow-valve", this,
572         &FGControls::get_outflow_valve, 
573         &FGControls::set_outflow_valve);
574   fgSetArchivable("/controls/pressurization/outflow-valve");
575
576   for (index = 0; index < MAX_PACKS; index++) {
577       char name[MAX_NAME_LEN];
578       snprintf(name, MAX_NAME_LEN,
579                "/controls/pressurization/pack[%d]/pack-on", index);  
580       fgTie(name, this, index,
581         &FGControls::get_pack_on, &FGControls::set_pack_on);
582       fgSetArchivable(name);
583   }
584  
585   // lights
586   fgTie("/controls/lighting/landing-lights", this,
587         &FGControls::get_landing_lights, 
588         &FGControls::set_landing_lights);
589   fgSetArchivable("/controls/lighting/landing-lights");  
590
591   fgTie("/controls/lighting/turn-off-lights", this,
592         &FGControls::get_turn_off_lights,
593         &FGControls::set_turn_off_lights);
594   fgSetArchivable("/controls/lighting/turn-off-lights");
595   
596   fgTie("/controls/lighting/taxi-light", this,
597         &FGControls::get_taxi_light, &FGControls::set_taxi_light);
598   fgSetArchivable("/controls/lighting/taxi-light");
599   
600   fgTie("/controls/lighting/logo-lights", this,
601         &FGControls::get_logo_lights, &FGControls::set_logo_lights);
602   fgSetArchivable("/controls/lighting/logo-lights");
603   
604   fgTie("/controls/lighting/nav-lights", this,
605         &FGControls::get_nav_lights, &FGControls::set_nav_lights);
606   fgSetArchivable("/controls/lighting/nav-lights");  
607
608   fgTie("/controls/lighting/beacon", this,
609         &FGControls::get_beacon, &FGControls::set_beacon);
610   fgSetArchivable("/controls/lighting/beacon");
611   
612   fgTie("/controls/lighting/strobe", this,
613         &FGControls::get_strobe, &FGControls::set_strobe);
614   fgSetArchivable("/controls/lighting/strobe");  
615
616   fgTie("/controls/lighting/panel-norm", this,
617         &FGControls::get_panel_norm, &FGControls::set_panel_norm);
618   fgSetArchivable("/controls/lighting/panel-norm");
619   
620   fgTie("/controls/lighting/instruments-norm", this,
621         &FGControls::get_instruments_norm, 
622         &FGControls::set_instruments_norm);
623   fgSetArchivable("/controls/lighting/instruments-norm");  
624
625   fgTie("/controls/lighting/dome-norm", this,
626         &FGControls::get_dome_norm, &FGControls::set_dome_norm);
627   fgSetArchivable("/controls/lighting/dome-norm"); 
628  
629 #ifdef FG_HAVE_ARMAMENT
630   // armament
631   fgTie("/controls/armament/master-arm", this,
632         &FGControls::get_master_arm, &FGControls::set_master_arm);
633   fgSetArchivable("/controls/armament/master-arm");  
634
635   fgTie("/controls/armament/station-select", this,
636         &FGControls::get_station_select, 
637         &FGControls::set_station_select);
638   fgSetArchivable("/controls/armament/station-select");  
639
640   fgTie("/controls/armament/release-all", this,
641         &FGControls::get_release_ALL, 
642         &FGControls::set_release_ALL);
643   fgSetArchivable("/controls/armament/release-all");  
644
645   for (index = 0; index < MAX_STATIONS; index++) {
646       char name[MAX_NAME_LEN];
647       snprintf(name, MAX_NAME_LEN,
648                "/controls/armament/station[%d]/stick-size", index);  
649       fgTie(name, this, index,
650         &FGControls::get_stick_size, &FGControls::set_stick_size);
651       fgSetArchivable(name);
652
653       snprintf(name, MAX_NAME_LEN, 
654           "/controls/armament/station[%d]/release-stick", index);  
655       fgTie(name, this, index,
656         &FGControls::get_release_stick, &FGControls::set_release_stick);
657       fgSetArchivable(name);
658
659       snprintf(name, MAX_NAME_LEN,
660                "/controls/armament/station[%d]/release-all", index);  
661       fgTie(name, this, index,
662         &FGControls::get_release_all, &FGControls::set_release_all);
663       fgSetArchivable(name);
664
665       snprintf(name, MAX_NAME_LEN,
666                "/controls/armament/station[%d]/jettison-all", index);  
667       fgTie(name, this, index,
668         &FGControls::get_jettison_all, &FGControls::set_jettison_all);
669       fgSetArchivable(name);
670   }
671
672 #endif
673
674   // seat
675   fgTie("/controls/seat/vertical-adjust", this,
676         &FGControls::get_vertical_adjust, 
677         &FGControls::set_vertical_adjust);
678   fgSetArchivable("/controls/seat/vertical-adjust");
679
680   fgTie("/controls/seat/fore-aft-adjust", this,
681         &FGControls::get_fore_aft_adjust, 
682         &FGControls::set_fore_aft_adjust);
683   fgSetArchivable("/controls/seat/fore-aft-adjust");
684   
685   for (index = 0; index < MAX_EJECTION_SEATS; index++) {
686       char name[MAX_NAME_LEN];
687       snprintf(name, MAX_NAME_LEN,
688                "/controls/seat/eject[%d]/initiate", index);
689       fgTie(name, this, index,
690            &FGControls::get_ejection_seat, 
691            &FGControls::set_ejection_seat);
692       fgSetArchivable(name);
693
694       snprintf(name, MAX_NAME_LEN,
695                "/controls/seat/eject[%d]/status", index);
696
697       fgTie(name, this, index,
698            &FGControls::get_eseat_status,
699            &FGControls::set_eseat_status);
700
701       fgSetArchivable(name);
702   }
703   
704   fgTie("/controls/seat/cmd_selector_valve", this,
705         &FGControls::get_cmd_selector_valve,
706         &FGControls::set_cmd_selector_valve);
707   fgSetArchivable("/controls/seat/eject/cmd_selector_valve");
708
709
710   // APU
711   fgTie("/controls/APU/off-start-run", this,
712         &FGControls::get_off_start_run, 
713         &FGControls::set_off_start_run);
714   fgSetArchivable("/controls/APU/off-start-run");
715
716   fgTie("/controls/APU/fire-switch", this,
717         &FGControls::get_APU_fire_switch, 
718         &FGControls::set_APU_fire_switch);
719   fgSetArchivable("/controls/APU/fire-switch");
720
721   // autoflight
722   for (index = 0; index < MAX_AUTOPILOTS; index++) {
723       char name[MAX_NAME_LEN];
724       snprintf(name, MAX_NAME_LEN, 
725          "/controls/autoflight/autopilot[%d]/engage", index);  
726       fgTie(name, this, index,
727         &FGControls::get_autopilot_engage, 
728         &FGControls::set_autopilot_engage);
729       fgSetArchivable(name);
730   }
731  
732   fgTie("/controls/autoflight/autothrottle-arm", this,
733         &FGControls::get_autothrottle_arm, 
734         &FGControls::set_autothrottle_arm);
735   fgSetArchivable("/controls/autoflight/autothrottle-arm");
736
737   fgTie("/controls/autoflight/autothrottle-engage", this,
738         &FGControls::get_autothrottle_engage, 
739         &FGControls::set_autothrottle_engage);
740   fgSetArchivable("/controls/autoflight/autothrottle-engage");
741
742   fgTie("/controls/autoflight/heading-select", this,
743         &FGControls::get_heading_select, 
744         &FGControls::set_heading_select);
745   fgSetArchivable("/controls/autoflight/heading-select");
746
747   fgTie("/controls/autoflight/altitude-select", this,
748         &FGControls::get_altitude_select, 
749         &FGControls::set_altitude_select);
750   fgSetArchivable("/controls/autoflight/altitude-select");
751
752   fgTie("/controls/autoflight/bank-angle-select", this,
753         &FGControls::get_bank_angle_select, 
754         &FGControls::set_bank_angle_select);
755   fgSetArchivable("/controls/autoflight/bank-angle-select");
756
757   fgTie("/controls/autoflight/vertical-speed-select", this,
758         &FGControls::get_vertical_speed_select, 
759         &FGControls::set_vertical_speed_select);
760   fgSetArchivable("/controls/autoflight/vertical-speed-select");
761
762   fgTie("/controls/autoflight/speed-select", this,
763         &FGControls::get_speed_select, 
764         &FGControls::set_speed_select);
765   fgSetArchivable("/controls/autoflight/speed-select");
766
767   fgTie("/controls/autoflight/mach-select", this,
768         &FGControls::get_mach_select, 
769         &FGControls::set_mach_select);
770   fgSetArchivable("/controls/autoflight/mach-select");
771
772   fgTie("/controls/autoflight/vertical-mode", this,
773         &FGControls::get_vertical_mode, 
774         &FGControls::set_vertical_mode);
775   fgSetArchivable("/controls/autoflight/vertical-mode");
776
777   fgTie("/controls/autoflight/lateral-mode", this,
778         &FGControls::get_lateral_mode, 
779         &FGControls::set_lateral_mode);
780   fgSetArchivable("/controls/autoflight/lateral-mode");
781
782 }
783
784 void FGControls::unbind ()
785 {
786   int index, i;
787   //Tie control properties.
788   fgUntie("/controls/flight/aileron");
789   fgUntie("/controls/flight/aileron-trim");
790   fgUntie("/controls/flight/elevator");
791   fgUntie("/controls/flight/elevator-trim");
792   fgUntie("/controls/flight/rudder");
793   fgUntie("/controls/flight/rudder-trim");
794   fgUntie("/controls/flight/flaps");
795   fgUntie("/controls/flight/slats");
796   fgUntie("/controls/flight/BLC");  
797   fgUntie("/controls/flight/spoilers");  
798   fgUntie("/controls/flight/speedbrake");  
799   fgUntie("/controls/flight/wing-sweep");  
800   fgUntie("/controls/flight/wing-fold");  
801   fgUntie("/controls/flight/drag-chute");
802   for (index = 0; index < MAX_ENGINES; index++) {
803     char name[MAX_NAME_LEN];
804     snprintf(name, MAX_NAME_LEN,
805              "/controls/engines/engine[%d]/throttle", index);
806     fgUntie(name);
807     snprintf(name, MAX_NAME_LEN,
808              "/controls/engines/engine[%d]/starter", index);
809     fgUntie(name);
810     snprintf(name, MAX_NAME_LEN,
811              "/controls/engines/engine[%d]/fuel_pump", index);
812     fgUntie(name);
813     snprintf(name, MAX_NAME_LEN,
814              "/controls/engines/engine[%d]/fire-switch", index);
815     fgUntie(name);
816     snprintf(name, MAX_NAME_LEN, 
817              "/controls/engines/engine[%d]/fire-bottle-discharge", index);
818     fgUntie(name);
819     snprintf(name, MAX_NAME_LEN,
820              "/controls/engines/engine[%d]/throttle_idle", index);
821     fgUntie(name);
822     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
823     fgUntie(name);
824     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
825     fgUntie(name);
826     snprintf(name, MAX_NAME_LEN, 
827              "/controls/engines/engine[%d]/propeller-pitch", index);
828     fgUntie(name);
829     snprintf(name, MAX_NAME_LEN,
830              "/controls/engines/engine[%d]/magnetos", index);
831     fgUntie(name);
832     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
833     fgUntie(name);
834     snprintf(name, MAX_NAME_LEN,
835              "/controls/engines/engine[%d]/cowl-flaps-norm", index);
836     fgUntie(name);
837     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/feather", index);
838     fgUntie(name);
839     snprintf(name, MAX_NAME_LEN,
840              "/controls/engines/engine[%d]/ignition", index);
841     fgUntie(name);
842     snprintf(name, MAX_NAME_LEN,
843              "/controls/engines/engine[%d]/augmentation", index);
844     fgUntie(name);
845     snprintf(name, MAX_NAME_LEN,
846              "/controls/engines/engine[%d]/reverser", index);
847     fgUntie(name);
848     snprintf(name, MAX_NAME_LEN,
849              "/controls/engines/engine[%d]/water-injection", index);
850     fgUntie(name);
851     snprintf(name, MAX_NAME_LEN,
852              "/controls/engines/engine[%d]/condition", index);
853     fgUntie(name);
854   }
855   fgUntie("/controls/fuel/dump-valve");
856   for (index = 0; index < MAX_TANKS; index++) {
857     char name[MAX_NAME_LEN];
858     snprintf(name, MAX_NAME_LEN,
859              "/controls/fuel/tank[%d]/fuel_selector", index);
860     fgUntie(name);
861     snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
862     fgUntie(name);
863     snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
864     fgUntie(name);
865     for (i = 0; index < MAX_BOOSTPUMPS; i++) {
866       snprintf(name, MAX_NAME_LEN,
867                "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
868       fgUntie(name);
869     }
870   }
871   fgUntie("/controls/gear/parking_brake");
872   fgUntie("/controls/gear/steering");
873   fgUntie("/controls/gear/gear_down");
874   fgUntie("/controls/gear/antiskid");
875   fgUntie("/controls/gear/tailhook");
876   fgUntie("/controls/gear/tailwheel-lock");
877   for (index = 0; index < MAX_WHEELS; index++) {
878     char name[MAX_NAME_LEN];
879     snprintf(name, MAX_NAME_LEN, "/controls/gear/wheel[%d]/brakes", index);
880     fgUntie(name);
881     snprintf(name, MAX_NAME_LEN, 
882        "/controls/gear/wheel[%d]/alternate-extension", index);
883     fgUntie(name);
884   }
885   fgUntie("/controls/anti-ice/wing-heat");
886   fgUntie("/controls/anti-ice/pitot-heat");
887   fgUntie("/controls/anti-ice/wiper");
888   fgUntie("/controls/anti-ice/window-heat");
889   for (index = 0; index < MAX_ENGINES; index++) {
890     char name[MAX_NAME_LEN];
891     snprintf(name, MAX_NAME_LEN,
892              "/controls/anti-ice/engine[%d]/carb-heat", index);
893     fgUntie(name);
894     snprintf(name, MAX_NAME_LEN,
895              "/controls/anti-ice/engine[%d]/inlet-heat", index);
896     fgUntie(name);
897   }
898   for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
899     char name[MAX_NAME_LEN];
900     snprintf(name, MAX_NAME_LEN, 
901        "/controls/hydraulic/system[%d]/engine-pump", index);
902     fgUntie(name);
903     snprintf(name, MAX_NAME_LEN, 
904        "/controls/hydraulic/system[%d]/electric-pump", index);
905     fgUntie(name);
906   }
907   fgUntie("/controls/electric/battery-switch");
908   fgUntie("/controls/electric/external-power");
909   fgUntie("/controls/electric/APU-generator");    
910   for (index = 0; index < MAX_ENGINES; index++) {
911     char name[MAX_NAME_LEN];
912      snprintf(name, MAX_NAME_LEN, 
913        "/controls/electric/engine[%d]/generator", index);
914     fgUntie(name);
915     snprintf(name, MAX_NAME_LEN, 
916        "/controls/electric/engine[%d]/bus-tie", index);
917     fgUntie(name);
918   }
919   fgUntie("/controls/pneumatic/APU-bleed");
920   for (index = 0; index < MAX_ENGINES; index++) {
921     char name[MAX_NAME_LEN];
922      snprintf(name, MAX_NAME_LEN, 
923        "/controls/pneumatic/engine[%d]/bleed", index);
924     fgUntie(name);
925   }
926   fgUntie("/controls/pressurization/mode");
927   fgUntie("/controls/pressurization/dump");
928   for (index = 0; index < MAX_PACKS; index++) {
929     char name[MAX_NAME_LEN];
930     snprintf(name, MAX_NAME_LEN, 
931        "/controls/pressurization/pack[%d]/pack-on", index);
932     fgUntie(name);
933   }
934   fgUntie("/controls/lighting/landing-lights");  
935   fgUntie("/controls/lighting/turn-off-lights");  
936   fgUntie("/controls/lighting/taxi-light");  
937   fgUntie("/controls/lighting/logo-lights");  
938   fgUntie("/controls/lighting/nav-lights");  
939   fgUntie("/controls/lighting/beacon");  
940   fgUntie("/controls/lighting/strobe");  
941   fgUntie("/controls/lighting/panel-norm");  
942   fgUntie("/controls/lighting/instruments-norm");  
943   fgUntie("/controls/lighting/dome-norm");
944
945 #ifdef FG_HAVE_ARMAMENT
946   fgUntie("/controls/armament/master-arm");  
947   fgUntie("/controls/armament/station-select");  
948   fgUntie("/controls/armament/release-all");  
949   for (index = 0; index < MAX_STATIONS; index++) {
950     char name[MAX_NAME_LEN];
951     snprintf(name, MAX_NAME_LEN, 
952        "/controls/armament/station[%d]/stick-size", index);
953     fgUntie(name);
954     snprintf(name, MAX_NAME_LEN, 
955        "/controls/armament/station[%d]/release-stick", index);
956     fgUntie(name);
957     snprintf(name, MAX_NAME_LEN, 
958        "/controls/armament/station[%d]/release-all", index);
959     fgUntie(name);
960     snprintf(name, MAX_NAME_LEN, 
961        "/controls/armament/station[%d]/jettison-all", index);
962     fgUntie(name);
963   }
964 #endif
965   fgUntie("/controls/seat/vertical-adjust");  
966   fgUntie("/controls/seat/fore-aft-adjust");  
967   for (index = 0; index < MAX_EJECTION_SEATS; index++) {
968     char name[MAX_NAME_LEN];
969     snprintf(name, MAX_NAME_LEN,
970        "/controls/seat/eject[%d]/initiate", index);
971     fgUntie(name);
972     snprintf(name, MAX_NAME_LEN,
973        "/controls/seat/eject[%d]/status", index);
974     fgUntie(name);
975   }
976   fgUntie("/controls/seat/cmd_selector_valve");
977   
978   fgUntie("/controls/APU/off-start-run");  
979   fgUntie("/controls/APU/fire-switch");  
980   for (index = 0; index < MAX_AUTOPILOTS; index++) {
981     char name[MAX_NAME_LEN];
982     snprintf(name, MAX_NAME_LEN,
983        "/controls/autoflight/autopilot[%d]/engage", index);
984     fgUntie(name);
985   }
986   fgUntie("/controls/autoflight/autothrottle-arm");  
987   fgUntie("/controls/autoflight/autothrottle-engage");  
988   fgUntie("/controls/autoflight/heading-select");  
989   fgUntie("/controls/autoflight/altitude-select");  
990   fgUntie("/controls/autoflight/bank-angle-select");  
991   fgUntie("/controls/autoflight/vertical-speed-select");  
992   fgUntie("/controls/autoflight/speed-select");  
993   fgUntie("/controls/autoflight/mach-select");  
994   fgUntie("/controls/autoflight/vertical-mode");  
995   fgUntie("/controls/autoflight/lateral-mode");  
996 }
997
998
999 void
1000 FGControls::update (double dt)
1001 {
1002 }
1003
1004
1005 \f
1006 ////////////////////////////////////////////////////////////////////////
1007 // Setters and adjusters.
1008 ////////////////////////////////////////////////////////////////////////
1009
1010 void
1011 FGControls::set_aileron (double pos)
1012 {
1013   aileron = pos;
1014   CLAMP( &aileron, -1.0, 1.0 );
1015                         
1016   // check for autocoordination
1017   if ( auto_coordination->getBoolValue() ) {
1018     set_rudder( aileron / 2.0 );
1019   }
1020 }
1021
1022 void
1023 FGControls::move_aileron (double amt)
1024 {
1025   aileron += amt;
1026   CLAMP( &aileron, -1.0, 1.0 );
1027                         
1028   // check for autocoordination
1029   if ( auto_coordination->getBoolValue() ) {
1030     set_rudder( aileron / 2.0 );
1031   }
1032 }
1033
1034 void
1035 FGControls::set_aileron_trim( double pos )
1036 {
1037     aileron_trim = pos;
1038     CLAMP( &aileron_trim, -1.0, 1.0 );
1039 }
1040
1041 void
1042 FGControls::move_aileron_trim( double amt )
1043 {
1044     aileron_trim += amt;
1045     CLAMP( &aileron_trim, -1.0, 1.0 );
1046 }
1047
1048 void
1049 FGControls::set_elevator( double pos )
1050 {
1051     elevator = pos;
1052     CLAMP( &elevator, -1.0, 1.0 );
1053 }
1054
1055 void
1056 FGControls::move_elevator( double amt )
1057 {
1058     elevator += amt;
1059     CLAMP( &elevator, -1.0, 1.0 );
1060 }
1061
1062 void
1063 FGControls::set_elevator_trim( double pos )
1064 {
1065     elevator_trim = pos;
1066     CLAMP( &elevator_trim, -1.0, 1.0 );
1067 }
1068
1069 void
1070 FGControls::move_elevator_trim( double amt )
1071 {
1072     elevator_trim += amt;
1073     CLAMP( &elevator_trim, -1.0, 1.0 );
1074 }
1075
1076 void
1077 FGControls::set_rudder( double pos )
1078 {
1079     rudder = pos;
1080     CLAMP( &rudder, -1.0, 1.0 );
1081 }
1082
1083 void
1084 FGControls::move_rudder( double amt )
1085 {
1086     rudder += amt;
1087     CLAMP( &rudder, -1.0, 1.0 );
1088 }
1089
1090 void
1091 FGControls::set_rudder_trim( double pos )
1092 {
1093     rudder_trim = pos;
1094     CLAMP( &rudder_trim, -1.0, 1.0 );
1095 }
1096
1097 void
1098 FGControls::move_rudder_trim( double amt )
1099 {
1100     rudder_trim += amt;
1101     CLAMP( &rudder_trim, -1.0, 1.0 );
1102 }
1103
1104 void
1105 FGControls::set_flaps( double pos )
1106 {
1107     flaps = pos;
1108     CLAMP( &flaps, 0.0, 1.0 );
1109 }
1110
1111 void
1112 FGControls::move_flaps( double amt )
1113 {
1114     flaps += amt;
1115     CLAMP( &flaps, 0.0, 1.0 );
1116 }
1117
1118 void
1119 FGControls::set_slats( double pos )
1120 {
1121     slats = pos;
1122     CLAMP( &slats, 0.0, 1.0 );
1123 }
1124
1125 void
1126 FGControls::move_slats( double amt )
1127 {
1128     slats += amt;
1129     CLAMP( &slats, 0.0, 1.0 );
1130 }
1131
1132 void
1133 FGControls::set_BLC( bool val )
1134 {
1135   BLC = val;
1136 }
1137
1138 void
1139 FGControls::set_spoilers( double pos )
1140 {
1141     spoilers = pos;
1142     CLAMP( &spoilers, 0.0, 1.0 );
1143 }
1144
1145 void
1146 FGControls::move_spoilers( double amt )
1147 {
1148     spoilers += amt;
1149     CLAMP( &spoilers, 0.0, 1.0 );
1150 }
1151
1152 void
1153 FGControls::set_speedbrake( double pos )
1154 {
1155     speedbrake = pos;
1156     CLAMP( &speedbrake, 0.0, 1.0 );
1157 }
1158
1159 void
1160 FGControls::move_speedbrake( double amt )
1161 {
1162     speedbrake += amt;
1163     CLAMP( &speedbrake, 0.0, 1.0 );
1164 }
1165
1166 void
1167 FGControls::set_wing_sweep( double pos )
1168 {
1169     wing_sweep = pos;
1170     CLAMP( &wing_sweep, 0.0, 1.0 );
1171 }
1172
1173 void
1174 FGControls::move_wing_sweep( double amt )
1175 {
1176     wing_sweep += amt;
1177     CLAMP( &wing_sweep, 0.0, 1.0 );
1178 }
1179
1180 void
1181 FGControls::set_wing_fold( bool val )
1182 {
1183   wing_fold = val;
1184 }
1185
1186 void
1187 FGControls::set_drag_chute( bool val )
1188 {
1189   drag_chute = val;
1190 }
1191
1192 void
1193 FGControls::set_throttle_idle( bool val )
1194 {
1195   throttle_idle = val;
1196 }
1197
1198 void
1199 FGControls::set_throttle( int engine, double pos )
1200 {
1201   if ( engine == ALL_ENGINES ) {
1202     for ( int i = 0; i < MAX_ENGINES; i++ ) {
1203       throttle[i] = pos;
1204       CLAMP( &throttle[i], 0.0, 1.0 );
1205     }
1206   } else {
1207     if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1208       throttle[engine] = pos;
1209       CLAMP( &throttle[engine], 0.0, 1.0 );
1210     }
1211   }
1212 }
1213
1214 void
1215 FGControls::move_throttle( int engine, double amt )
1216 {
1217     if ( engine == ALL_ENGINES ) {
1218         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1219             throttle[i] += amt;
1220             CLAMP( &throttle[i], 0.0, 1.0 );
1221         }
1222     } else {
1223         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1224             throttle[engine] += amt;
1225             CLAMP( &throttle[engine], 0.0, 1.0 );
1226         }
1227     }
1228 }
1229
1230 void
1231 FGControls::set_starter( int engine, bool flag )
1232 {
1233     if ( engine == ALL_ENGINES ) {
1234         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1235             starter[i] = flag;
1236         }
1237     } else {
1238         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1239             starter[engine] = flag;
1240         }
1241     }
1242 }
1243
1244 void
1245 FGControls::set_fuel_pump( int engine, bool val )
1246 {
1247     if ( engine == ALL_ENGINES ) {
1248         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1249             fuel_pump[i] = val;
1250         }
1251     } else {
1252         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1253             fuel_pump[engine] = val;
1254         }
1255     }
1256 }
1257
1258 void
1259 FGControls::set_fire_switch( int engine, bool val )
1260 {
1261     if ( engine == ALL_ENGINES ) {
1262         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1263             fire_switch[i] = val;
1264         }
1265     } else {
1266         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1267             fire_switch[engine] = val;
1268         }
1269     }
1270 }
1271
1272 void
1273 FGControls::set_fire_bottle_discharge( int engine, bool val )
1274 {
1275     if ( engine == ALL_ENGINES ) {
1276         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1277             fire_bottle_discharge[i] = val;
1278         }
1279     } else {
1280         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1281             fire_bottle_discharge[engine] = val;
1282         }
1283     }
1284 }
1285
1286 void
1287 FGControls::set_cutoff( int engine, bool val )
1288 {
1289     if ( engine == ALL_ENGINES ) {
1290         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1291             cutoff[i] = val;
1292         }
1293     } else {
1294         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1295             cutoff[engine] = val;
1296         }
1297     }
1298 }
1299
1300
1301 void
1302 FGControls::set_mixture( int engine, double pos )
1303 {
1304     if ( engine == ALL_ENGINES ) {
1305         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1306             mixture[i] = pos;
1307             CLAMP( &mixture[i], 0.0, 1.0 );
1308         }
1309     } else {
1310         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1311             mixture[engine] = pos;
1312             CLAMP( &mixture[engine], 0.0, 1.0 );
1313         }
1314     }
1315 }
1316
1317 void
1318 FGControls::move_mixture( int engine, double amt )
1319 {
1320     if ( engine == ALL_ENGINES ) {
1321         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1322             mixture[i] += amt;
1323             CLAMP( &mixture[i], 0.0, 1.0 );
1324         }
1325     } else {
1326         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1327             mixture[engine] += amt;
1328             CLAMP( &mixture[engine], 0.0, 1.0 );
1329         }
1330     }
1331 }
1332
1333 void
1334 FGControls::set_prop_advance( int engine, double pos )
1335 {
1336     if ( engine == ALL_ENGINES ) {
1337         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1338             prop_advance[i] = pos;
1339             CLAMP( &prop_advance[i], 0.0, 1.0 );
1340         }
1341     } else {
1342         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1343             prop_advance[engine] = pos;
1344             CLAMP( &prop_advance[engine], 0.0, 1.0 );
1345         }
1346     }
1347 }
1348
1349 void
1350 FGControls::move_prop_advance( int engine, double amt )
1351 {
1352     if ( engine == ALL_ENGINES ) {
1353         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1354             prop_advance[i] += amt;
1355             CLAMP( &prop_advance[i], 0.0, 1.0 );
1356         }
1357     } else {
1358         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1359             prop_advance[engine] += amt;
1360             CLAMP( &prop_advance[engine], 0.0, 1.0 );
1361         }
1362     }
1363 }
1364
1365 void
1366 FGControls::set_magnetos( int engine, int pos )
1367 {
1368     if ( engine == ALL_ENGINES ) {
1369         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1370             magnetos[i] = pos;
1371             CLAMP( &magnetos[i], 0, 3 );
1372         }
1373     } else {
1374         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1375             magnetos[engine] = pos;
1376             CLAMP( &magnetos[engine], 0, 3 );
1377         }
1378     }
1379 }
1380
1381 void
1382 FGControls::move_magnetos( int engine, int amt )
1383 {
1384     if ( engine == ALL_ENGINES ) {
1385         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1386             magnetos[i] += amt;
1387             CLAMP( &magnetos[i], 0, 3 );
1388         }
1389     } else {
1390         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1391             magnetos[engine] += amt;
1392             CLAMP( &magnetos[engine], 0, 3 );
1393         }
1394     }
1395 }
1396
1397 void
1398 FGControls::set_nitrous_injection( int engine, bool val )
1399 {
1400     if ( engine == ALL_ENGINES ) {
1401         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1402             nitrous_injection[i] = val;
1403         }
1404     } else {
1405         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1406             nitrous_injection[engine] = val;
1407         }
1408     }
1409 }
1410
1411
1412 void
1413 FGControls::set_cowl_flaps_norm( int engine, double pos )
1414 {
1415     if ( engine == ALL_ENGINES ) {
1416         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1417             cowl_flaps_norm[i] = pos;
1418             CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1419         }
1420     } else {
1421         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1422             cowl_flaps_norm[engine] = pos;
1423             CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1424         }
1425     }
1426 }
1427
1428 void
1429 FGControls::move_cowl_flaps_norm( int engine, double amt )
1430 {
1431     if ( engine == ALL_ENGINES ) {
1432         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1433             cowl_flaps_norm[i] += amt;
1434             CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1435         }
1436     } else {
1437         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1438             cowl_flaps_norm[engine] += amt;
1439             CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1440         }
1441     }
1442 }
1443
1444 void
1445 FGControls::set_feather( int engine, bool val )
1446 {
1447     if ( engine == ALL_ENGINES ) {
1448         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1449             feather[i] = val;
1450         }
1451     } else {
1452         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1453             feather[engine] = val;
1454         }
1455     }
1456 }
1457
1458 void
1459 FGControls::set_ignition( int engine, int pos )
1460 {
1461     if ( engine == ALL_ENGINES ) {
1462         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1463             ignition[i] = pos;
1464             CLAMP( &ignition[i], 0, 3 );
1465         }
1466     } else {
1467         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1468             ignition[engine] = pos;
1469             CLAMP( &ignition[engine], 0, 3 );
1470         }
1471     }
1472 }
1473
1474 void
1475 FGControls::set_augmentation( int engine, bool val )
1476 {
1477     if ( engine == ALL_ENGINES ) {
1478         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1479             augmentation[i] = val;
1480         }
1481     } else {
1482         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1483             augmentation[engine] = val;
1484         }
1485     }
1486 }
1487
1488 void
1489 FGControls::set_reverser( int engine, bool val )
1490 {
1491     if ( engine == ALL_ENGINES ) {
1492         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1493             reverser[i] = val;
1494         }
1495     } else {
1496         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1497             reverser[engine] = val;
1498         }
1499     }
1500 }
1501
1502 void
1503 FGControls::set_water_injection( int engine, bool val )
1504 {
1505     if ( engine == ALL_ENGINES ) {
1506         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1507             water_injection[i] = val;
1508         }
1509     } else {
1510         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1511             water_injection[engine] = val;
1512         }
1513     }
1514 }
1515
1516 void
1517 FGControls::set_condition( int engine, int val )
1518 {
1519     if ( engine == ALL_ENGINES ) {
1520         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1521             condition[i] = val;
1522             CLAMP( &condition[i], 0, 3 );
1523         }
1524     } else {
1525         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1526             condition[engine] = val;
1527             CLAMP( &condition[engine], 0, 3 );
1528         }
1529     }
1530 }
1531
1532 void
1533 FGControls::set_dump_valve( bool val )
1534 {
1535     dump_valve = val;
1536 }
1537
1538
1539 void
1540 FGControls::set_fuel_selector( int tank, bool pos )
1541 {
1542     if ( tank == ALL_TANKS ) {
1543         for ( int i = 0; i < MAX_TANKS; i++ ) {
1544             fuel_selector[i] = pos;
1545         }
1546     } else {
1547         if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1548             fuel_selector[tank] = pos;
1549         }
1550     }
1551 }
1552
1553 void
1554 FGControls::set_to_engine( int tank, int engine )
1555 {
1556     if ( tank == ALL_TANKS ) {
1557         for ( int i = 0; i < MAX_TANKS; i++ ) {
1558             to_engine[i] = engine;
1559         }
1560     } else {
1561         if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1562             to_engine[tank] = engine;
1563         }
1564     }
1565 }
1566
1567 void
1568 FGControls::set_to_tank( int tank, int dest_tank )
1569 {
1570     if ( tank == ALL_TANKS ) {
1571         for ( int i = 0; i < MAX_TANKS; i++ ) {
1572             to_tank[i] = dest_tank;
1573         }
1574     } else {
1575         if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1576             to_tank[tank] = dest_tank;
1577         }
1578     }
1579 }
1580
1581 void
1582 FGControls::set_boost_pump( int index, bool val ) 
1583 {
1584     if ( index == -1 ) {
1585         for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1586             boost_pump[i] = val;
1587         }
1588     } else {
1589         if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1590             boost_pump[index] = val;
1591         }
1592     }
1593 }
1594
1595
1596 void
1597 FGControls::set_parking_brake( double pos )
1598 {
1599     parking_brake = pos;
1600     CLAMP(&parking_brake, 0.0, 1.0);
1601 }
1602
1603 void
1604 FGControls::set_steering( double angle )
1605 {
1606     steering = angle;
1607     CLAMP(&steering, -80.0, 80.0);
1608 }
1609
1610 void
1611 FGControls::move_steering( double angle )
1612 {
1613     steering += angle;
1614     CLAMP(&steering, -80.0, 80.0);
1615 }
1616
1617 void
1618 FGControls::set_gear_down( bool gear )
1619 {
1620   gear_down = gear;
1621 }
1622
1623 void
1624 FGControls::set_antiskid( bool state )
1625 {
1626   antiskid = state;
1627 }
1628
1629 void
1630 FGControls::set_tailhook( bool state )
1631 {
1632   tailhook = state;
1633 }
1634
1635 void
1636 FGControls::set_tailwheel_lock( bool state )
1637 {
1638   tailwheel_lock = state;
1639 }
1640
1641
1642 void
1643 FGControls::set_brake( int wheel, double pos )
1644 {
1645     if ( wheel == ALL_WHEELS ) {
1646         for ( int i = 0; i < MAX_WHEELS; i++ ) {
1647             brake[i] = pos;
1648             CLAMP( &brake[i], 0.0, 1.0 );
1649         }
1650     } else {
1651         if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1652             brake[wheel] = pos;
1653             CLAMP( &brake[wheel], 0.0, 1.0 );
1654         }
1655     }
1656 }
1657
1658 void
1659 FGControls::move_brake( int wheel, double amt )
1660 {
1661     if ( wheel == ALL_WHEELS ) {
1662         for ( int i = 0; i < MAX_WHEELS; i++ ) {
1663             brake[i] += amt;
1664             CLAMP( &brake[i], 0.0, 1.0 );
1665         }
1666     } else {
1667         if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1668             brake[wheel] += amt;
1669             CLAMP( &brake[wheel], 0.0, 1.0 );
1670         }
1671     }
1672 }
1673
1674 void
1675 FGControls::set_alternate_extension( int wheel, bool val )
1676 {
1677     if ( wheel == ALL_WHEELS ) {
1678         for ( int i = 0; i < MAX_WHEELS; i++ ) {
1679             alternate_extension[i] = val;
1680         }
1681     } else {
1682         if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1683             alternate_extension[wheel] = val;
1684         }
1685     }
1686 }
1687
1688 void
1689 FGControls::set_wing_heat( bool state )
1690 {
1691   wing_heat = state;
1692 }
1693
1694 void
1695 FGControls::set_pitot_heat( bool state )
1696 {
1697   pitot_heat = state;
1698 }
1699
1700 void
1701 FGControls::set_wiper( int state )
1702 {
1703   wiper = state;
1704 }
1705
1706 void
1707 FGControls::set_window_heat( bool state )
1708 {
1709   window_heat = state;
1710 }
1711
1712 void
1713 FGControls::set_carb_heat( int engine, bool val )
1714 {
1715     if ( engine == ALL_ENGINES ) {
1716         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1717             carb_heat[i] = val;
1718         }
1719     } else {
1720         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1721             carb_heat[engine] = val;
1722         }
1723     }
1724 }
1725
1726 void
1727 FGControls::set_inlet_heat( int engine, bool val )
1728 {
1729     if ( engine == ALL_ENGINES ) {
1730         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1731             inlet_heat[i] = val;
1732         }
1733     } else {
1734         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1735             inlet_heat[engine] = val;
1736         }
1737     }
1738 }
1739
1740 void
1741 FGControls::set_engine_pump( int system, bool val )
1742 {
1743     if ( system == ALL_HYD_SYSTEMS ) {
1744         for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1745             engine_pump[i] = val;
1746         }
1747     } else {
1748         if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1749             engine_pump[system] = val;
1750         }
1751     }
1752 }
1753
1754 void
1755 FGControls::set_electric_pump( int system, bool val )
1756 {
1757     if ( system == ALL_HYD_SYSTEMS ) {
1758         for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1759             electric_pump[i] = val;
1760         }
1761     } else {
1762         if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1763             electric_pump[system] = val;
1764         }
1765     }
1766 }
1767
1768 void
1769 FGControls::set_battery_switch( bool state )
1770 {
1771   battery_switch = state;
1772 }
1773
1774 void
1775 FGControls::set_external_power( bool state )
1776 {
1777   external_power = state;
1778 }
1779
1780 void
1781 FGControls::set_APU_generator( bool state )
1782 {
1783   APU_generator = state;
1784 }
1785
1786 void
1787 FGControls::set_generator_breaker( int engine, bool val )
1788 {
1789     if ( engine == ALL_ENGINES ) {
1790         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1791             generator_breaker[i] = val;
1792         }
1793     } else {
1794         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1795             generator_breaker[engine] = val;
1796         }
1797     }
1798 }
1799
1800 void
1801 FGControls::set_bus_tie( int engine, bool val )
1802 {
1803     if ( engine == ALL_ENGINES ) {
1804         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1805             bus_tie[i] = val;
1806         }
1807     } else {
1808         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1809             bus_tie[engine] = val;
1810         }
1811     }
1812 }
1813
1814 void
1815 FGControls::set_APU_bleed( bool state )
1816 {
1817   APU_bleed = state;
1818 }
1819
1820 void
1821 FGControls::set_engine_bleed( int engine, bool val )
1822 {
1823     if ( engine == ALL_ENGINES ) {
1824         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1825             engine_bleed[i] = val;
1826         }
1827     } else {
1828         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1829             engine_bleed[engine] = val;
1830         }
1831     }
1832 }
1833
1834 void
1835 FGControls::set_mode( int new_mode )
1836 {
1837   mode = new_mode;
1838 }
1839
1840 void
1841 FGControls::set_outflow_valve( double pos )
1842 {
1843   outflow_valve = pos;
1844   CLAMP( &outflow_valve, 0.0, 1.0 );
1845 }
1846
1847 void
1848 FGControls::move_outflow_valve( double amt )
1849 {
1850   outflow_valve += amt;
1851   CLAMP( &outflow_valve, 0.0, 1.0 );
1852 }
1853
1854 void
1855 FGControls::set_dump( bool state )
1856 {
1857   dump = state;
1858 }
1859
1860 void
1861 FGControls::set_pack_on( int pack, bool val )
1862 {
1863     if ( pack == ALL_PACKS ) {
1864         for ( int i = 0; i < MAX_PACKS; i++ ) {
1865             pack_on[i] = val;
1866         }
1867     } else {
1868         if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1869             pack_on[pack] = val;
1870         }
1871     }
1872 }
1873
1874 void
1875 FGControls::set_landing_lights( bool state )
1876 {
1877   landing_lights = state;
1878 }
1879
1880 void
1881 FGControls::set_turn_off_lights( bool state )
1882 {
1883   turn_off_lights = state;
1884 }
1885
1886 void
1887 FGControls::set_taxi_light( bool state )
1888 {
1889   taxi_light = state;
1890 }
1891
1892 void
1893 FGControls::set_logo_lights( bool state )
1894 {
1895   logo_lights = state;
1896 }
1897
1898 void
1899 FGControls::set_nav_lights( bool state )
1900 {
1901   nav_lights = state;
1902 }
1903
1904 void
1905 FGControls::set_beacon( bool state )
1906 {
1907   beacon = state;
1908 }
1909
1910 void
1911 FGControls::set_strobe( bool state )
1912 {
1913   strobe = state;
1914 }
1915
1916 void
1917 FGControls::set_panel_norm( double intensity )
1918 {
1919   panel_norm = intensity;
1920   CLAMP( &panel_norm, 0.0, 1.0 );
1921 }
1922
1923 void
1924 FGControls::move_panel_norm( double amt )
1925 {
1926   panel_norm += amt;
1927   CLAMP( &panel_norm, 0.0, 1.0 );
1928 }
1929
1930 void
1931 FGControls::set_instruments_norm( double intensity )
1932 {
1933   instruments_norm = intensity;
1934   CLAMP( &instruments_norm, 0.0, 1.0 );
1935 }
1936
1937 void
1938 FGControls::move_instruments_norm( double amt )
1939 {
1940   instruments_norm += amt;
1941   CLAMP( &instruments_norm, 0.0, 1.0 );
1942 }
1943
1944 void
1945 FGControls::set_dome_norm( double intensity )
1946 {
1947   dome_norm = intensity;
1948   CLAMP( &dome_norm, 0.0, 1.0 );
1949 }
1950
1951 void
1952 FGControls::move_dome_norm( double amt )
1953 {
1954   dome_norm += amt;
1955   CLAMP( &dome_norm, 0.0, 1.0 );
1956 }
1957
1958 #ifdef FG_HAVE_ARMAMENT
1959
1960 void
1961 FGControls::set_master_arm( bool val )
1962 {
1963   master_arm = val;
1964 }
1965
1966 void
1967 FGControls::set_station_select( int station )
1968 {
1969   station_select = station;
1970   CLAMP( &station_select, 0, MAX_STATIONS );
1971 }
1972
1973 void
1974 FGControls::set_release_ALL( bool val )
1975 {
1976   release_ALL = val;
1977 }
1978
1979 void
1980 FGControls::set_stick_size( int station, int size )
1981 {
1982     if ( station == ALL_STATIONS ) {
1983         for ( int i = 0; i < MAX_STATIONS; i++ ) {
1984             stick_size[i] = size;
1985             CLAMP( &stick_size[i], 1, 20 );
1986         }
1987     } else {
1988         if ( (station >= 0) && (station < MAX_STATIONS) ) {
1989             stick_size[station] = size;
1990             CLAMP( &stick_size[station], 1, 20 );
1991         }
1992     }
1993 }
1994
1995 void
1996 FGControls::set_release_stick( int station, bool val )
1997 {
1998     if ( station == ALL_STATIONS ) {
1999         for ( int i = 0; i < MAX_STATIONS; i++ ) {
2000             release_stick[i] = val;
2001         }
2002     } else {
2003         if ( (station >= 0) && (station < MAX_STATIONS) ) {
2004             release_stick[station] = val;
2005         }
2006     }
2007 }
2008
2009 void
2010 FGControls::set_release_all( int station, bool val )
2011 {
2012     if ( station == ALL_STATIONS ) {
2013         for ( int i = 0; i < MAX_STATIONS; i++ ) {
2014             release_all[i] = val;
2015         }
2016     } else {
2017         if ( (station >= 0) && (station < MAX_STATIONS) ) {
2018             release_all[station] = val;
2019         }
2020     }
2021 }
2022
2023 void
2024 FGControls::set_jettison_all( int station, bool val )
2025 {
2026     if ( station == ALL_STATIONS ) {
2027         for ( int i = 0; i < MAX_STATIONS; i++ ) {
2028             jettison_all[i] = val;
2029         }
2030     } else {
2031         if ( (station >= 0) && (station < MAX_STATIONS) ) {
2032             jettison_all[station] = val;
2033         }
2034     }
2035 }
2036
2037 #endif
2038
2039 void
2040 FGControls::set_vertical_adjust( double pos )
2041 {
2042   vertical_adjust = pos;
2043   CLAMP( &vertical_adjust, -1.0, 1.0 );
2044 }
2045
2046 void
2047 FGControls::move_vertical_adjust( double amt )
2048 {
2049   vertical_adjust += amt;
2050   CLAMP( &vertical_adjust, -1.0, 1.0 );
2051 }
2052
2053 void
2054 FGControls::set_fore_aft_adjust( double pos )
2055 {
2056   fore_aft_adjust = pos;
2057   CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2058 }
2059
2060 void
2061 FGControls::move_fore_aft_adjust( double amt )
2062 {
2063   fore_aft_adjust += amt;
2064   CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2065 }
2066
2067 void
2068 FGControls::set_ejection_seat( int which_seat, bool val )
2069 {
2070     if ( which_seat == ALL_EJECTION_SEATS ) {
2071         for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2072             eject[i] = val;
2073         }
2074     } else {
2075         if ( (which_seat >= 0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2076             if ( eseat_status[which_seat] == SEAT_SAFED ||
2077                  eseat_status[which_seat] == SEAT_FAIL )
2078             {
2079                 // we can never eject if SEAT_SAFED or SEAT_FAIL
2080                 val = false;
2081             }
2082
2083             eject[which_seat] = val;
2084         }
2085     }
2086 }
2087
2088 void
2089 FGControls::set_eseat_status( int which_seat, int val )
2090 {
2091     if ( which_seat == ALL_EJECTION_SEATS ) {
2092         for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2093             eseat_status[i] = val;
2094         }
2095     } else {
2096         if ( (which_seat >=0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2097             eseat_status[which_seat] = val;
2098         }
2099     }
2100 }
2101
2102 void
2103 FGControls::set_cmd_selector_valve( int val )
2104 {
2105   cmd_selector_valve = val;
2106 }
2107
2108
2109 void
2110 FGControls::set_off_start_run( int pos )
2111 {
2112   off_start_run = pos;
2113   CLAMP( &off_start_run, 0, 3 );
2114 }
2115
2116 void
2117 FGControls::set_APU_fire_switch( bool val )
2118 {
2119   APU_fire_switch = val;
2120 }
2121
2122 void
2123 FGControls::set_autothrottle_arm( bool val )
2124 {
2125   autothrottle_arm = val;
2126 }
2127
2128 void
2129 FGControls::set_autothrottle_engage( bool val )
2130 {
2131   autothrottle_engage = val;
2132 }
2133
2134 void
2135 FGControls::set_heading_select( double heading )
2136 {
2137   heading_select = heading;
2138   CLAMP( &heading_select, 0.0, 360.0 );
2139 }
2140
2141 void
2142 FGControls::move_heading_select( double amt )
2143 {
2144   heading_select += amt;
2145   CLAMP( &heading_select, 0.0, 360.0 );
2146 }
2147
2148 void
2149 FGControls::set_altitude_select( double altitude )
2150 {
2151   altitude_select = altitude;
2152   CLAMP( &altitude_select, -1000.0, 100000.0 );
2153 }
2154
2155 void
2156 FGControls::move_altitude_select( double amt )
2157 {
2158   altitude_select += amt;
2159   CLAMP( &altitude_select, -1000.0, 100000.0 );
2160 }
2161
2162 void
2163 FGControls::set_bank_angle_select( double angle )
2164 {
2165   bank_angle_select = angle;
2166   CLAMP( &bank_angle_select, 10.0, 30.0 );
2167 }
2168
2169 void
2170 FGControls::move_bank_angle_select( double amt )
2171 {
2172   bank_angle_select += amt;
2173   CLAMP( &bank_angle_select, 10.0, 30.0 );
2174 }
2175
2176 void
2177 FGControls::set_vertical_speed_select( double speed )
2178 {
2179   vertical_speed_select = speed;
2180   CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2181 }
2182
2183 void
2184 FGControls::move_vertical_speed_select( double amt )
2185 {
2186   vertical_speed_select += amt;
2187   CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2188 }
2189
2190 void
2191 FGControls::set_speed_select( double speed )
2192 {
2193   speed_select = speed;
2194   CLAMP( &speed_select, 60.0, 400.0 );
2195 }
2196
2197 void
2198 FGControls::move_speed_select( double amt )
2199 {
2200   speed_select += amt;
2201   CLAMP( &speed_select, 60.0, 400.0 );
2202 }
2203
2204 void
2205 FGControls::set_mach_select( double mach )
2206 {
2207   mach_select = mach;
2208   CLAMP( &mach_select, 0.4, 4.0 );
2209 }
2210
2211 void
2212 FGControls::move_mach_select( double amt )
2213 {
2214   mach_select += amt;
2215   CLAMP( &mach_select, 0.4, 4.0 );
2216 }
2217
2218 void
2219 FGControls::set_vertical_mode( int mode )
2220 {
2221   vertical_mode = mode;
2222   CLAMP( &vertical_mode, 0, 4 );
2223 }
2224
2225 void
2226 FGControls::set_lateral_mode( int mode )
2227 {
2228   lateral_mode = mode;
2229   CLAMP( &lateral_mode, 0, 4 );
2230 }
2231
2232 void
2233 FGControls::set_autopilot_engage( int ap, bool val )
2234 {
2235     if ( ap == ALL_AUTOPILOTS ) {
2236         for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2237             autopilot_engage[i] = val;
2238         }
2239     } else {
2240         if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2241             autopilot_engage[ap] = val;
2242         }
2243     }
2244 }