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