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