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