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