~ubuntu-branches/ubuntu/precise/flightgear/precise

« back to all changes in this revision

Viewing changes to src/Aircraft/controls.cxx

  • Committer: Package Import Robot
  • Author(s): Ove Kaaven
  • Date: 2011-09-03 22:16:12 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20110903221612-2cjy0z7ztj5nkln5
Tags: 2.4.0-1
* New upstream release. Closes: #638588.
* Build-Depend on OpenSceneGraph 3.0, and the Subversion library.
* Recommend fgfs-scenery-base.
* Enable parallel builds (shorter compile times on multicore CPUs).
* Removed hack that tried to build without optimizations if
  building with optimizations fails.

Show diffs side-by-side

added added

removed removed

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