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