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