]> git.mxchange.org Git - flightgear.git/blob - src/Controls/controls.cxx
Fix a misuse of a return value that lead to an error message being displayed
[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  - 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 #ifdef FG_HAVE_ARMAMENT
664   // armament
665   fgTie("/controls/armament/master-arm", this,
666         &FGControls::get_master_arm, &FGControls::set_master_arm);
667   fgSetArchivable("/controls/armament/master-arm");  
668
669   fgTie("/controls/armament/station-select", this,
670         &FGControls::get_station_select, 
671         &FGControls::set_station_select);
672   fgSetArchivable("/controls/armament/station-select");  
673
674   fgTie("/controls/armament/release-all", this,
675         &FGControls::get_release_ALL, 
676         &FGControls::set_release_ALL);
677   fgSetArchivable("/controls/armament/release-all");  
678
679   for (index = 0; index < MAX_STATIONS; index++) {
680       char name[MAX_NAME_LEN];
681       snprintf(name, MAX_NAME_LEN,
682                "/controls/armament/station[%d]/stick-size", index);  
683       fgTie(name, this, index,
684         &FGControls::get_stick_size, &FGControls::set_stick_size);
685       fgSetArchivable(name);
686
687       snprintf(name, MAX_NAME_LEN, 
688           "/controls/armament/station[%d]/release-stick", index);  
689       fgTie(name, this, index,
690         &FGControls::get_release_stick, &FGControls::set_release_stick);
691       fgSetArchivable(name);
692
693       snprintf(name, MAX_NAME_LEN,
694                "/controls/armament/station[%d]/release-all", index);  
695       fgTie(name, this, index,
696         &FGControls::get_release_all, &FGControls::set_release_all);
697       fgSetArchivable(name);
698
699       snprintf(name, MAX_NAME_LEN,
700                "/controls/armament/station[%d]/jettison-all", index);  
701       fgTie(name, this, index,
702         &FGControls::get_jettison_all, &FGControls::set_jettison_all);
703       fgSetArchivable(name);
704   }
705
706 #endif
707
708   // seat
709   fgTie("/controls/seat/vertical-adjust", this,
710         &FGControls::get_vertical_adjust, 
711         &FGControls::set_vertical_adjust);
712   fgSetArchivable("/controls/seat/vertical-adjust");
713
714   fgTie("/controls/seat/fore-aft-adjust", this,
715         &FGControls::get_fore_aft_adjust, 
716         &FGControls::set_fore_aft_adjust);
717   fgSetArchivable("/controls/seat/fore-aft-adjust");
718   
719   for (index = 0; index < MAX_EJECTION_SEATS; index++) {
720       char name[MAX_NAME_LEN];
721       snprintf(name, MAX_NAME_LEN,
722                "/controls/seat/eject[%d]/initiate", index);
723       fgTie(name, this, index,
724            &FGControls::get_ejection_seat, 
725            &FGControls::set_ejection_seat);
726       fgSetArchivable(name);
727
728       snprintf(name, MAX_NAME_LEN,
729                "/controls/seat/eject[%d]/status", index);
730
731       fgTie(name, this, index,
732            &FGControls::get_eseat_status,
733            &FGControls::set_eseat_status);
734
735       fgSetArchivable(name);
736   }
737   
738   fgTie("/controls/seat/cmd_selector_valve", this,
739         &FGControls::get_cmd_selector_valve,
740         &FGControls::set_cmd_selector_valve);
741   fgSetArchivable("/controls/seat/eject/cmd_selector_valve");
742
743
744   // APU
745   fgTie("/controls/APU/off-start-run", this,
746         &FGControls::get_off_start_run, 
747         &FGControls::set_off_start_run);
748   fgSetArchivable("/controls/APU/off-start-run");
749
750   fgTie("/controls/APU/fire-switch", this,
751         &FGControls::get_APU_fire_switch, 
752         &FGControls::set_APU_fire_switch);
753   fgSetArchivable("/controls/APU/fire-switch");
754
755   // autoflight
756   for (index = 0; index < MAX_AUTOPILOTS; index++) {
757       char name[MAX_NAME_LEN];
758       snprintf(name, MAX_NAME_LEN, 
759          "/controls/autoflight/autopilot[%d]/engage", index);  
760       fgTie(name, this, index,
761         &FGControls::get_autopilot_engage, 
762         &FGControls::set_autopilot_engage);
763       fgSetArchivable(name);
764   }
765  
766   fgTie("/controls/autoflight/autothrottle-arm", this,
767         &FGControls::get_autothrottle_arm, 
768         &FGControls::set_autothrottle_arm);
769   fgSetArchivable("/controls/autoflight/autothrottle-arm");
770
771   fgTie("/controls/autoflight/autothrottle-engage", this,
772         &FGControls::get_autothrottle_engage, 
773         &FGControls::set_autothrottle_engage);
774   fgSetArchivable("/controls/autoflight/autothrottle-engage");
775
776   fgTie("/controls/autoflight/heading-select", this,
777         &FGControls::get_heading_select, 
778         &FGControls::set_heading_select);
779   fgSetArchivable("/controls/autoflight/heading-select");
780
781   fgTie("/controls/autoflight/altitude-select", this,
782         &FGControls::get_altitude_select, 
783         &FGControls::set_altitude_select);
784   fgSetArchivable("/controls/autoflight/altitude-select");
785
786   fgTie("/controls/autoflight/bank-angle-select", this,
787         &FGControls::get_bank_angle_select, 
788         &FGControls::set_bank_angle_select);
789   fgSetArchivable("/controls/autoflight/bank-angle-select");
790
791   fgTie("/controls/autoflight/vertical-speed-select", this,
792         &FGControls::get_vertical_speed_select, 
793         &FGControls::set_vertical_speed_select);
794   fgSetArchivable("/controls/autoflight/vertical-speed-select");
795
796   fgTie("/controls/autoflight/speed-select", this,
797         &FGControls::get_speed_select, 
798         &FGControls::set_speed_select);
799   fgSetArchivable("/controls/autoflight/speed-select");
800
801   fgTie("/controls/autoflight/mach-select", this,
802         &FGControls::get_mach_select, 
803         &FGControls::set_mach_select);
804   fgSetArchivable("/controls/autoflight/mach-select");
805
806   fgTie("/controls/autoflight/vertical-mode", this,
807         &FGControls::get_vertical_mode, 
808         &FGControls::set_vertical_mode);
809   fgSetArchivable("/controls/autoflight/vertical-mode");
810
811   fgTie("/controls/autoflight/lateral-mode", this,
812         &FGControls::get_lateral_mode, 
813         &FGControls::set_lateral_mode);
814   fgSetArchivable("/controls/autoflight/lateral-mode");
815
816 }
817
818 void FGControls::unbind ()
819 {
820   int index, i;
821   //Tie control properties.
822   fgUntie("/controls/flight/aileron");
823   fgUntie("/controls/flight/aileron-trim");
824   fgUntie("/controls/flight/elevator");
825   fgUntie("/controls/flight/elevator-trim");
826   fgUntie("/controls/flight/rudder");
827   fgUntie("/controls/flight/rudder-trim");
828   fgUntie("/controls/flight/flaps");
829   fgUntie("/controls/flight/slats");
830   fgUntie("/controls/flight/BLC");  
831   fgUntie("/controls/flight/spoilers");  
832   fgUntie("/controls/flight/speedbrake");  
833   fgUntie("/controls/flight/wing-sweep");  
834   fgUntie("/controls/flight/wing-fold");  
835   fgUntie("/controls/flight/drag-chute");
836   for (index = 0; index < MAX_ENGINES; index++) {
837     char name[MAX_NAME_LEN];
838     snprintf(name, MAX_NAME_LEN,
839              "/controls/engines/engine[%d]/throttle", index);
840     fgUntie(name);
841     snprintf(name, MAX_NAME_LEN,
842              "/controls/engines/engine[%d]/starter", index);
843     fgUntie(name);
844     snprintf(name, MAX_NAME_LEN,
845              "/controls/engines/engine[%d]/fuel_pump", index);
846     fgUntie(name);
847     snprintf(name, MAX_NAME_LEN,
848              "/controls/engines/engine[%d]/fire-switch", index);
849     fgUntie(name);
850     snprintf(name, MAX_NAME_LEN, 
851              "/controls/engines/engine[%d]/fire-bottle-discharge", index);
852     fgUntie(name);
853     snprintf(name, MAX_NAME_LEN,
854              "/controls/engines/engine[%d]/throttle_idle", index);
855     fgUntie(name);
856     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/cutoff", index);
857     fgUntie(name);
858     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/mixture", index);
859     fgUntie(name);
860     snprintf(name, MAX_NAME_LEN, 
861              "/controls/engines/engine[%d]/propeller-pitch", index);
862     fgUntie(name);
863     snprintf(name, MAX_NAME_LEN,
864              "/controls/engines/engine[%d]/magnetos", index);
865     fgUntie(name);
866     snprintf(name, MAX_NAME_LEN, "/controls/engines/engine[%d]/WEP", index);
867     fgUntie(name);
868     snprintf(name, MAX_NAME_LEN,
869              "/controls/engines/engine[%d]/cowl-flaps-norm", index);
870     fgUntie(name);
871     snprintf(name, MAX_NAME_LEN,
872              "/controls/engines/engine[%d]/propeller-feather", index);
873     fgUntie(name);
874     snprintf(name, MAX_NAME_LEN,
875              "/controls/engines/engine[%d]/ignition", index);
876     fgUntie(name);
877     snprintf(name, MAX_NAME_LEN,
878              "/controls/engines/engine[%d]/augmentation", index);
879     fgUntie(name);
880     snprintf(name, MAX_NAME_LEN,
881              "/controls/engines/engine[%d]/reverser", index);
882     fgUntie(name);
883     snprintf(name, MAX_NAME_LEN,
884              "/controls/engines/engine[%d]/water-injection", index);
885     fgUntie(name);
886     snprintf(name, MAX_NAME_LEN,
887              "/controls/engines/engine[%d]/condition", index);
888     fgUntie(name);
889   }
890   fgUntie("/controls/fuel/dump-valve");
891   for (index = 0; index < MAX_TANKS; index++) {
892     char name[MAX_NAME_LEN];
893     snprintf(name, MAX_NAME_LEN,
894              "/controls/fuel/tank[%d]/fuel_selector", index);
895     fgUntie(name);
896     snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_engine", index);
897     fgUntie(name);
898     snprintf(name, MAX_NAME_LEN, "/controls/fuel/tank[%d]/to_tank", index);
899     fgUntie(name);
900     for (i = 0; index < MAX_BOOSTPUMPS; i++) {
901       snprintf(name, MAX_NAME_LEN,
902                "/controls/fuel/tank[%d]/boost-pump[%d]", index, i);
903       fgUntie(name);
904     }
905   }
906   fgUntie("/controls/gear/brake-left");
907   fgUntie("/controls/gear/brake-right");
908   fgUntie("/controls/gear/brake-parking");
909   fgUntie("/controls/gear/steering");
910   fgUntie("/controls/gear/gear_down");
911   fgUntie("/controls/gear/antiskid");
912   fgUntie("/controls/gear/tailhook");
913   fgUntie("/controls/gear/launchbar");
914   fgUntie("/controls/gear/catapult-launch-cmd");
915   fgUntie("/controls/gear/tailwheel-lock");
916   for (index = 0; index < MAX_WHEELS; index++) {
917     char name[MAX_NAME_LEN];
918     snprintf(name, MAX_NAME_LEN, 
919        "/controls/gear/wheel[%d]/alternate-extension", index);
920     fgUntie(name);
921   }
922   fgUntie("/controls/anti-ice/wing-heat");
923   fgUntie("/controls/anti-ice/pitot-heat");
924   fgUntie("/controls/anti-ice/wiper");
925   fgUntie("/controls/anti-ice/window-heat");
926   for (index = 0; index < MAX_ENGINES; index++) {
927     char name[MAX_NAME_LEN];
928     snprintf(name, MAX_NAME_LEN,
929              "/controls/anti-ice/engine[%d]/carb-heat", index);
930     fgUntie(name);
931     snprintf(name, MAX_NAME_LEN,
932              "/controls/anti-ice/engine[%d]/inlet-heat", index);
933     fgUntie(name);
934   }
935   for (index = 0; index < MAX_HYD_SYSTEMS; index++) {
936     char name[MAX_NAME_LEN];
937     snprintf(name, MAX_NAME_LEN, 
938        "/controls/hydraulic/system[%d]/engine-pump", index);
939     fgUntie(name);
940     snprintf(name, MAX_NAME_LEN, 
941        "/controls/hydraulic/system[%d]/electric-pump", index);
942     fgUntie(name);
943   }
944   fgUntie("/controls/electric/battery-switch");
945   fgUntie("/controls/electric/external-power");
946   fgUntie("/controls/electric/APU-generator");    
947   for (index = 0; index < MAX_ENGINES; index++) {
948     char name[MAX_NAME_LEN];
949      snprintf(name, MAX_NAME_LEN, 
950        "/controls/electric/engine[%d]/generator", index);
951     fgUntie(name);
952     snprintf(name, MAX_NAME_LEN, 
953        "/controls/electric/engine[%d]/bus-tie", index);
954     fgUntie(name);
955   }
956   fgUntie("/controls/pneumatic/APU-bleed");
957   for (index = 0; index < MAX_ENGINES; index++) {
958     char name[MAX_NAME_LEN];
959      snprintf(name, MAX_NAME_LEN, 
960        "/controls/pneumatic/engine[%d]/bleed", index);
961     fgUntie(name);
962   }
963   fgUntie("/controls/pressurization/mode");
964   fgUntie("/controls/pressurization/dump");
965   for (index = 0; index < MAX_PACKS; index++) {
966     char name[MAX_NAME_LEN];
967     snprintf(name, MAX_NAME_LEN, 
968        "/controls/pressurization/pack[%d]/pack-on", index);
969     fgUntie(name);
970   }
971   fgUntie("/controls/lighting/landing-lights");  
972   fgUntie("/controls/lighting/turn-off-lights");  
973   fgUntie("/controls/lighting/taxi-light");  
974   fgUntie("/controls/lighting/logo-lights");  
975   fgUntie("/controls/lighting/nav-lights");  
976   fgUntie("/controls/lighting/beacon");  
977   fgUntie("/controls/lighting/strobe");  
978   fgUntie("/controls/lighting/panel-norm");  
979   fgUntie("/controls/lighting/instruments-norm");  
980   fgUntie("/controls/lighting/dome-norm");
981
982 #ifdef FG_HAVE_ARMAMENT
983   fgUntie("/controls/armament/master-arm");  
984   fgUntie("/controls/armament/station-select");  
985   fgUntie("/controls/armament/release-all");  
986   for (index = 0; index < MAX_STATIONS; index++) {
987     char name[MAX_NAME_LEN];
988     snprintf(name, MAX_NAME_LEN, 
989        "/controls/armament/station[%d]/stick-size", index);
990     fgUntie(name);
991     snprintf(name, MAX_NAME_LEN, 
992        "/controls/armament/station[%d]/release-stick", index);
993     fgUntie(name);
994     snprintf(name, MAX_NAME_LEN, 
995        "/controls/armament/station[%d]/release-all", index);
996     fgUntie(name);
997     snprintf(name, MAX_NAME_LEN, 
998        "/controls/armament/station[%d]/jettison-all", index);
999     fgUntie(name);
1000   }
1001 #endif
1002   fgUntie("/controls/seat/vertical-adjust");  
1003   fgUntie("/controls/seat/fore-aft-adjust");  
1004   for (index = 0; index < MAX_EJECTION_SEATS; index++) {
1005     char name[MAX_NAME_LEN];
1006     snprintf(name, MAX_NAME_LEN,
1007        "/controls/seat/eject[%d]/initiate", index);
1008     fgUntie(name);
1009     snprintf(name, MAX_NAME_LEN,
1010        "/controls/seat/eject[%d]/status", index);
1011     fgUntie(name);
1012   }
1013   fgUntie("/controls/seat/cmd_selector_valve");
1014   
1015   fgUntie("/controls/APU/off-start-run");  
1016   fgUntie("/controls/APU/fire-switch");  
1017   for (index = 0; index < MAX_AUTOPILOTS; index++) {
1018     char name[MAX_NAME_LEN];
1019     snprintf(name, MAX_NAME_LEN,
1020        "/controls/autoflight/autopilot[%d]/engage", index);
1021     fgUntie(name);
1022   }
1023   fgUntie("/controls/autoflight/autothrottle-arm");  
1024   fgUntie("/controls/autoflight/autothrottle-engage");  
1025   fgUntie("/controls/autoflight/heading-select");  
1026   fgUntie("/controls/autoflight/altitude-select");  
1027   fgUntie("/controls/autoflight/bank-angle-select");  
1028   fgUntie("/controls/autoflight/vertical-speed-select");  
1029   fgUntie("/controls/autoflight/speed-select");  
1030   fgUntie("/controls/autoflight/mach-select");  
1031   fgUntie("/controls/autoflight/vertical-mode");  
1032   fgUntie("/controls/autoflight/lateral-mode");  
1033 }
1034
1035
1036 void
1037 FGControls::update (double dt)
1038 {
1039 }
1040
1041
1042 \f
1043 ////////////////////////////////////////////////////////////////////////
1044 // Setters and adjusters.
1045 ////////////////////////////////////////////////////////////////////////
1046
1047 void
1048 FGControls::set_aileron (double pos)
1049 {
1050   aileron = pos;
1051   CLAMP( &aileron, -1.0, 1.0 );
1052                         
1053   // check for autocoordination
1054   if ( auto_coordination->getBoolValue() ) {
1055     set_rudder( aileron / 2.0 );
1056   }
1057 }
1058
1059 void
1060 FGControls::move_aileron (double amt)
1061 {
1062   aileron += amt;
1063   CLAMP( &aileron, -1.0, 1.0 );
1064                         
1065   // check for autocoordination
1066   if ( auto_coordination->getBoolValue() ) {
1067     set_rudder( aileron / 2.0 );
1068   }
1069 }
1070
1071 void
1072 FGControls::set_aileron_trim( double pos )
1073 {
1074     aileron_trim = pos;
1075     CLAMP( &aileron_trim, -1.0, 1.0 );
1076 }
1077
1078 void
1079 FGControls::move_aileron_trim( double amt )
1080 {
1081     aileron_trim += amt;
1082     CLAMP( &aileron_trim, -1.0, 1.0 );
1083 }
1084
1085 void
1086 FGControls::set_elevator( double pos )
1087 {
1088     elevator = pos;
1089     CLAMP( &elevator, -1.0, 1.0 );
1090 }
1091
1092 void
1093 FGControls::move_elevator( double amt )
1094 {
1095     elevator += amt;
1096     CLAMP( &elevator, -1.0, 1.0 );
1097 }
1098
1099 void
1100 FGControls::set_elevator_trim( double pos )
1101 {
1102     elevator_trim = pos;
1103     CLAMP( &elevator_trim, -1.0, 1.0 );
1104 }
1105
1106 void
1107 FGControls::move_elevator_trim( double amt )
1108 {
1109     elevator_trim += amt;
1110     CLAMP( &elevator_trim, -1.0, 1.0 );
1111 }
1112
1113 void
1114 FGControls::set_rudder( double pos )
1115 {
1116     rudder = pos;
1117     CLAMP( &rudder, -1.0, 1.0 );
1118 }
1119
1120 void
1121 FGControls::move_rudder( double amt )
1122 {
1123     rudder += amt;
1124     CLAMP( &rudder, -1.0, 1.0 );
1125 }
1126
1127 void
1128 FGControls::set_rudder_trim( double pos )
1129 {
1130     rudder_trim = pos;
1131     CLAMP( &rudder_trim, -1.0, 1.0 );
1132 }
1133
1134 void
1135 FGControls::move_rudder_trim( double amt )
1136 {
1137     rudder_trim += amt;
1138     CLAMP( &rudder_trim, -1.0, 1.0 );
1139 }
1140
1141 void
1142 FGControls::set_flaps( double pos )
1143 {
1144     flaps = pos;
1145     CLAMP( &flaps, 0.0, 1.0 );
1146 }
1147
1148 void
1149 FGControls::move_flaps( double amt )
1150 {
1151     flaps += amt;
1152     CLAMP( &flaps, 0.0, 1.0 );
1153 }
1154
1155 void
1156 FGControls::set_slats( double pos )
1157 {
1158     slats = pos;
1159     CLAMP( &slats, 0.0, 1.0 );
1160 }
1161
1162 void
1163 FGControls::move_slats( double amt )
1164 {
1165     slats += amt;
1166     CLAMP( &slats, 0.0, 1.0 );
1167 }
1168
1169 void
1170 FGControls::set_BLC( bool val )
1171 {
1172   BLC = val;
1173 }
1174
1175 void
1176 FGControls::set_spoilers( double pos )
1177 {
1178     spoilers = pos;
1179     CLAMP( &spoilers, 0.0, 1.0 );
1180 }
1181
1182 void
1183 FGControls::move_spoilers( double amt )
1184 {
1185     spoilers += amt;
1186     CLAMP( &spoilers, 0.0, 1.0 );
1187 }
1188
1189 void
1190 FGControls::set_speedbrake( double pos )
1191 {
1192     speedbrake = pos;
1193     CLAMP( &speedbrake, 0.0, 1.0 );
1194 }
1195
1196 void
1197 FGControls::move_speedbrake( double amt )
1198 {
1199     speedbrake += amt;
1200     CLAMP( &speedbrake, 0.0, 1.0 );
1201 }
1202
1203 void
1204 FGControls::set_wing_sweep( double pos )
1205 {
1206     wing_sweep = pos;
1207     CLAMP( &wing_sweep, 0.0, 1.0 );
1208 }
1209
1210 void
1211 FGControls::move_wing_sweep( double amt )
1212 {
1213     wing_sweep += amt;
1214     CLAMP( &wing_sweep, 0.0, 1.0 );
1215 }
1216
1217 void
1218 FGControls::set_wing_fold( bool val )
1219 {
1220   wing_fold = val;
1221 }
1222
1223 void
1224 FGControls::set_drag_chute( bool val )
1225 {
1226   drag_chute = val;
1227 }
1228
1229 void
1230 FGControls::set_throttle_idle( bool val )
1231 {
1232   throttle_idle = val;
1233 }
1234
1235 void
1236 FGControls::set_throttle( int engine, double pos )
1237 {
1238   if ( engine == ALL_ENGINES ) {
1239     for ( int i = 0; i < MAX_ENGINES; i++ ) {
1240       throttle[i] = pos;
1241       CLAMP( &throttle[i], 0.0, 1.0 );
1242     }
1243   } else {
1244     if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1245       throttle[engine] = pos;
1246       CLAMP( &throttle[engine], 0.0, 1.0 );
1247     }
1248   }
1249 }
1250
1251 void
1252 FGControls::move_throttle( int engine, double amt )
1253 {
1254     if ( engine == ALL_ENGINES ) {
1255         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1256             throttle[i] += amt;
1257             CLAMP( &throttle[i], 0.0, 1.0 );
1258         }
1259     } else {
1260         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1261             throttle[engine] += amt;
1262             CLAMP( &throttle[engine], 0.0, 1.0 );
1263         }
1264     }
1265 }
1266
1267 void
1268 FGControls::set_starter( int engine, bool flag )
1269 {
1270     if ( engine == ALL_ENGINES ) {
1271         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1272             starter[i] = flag;
1273         }
1274     } else {
1275         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1276             starter[engine] = flag;
1277         }
1278     }
1279 }
1280
1281 void
1282 FGControls::set_fuel_pump( int engine, bool val )
1283 {
1284     if ( engine == ALL_ENGINES ) {
1285         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1286             fuel_pump[i] = val;
1287         }
1288     } else {
1289         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1290             fuel_pump[engine] = val;
1291         }
1292     }
1293 }
1294
1295 void
1296 FGControls::set_fire_switch( int engine, bool val )
1297 {
1298     if ( engine == ALL_ENGINES ) {
1299         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1300             fire_switch[i] = val;
1301         }
1302     } else {
1303         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1304             fire_switch[engine] = val;
1305         }
1306     }
1307 }
1308
1309 void
1310 FGControls::set_fire_bottle_discharge( int engine, bool val )
1311 {
1312     if ( engine == ALL_ENGINES ) {
1313         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1314             fire_bottle_discharge[i] = val;
1315         }
1316     } else {
1317         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1318             fire_bottle_discharge[engine] = val;
1319         }
1320     }
1321 }
1322
1323 void
1324 FGControls::set_cutoff( int engine, bool val )
1325 {
1326     if ( engine == ALL_ENGINES ) {
1327         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1328             cutoff[i] = val;
1329         }
1330     } else {
1331         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1332             cutoff[engine] = val;
1333         }
1334     }
1335 }
1336
1337
1338 void
1339 FGControls::set_mixture( int engine, double pos )
1340 {
1341     if ( engine == ALL_ENGINES ) {
1342         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1343             mixture[i] = pos;
1344             CLAMP( &mixture[i], 0.0, 1.0 );
1345         }
1346     } else {
1347         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1348             mixture[engine] = pos;
1349             CLAMP( &mixture[engine], 0.0, 1.0 );
1350         }
1351     }
1352 }
1353
1354 void
1355 FGControls::move_mixture( int engine, double amt )
1356 {
1357     if ( engine == ALL_ENGINES ) {
1358         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1359             mixture[i] += amt;
1360             CLAMP( &mixture[i], 0.0, 1.0 );
1361         }
1362     } else {
1363         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1364             mixture[engine] += amt;
1365             CLAMP( &mixture[engine], 0.0, 1.0 );
1366         }
1367     }
1368 }
1369
1370 void
1371 FGControls::set_prop_advance( int engine, double pos )
1372 {
1373     if ( engine == ALL_ENGINES ) {
1374         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1375             prop_advance[i] = pos;
1376             CLAMP( &prop_advance[i], 0.0, 1.0 );
1377         }
1378     } else {
1379         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1380             prop_advance[engine] = pos;
1381             CLAMP( &prop_advance[engine], 0.0, 1.0 );
1382         }
1383     }
1384 }
1385
1386 void
1387 FGControls::move_prop_advance( int engine, double amt )
1388 {
1389     if ( engine == ALL_ENGINES ) {
1390         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1391             prop_advance[i] += amt;
1392             CLAMP( &prop_advance[i], 0.0, 1.0 );
1393         }
1394     } else {
1395         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1396             prop_advance[engine] += amt;
1397             CLAMP( &prop_advance[engine], 0.0, 1.0 );
1398         }
1399     }
1400 }
1401
1402 void
1403 FGControls::set_magnetos( int engine, int pos )
1404 {
1405     if ( engine == ALL_ENGINES ) {
1406         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1407             magnetos[i] = pos;
1408             CLAMP( &magnetos[i], 0, 3 );
1409         }
1410     } else {
1411         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1412             magnetos[engine] = pos;
1413             CLAMP( &magnetos[engine], 0, 3 );
1414         }
1415     }
1416 }
1417
1418 void
1419 FGControls::move_magnetos( int engine, int amt )
1420 {
1421     if ( engine == ALL_ENGINES ) {
1422         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1423             magnetos[i] += amt;
1424             CLAMP( &magnetos[i], 0, 3 );
1425         }
1426     } else {
1427         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1428             magnetos[engine] += amt;
1429             CLAMP( &magnetos[engine], 0, 3 );
1430         }
1431     }
1432 }
1433
1434 void
1435 FGControls::set_nitrous_injection( int engine, bool val )
1436 {
1437     if ( engine == ALL_ENGINES ) {
1438         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1439             nitrous_injection[i] = val;
1440         }
1441     } else {
1442         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1443             nitrous_injection[engine] = val;
1444         }
1445     }
1446 }
1447
1448
1449 void
1450 FGControls::set_cowl_flaps_norm( int engine, double pos )
1451 {
1452     if ( engine == ALL_ENGINES ) {
1453         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1454             cowl_flaps_norm[i] = pos;
1455             CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1456         }
1457     } else {
1458         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1459             cowl_flaps_norm[engine] = pos;
1460             CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1461         }
1462     }
1463 }
1464
1465 void
1466 FGControls::move_cowl_flaps_norm( int engine, double amt )
1467 {
1468     if ( engine == ALL_ENGINES ) {
1469         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1470             cowl_flaps_norm[i] += amt;
1471             CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 );
1472         }
1473     } else {
1474         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1475             cowl_flaps_norm[engine] += amt;
1476             CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 );
1477         }
1478     }
1479 }
1480
1481 void
1482 FGControls::set_feather( int engine, bool val )
1483 {
1484     if ( engine == ALL_ENGINES ) {
1485         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1486             feather[i] = val;
1487         }
1488     } else {
1489         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1490             feather[engine] = val;
1491         }
1492     }
1493 }
1494
1495 void
1496 FGControls::set_ignition( int engine, int pos )
1497 {
1498     if ( engine == ALL_ENGINES ) {
1499         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1500             ignition[i] = pos;
1501             CLAMP( &ignition[i], 0, 3 );
1502         }
1503     } else {
1504         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1505             ignition[engine] = pos;
1506             CLAMP( &ignition[engine], 0, 3 );
1507         }
1508     }
1509 }
1510
1511 void
1512 FGControls::set_augmentation( int engine, bool val )
1513 {
1514     if ( engine == ALL_ENGINES ) {
1515         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1516             augmentation[i] = val;
1517         }
1518     } else {
1519         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1520             augmentation[engine] = val;
1521         }
1522     }
1523 }
1524
1525 void
1526 FGControls::set_reverser( int engine, bool val )
1527 {
1528     if ( engine == ALL_ENGINES ) {
1529         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1530             reverser[i] = val;
1531         }
1532     } else {
1533         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1534             reverser[engine] = val;
1535         }
1536     }
1537 }
1538
1539 void
1540 FGControls::set_water_injection( int engine, bool val )
1541 {
1542     if ( engine == ALL_ENGINES ) {
1543         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1544             water_injection[i] = val;
1545         }
1546     } else {
1547         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1548             water_injection[engine] = val;
1549         }
1550     }
1551 }
1552
1553 void
1554 FGControls::set_condition( int engine, double val )
1555 {
1556     if ( engine == ALL_ENGINES ) {
1557         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1558             condition[i] = val;
1559             CLAMP( &condition[i], 0.0, 1.0 );
1560         }
1561     } else {
1562         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1563             condition[engine] = val;
1564             CLAMP( &condition[engine], 0.0, 1.0 );
1565         }
1566     }
1567 }
1568
1569 void
1570 FGControls::set_dump_valve( bool val )
1571 {
1572     dump_valve = val;
1573 }
1574
1575
1576 void
1577 FGControls::set_fuel_selector( int tank, bool pos )
1578 {
1579     if ( tank == ALL_TANKS ) {
1580         for ( int i = 0; i < MAX_TANKS; i++ ) {
1581             fuel_selector[i] = pos;
1582         }
1583     } else {
1584         if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1585             fuel_selector[tank] = pos;
1586         }
1587     }
1588 }
1589
1590 void
1591 FGControls::set_to_engine( int tank, int engine )
1592 {
1593     if ( tank == ALL_TANKS ) {
1594         for ( int i = 0; i < MAX_TANKS; i++ ) {
1595             to_engine[i] = engine;
1596         }
1597     } else {
1598         if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1599             to_engine[tank] = engine;
1600         }
1601     }
1602 }
1603
1604 void
1605 FGControls::set_to_tank( int tank, int dest_tank )
1606 {
1607     if ( tank == ALL_TANKS ) {
1608         for ( int i = 0; i < MAX_TANKS; i++ ) {
1609             to_tank[i] = dest_tank;
1610         }
1611     } else {
1612         if ( (tank >= 0) && (tank < MAX_TANKS) ) {
1613             to_tank[tank] = dest_tank;
1614         }
1615     }
1616 }
1617
1618 void
1619 FGControls::set_boost_pump( int index, bool val ) 
1620 {
1621     if ( index == -1 ) {
1622         for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) {
1623             boost_pump[i] = val;
1624         }
1625     } else {
1626         if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) {
1627             boost_pump[index] = val;
1628         }
1629     }
1630 }
1631
1632
1633 void
1634 FGControls::set_brake_left( double pos )
1635 {
1636     brake_left = pos;
1637     CLAMP(&brake_left, 0.0, 1.0);
1638 }
1639
1640 void
1641 FGControls::move_brake_left( double amt )
1642 {
1643     brake_left += amt;
1644     CLAMP( &brake_left, 0.0, 1.0 );
1645 }
1646
1647 void
1648 FGControls::set_brake_right( double pos )
1649 {
1650     brake_right = pos;
1651     CLAMP(&brake_right, 0.0, 1.0);
1652 }
1653
1654 void
1655 FGControls::move_brake_right( double amt )
1656 {
1657     brake_right += amt;
1658     CLAMP( &brake_right, 0.0, 1.0 );
1659 }
1660
1661 void
1662 FGControls::set_copilot_brake_left( double pos )
1663 {
1664     copilot_brake_left = pos;
1665     CLAMP(&brake_left, 0.0, 1.0);
1666 }
1667
1668 void
1669 FGControls::set_copilot_brake_right( double pos )
1670 {
1671     copilot_brake_right = pos;
1672     CLAMP(&brake_right, 0.0, 1.0);
1673 }
1674
1675 void
1676 FGControls::set_brake_parking( double pos )
1677 {
1678     brake_parking = pos;
1679     CLAMP(&brake_parking, 0.0, 1.0);
1680 }
1681
1682 void
1683 FGControls::set_steering( double angle )
1684 {
1685     steering = angle;
1686     CLAMP(&steering, -80.0, 80.0);
1687 }
1688
1689 void
1690 FGControls::move_steering( double angle )
1691 {
1692     steering += angle;
1693     CLAMP(&steering, -80.0, 80.0);
1694 }
1695
1696 void
1697 FGControls::set_gear_down( bool gear )
1698 {
1699   gear_down = gear;
1700 }
1701
1702 void
1703 FGControls::set_antiskid( bool state )
1704 {
1705   antiskid = state;
1706 }
1707
1708 void
1709 FGControls::set_tailhook( bool state )
1710 {
1711   tailhook = state;
1712 }
1713
1714 void
1715 FGControls::set_launchbar( bool state )
1716 {
1717   launchbar = state;
1718 }
1719
1720 void
1721 FGControls::set_catapult_launch_cmd( bool state )
1722 {
1723   catapult_launch_cmd = state;
1724 }
1725
1726 void
1727 FGControls::set_tailwheel_lock( bool state )
1728 {
1729   tailwheel_lock = state;
1730 }
1731
1732
1733 void
1734 FGControls::set_alternate_extension( int wheel, bool val )
1735 {
1736     if ( wheel == ALL_WHEELS ) {
1737         for ( int i = 0; i < MAX_WHEELS; i++ ) {
1738             alternate_extension[i] = val;
1739         }
1740     } else {
1741         if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
1742             alternate_extension[wheel] = val;
1743         }
1744     }
1745 }
1746
1747 void
1748 FGControls::set_wing_heat( bool state )
1749 {
1750   wing_heat = state;
1751 }
1752
1753 void
1754 FGControls::set_pitot_heat( bool state )
1755 {
1756   pitot_heat = state;
1757 }
1758
1759 void
1760 FGControls::set_wiper( int state )
1761 {
1762   wiper = state;
1763 }
1764
1765 void
1766 FGControls::set_window_heat( bool state )
1767 {
1768   window_heat = state;
1769 }
1770
1771 void
1772 FGControls::set_carb_heat( int engine, bool val )
1773 {
1774     if ( engine == ALL_ENGINES ) {
1775         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1776             carb_heat[i] = val;
1777         }
1778     } else {
1779         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1780             carb_heat[engine] = val;
1781         }
1782     }
1783 }
1784
1785 void
1786 FGControls::set_inlet_heat( int engine, bool val )
1787 {
1788     if ( engine == ALL_ENGINES ) {
1789         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1790             inlet_heat[i] = val;
1791         }
1792     } else {
1793         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1794             inlet_heat[engine] = val;
1795         }
1796     }
1797 }
1798
1799 void
1800 FGControls::set_engine_pump( int system, bool val )
1801 {
1802     if ( system == ALL_HYD_SYSTEMS ) {
1803         for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1804             engine_pump[i] = val;
1805         }
1806     } else {
1807         if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1808             engine_pump[system] = val;
1809         }
1810     }
1811 }
1812
1813 void
1814 FGControls::set_electric_pump( int system, bool val )
1815 {
1816     if ( system == ALL_HYD_SYSTEMS ) {
1817         for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) {
1818             electric_pump[i] = val;
1819         }
1820     } else {
1821         if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) {
1822             electric_pump[system] = val;
1823         }
1824     }
1825 }
1826
1827 void
1828 FGControls::set_battery_switch( bool state )
1829 {
1830   battery_switch = state;
1831 }
1832
1833 void
1834 FGControls::set_external_power( bool state )
1835 {
1836   external_power = state;
1837 }
1838
1839 void
1840 FGControls::set_APU_generator( bool state )
1841 {
1842   APU_generator = state;
1843 }
1844
1845 void
1846 FGControls::set_generator_breaker( int engine, bool val )
1847 {
1848     if ( engine == ALL_ENGINES ) {
1849         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1850             generator_breaker[i] = val;
1851         }
1852     } else {
1853         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1854             generator_breaker[engine] = val;
1855         }
1856     }
1857 }
1858
1859 void
1860 FGControls::set_bus_tie( int engine, bool val )
1861 {
1862     if ( engine == ALL_ENGINES ) {
1863         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1864             bus_tie[i] = val;
1865         }
1866     } else {
1867         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1868             bus_tie[engine] = val;
1869         }
1870     }
1871 }
1872
1873 void
1874 FGControls::set_APU_bleed( bool state )
1875 {
1876   APU_bleed = state;
1877 }
1878
1879 void
1880 FGControls::set_engine_bleed( int engine, bool val )
1881 {
1882     if ( engine == ALL_ENGINES ) {
1883         for ( int i = 0; i < MAX_ENGINES; i++ ) {
1884             engine_bleed[i] = val;
1885         }
1886     } else {
1887         if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
1888             engine_bleed[engine] = val;
1889         }
1890     }
1891 }
1892
1893 void
1894 FGControls::set_mode( int new_mode )
1895 {
1896   mode = new_mode;
1897 }
1898
1899 void
1900 FGControls::set_outflow_valve( double pos )
1901 {
1902   outflow_valve = pos;
1903   CLAMP( &outflow_valve, 0.0, 1.0 );
1904 }
1905
1906 void
1907 FGControls::move_outflow_valve( double amt )
1908 {
1909   outflow_valve += amt;
1910   CLAMP( &outflow_valve, 0.0, 1.0 );
1911 }
1912
1913 void
1914 FGControls::set_dump( bool state )
1915 {
1916   dump = state;
1917 }
1918
1919 void
1920 FGControls::set_pack_on( int pack, bool val )
1921 {
1922     if ( pack == ALL_PACKS ) {
1923         for ( int i = 0; i < MAX_PACKS; i++ ) {
1924             pack_on[i] = val;
1925         }
1926     } else {
1927         if ( (pack >= 0) && (pack < MAX_PACKS) ) {
1928             pack_on[pack] = val;
1929         }
1930     }
1931 }
1932
1933 void
1934 FGControls::set_landing_lights( bool state )
1935 {
1936   landing_lights = state;
1937 }
1938
1939 void
1940 FGControls::set_turn_off_lights( bool state )
1941 {
1942   turn_off_lights = state;
1943 }
1944
1945 void
1946 FGControls::set_taxi_light( bool state )
1947 {
1948   taxi_light = state;
1949 }
1950
1951 void
1952 FGControls::set_logo_lights( bool state )
1953 {
1954   logo_lights = state;
1955 }
1956
1957 void
1958 FGControls::set_nav_lights( bool state )
1959 {
1960   nav_lights = state;
1961 }
1962
1963 void
1964 FGControls::set_beacon( bool state )
1965 {
1966   beacon = state;
1967 }
1968
1969 void
1970 FGControls::set_strobe( bool state )
1971 {
1972   strobe = state;
1973 }
1974
1975 void
1976 FGControls::set_panel_norm( double intensity )
1977 {
1978   panel_norm = intensity;
1979   CLAMP( &panel_norm, 0.0, 1.0 );
1980 }
1981
1982 void
1983 FGControls::move_panel_norm( double amt )
1984 {
1985   panel_norm += amt;
1986   CLAMP( &panel_norm, 0.0, 1.0 );
1987 }
1988
1989 void
1990 FGControls::set_instruments_norm( double intensity )
1991 {
1992   instruments_norm = intensity;
1993   CLAMP( &instruments_norm, 0.0, 1.0 );
1994 }
1995
1996 void
1997 FGControls::move_instruments_norm( double amt )
1998 {
1999   instruments_norm += amt;
2000   CLAMP( &instruments_norm, 0.0, 1.0 );
2001 }
2002
2003 void
2004 FGControls::set_dome_norm( double intensity )
2005 {
2006   dome_norm = intensity;
2007   CLAMP( &dome_norm, 0.0, 1.0 );
2008 }
2009
2010 void
2011 FGControls::move_dome_norm( double amt )
2012 {
2013   dome_norm += amt;
2014   CLAMP( &dome_norm, 0.0, 1.0 );
2015 }
2016
2017 #ifdef FG_HAVE_ARMAMENT
2018
2019 void
2020 FGControls::set_master_arm( bool val )
2021 {
2022   master_arm = val;
2023 }
2024
2025 void
2026 FGControls::set_station_select( int station )
2027 {
2028   station_select = station;
2029   CLAMP( &station_select, 0, MAX_STATIONS );
2030 }
2031
2032 void
2033 FGControls::set_release_ALL( bool val )
2034 {
2035   release_ALL = val;
2036 }
2037
2038 void
2039 FGControls::set_stick_size( int station, int size )
2040 {
2041     if ( station == ALL_STATIONS ) {
2042         for ( int i = 0; i < MAX_STATIONS; i++ ) {
2043             stick_size[i] = size;
2044             CLAMP( &stick_size[i], 1, 20 );
2045         }
2046     } else {
2047         if ( (station >= 0) && (station < MAX_STATIONS) ) {
2048             stick_size[station] = size;
2049             CLAMP( &stick_size[station], 1, 20 );
2050         }
2051     }
2052 }
2053
2054 void
2055 FGControls::set_release_stick( int station, bool val )
2056 {
2057     if ( station == ALL_STATIONS ) {
2058         for ( int i = 0; i < MAX_STATIONS; i++ ) {
2059             release_stick[i] = val;
2060         }
2061     } else {
2062         if ( (station >= 0) && (station < MAX_STATIONS) ) {
2063             release_stick[station] = val;
2064         }
2065     }
2066 }
2067
2068 void
2069 FGControls::set_release_all( int station, bool val )
2070 {
2071     if ( station == ALL_STATIONS ) {
2072         for ( int i = 0; i < MAX_STATIONS; i++ ) {
2073             release_all[i] = val;
2074         }
2075     } else {
2076         if ( (station >= 0) && (station < MAX_STATIONS) ) {
2077             release_all[station] = val;
2078         }
2079     }
2080 }
2081
2082 void
2083 FGControls::set_jettison_all( int station, bool val )
2084 {
2085     if ( station == ALL_STATIONS ) {
2086         for ( int i = 0; i < MAX_STATIONS; i++ ) {
2087             jettison_all[i] = val;
2088         }
2089     } else {
2090         if ( (station >= 0) && (station < MAX_STATIONS) ) {
2091             jettison_all[station] = val;
2092         }
2093     }
2094 }
2095
2096 #endif
2097
2098 void
2099 FGControls::set_vertical_adjust( double pos )
2100 {
2101   vertical_adjust = pos;
2102   CLAMP( &vertical_adjust, -1.0, 1.0 );
2103 }
2104
2105 void
2106 FGControls::move_vertical_adjust( double amt )
2107 {
2108   vertical_adjust += amt;
2109   CLAMP( &vertical_adjust, -1.0, 1.0 );
2110 }
2111
2112 void
2113 FGControls::set_fore_aft_adjust( double pos )
2114 {
2115   fore_aft_adjust = pos;
2116   CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2117 }
2118
2119 void
2120 FGControls::move_fore_aft_adjust( double amt )
2121 {
2122   fore_aft_adjust += amt;
2123   CLAMP( &fore_aft_adjust, -1.0, 1.0 );
2124 }
2125
2126 void
2127 FGControls::set_ejection_seat( int which_seat, bool val )
2128 {
2129     if ( which_seat == ALL_EJECTION_SEATS ) {
2130         for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2131             eject[i] = val;
2132         }
2133     } else {
2134         if ( (which_seat >= 0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2135             if ( eseat_status[which_seat] == SEAT_SAFED ||
2136                  eseat_status[which_seat] == SEAT_FAIL )
2137             {
2138                 // we can never eject if SEAT_SAFED or SEAT_FAIL
2139                 val = false;
2140             }
2141
2142             eject[which_seat] = val;
2143         }
2144     }
2145 }
2146
2147 void
2148 FGControls::set_eseat_status( int which_seat, int val )
2149 {
2150     if ( which_seat == ALL_EJECTION_SEATS ) {
2151         for ( int i = 0; i < MAX_EJECTION_SEATS; i++ ) {
2152             eseat_status[i] = val;
2153         }
2154     } else {
2155         if ( (which_seat >=0) && (which_seat <= MAX_EJECTION_SEATS) ) {
2156             eseat_status[which_seat] = val;
2157         }
2158     }
2159 }
2160
2161 void
2162 FGControls::set_cmd_selector_valve( int val )
2163 {
2164   cmd_selector_valve = val;
2165 }
2166
2167
2168 void
2169 FGControls::set_off_start_run( int pos )
2170 {
2171   off_start_run = pos;
2172   CLAMP( &off_start_run, 0, 3 );
2173 }
2174
2175 void
2176 FGControls::set_APU_fire_switch( bool val )
2177 {
2178   APU_fire_switch = val;
2179 }
2180
2181 void
2182 FGControls::set_autothrottle_arm( bool val )
2183 {
2184   autothrottle_arm = val;
2185 }
2186
2187 void
2188 FGControls::set_autothrottle_engage( bool val )
2189 {
2190   autothrottle_engage = val;
2191 }
2192
2193 void
2194 FGControls::set_heading_select( double heading )
2195 {
2196   heading_select = heading;
2197   CLAMP( &heading_select, 0.0, 360.0 );
2198 }
2199
2200 void
2201 FGControls::move_heading_select( double amt )
2202 {
2203   heading_select += amt;
2204   CLAMP( &heading_select, 0.0, 360.0 );
2205 }
2206
2207 void
2208 FGControls::set_altitude_select( double altitude )
2209 {
2210   altitude_select = altitude;
2211   CLAMP( &altitude_select, -1000.0, 100000.0 );
2212 }
2213
2214 void
2215 FGControls::move_altitude_select( double amt )
2216 {
2217   altitude_select += amt;
2218   CLAMP( &altitude_select, -1000.0, 100000.0 );
2219 }
2220
2221 void
2222 FGControls::set_bank_angle_select( double angle )
2223 {
2224   bank_angle_select = angle;
2225   CLAMP( &bank_angle_select, 10.0, 30.0 );
2226 }
2227
2228 void
2229 FGControls::move_bank_angle_select( double amt )
2230 {
2231   bank_angle_select += amt;
2232   CLAMP( &bank_angle_select, 10.0, 30.0 );
2233 }
2234
2235 void
2236 FGControls::set_vertical_speed_select( double speed )
2237 {
2238   vertical_speed_select = speed;
2239   CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2240 }
2241
2242 void
2243 FGControls::move_vertical_speed_select( double amt )
2244 {
2245   vertical_speed_select += amt;
2246   CLAMP( &vertical_speed_select, -3000.0, 4000.0 );
2247 }
2248
2249 void
2250 FGControls::set_speed_select( double speed )
2251 {
2252   speed_select = speed;
2253   CLAMP( &speed_select, 60.0, 400.0 );
2254 }
2255
2256 void
2257 FGControls::move_speed_select( double amt )
2258 {
2259   speed_select += amt;
2260   CLAMP( &speed_select, 60.0, 400.0 );
2261 }
2262
2263 void
2264 FGControls::set_mach_select( double mach )
2265 {
2266   mach_select = mach;
2267   CLAMP( &mach_select, 0.4, 4.0 );
2268 }
2269
2270 void
2271 FGControls::move_mach_select( double amt )
2272 {
2273   mach_select += amt;
2274   CLAMP( &mach_select, 0.4, 4.0 );
2275 }
2276
2277 void
2278 FGControls::set_vertical_mode( int mode )
2279 {
2280   vertical_mode = mode;
2281   CLAMP( &vertical_mode, 0, 4 );
2282 }
2283
2284 void
2285 FGControls::set_lateral_mode( int mode )
2286 {
2287   lateral_mode = mode;
2288   CLAMP( &lateral_mode, 0, 4 );
2289 }
2290
2291 void
2292 FGControls::set_autopilot_engage( int ap, bool val )
2293 {
2294     if ( ap == ALL_AUTOPILOTS ) {
2295         for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) {
2296             autopilot_engage[i] = val;
2297         }
2298     } else {
2299         if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) {
2300             autopilot_engage[ap] = val;
2301         }
2302     }
2303 }