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