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