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