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