From c3cefaf883ddadb467c0e5da7f966558cbc2355b Mon Sep 17 00:00:00 2001 From: ehofman Date: Tue, 1 Apr 2003 12:43:18 +0000 Subject: [PATCH] Updates to the controls properties tree. This is a major update so there may be one or two 'old' refferences left. To simplify the transisition there is a file called README.properties in the docs-mini directory of FlightGear that explains the new controls layout. --- docs-mini/README.properties | 140 +++ src/Autopilot/newauto.cxx | 2 +- src/Controls/controls.cxx | 1756 ++++++++++++++++++++++++++++++++-- src/Controls/controls.hxx | 488 +++++++++- src/FDM/JSBSim/FGEngine.cpp | 2 + src/FDM/JSBSim/FGEngine.h | 22 +- src/FDM/JSBSim/JSBSim.cxx | 42 +- src/FDM/JSBSim/JSBSim.hxx | 4 +- src/FDM/LaRCsim.cxx | 10 +- src/FDM/YASim/YASim.cxx | 18 +- src/Input/fgjs.cxx | 14 +- src/Network/native_ctrls.cxx | 57 +- 12 files changed, 2371 insertions(+), 184 deletions(-) create mode 100644 docs-mini/README.properties diff --git a/docs-mini/README.properties b/docs-mini/README.properties new file mode 100644 index 000000000..84ed29565 --- /dev/null +++ b/docs-mini/README.properties @@ -0,0 +1,140 @@ + +Flight Controls +--------------- +/controls/flight/aileron +/controls/flight/aileron-trim +/controls/flight/elevator +/controls/flight/elevator-trim +/controls/flight/rudder +/controls/flight/rudder-trim +/controls/flight/flaps +/controls/flight/slats +/controls/flight/BLC // Boundary Layer Control +/controls/flight/spoilers +/controls/flight/speedbrake +/controls/flight/wing-sweep +/controls/flight/wing-fold +/controls/flight/drag-chute + +Engines +------- +/controls/engines/throttle_idle +/controls/engines/engine[%d]/throttle +/controls/engines/engine[%d]/starter +/controls/engines/engine[%d]/fuel-pump +/controls/engines/engine[%d]/fire-switch +/controls/engines/engine[%d]/fire-bottle-discharge +/controls/engines/engine[%d]/cutoff +/controls/engines/engine[%d]/mixture +/controls/engines/engine[%d]/propeller-pitch +/controls/engines/engine[%d]/magnetos +/controls/engines/engine[%d]/WEP +/controls/engines/engine[%d]/cowl-flaps-norm +/controls/engines/engine[%d]/feather +/controls/engines/engine[%d]/ignition +/controls/engines/engine[%d]/augmentation +/controls/engines/engine[%d]/reverser +/controls/engines/engine[%d]/water-injection +/controls/engines/engine[%d]/condition + +Fuel +---- +/controls/fuel/dump-valve +/controls/fuel/tank[%d]/fuel_selector +/controls/fuel/tank[%d]/to_engine +/controls/fuel/tank[%d]/to_tank +/controls/fuel/tank[%d]/boost-pump[%d] + +Gear +---- +/controls/gear/parking-brake +/controls/gear/steering +/controls/gear/gear-down +/controls/gear/antiskid +/controls/gear/tailhook +/controls/gear/tailwheel-lock +/controls/gear/wheel[%d]/brake +/controls/gear/wheel[%d]/alternate-extension + +Anti-Ice +-------- +/controls/anti-ice/wing-heat +/controls/anti-ice/pitot-heat +/controls/anti-ice/wiper +/controls/anti-ice/window-heat +/controls/anti-ice/engine[%d]/carb-heat +/controls/anti-ice/engine[%d]/inlet-heat + +Hydraulics +---------- +/controls/hydraulic/system[%d]/engine-pump +/controls/hydraulic/system[%d]/electric-pump + +Electric +-------- +/controls/electric/battery-switch +/controls/electric/external-power +/controls/electric/APU-generator +/controls/electric/engine[%d]/generator +/controls/electric/engine[%d]/bus-tie + +Pneumatic +--------- +/controls/pneumatic/APU-bleed +/controls/pneumatic/engine[%d]/bleed + +Pressurization +-------------- +/controls/pressurization/mode +/controls/pressurization/dump +/controls/pressurization/outflow-valve +/controls/pressurization/pack[%d]/pack-on + +Lights +------ +/controls/lighting/landing-lights +/controls/lighting/turn-off-lights +/controls/lighting/taxi-light +/controls/lighting/logo-lights +/controls/lighting/nav-lights +/controls/lighting/beacon +/controls/lighting/strobe +/controls/lighting/panel-norm +/controls/lighting/instruments-norm +/controls/lighting/dome-norm + +Armament +-------- +/controls/armament/master-arm +/controls/armament/station-select +/controls/armament/release-all +/controls/armament/station[%d]/stick-size +/controls/armament/station[%d]/release-stick +/controls/armament/station[%d]/release-all +/controls/armament/station[%d]/jettison-all + +Seat +---- +/controls/seat/vertical-adjust +/controls/seat/fore-aft-adjust +/controls/seat/eject + +APU +--- +/controls/APU/off-start-run +/controls/APU/fire-switch + +Autoflight +---------- +/controls/autoflight/autopilot[%d]/engage +/controls/autoflight/autothrottle-arm +/controls/autoflight/autothrottle-engage +/controls/autoflight/heading-select +/controls/autoflight/altitude-select +/controls/autoflight/bank-angle-select +/controls/autoflight/vertical-speed-select +/controls/autoflight/speed-select +/controls/autoflight/mach-select +/controls/autoflight/vertical-mode +/controls/autoflight/lateral-mode + diff --git a/src/Autopilot/newauto.cxx b/src/Autopilot/newauto.cxx index 668811a6c..315852d6f 100644 --- a/src/Autopilot/newauto.cxx +++ b/src/Autopilot/newauto.cxx @@ -240,7 +240,7 @@ void FGAutopilot::init () roll_out_node = fgGetNode("/autopilot/config/roll-out-deg", true); roll_out_smooth_node = fgGetNode("/autopilot/config/roll-out-smooth-deg", true); - current_throttle = fgGetNode("/controls/throttle"); + current_throttle = fgGetNode("/controls/engines/engine/throttle"); // initialize config properties with defaults (in case config isn't there) if ( TargetClimbRate->getFloatValue() < 1 ) diff --git a/src/Controls/controls.cxx b/src/Controls/controls.cxx index dc3892e20..6b0967f7f 100644 --- a/src/Controls/controls.cxx +++ b/src/Controls/controls.cxx @@ -60,11 +60,57 @@ FGControls::FGControls() : rudder( 0.0 ), rudder_trim( 0.0 ), flaps( 0.0 ), - parking_brake( 0.0 ), - speed_brake( 0.0 ), + slats( 0.0 ), + BLC( false ), spoilers( 0.0 ), + speedbrake( 0.0 ), + wing_sweep( 0.0 ), + wing_fold( false ), + drag_chute( false ), throttle_idle( true ), - gear_down( false ) + dump_valve( false ), + parking_brake( 0.0 ), + steering( 0.0 ), + gear_down( true ), + antiskid( true ), + tailhook( false ), + tailwheel_lock( false ), + wing_heat( false ), + pitot_heat( true ), + wiper( 0 ), + window_heat( false ), + battery_switch( true ), + external_power( false ), + APU_generator( false ), + APU_bleed( false ), + mode( 0 ), + dump( false ), + taxi_light( false ), + logo_lights( false ), + nav_lights( false ), + beacon( false ), + strobe( false ), + panel_norm( 0.0 ), + instruments_norm( 0.0 ), + dome_norm( 0.0 ), + master_arm( false ), + station_select( 1 ), + release_ALL( false ), + vertical_adjust( 0.0 ), + fore_aft_adjust( 0.0 ), + eject( false ), + off_start_run( 0 ), + APU_fire_switch( false ), + autothrottle_arm( false ), + autothrottle_engage( false ), + heading_select( 0.0 ), + altitude_select( 50000.0 ), + bank_angle_select( 30.0 ), + vertical_speed_select( 0.0 ), + speed_select( 0.0 ), + mach_select( 0.0 ), + vertical_mode( 0 ), + lateral_mode( 0 ) { } @@ -77,13 +123,50 @@ void FGControls::reset_all() set_elevator_trim( 0.0 ); set_rudder( 0.0 ); set_rudder_trim( 0.0 ); + BLC = false; + set_spoilers( 0.0 ); + set_speedbrake( 0.0 ); + set_wing_sweep( 0.0 ); + wing_fold = false; + drag_chute = false; set_throttle( ALL_ENGINES, 0.0 ); set_starter( ALL_ENGINES, false ); set_magnetos( ALL_ENGINES, 0 ); set_fuel_pump( ALL_ENGINES, false ); + set_fire_switch( ALL_ENGINES, false ); + set_fire_bottle_discharge( ALL_ENGINES, false ); + set_cutoff( ALL_ENGINES, true ); + set_nitrous_injection( ALL_ENGINES, false ); + set_cowl_flaps_norm( ALL_ENGINES, 1.0 ); + set_feather( ALL_ENGINES, false ); + set_ignition( ALL_ENGINES, false ); + set_augmentation( ALL_ENGINES, false ); + set_reverser( ALL_ENGINES, false ); + set_water_injection( ALL_ENGINES, false ); + set_condition( ALL_ENGINES, 0 ); throttle_idle = true; set_fuel_selector( ALL_TANKS, true ); + dump_valve = false; + steering = 0.0; gear_down = true; + tailhook = false; + tailwheel_lock = false; + set_carb_heat( ALL_ENGINES, false ); + set_inlet_heat( ALL_ENGINES, false ); + wing_heat = false; + pitot_heat = true; + wiper = 0; + window_heat = false; + set_engine_pump( ALL_HYD_SYSTEMS, true ); + set_electric_pump( ALL_HYD_SYSTEMS, true ); + landing_lights = false; + turn_off_lights = false; + master_arm = false; + eject = false; + APU_fire_switch = false; + autothrottle_arm = false; + autothrottle_engage = false; + set_autopilot_engage( ALL_AUTOPILOTS, false ); } @@ -95,6 +178,7 @@ FGControls::~FGControls() { void FGControls::init () { + throttle_idle = true; for ( int engine = 0; engine < MAX_ENGINES; engine++ ) { throttle[engine] = 0.0; mixture[engine] = 1.0; @@ -102,10 +186,19 @@ FGControls::init () prop_advance[engine] = 1.0; magnetos[engine] = 0; starter[engine] = false; + ignition[engine] = false; + fire_switch[engine] = false; + cutoff[engine] = true; + augmentation[engine] = false; + reverser[engine] = false; + water_injection[engine] = false; + nitrous_injection[engine] = false; + condition[engine] = 0; } for ( int wheel = 0; wheel < MAX_WHEELS; wheel++ ) { brake[wheel] = 0.0; + alternate_extension[wheel] = false; } auto_coordination = fgGetNode("/sim/auto-coordination", true); @@ -115,118 +208,721 @@ FGControls::init () void FGControls::bind () { - fgTie("/controls/aileron", this, + int index, i; + + // flight controls + fgTie("/controls/flight/aileron", this, &FGControls::get_aileron, &FGControls::set_aileron); - fgSetArchivable("/controls/aileron"); - fgTie("/controls/aileron-trim", this, + fgSetArchivable("/controls/flight/aileron"); + + fgTie("/controls/flight/aileron-trim", this, &FGControls::get_aileron_trim, &FGControls::set_aileron_trim); - fgSetArchivable("/controls/aileron-trim"); - fgTie("/controls/elevator", this, + fgSetArchivable("/controls/flight/aileron-trim"); + + fgTie("/controls/flight/elevator", this, &FGControls::get_elevator, &FGControls::set_elevator); - fgSetArchivable("/controls/elevator"); - fgTie("/controls/elevator-trim", this, + fgSetArchivable("/controls/flight/elevator"); + + fgTie("/controls/flight/elevator-trim", this, &FGControls::get_elevator_trim, &FGControls::set_elevator_trim); - fgSetArchivable("/controls/elevator-trim"); - fgTie("/controls/rudder", this, + fgSetArchivable("/controls/flight/elevator-trim"); + + fgTie("/controls/flight/rudder", this, &FGControls::get_rudder, &FGControls::set_rudder); - fgSetArchivable("/controls/rudder"); - fgTie("/controls/rudder-trim", this, + fgSetArchivable("/controls/flight/rudder"); + + fgTie("/controls/flight/rudder-trim", this, &FGControls::get_rudder_trim, &FGControls::set_rudder_trim); - fgSetArchivable("/controls/rudder-trim"); - fgTie("/controls/flaps", this, + fgSetArchivable("/controls/flight/rudder-trim"); + + fgTie("/controls/flight/flaps", this, &FGControls::get_flaps, &FGControls::set_flaps); - fgSetArchivable("/controls/flaps"); - int index; + fgSetArchivable("/controls/flight/flaps"); + + fgTie("/controls/flight/slats", this, + &FGControls::get_slats, &FGControls::set_slats); + fgSetArchivable("/controls/flight/slats"); + + fgTie("/controls/flight/BLC", this, + &FGControls::get_BLC, &FGControls::set_BLC); + fgSetArchivable("/controls/flight/BLC"); + + fgTie("/controls/flight/spoilers", this, + &FGControls::get_spoilers, &FGControls::set_spoilers); + fgSetArchivable("/controls/flight/spoilers"); + + fgTie("/controls/flight/speedbrake", this, + &FGControls::get_speedbrake, &FGControls::set_speedbrake); + fgSetArchivable("/controls/flight/speedbrake"); + + fgTie("/controls/flight/wing-sweep", this, + &FGControls::get_wing_sweep, &FGControls::set_wing_sweep); + fgSetArchivable("/controls/flight/wing-sweep"); + + fgTie("/controls/flight/wing-fold", this, + &FGControls::get_wing_fold, &FGControls::set_wing_fold); + fgSetArchivable("/controls/flight/wing-fold"); + + fgTie("/controls/flight/drag-chute", this, + &FGControls::get_drag_chute, &FGControls::set_drag_chute); + fgSetArchivable("/controls/flight/drag-chute"); + + // engines + fgTie("/controls/engines/throttle_idle", this, + &FGControls::get_throttle_idle, &FGControls::set_throttle_idle); + fgSetArchivable("/controls/engines/throttle_idle"); + for (index = 0; index < MAX_ENGINES; index++) { char name[32]; - sprintf(name, "/controls/throttle[%d]", index); + sprintf(name, "/controls/engines/engine[%d]/throttle", index); fgTie(name, this, index, &FGControls::get_throttle, &FGControls::set_throttle); fgSetArchivable(name); - sprintf(name, "/controls/mixture[%d]", index); - fgTie(name, this, index, - &FGControls::get_mixture, &FGControls::set_mixture); - fgSetArchivable(name); - sprintf(name, "/controls/fuel-pump[%d]", index); - fgTie(name, this, index, - &FGControls::get_fuel_pump, &FGControls::set_fuel_pump); - fgSetArchivable(name); - sprintf(name, "/controls/propeller-pitch[%d]", index); - fgTie(name, this, index, - &FGControls::get_prop_advance, &FGControls::set_prop_advance); - fgSetArchivable(name); - sprintf(name, "/controls/magnetos[%d]", index); - fgTie(name, this, index, - &FGControls::get_magnetos, &FGControls::set_magnetos); - fgSetArchivable(name); - sprintf(name, "/controls/starter[%d]", index); + + sprintf(name, "/controls/engines/engine[%d]/starter", index); fgTie(name, this, index, &FGControls::get_starter, &FGControls::set_starter); fgSetArchivable(name); + + sprintf(name, "/controls/engines/engine[%d]/fuel-pump", index); + fgTie(name, this, index, + &FGControls::get_fuel_pump, &FGControls::set_fuel_pump); + fgSetArchivable(name); + + sprintf(name, "/controls/engines/engine[%d]/fire-switch", index); + fgTie(name, this, index, + &FGControls::get_fire_switch, &FGControls::set_fire_switch); + fgSetArchivable(name); + + sprintf(name, + "/controls/engines/engine[%d]/fire-bottle-discharge", index); + fgTie(name, this, index, + &FGControls::get_fire_bottle_discharge, + &FGControls::set_fire_bottle_discharge); + fgSetArchivable(name); + + sprintf(name, "/controls/engines/engine[%d]/cutoff", index); + fgTie(name, this, index, + &FGControls::get_cutoff, &FGControls::set_cutoff); + fgSetArchivable(name); + + sprintf(name, "/controls/engines/engine[%d]/mixture", index); + fgTie(name, this, index, + &FGControls::get_mixture, &FGControls::set_mixture); + fgSetArchivable(name); + + sprintf(name, + "/controls/engines/engine[%d]/propeller-pitch", index); + fgTie(name, this, index, + &FGControls::get_prop_advance, + &FGControls::set_prop_advance); + fgSetArchivable(name); + + sprintf(name, "/controls/engines/engine[%d]/magnetos", index); + fgTie(name, this, index, + &FGControls::get_magnetos, &FGControls::set_magnetos); + fgSetArchivable(name); + + sprintf(name, "/controls/engines/engine[%d]/WEP", index); + fgTie(name, this, index, + &FGControls::get_nitrous_injection, + &FGControls::set_nitrous_injection); + fgSetArchivable(name); + + sprintf(name, + "/controls/engines/engine[%d]/cowl-flaps-norm", index); + fgTie(name, this, index, + &FGControls::get_cowl_flaps_norm, + &FGControls::set_cowl_flaps_norm); + fgSetArchivable(name); + + sprintf(name, "/controls/engines/engine[%d]/feather", index); + fgTie(name, this, index, + &FGControls::get_feather, &FGControls::set_feather); + fgSetArchivable(name); + + sprintf(name, "/controls/engines/engine[%d]/ignition", index); + fgTie(name, this, index, + &FGControls::get_ignition, &FGControls::set_ignition); + fgSetArchivable(name); + + sprintf(name, "/controls/engines/engine[%d]/augmentation", index); + fgTie(name, this, index, + &FGControls::get_augmentation, + &FGControls::set_augmentation); + fgSetArchivable(name); + + sprintf(name, "/controls/engines/engine[%d]/reverser", index); + fgTie(name, this, index, + &FGControls::get_reverser, &FGControls::set_reverser); + fgSetArchivable(name); + + sprintf(name, + "/controls/engines/engine[%d]/water-injection", index); + fgTie(name, this, index, + &FGControls::get_water_injection, + &FGControls::set_water_injection); + fgSetArchivable(name); + + sprintf(name, "/controls/engines/engine[%d]/condition", index); + fgTie(name, this, index, + &FGControls::get_condition, &FGControls::set_condition); + fgSetArchivable(name); } - fgTie("/controls/parking-brake", this, - &FGControls::get_parking_brake, &FGControls::set_parking_brake); - fgSetArchivable("/controls/speed-brake"); - fgTie("/controls/speed-brake", this, - &FGControls::get_speed_brake, &FGControls::set_speed_brake); - fgSetArchivable("/controls/speed-brake"); - fgTie("/controls/spoilers", this, - &FGControls::get_spoilers, &FGControls::set_spoilers); - fgSetArchivable("/controls/spoilers"); + + // fuel + fgTie("/controls/fuel/dump-valve", this, + &FGControls::get_dump_valve, &FGControls::set_dump_valve); + fgSetArchivable("/controls/fuel/dump-valve"); + + for (index = 0; index < MAX_TANKS; index++) { + char name[32]; + sprintf(name, "/controls/fuel/tank[%d]/fuel_selector", index); + fgTie(name, this, index, + &FGControls::get_fuel_selector, + &FGControls::set_fuel_selector); + fgSetArchivable(name); + + sprintf(name, "/controls/fuel/tank[%d]/to_engine", index); + fgTie(name, this, index, + &FGControls::get_to_engine, &FGControls::set_to_engine); + fgSetArchivable(name); + + sprintf(name, "/controls/fuel/tank[%d]/to_tank", index); + fgTie(name, this, index, + &FGControls::get_to_tank, &FGControls::set_to_tank); + fgSetArchivable(name); + + for (i = 0; i < MAX_BOOSTPUMPS; i++) { + char name[32]; + sprintf(name, + "/controls/fuel/tank[%d]/boost-pump[%d]", index, i); + fgTie(name, this, index * 2 + i, + &FGControls::get_boost_pump, + &FGControls::set_boost_pump); + fgSetArchivable(name); + } + } + + // gear + fgTie("/controls/gear/parking-brake", this, + &FGControls::get_parking_brake, + &FGControls::set_parking_brake); + fgSetArchivable("/controls/parking-brake"); + + fgTie("/controls/gear/steering", this, + &FGControls::get_steering, &FGControls::set_steering); + fgSetArchivable("/controls/gear/steering"); + + fgTie("/controls/gear/gear-down", this, + &FGControls::get_gear_down, &FGControls::set_gear_down); + fgSetArchivable("/controls/gear/gear-down"); + + fgTie("/controls/gear/antiskid", this, + &FGControls::get_antiskid, &FGControls::set_antiskid); + fgSetArchivable("/controls/gear/antiskid"); + + fgTie("/controls/gear/tailhook", this, + &FGControls::get_tailhook, &FGControls::set_tailhook); + fgSetArchivable("/controls/gear/tailhook"); + + fgTie("/controls/gear/tailwheel-lock", this, + &FGControls::get_tailwheel_lock, + &FGControls::set_tailwheel_lock); + fgSetArchivable("/controls/gear/tailwheel-lock"); + for (index = 0; index < MAX_WHEELS; index++) { char name[32]; - sprintf(name, "/controls/brakes[%d]", index); + sprintf(name, "/controls/gear/wheel[%d]/brake", index); fgTie(name, this, index, &FGControls::get_brake, &FGControls::set_brake); fgSetArchivable(name); - } - for (index = 0; index < MAX_TANKS; index++) { - char name[32]; - sprintf(name, "/controls/fuel-selector[%d]", index); + + sprintf(name, "/controls/gear/wheel[%d]/alternate-extension", index); fgTie(name, this, index, - &FGControls::get_fuel_selector, &FGControls::set_fuel_selector); + &FGControls::get_alternate_extension, + &FGControls::set_alternate_extension); fgSetArchivable(name); } - fgTie("/controls/gear-down", this, - &FGControls::get_gear_down, &FGControls::set_gear_down); - fgSetArchivable("/controls/gear-down"); + + // anti-ice + fgTie("/controls/anti-ice/wing-heat", this, + &FGControls::get_wing_heat, &FGControls::set_wing_heat); + fgSetArchivable("/controls/anti-ice/wing-heat"); + + fgTie("/controls/anti-ice/pitot-heat", this, + &FGControls::get_pitot_heat, &FGControls::set_pitot_heat); + fgSetArchivable("/controls/anti-ice/pitot-heat"); + + fgTie("/controls/anti-ice/wiper", this, + &FGControls::get_wiper, &FGControls::set_wiper); + fgSetArchivable("/controls/anti-ice/wiper"); + + fgTie("/controls/anti-ice/window-heat", this, + &FGControls::get_window_heat, &FGControls::set_window_heat); + fgSetArchivable("/controls/anti-ice/window-heat"); + + for (index = 0; index < MAX_ENGINES; index++) { + char name[32]; + sprintf(name, "/controls/anti-ice/engine[%d]/carb-heat", index); + fgTie(name, this, index, + &FGControls::get_carb_heat, &FGControls::set_carb_heat); + fgSetArchivable(name); + + sprintf(name, "/controls/anti-ice/engine[%d]/inlet-heat", index); + fgTie(name, this, index, + &FGControls::get_inlet_heat, &FGControls::set_inlet_heat); + fgSetArchivable(name); + } + + // hydraulics + for (index = 0; index < MAX_HYD_SYSTEMS; index++) { + char name[32]; + sprintf(name, + "/controls/hydraulic/system[%d]/engine-pump", index); + fgTie(name, this, index, + &FGControls::get_engine_pump, &FGControls::set_engine_pump); + fgSetArchivable(name); + + sprintf(name, + "/controls/hydraulic/system[%d]/electric-pump", index); + fgTie(name, this, index, + &FGControls::get_electric_pump, + &FGControls::set_electric_pump); + fgSetArchivable(name); + } + + // electric + fgTie("/controls/electric/battery-switch", this, + &FGControls::get_battery_switch, + &FGControls::set_battery_switch); + fgSetArchivable("/controls/electric/battery-switch"); + + fgTie("/controls/electric/external-power", this, + &FGControls::get_external_power, + &FGControls::set_external_power); + fgSetArchivable("/controls/electric/external-power"); + + fgTie("/controls/electric/APU-generator", this, + &FGControls::get_APU_generator, + &FGControls::set_APU_generator); + fgSetArchivable("/controls/electric/APU-generator"); + + for (index = 0; index < MAX_ENGINES; index++) { + char name[32]; + sprintf(name, + "/controls/electric/engine[%d]/generator", index); + fgTie(name, this, index, + &FGControls::get_generator_breaker, + &FGControls::set_generator_breaker); + fgSetArchivable(name); + + sprintf(name, "/controls/electric/engine[%d]/bus-tie", index); + fgTie(name, this, index, + &FGControls::get_bus_tie, + &FGControls::set_bus_tie); + fgSetArchivable(name); + } + + // pneumatic + fgTie("/controls/pneumatic/APU-bleed", this, + &FGControls::get_APU_bleed, + &FGControls::set_APU_bleed); + fgSetArchivable("/controls/pneumatic/APU-bleed"); + + for (index = 0; index < MAX_ENGINES; index++) { + char name[32]; + sprintf(name, + "/controls/pneumatic/engine[%d]/bleed", index); + fgTie(name, this, index, + &FGControls::get_engine_bleed, + &FGControls::set_engine_bleed); + fgSetArchivable(name); + } + + // pressurization + fgTie("/controls/pressurization/mode", this, + &FGControls::get_mode, &FGControls::set_mode); + fgSetArchivable("/controls/pressurization/mode"); + + fgTie("/controls/pressurization/dump", this, + &FGControls::get_dump, &FGControls::set_dump); + fgSetArchivable("/controls/pressurization/dump"); + + fgTie("/controls/pressurization/outflow-valve", this, + &FGControls::get_outflow_valve, + &FGControls::set_outflow_valve); + fgSetArchivable("/controls/pressurization/outflow-valve"); + + for (index = 0; index < MAX_PACKS; index++) { + char name[32]; + sprintf(name, "/controls/pressurization/pack[%d]/pack-on", index); + fgTie(name, this, index, + &FGControls::get_pack_on, &FGControls::set_pack_on); + fgSetArchivable(name); + } + + // lights + fgTie("/controls/lighting/landing-lights", this, + &FGControls::get_landing_lights, + &FGControls::set_landing_lights); + fgSetArchivable("/controls/lighting/landing-lights"); + + fgTie("/controls/lighting/turn-off-lights", this, + &FGControls::get_turn_off_lights, + &FGControls::set_turn_off_lights); + fgSetArchivable("/controls/lighting/turn-off-lights"); + + fgTie("/controls/lighting/taxi-light", this, + &FGControls::get_taxi_light, &FGControls::set_taxi_light); + fgSetArchivable("/controls/lighting/taxi-light"); + + fgTie("/controls/lighting/logo-lights", this, + &FGControls::get_logo_lights, &FGControls::set_logo_lights); + fgSetArchivable("/controls/lighting/logo-lights"); + + fgTie("/controls/lighting/nav-lights", this, + &FGControls::get_nav_lights, &FGControls::set_nav_lights); + fgSetArchivable("/controls/lighting/nav-lights"); + + fgTie("/controls/lighting/beacon", this, + &FGControls::get_beacon, &FGControls::set_beacon); + fgSetArchivable("/controls/lighting/beacon"); + + fgTie("/controls/lighting/strobe", this, + &FGControls::get_strobe, &FGControls::set_strobe); + fgSetArchivable("/controls/lighting/strobe"); + + fgTie("/controls/lighting/panel-norm", this, + &FGControls::get_panel_norm, &FGControls::set_panel_norm); + fgSetArchivable("/controls/lighting/panel-norm"); + + fgTie("/controls/lighting/instruments-norm", this, + &FGControls::get_instruments_norm, + &FGControls::set_instruments_norm); + fgSetArchivable("/controls/lighting/instruments-norm"); + + fgTie("/controls/lighting/dome-norm", this, + &FGControls::get_dome_norm, &FGControls::set_dome_norm); + fgSetArchivable("/controls/lighting/dome-norm"); + +#ifdef FG_HAVE_ARMAMENT + // armament + fgTie("/controls/armament/master-arm", this, + &FGControls::get_master_arm, &FGControls::set_master_arm); + fgSetArchivable("/controls/armament/master-arm"); + + fgTie("/controls/armament/station-select", this, + &FGControls::get_station_select, + &FGControls::set_station_select); + fgSetArchivable("/controls/armament/station-select"); + + fgTie("/controls/armament/release-all", this, + &FGControls::get_release_ALL, + &FGControls::set_release_ALL); + fgSetArchivable("/controls/armament/release-all"); + + for (index = 0; index < MAX_STATIONS; index++) { + char name[32]; + sprintf(name, "/controls/armament/station[%d]/stick-size", index); + fgTie(name, this, index, + &FGControls::get_stick_size, &FGControls::set_stick_size); + fgSetArchivable(name); + + sprintf(name, + "/controls/armament/station[%d]/release-stick", index); + fgTie(name, this, index, + &FGControls::get_release_stick, &FGControls::set_release_stick); + fgSetArchivable(name); + + sprintf(name, "/controls/armament/station[%d]/release-all", index); + fgTie(name, this, index, + &FGControls::get_release_all, &FGControls::set_release_all); + fgSetArchivable(name); + + sprintf(name, "/controls/armament/station[%d]/jettison-all", index); + fgTie(name, this, index, + &FGControls::get_jettison_all, &FGControls::set_jettison_all); + fgSetArchivable(name); + } + +#endif + + // seat + fgTie("/controls/seat/vertical-adjust", this, + &FGControls::get_vertical_adjust, + &FGControls::set_vertical_adjust); + fgSetArchivable("/controls/seat/vertical-adjust"); + + fgTie("/controls/seat/fore-aft-adjust", this, + &FGControls::get_fore_aft_adjust, + &FGControls::set_fore_aft_adjust); + fgSetArchivable("/controls/seat/fore-aft-adjust"); + + fgTie("/controls/seat/eject", this, + &FGControls::get_eject, &FGControls::set_eject); + fgSetArchivable("/controls/seat/eject"); + + // APU + fgTie("/controls/APU/off-start-run", this, + &FGControls::get_off_start_run, + &FGControls::set_off_start_run); + fgSetArchivable("/controls/APU/off-start-run"); + + fgTie("/controls/APU/fire-switch", this, + &FGControls::get_APU_fire_switch, + &FGControls::set_APU_fire_switch); + fgSetArchivable("/controls/APU/fire-switch"); + + // autoflight + for (index = 0; index < MAX_AUTOPILOTS; index++) { + char name[32]; + sprintf(name, + "/controls/autoflight/autopilot[%d]/engage", index); + fgTie(name, this, index, + &FGControls::get_autopilot_engage, + &FGControls::set_autopilot_engage); + fgSetArchivable(name); + } + + fgTie("/controls/autoflight/autothrottle-arm", this, + &FGControls::get_autothrottle_arm, + &FGControls::set_autothrottle_arm); + fgSetArchivable("/controls/autoflight/autothrottle-arm"); + + fgTie("/controls/autoflight/autothrottle-engage", this, + &FGControls::get_autothrottle_engage, + &FGControls::set_autothrottle_engage); + fgSetArchivable("/controls/autoflight/autothrottle-engage"); + + fgTie("/controls/autoflight/heading-select", this, + &FGControls::get_heading_select, + &FGControls::set_heading_select); + fgSetArchivable("/controls/autoflight/heading-select"); + + fgTie("/controls/autoflight/altitude-select", this, + &FGControls::get_altitude_select, + &FGControls::set_altitude_select); + fgSetArchivable("/controls/autoflight/altitude-select"); + + fgTie("/controls/autoflight/bank-angle-select", this, + &FGControls::get_bank_angle_select, + &FGControls::set_bank_angle_select); + fgSetArchivable("/controls/autoflight/bank-angle-select"); + + fgTie("/controls/autoflight/vertical-speed-select", this, + &FGControls::get_vertical_speed_select, + &FGControls::set_vertical_speed_select); + fgSetArchivable("/controls/autoflight/vertical-speed-select"); + + fgTie("/controls/autoflight/speed-select", this, + &FGControls::get_speed_select, + &FGControls::set_speed_select); + fgSetArchivable("/controls/autoflight/speed-select"); + + fgTie("/controls/autoflight/mach-select", this, + &FGControls::get_mach_select, + &FGControls::set_mach_select); + fgSetArchivable("/controls/autoflight/mach-select"); + + fgTie("/controls/autoflight/vertical-mode", this, + &FGControls::get_vertical_mode, + &FGControls::set_vertical_mode); + fgSetArchivable("/controls/autoflight/vertical-mode"); + + fgTie("/controls/autoflight/lateral-mode", this, + &FGControls::get_lateral_mode, + &FGControls::set_lateral_mode); + fgSetArchivable("/controls/autoflight/lateral-mode"); + } - -void -FGControls::unbind () +void FGControls::unbind () { - // Tie control properties. - fgUntie("/controls/aileron"); - fgUntie("/controls/aileron-trim"); - fgUntie("/controls/elevator"); - fgUntie("/controls/elevator-trim"); - fgUntie("/controls/rudder"); - fgUntie("/controls/rudder-trim"); - fgUntie("/controls/flaps"); - int index; + int index, i; + //Tie control properties. + fgUntie("/controls/flight/aileron"); + fgUntie("/controls/flight/aileron-trim"); + fgUntie("/controls/flight/elevator"); + fgUntie("/controls/flight/elevator-trim"); + fgUntie("/controls/flight/rudder"); + fgUntie("/controls/flight/rudder-trim"); + fgUntie("/controls/flight/flaps"); + fgUntie("/controls/flight/slats"); + fgUntie("/controls/flight/BLC"); + fgUntie("/controls/flight/spoilers"); + fgUntie("/controls/flight/speedbrake"); + fgUntie("/controls/flight/wing-sweep"); + fgUntie("/controls/flight/wing-fold"); + fgUntie("/controls/flight/drag-chute"); for (index = 0; index < MAX_ENGINES; index++) { char name[32]; - sprintf(name, "/controls/throttle[%d]", index); + sprintf(name, "/controls/engines/engine[%d]/throttle", index); fgUntie(name); - sprintf(name, "/controls/mixture[%d]", index); + sprintf(name, "/controls/engines/engine[%d]/starter", index); fgUntie(name); - sprintf(name, "/controls/fuel-pump[%d]", index); + sprintf(name, "/controls/engines/engine[%d]/fuel_pump", index); fgUntie(name); - sprintf(name, "/controls/propeller-pitch[%d]", index); + sprintf(name, "/controls/engines/engine[%d]/fire-switch", index); fgUntie(name); - sprintf(name, "/controls/magnetos[%d]", index); + sprintf(name, + "/controls/engines/engine[%d]/fire-bottle-discharge", index); fgUntie(name); - sprintf(name, "/controls/starter[%d]", index); + sprintf(name, "/controls/engines/engine[%d]/throttle_idle", index); + fgUntie(name); + sprintf(name, "/controls/engines/engine[%d]/cutoff", index); + fgUntie(name); + sprintf(name, "/controls/engines/engine[%d]/mixture", index); + fgUntie(name); + sprintf(name, + "/controls/engines/engine[%d]/propeller-pitch", index); + fgUntie(name); + sprintf(name, "/controls/engines/engine[%d]/magnetos", index); + fgUntie(name); + sprintf(name, "/controls/engines/engine[%d]/WEP", index); + fgUntie(name); + sprintf(name, "/controls/engines/engine[%d]/cowl-flaps-norm", index); + fgUntie(name); + sprintf(name, "/controls/engines/engine[%d]/feather", index); + fgUntie(name); + sprintf(name, "/controls/engines/engine[%d]/ignition", index); + fgUntie(name); + sprintf(name, "/controls/engines/engine[%d]/augmentation", index); + fgUntie(name); + sprintf(name, "/controls/engines/engine[%d]/reverser", index); + fgUntie(name); + sprintf(name, "/controls/engines/engine[%d]/water-injection", index); + fgUntie(name); + sprintf(name, "/controls/engines/engine[%d]/condition", index); fgUntie(name); } + fgUntie("/controls/fuel/dump-valve"); + for (index = 0; index < MAX_TANKS; index++) { + char name[32]; + sprintf(name, "/controls/fuel/tank[%d]/fuel_selector", index); + fgUntie(name); + sprintf(name, "/controls/fuel/tank[%d]/to_engine", index); + fgUntie(name); + sprintf(name, "/controls/fuel/tank[%d]/to_tank", index); + fgUntie(name); + for (i = 0; index < MAX_BOOSTPUMPS; i++) { + sprintf(name, "/controls/fuel/tank[%d]/boost-pump[%d]", index, i); + fgUntie(name); + } + } + fgUntie("/controls/gear/parking_brake"); + fgUntie("/controls/gear/steering"); + fgUntie("/controls/gear/gear_down"); + fgUntie("/controls/gear/antiskid"); + fgUntie("/controls/gear/tailhook"); + fgUntie("/controls/gear/tailwheel-lock"); for (index = 0; index < MAX_WHEELS; index++) { char name[32]; - sprintf(name, "/controls/brakes[%d]", index); + sprintf(name, "/controls/gear/wheel[%d]/brakes", index); + fgUntie(name); + sprintf(name, + "/controls/gear/wheel[%d]/alternate-extension", index); fgUntie(name); } - fgUntie("/controls/fuel-selector"); - fgUntie("/controls/gear-down"); + fgUntie("/controls/anti-ice/wing-heat"); + fgUntie("/controls/anti-ice/pitot-heat"); + fgUntie("/controls/anti-ice/wiper"); + fgUntie("/controls/anti-ice/window-heat"); + for (index = 0; index < MAX_ENGINES; index++) { + char name[32]; + sprintf(name, "/controls/anti-ice/engine[%d]/carb-heat", index); + fgUntie(name); + sprintf(name, "/controls/anti-ice/engine[%d]/inlet-heat", index); + fgUntie(name); + } + for (index = 0; index < MAX_HYD_SYSTEMS; index++) { + char name[32]; + sprintf(name, + "/controls/hydraulic/system[%d]/engine-pump", index); + fgUntie(name); + sprintf(name, + "/controls/hydraulic/system[%d]/electric-pump", index); + fgUntie(name); + } + fgUntie("/controls/electric/battery-switch"); + fgUntie("/controls/electric/external-power"); + fgUntie("/controls/electric/APU-generator"); + for (index = 0; index < MAX_ENGINES; index++) { + char name[32]; + sprintf(name, + "/controls/electric/engine[%d]/generator", index); + fgUntie(name); + sprintf(name, + "/controls/electric/engine[%d]/bus-tie", index); + fgUntie(name); + } + fgUntie("/controls/pneumatic/APU-bleed"); + for (index = 0; index < MAX_ENGINES; index++) { + char name[32]; + sprintf(name, + "/controls/pneumatic/engine[%d]/bleed", index); + fgUntie(name); + } + fgUntie("/controls/pressurization/mode"); + fgUntie("/controls/pressurization/dump"); + for (index = 0; index < MAX_PACKS; index++) { + char name[32]; + sprintf(name, + "/controls/pressurization/pack[%d]/pack-on", index); + fgUntie(name); + } + fgUntie("/controls/lighting/landing-lights"); + fgUntie("/controls/lighting/turn-off-lights"); + fgUntie("/controls/lighting/taxi-light"); + fgUntie("/controls/lighting/logo-lights"); + fgUntie("/controls/lighting/nav-lights"); + fgUntie("/controls/lighting/beacon"); + fgUntie("/controls/lighting/strobe"); + fgUntie("/controls/lighting/panel-norm"); + fgUntie("/controls/lighting/instruments-norm"); + fgUntie("/controls/lighting/dome-norm"); + +#ifdef FG_HAVE_ARMAMENT + fgUntie("/controls/armament/master-arm"); + fgUntie("/controls/armament/station-select"); + fgUntie("/controls/armament/release-all"); + for (index = 0; index < MAX_STATIONS; index++) { + char name[32]; + sprintf(name, + "/controls/armament/station[%d]/stick-size", index); + fgUntie(name); + sprintf(name, + "/controls/armament/station[%d]/release-stick", index); + fgUntie(name); + sprintf(name, + "/controls/armament/station[%d]/release-all", index); + fgUntie(name); + sprintf(name, + "/controls/armament/station[%d]/jettison-all", index); + fgUntie(name); + } +#endif + fgUntie("/controls/seat/vertical-adjust"); + fgUntie("/controls/seat/fore-aft-adjust"); + fgUntie("/controls/seat/eject"); + fgUntie("/controls/APU/off-start-run"); + fgUntie("/controls/APU/fire-switch"); + for (index = 0; index < MAX_AUTOPILOTS; index++) { + char name[32]; + sprintf(name, + "/controls/autoflight/autopilot[%d]/engage", index); + fgUntie(name); + } + fgUntie("/controls/autoflight/autothrottle-arm"); + fgUntie("/controls/autoflight/autothrottle-engage"); + fgUntie("/controls/autoflight/heading-select"); + fgUntie("/controls/autoflight/altitude-select"); + fgUntie("/controls/autoflight/bank-angle-select"); + fgUntie("/controls/autoflight/vertical-speed-select"); + fgUntie("/controls/autoflight/speed-select"); + fgUntie("/controls/autoflight/mach-select"); + fgUntie("/controls/autoflight/vertical-mode"); + fgUntie("/controls/autoflight/lateral-mode"); } @@ -349,6 +1045,86 @@ FGControls::move_flaps( double amt ) CLAMP( &flaps, 0.0, 1.0 ); } +void +FGControls::set_slats( double pos ) +{ + slats = pos; + CLAMP( &slats, 0.0, 1.0 ); +} + +void +FGControls::move_slats( double amt ) +{ + slats += amt; + CLAMP( &slats, 0.0, 1.0 ); +} + +void +FGControls::set_BLC( bool val ) +{ + BLC = val; +} + +void +FGControls::set_spoilers( double pos ) +{ + spoilers = pos; + CLAMP( &spoilers, 0.0, 1.0 ); +} + +void +FGControls::move_spoilers( double amt ) +{ + spoilers += amt; + CLAMP( &spoilers, 0.0, 1.0 ); +} + +void +FGControls::set_speedbrake( double pos ) +{ + speedbrake = pos; + CLAMP( &speedbrake, 0.0, 1.0 ); +} + +void +FGControls::move_speedbrake( double amt ) +{ + speedbrake += amt; + CLAMP( &speedbrake, 0.0, 1.0 ); +} + +void +FGControls::set_wing_sweep( double pos ) +{ + wing_sweep = pos; + CLAMP( &wing_sweep, 0.0, 1.0 ); +} + +void +FGControls::move_wing_sweep( double amt ) +{ + wing_sweep += amt; + CLAMP( &wing_sweep, 0.0, 1.0 ); +} + +void +FGControls::set_wing_fold( bool val ) +{ + wing_fold = val; +} + +void +FGControls::set_drag_chute( bool val ) +{ + drag_chute = val; +} + +void +FGControls::set_throttle_idle( bool val ) +{ + throttle_idle = val; +} + void FGControls::set_throttle( int engine, double pos ) { @@ -381,6 +1157,77 @@ FGControls::move_throttle( int engine, double amt ) } } +void +FGControls::set_starter( int engine, bool flag ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + starter[i] = flag; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + starter[engine] = flag; + } + } +} + +void +FGControls::set_fuel_pump( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + fuel_pump[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + fuel_pump[engine] = val; + } + } +} + +void +FGControls::set_fire_switch( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + fire_switch[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + fire_switch[engine] = val; + } + } +} + +void +FGControls::set_fire_bottle_discharge( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + fire_bottle_discharge[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + fire_bottle_discharge[engine] = val; + } + } +} + +void +FGControls::set_cutoff( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + cutoff[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + cutoff[engine] = val; + } + } +} + + void FGControls::set_mixture( int engine, double pos ) { @@ -413,20 +1260,6 @@ FGControls::move_mixture( int engine, double amt ) } } -void -FGControls::set_fuel_pump( int engine, bool val ) -{ - if ( engine == ALL_ENGINES ) { - for ( int i = 0; i < MAX_ENGINES; i++ ) { - fuel_pump[i] = val; - } - } else { - if ( (engine >= 0) && (engine < MAX_ENGINES) ) { - fuel_pump[engine] = val; - } - } -} - void FGControls::set_prop_advance( int engine, double pos ) { @@ -492,19 +1325,147 @@ FGControls::move_magnetos( int engine, int amt ) } void -FGControls::set_starter( int engine, bool flag ) +FGControls::set_nitrous_injection( int engine, bool val ) { if ( engine == ALL_ENGINES ) { for ( int i = 0; i < MAX_ENGINES; i++ ) { - starter[i] = flag; + nitrous_injection[i] = val; } } else { if ( (engine >= 0) && (engine < MAX_ENGINES) ) { - starter[engine] = flag; + nitrous_injection[engine] = val; } } } + +void +FGControls::set_cowl_flaps_norm( int engine, double pos ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + cowl_flaps_norm[i] = pos; + CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 ); + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + cowl_flaps_norm[engine] = pos; + CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 ); + } + } +} + +void +FGControls::move_cowl_flaps_norm( int engine, double amt ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + cowl_flaps_norm[i] += amt; + CLAMP( &cowl_flaps_norm[i], 0.0, 1.0 ); + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + cowl_flaps_norm[engine] += amt; + CLAMP( &cowl_flaps_norm[engine], 0.0, 1.0 ); + } + } +} + +void +FGControls::set_feather( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + feather[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + feather[engine] = val; + } + } +} + +void +FGControls::set_ignition( int engine, int pos ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + ignition[i] = pos; + CLAMP( &ignition[i], 0, 3 ); + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + ignition[engine] = pos; + CLAMP( &ignition[engine], 0, 3 ); + } + } +} + +void +FGControls::set_augmentation( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + augmentation[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + augmentation[engine] = val; + } + } +} + +void +FGControls::set_reverser( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + reverser[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + reverser[engine] = val; + } + } +} + +void +FGControls::set_water_injection( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + water_injection[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + water_injection[engine] = val; + } + } +} + +void +FGControls::set_condition( int engine, int val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + condition[i] = val; + CLAMP( &condition[i], 0, 3 ); + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + condition[engine] = val; + CLAMP( &condition[engine], 0, 3 ); + } + } +} + +void +FGControls::set_dump_valve( bool val ) +{ + dump_valve = val; +} + + void FGControls::set_fuel_selector( int tank, bool pos ) { @@ -519,6 +1480,48 @@ FGControls::set_fuel_selector( int tank, bool pos ) } } +void +FGControls::set_to_engine( int tank, int engine ) +{ + if ( tank == ALL_TANKS ) { + for ( int i = 0; i < MAX_TANKS; i++ ) { + to_engine[i] = engine; + } + } else { + if ( (tank >= 0) && (tank < MAX_TANKS) ) { + to_engine[tank] = engine; + } + } +} + +void +FGControls::set_to_tank( int tank, int dest_tank ) +{ + if ( tank == ALL_TANKS ) { + for ( int i = 0; i < MAX_TANKS; i++ ) { + to_tank[i] = dest_tank; + } + } else { + if ( (tank >= 0) && (tank < MAX_TANKS) ) { + to_tank[tank] = dest_tank; + } + } +} + +void +FGControls::set_boost_pump( int index, bool val ) +{ + if ( index == -1 ) { + for ( int i = 0; i < (MAX_TANKS * MAX_BOOSTPUMPS); i++ ) { + boost_pump[i] = val; + } + } else { + if ( (index >= 0) && (index < (MAX_TANKS * MAX_BOOSTPUMPS)) ) { + boost_pump[index] = val; + } + } +} + void FGControls::set_parking_brake( double pos ) @@ -528,19 +1531,44 @@ FGControls::set_parking_brake( double pos ) } void -FGControls::set_speed_brake( double pos ) +FGControls::set_steering( double angle ) { - speed_brake = pos; - CLAMP(&speed_brake, 0.0, 1.0); + steering = angle; + CLAMP(&steering, -80.0, 80.0); } void -FGControls::set_spoilers( double pos ) +FGControls::move_steering( double angle ) { - spoilers = pos; - CLAMP(&spoilers, 0.0, 1.0); + steering += angle; + CLAMP(&steering, -80.0, 80.0); } +void +FGControls::set_gear_down( bool gear ) +{ + gear_down = gear; +} + +void +FGControls::set_antiskid( bool state ) +{ + antiskid = state; +} + +void +FGControls::set_tailhook( bool state ) +{ + tailhook = state; +} + +void +FGControls::set_tailwheel_lock( bool state ) +{ + tailwheel_lock = state; +} + + void FGControls::set_brake( int wheel, double pos ) { @@ -574,9 +1602,537 @@ FGControls::move_brake( int wheel, double amt ) } void -FGControls::set_gear_down( bool gear ) +FGControls::set_alternate_extension( int wheel, bool val ) { - gear_down = gear; + if ( wheel == ALL_WHEELS ) { + for ( int i = 0; i < MAX_WHEELS; i++ ) { + alternate_extension[i] = val; + } + } else { + if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) { + alternate_extension[wheel] = val; + } + } } +void +FGControls::set_wing_heat( bool state ) +{ + wing_heat = state; +} +void +FGControls::set_pitot_heat( bool state ) +{ + pitot_heat = state; +} + +void +FGControls::set_wiper( int state ) +{ + wiper = state; +} + +void +FGControls::set_window_heat( bool state ) +{ + window_heat = state; +} + +void +FGControls::set_carb_heat( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + carb_heat[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + carb_heat[engine] = val; + } + } +} + +void +FGControls::set_inlet_heat( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + inlet_heat[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + inlet_heat[engine] = val; + } + } +} + +void +FGControls::set_engine_pump( int system, bool val ) +{ + if ( system == ALL_HYD_SYSTEMS ) { + for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) { + engine_pump[i] = val; + } + } else { + if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) { + engine_pump[system] = val; + } + } +} + +void +FGControls::set_electric_pump( int system, bool val ) +{ + if ( system == ALL_HYD_SYSTEMS ) { + for ( int i = 0; i < MAX_HYD_SYSTEMS; i++ ) { + electric_pump[i] = val; + } + } else { + if ( (system >= 0) && (system < MAX_HYD_SYSTEMS) ) { + electric_pump[system] = val; + } + } +} + +void +FGControls::set_battery_switch( bool state ) +{ + battery_switch = state; +} + +void +FGControls::set_external_power( bool state ) +{ + external_power = state; +} + +void +FGControls::set_APU_generator( bool state ) +{ + APU_generator = state; +} + +void +FGControls::set_generator_breaker( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + generator_breaker[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + generator_breaker[engine] = val; + } + } +} + +void +FGControls::set_bus_tie( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + bus_tie[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + bus_tie[engine] = val; + } + } +} + +void +FGControls::set_APU_bleed( bool state ) +{ + APU_bleed = state; +} + +void +FGControls::set_engine_bleed( int engine, bool val ) +{ + if ( engine == ALL_ENGINES ) { + for ( int i = 0; i < MAX_ENGINES; i++ ) { + engine_bleed[i] = val; + } + } else { + if ( (engine >= 0) && (engine < MAX_ENGINES) ) { + engine_bleed[engine] = val; + } + } +} + +void +FGControls::set_mode( int new_mode ) +{ + mode = new_mode; +} + +void +FGControls::set_outflow_valve( double pos ) +{ + outflow_valve = pos; + CLAMP( &outflow_valve, 0.0, 1.0 ); +} + +void +FGControls::move_outflow_valve( double amt ) +{ + outflow_valve += amt; + CLAMP( &outflow_valve, 0.0, 1.0 ); +} + +void +FGControls::set_dump( bool state ) +{ + dump = state; +} + +void +FGControls::set_pack_on( int pack, bool val ) +{ + if ( pack == ALL_PACKS ) { + for ( int i = 0; i < MAX_PACKS; i++ ) { + pack_on[i] = val; + } + } else { + if ( (pack >= 0) && (pack < MAX_PACKS) ) { + pack_on[pack] = val; + } + } +} + +void +FGControls::set_landing_lights( bool state ) +{ + landing_lights = state; +} + +void +FGControls::set_turn_off_lights( bool state ) +{ + turn_off_lights = state; +} + +void +FGControls::set_taxi_light( bool state ) +{ + taxi_light = state; +} + +void +FGControls::set_logo_lights( bool state ) +{ + logo_lights = state; +} + +void +FGControls::set_nav_lights( bool state ) +{ + nav_lights = state; +} + +void +FGControls::set_beacon( bool state ) +{ + beacon = state; +} + +void +FGControls::set_strobe( bool state ) +{ + strobe = state; +} + +void +FGControls::set_panel_norm( double intensity ) +{ + panel_norm = intensity; + CLAMP( &panel_norm, 0.0, 1.0 ); +} + +void +FGControls::move_panel_norm( double amt ) +{ + panel_norm += amt; + CLAMP( &panel_norm, 0.0, 1.0 ); +} + +void +FGControls::set_instruments_norm( double intensity ) +{ + instruments_norm = intensity; + CLAMP( &instruments_norm, 0.0, 1.0 ); +} + +void +FGControls::move_instruments_norm( double amt ) +{ + instruments_norm += amt; + CLAMP( &instruments_norm, 0.0, 1.0 ); +} + +void +FGControls::set_dome_norm( double intensity ) +{ + dome_norm = intensity; + CLAMP( &dome_norm, 0.0, 1.0 ); +} + +void +FGControls::move_dome_norm( double amt ) +{ + dome_norm += amt; + CLAMP( &dome_norm, 0.0, 1.0 ); +} + +#ifdef FG_HAVE_ARMAMENT + +void +FGControls::set_master_arm( bool val ) +{ + master_arm = val; +} + +void +FGControls::set_station_select( int station ) +{ + station_select = station; + CLAMP( &station_select, 0, MAX_STATIONS ); +} + +void +FGControls::set_release_ALL( bool val ) +{ + release_ALL = val; +} + +void +FGControls::set_stick_size( int station, int size ) +{ + if ( station == ALL_STATIONS ) { + for ( int i = 0; i < MAX_STATIONS; i++ ) { + stick_size[i] = size; + CLAMP( &stick_size[i], 1, 20 ); + } + } else { + if ( (station >= 0) && (station < MAX_STATIONS) ) { + stick_size[station] = size; + CLAMP( &stick_size[station], 1, 20 ); + } + } +} + +void +FGControls::set_release_stick( int station, bool val ) +{ + if ( station == ALL_STATIONS ) { + for ( int i = 0; i < MAX_STATIONS; i++ ) { + release_stick[i] = val; + } + } else { + if ( (station >= 0) && (station < MAX_STATIONS) ) { + release_stick[station] = val; + } + } +} + +void +FGControls::set_release_all( int station, bool val ) +{ + if ( station == ALL_STATIONS ) { + for ( int i = 0; i < MAX_STATIONS; i++ ) { + release_all[i] = val; + } + } else { + if ( (station >= 0) && (station < MAX_STATIONS) ) { + release_all[station] = val; + } + } +} + +void +FGControls::set_jettison_all( int station, bool val ) +{ + if ( station == ALL_STATIONS ) { + for ( int i = 0; i < MAX_STATIONS; i++ ) { + jettison_all[i] = val; + } + } else { + if ( (station >= 0) && (station < MAX_STATIONS) ) { + jettison_all[station] = val; + } + } +} + +#endif + +void +FGControls::set_vertical_adjust( double pos ) +{ + vertical_adjust = pos; + CLAMP( &vertical_adjust, -1.0, 1.0 ); +} + +void +FGControls::move_vertical_adjust( double amt ) +{ + vertical_adjust += amt; + CLAMP( &vertical_adjust, -1.0, 1.0 ); +} + +void +FGControls::set_fore_aft_adjust( double pos ) +{ + fore_aft_adjust = pos; + CLAMP( &fore_aft_adjust, -1.0, 1.0 ); +} + +void +FGControls::move_fore_aft_adjust( double amt ) +{ + fore_aft_adjust += amt; + CLAMP( &fore_aft_adjust, -1.0, 1.0 ); +} + +void +FGControls::set_eject( bool val ) +{ + eject = val; +} + +void +FGControls::set_off_start_run( int pos ) +{ + off_start_run = pos; + CLAMP( &off_start_run, 0, 3 ); +} + +void +FGControls::set_APU_fire_switch( bool val ) +{ + APU_fire_switch = val; +} + +void +FGControls::set_autothrottle_arm( bool val ) +{ + autothrottle_arm = val; +} + +void +FGControls::set_autothrottle_engage( bool val ) +{ + autothrottle_engage = val; +} + +void +FGControls::set_heading_select( double heading ) +{ + heading_select = heading; + CLAMP( &heading_select, 0.0, 360.0 ); +} + +void +FGControls::move_heading_select( double amt ) +{ + heading_select += amt; + CLAMP( &heading_select, 0.0, 360.0 ); +} + +void +FGControls::set_altitude_select( double altitude ) +{ + altitude_select = altitude; + CLAMP( &altitude_select, -1000.0, 100000.0 ); +} + +void +FGControls::move_altitude_select( double amt ) +{ + altitude_select += amt; + CLAMP( &altitude_select, -1000.0, 100000.0 ); +} + +void +FGControls::set_bank_angle_select( double angle ) +{ + bank_angle_select = angle; + CLAMP( &bank_angle_select, 10.0, 30.0 ); +} + +void +FGControls::move_bank_angle_select( double amt ) +{ + bank_angle_select += amt; + CLAMP( &bank_angle_select, 10.0, 30.0 ); +} + +void +FGControls::set_vertical_speed_select( double speed ) +{ + vertical_speed_select = speed; + CLAMP( &vertical_speed_select, -3000.0, 4000.0 ); +} + +void +FGControls::move_vertical_speed_select( double amt ) +{ + vertical_speed_select += amt; + CLAMP( &vertical_speed_select, -3000.0, 4000.0 ); +} + +void +FGControls::set_speed_select( double speed ) +{ + speed_select = speed; + CLAMP( &speed_select, 60.0, 400.0 ); +} + +void +FGControls::move_speed_select( double amt ) +{ + speed_select += amt; + CLAMP( &speed_select, 60.0, 400.0 ); +} + +void +FGControls::set_mach_select( double mach ) +{ + mach_select = mach; + CLAMP( &mach_select, 0.4, 4.0 ); +} + +void +FGControls::move_mach_select( double amt ) +{ + mach_select += amt; + CLAMP( &mach_select, 0.4, 4.0 ); +} + +void +FGControls::set_vertical_mode( int mode ) +{ + vertical_mode = mode; + CLAMP( &vertical_mode, 0, 4 ); +} + +void +FGControls::set_lateral_mode( int mode ) +{ + lateral_mode = mode; + CLAMP( &lateral_mode, 0, 4 ); +} + +void +FGControls::set_autopilot_engage( int ap, bool val ) +{ + if ( ap == ALL_AUTOPILOTS ) { + for ( int i = 0; i < MAX_AUTOPILOTS; i++ ) { + autopilot_engage[i] = val; + } + } else { + if ( (ap >= 0) && (ap < MAX_AUTOPILOTS) ) { + autopilot_engage[ap] = val; + } + } +} diff --git a/src/Controls/controls.hxx b/src/Controls/controls.hxx index 1d7ae58e4..4175f421e 100644 --- a/src/Controls/controls.hxx +++ b/src/Controls/controls.hxx @@ -53,11 +53,41 @@ public: enum { ALL_TANKS = -1, - MAX_TANKS = 4 + MAX_TANKS = 8 + }; + + enum { + ALL_BOOSTPUMPS = -1, + MAX_BOOSTPUMPS = 2 + }; + + enum { + ALL_HYD_SYSTEMS = -1, + MAX_HYD_SYSTEMS = 4 + }; + + enum { + ALL_PACKS = -1, + MAX_PACKS = 4 + }; + + enum { + ALL_LIGHTS = -1, + MAX_LIGHTS = 4 + }; + + enum { + ALL_STATIONS = -1, + MAX_STATIONS = 12 + }; + + enum { + ALL_AUTOPILOTS = -1, + MAX_AUTOPILOTS = 3 }; private: - + // controls/flight/ double aileron; double aileron_trim; double elevator; @@ -65,19 +95,143 @@ private: double rudder; double rudder_trim; double flaps; - double throttle[MAX_ENGINES]; - double mixture[MAX_ENGINES]; - bool fuel_pump[MAX_ENGINES]; - double prop_advance[MAX_ENGINES]; - double parking_brake; - double speed_brake; + double slats; + bool BLC; // Boundary Layer Control double spoilers; - double brake[MAX_WHEELS]; - int magnetos[MAX_ENGINES]; + double speedbrake; + double wing_sweep; + bool wing_fold; + bool drag_chute; + + // controls/engines/ bool throttle_idle; + + // controls/engines/engine[n]/ + double throttle[MAX_ENGINES]; bool starter[MAX_ENGINES]; + bool fuel_pump[MAX_ENGINES]; + bool fire_switch[MAX_ENGINES]; + bool fire_bottle_discharge[MAX_ENGINES]; + bool cutoff[MAX_ENGINES]; + double mixture[MAX_ENGINES]; + double prop_advance[MAX_ENGINES]; + int magnetos[MAX_ENGINES]; + bool nitrous_injection[MAX_ENGINES]; // War Emergency Power + double cowl_flaps_norm[MAX_ENGINES]; + bool feather[MAX_ENGINES]; + int ignition[MAX_ENGINES]; + bool augmentation[MAX_ENGINES]; + bool reverser[MAX_ENGINES]; + bool water_injection[MAX_ENGINES]; + int condition[MAX_ENGINES]; // turboprop speed select + + // controls/fuel/ + bool dump_valve; + + // controls/fuel/tank[n]/ bool fuel_selector[MAX_TANKS]; + int to_engine[MAX_TANKS]; + int to_tank[MAX_TANKS]; + + // controls/fuel/tank[n]/pump[p]/ + bool boost_pump[MAX_TANKS * MAX_BOOSTPUMPS]; + + // controls/gear/ + double parking_brake; + double steering; bool gear_down; + bool antiskid; + bool tailhook; + bool tailwheel_lock; + + // controls/gear/wheel[n]/ + double brake[MAX_WHEELS]; + bool alternate_extension[MAX_WHEELS]; + + // controls/anti-ice/ + bool wing_heat; + bool pitot_heat; + int wiper; + bool window_heat; + + // controls/anti-ice/engine[n]/ + bool carb_heat[MAX_ENGINES]; + bool inlet_heat[MAX_ENGINES]; + + // controls/hydraulic/system[n]/ + bool engine_pump[MAX_HYD_SYSTEMS]; + bool electric_pump[MAX_HYD_SYSTEMS]; + + // controls/electric/ + bool battery_switch; + bool external_power; + bool APU_generator; + + // controls/electric/engine[n]/ + bool generator_breaker[MAX_ENGINES]; + bool bus_tie[MAX_ENGINES]; + + // controls/pneumatic/ + bool APU_bleed; + + // controls/pneumatic/engine[n]/ + bool engine_bleed[MAX_ENGINES]; + + // controls/pressurization/ + int mode; + bool dump; + double outflow_valve; + + // controls/pressurization/pack[n]/ + bool pack_on[MAX_PACKS]; + + // controls/lighting/ + bool landing_lights; + bool turn_off_lights; + bool taxi_light; + bool logo_lights; + bool nav_lights; + bool beacon; + bool strobe; + double panel_norm; + double instruments_norm; + double dome_norm; + + // controls/armament/ + bool master_arm; + int station_select; + bool release_ALL; + + // controls/armament/station[n]/ + int stick_size[MAX_STATIONS]; + bool release_stick[MAX_STATIONS]; + bool release_all[MAX_STATIONS]; + bool jettison_all[MAX_STATIONS]; + + // controls/seat/ + double vertical_adjust; + double fore_aft_adjust; + bool eject; + + // controls/APU/ + int off_start_run; + bool APU_fire_switch; + + // controls/autoflight/autopilot[n]/ + bool autopilot_engage[MAX_AUTOPILOTS]; + + // controls/autoflight/ + bool autothrottle_arm; + bool autothrottle_engage; + double heading_select; + double altitude_select; + double bank_angle_select; + double vertical_speed_select; + double speed_select; + double mach_select; + int vertical_mode; + int lateral_mode; + SGPropertyNode * auto_coordination; @@ -96,6 +250,7 @@ public: void reset_all(void); // Query functions + // controls/flight/ inline double get_aileron() const { return aileron; } inline double get_aileron_trim() const { return aileron_trim; } inline double get_elevator() const { return elevator; } @@ -103,24 +258,170 @@ public: inline double get_rudder() const { return rudder; } inline double get_rudder_trim() const { return rudder_trim; } inline double get_flaps() const { return flaps; } + inline double get_slats() const { return slats; } + inline bool get_BLC() const { return BLC; } + inline double get_spoilers() const { return spoilers; } + inline double get_speedbrake() const { return speedbrake; } + inline double get_wing_sweep() const { return wing_sweep; } + inline bool get_wing_fold() const { return wing_fold; } + inline bool get_drag_chute() const { return drag_chute; } + + // controls/engines/ + inline bool get_throttle_idle() const { return throttle_idle; } + + // controls/engines/engine[n]/ inline double get_throttle(int engine) const { return throttle[engine]; } - inline double get_mixture(int engine) const { return mixture[engine]; } + inline bool get_starter(int engine) const { return starter[engine]; } inline bool get_fuel_pump(int engine) const { return fuel_pump[engine]; } + inline bool get_fire_switch(int engine) const { return fire_switch[engine]; } + inline bool get_fire_bottle_discharge(int engine) const { + return fire_bottle_discharge[engine]; + } + inline bool get_cutoff(int engine) const { return cutoff[engine]; } + inline double get_mixture(int engine) const { return mixture[engine]; } inline double get_prop_advance(int engine) const { return prop_advance[engine]; } - inline double get_parking_brake() const { return parking_brake; } - inline double get_speed_brake() const { return speed_brake; } - inline double get_spoilers() const { return spoilers; } - inline double get_brake(int wheel) const { return brake[wheel]; } inline int get_magnetos(int engine) const { return magnetos[engine]; } - inline bool get_starter(int engine) const { return starter[engine]; } + inline bool get_nitrous_injection(int engine) const { + return nitrous_injection[engine]; + } + inline double get_cowl_flaps_norm(int engine) const { + return cowl_flaps_norm[engine]; + } + inline bool get_feather(int engine) const { return feather[engine]; } + inline int get_ignition(int engine) const { return ignition[engine]; } + inline bool get_augmentation(int engine) const { return augmentation[engine]; } + inline bool get_reverser(int engine) const { return reverser[engine]; } + inline bool get_water_injection(int engine) const { + return water_injection[engine]; + } + inline int get_condition(int engine) const { return condition[engine]; } + + // controls/fuel/ + inline bool get_dump_valve() const { return dump_valve; } + + // controls/fuel/tank[n]/ inline bool get_fuel_selector(int tank) const { return fuel_selector[tank]; } + inline int get_to_engine(int tank) const { return to_engine[tank]; } + inline int get_to_tank(int tank) const { return to_tank[tank]; } + + // controls/fuel/tank[n]/pump[p]/ + inline bool get_boost_pump(int index) const { + return boost_pump[index]; + } + + // controls/gear/ + inline double get_parking_brake() const { return parking_brake; } + inline double get_steering() const { return steering; } inline bool get_gear_down() const { return gear_down; } + inline bool get_antiskid() const { return antiskid; } + inline bool get_tailhook() const { return tailhook; } + inline bool get_tailwheel_lock() const { return tailwheel_lock; } + + // controls/gear/wheel[n]/ + inline double get_brake(int wheel) const { return brake[wheel]; } + inline bool get_alternate_extension(int wheel) const { + return alternate_extension[wheel]; + } + + // controls/anti-ice/ + inline bool get_wing_heat() const { return wing_heat; } + inline bool get_pitot_heat() const { return pitot_heat; } + inline int get_wiper() const { return wiper; } + inline bool get_window_heat() const { return window_heat; } + + // controls/anti-ice/engine[n]/ + inline bool get_carb_heat(int engine) const { return carb_heat[engine]; } + inline bool get_inlet_heat(int engine) const { return inlet_heat[engine]; } + + // controls/hydraulic/system[n]/ + inline bool get_engine_pump(int system) const { return engine_pump[system]; } + inline bool get_electric_pump(int system) const { return electric_pump[system]; } + + // controls/electric/ + inline bool get_battery_switch() const { return battery_switch; } + inline bool get_external_power() const { return external_power; } + inline bool get_APU_generator() const { return APU_generator; } + + // controls/electric/engine[n]/ + inline bool get_generator_breaker(int engine) const { + return generator_breaker[engine]; + } + inline bool get_bus_tie(int engine) const { return bus_tie[engine]; } + + // controls/pneumatic/ + inline bool get_APU_bleed() const { return APU_bleed; } + + // controls/pneumatic/engine[n]/ + inline bool get_engine_bleed(int engine) const { return engine_bleed[engine]; } + + // controls/pressurization/ + inline int get_mode() const { return mode; } + inline double get_outflow_valve() const { return outflow_valve; } + inline bool get_dump() const { return dump; } + + // controls/pressurization/pack[n]/ + inline bool get_pack_on(int pack) const { return pack_on[pack]; } + + // controls/lighting/ + inline bool get_landing_lights() const { return landing_lights; } + inline bool get_turn_off_lights() const { return turn_off_lights; } + inline bool get_taxi_light() const { return taxi_light; } + inline bool get_logo_lights() const { return logo_lights; } + inline bool get_nav_lights() const { return nav_lights; } + inline bool get_beacon() const { return beacon; } + inline bool get_strobe() const { return strobe; } + inline double get_panel_norm() const { return panel_norm; } + inline double get_instruments_norm() const { return instruments_norm; } + inline double get_dome_norm() const { return dome_norm; } + +#ifdef FG_HAVE_ARMAMENT + // controls/armament/ + inline bool get_master_arm() const { return master_arm; } + inline int get_station_select() const { return station_select; } + inline bool get_release_ALL() const { return release_ALL; } + + // controls/armament/station[n]/ + inline int get_stick_size(int station) const { return stick_size[station]; } + inline bool get_release_stick(int station) const { return release_stick[station]; } + inline bool get_release_all(int station) const { return release_all[station]; } + inline bool get_jettison_all(int station) const { return jettison_all[station]; } +#endif + + // controls/seat/ + inline double get_vertical_adjust() const { return vertical_adjust; } + inline double get_fore_aft_adjust() const { return fore_aft_adjust; } + inline bool get_eject() const { return eject; } + + // controls/APU/ + inline int get_off_start_run() const { return off_start_run; } + inline bool get_APU_fire_switch() const { return APU_fire_switch; } + + // controls/autoflight/ + inline bool get_autothrottle_arm() const { return autothrottle_arm; } + inline bool get_autothrottle_engage() const { return autothrottle_engage; } + inline double get_heading_select() const { return heading_select; } + inline double get_altitude_select() const { return altitude_select; } + inline double get_bank_angle_select() const { return bank_angle_select; } + inline double get_vertical_speed_select() const { + return vertical_speed_select; + } + inline double get_speed_select() const { return speed_select; } + inline double get_mach_select() const { return mach_select; } + inline int get_vertical_mode() const { return vertical_mode; } + inline int get_lateral_mode() const { return lateral_mode; } + + // controls/autoflight/autopilot[n]/ + inline bool get_autopilot_engage(int ap) const { + return autopilot_engage[ap]; + } + // Update functions + // controls/flight/ void set_aileron( double pos ); void move_aileron( double amt ); void set_aileron_trim( double pos ); @@ -135,23 +436,168 @@ public: void move_rudder_trim( double amt ); void set_flaps( double pos ); void move_flaps( double amt ); + void set_slats( double pos ); + void move_slats( double amt ); + void set_BLC( bool val ); + void set_spoilers( double pos ); + void move_spoilers( double amt ); + void set_speedbrake( double pos ); + void move_speedbrake( double amt ); + void set_wing_sweep( double pos ); + void move_wing_sweep( double amt ); + void set_wing_fold( bool val ); + void set_drag_chute( bool val ); + + // controls/engines/ + void set_throttle_idle( bool val ); + + // controls/engines/engine[n]/ void set_throttle( int engine, double pos ); void move_throttle( int engine, double amt ); + void set_starter( int engine, bool flag ); + void set_fuel_pump( int engine, bool val ); + void set_fire_switch( int engine, bool val ); + void set_fire_bottle_discharge( int engine, bool val ); + void set_cutoff( int engine, bool val ); void set_mixture( int engine, double pos ); void move_mixture( int engine, double amt ); - void set_fuel_pump( int engine, bool val ); void set_prop_advance( int engine, double pos ); void move_prop_advance( int engine, double amt ); void set_magnetos( int engine, int pos ); void move_magnetos( int engine, int amt ); - void set_starter( int engine, bool flag ); + void set_nitrous_injection( int engine, bool val ); + void set_cowl_flaps_norm( int engine, double pos ); + void move_cowl_flaps_norm( int engine, double amt ); + void set_feather( int engine, bool val ); + void set_ignition( int engine, int val ); + void set_augmentation( int engine, bool val ); + void set_reverser( int engine, bool val ); + void set_water_injection( int engine, bool val ); + void set_condition( int engine, int val ); + + // controls/fuel + void set_dump_valve( bool val ); + + // controls/fuel/tank[n]/ void set_fuel_selector( int tank, bool pos ); + void set_to_engine( int tank, int engine ); + void set_to_tank( int tank, int dest_tank ); + + // controls/fuel/tank[n]/pump[p] + void set_boost_pump( int index, bool val ); + + // controls/gear/ void set_parking_brake( double pos ); - void set_speed_brake( double pos ); - void set_spoilers( double pos ); + void set_steering( double pos ); + void move_steering( double amt ); + void set_gear_down( bool gear ); + void set_antiskid( bool val ); + void set_tailhook( bool val ); + void set_tailwheel_lock( bool val ); + + // controls/gear/wheel[n]/ void set_brake( int wheel, double pos ); void move_brake( int wheel, double amt ); - void set_gear_down( bool gear ); + void set_alternate_extension( int wheel, bool val ); + + // controls/anti-ice/ + void set_wing_heat( bool val ); + void set_pitot_heat( bool val ); + void set_wiper( int speed ); + void set_window_heat( bool val ); + + // controls/anti-ice/engine[n]/ + void set_carb_heat( int engine, bool val ); + void set_inlet_heat( int engine, bool val ); + + // controls/hydraulic/system[n]/ + void set_engine_pump( int system, bool val ); + void set_electric_pump( int system, bool val ); + + // controls/electric/ + void set_battery_switch( bool val ); + void set_external_power( bool val ); + void set_APU_generator( bool val ); + + // controls/electric/engine[n]/ + void set_generator_breaker( int engine, bool val ); + void set_bus_tie( int engine, bool val ); + + // controls/pneumatic/ + void set_APU_bleed( bool val ); + + // controls/pneumatic/engine[n]/ + void set_engine_bleed( int engine, bool val ); + + // controls/pressurization/ + void set_mode( int mode ); + void set_outflow_valve( double pos ); + void move_outflow_valve( double amt ); + void set_dump( bool val ); + + // controls/pressurization/pack[n]/ + void set_pack_on( int pack, bool val ); + + // controls/lighting/ + void set_landing_lights( bool val ); + void set_turn_off_lights( bool val ); + void set_taxi_light( bool val ); + void set_logo_lights( bool val ); + void set_nav_lights( bool val ); + void set_beacon( bool val ); + void set_strobe( bool val ); + void set_panel_norm( double intensity ); + void move_panel_norm( double amt ); + void set_instruments_norm( double intensity ); + void move_instruments_norm( double amt ); + void set_dome_norm( double intensity ); + void move_dome_norm( double amt ); + +#ifdef FG_HAVE_ARMAMENT + // controls/armament/ + void set_master_arm( bool val ); + void set_station_select( int station ); + void set_release_ALL( bool val ); + + // controls/armament/station[n]/ + void set_stick_size( int station, int size ); + void set_release_stick( int station, bool val ); + void set_release_all( int station, bool val ); + void set_jettison_all( int station, bool val ); +#endif + + // controls/seat/ + void set_vertical_adjust( double pos ); + void move_vertical_adjust( double amt ); + void set_fore_aft_adjust( double pos ); + void move_fore_aft_adjust( double amt ); + void set_eject( bool val ); + + // controls/APU/ + void set_off_start_run( int pos ); + void set_APU_fire_switch( bool val ); + + // controls/autoflight/ + void set_autothrottle_arm( bool val ); + void set_autothrottle_engage( bool val ); + void set_heading_select( double heading ); + void move_heading_select( double amt ); + void set_altitude_select( double altitude ); + void move_altitude_select( double amt ); + void set_bank_angle_select( double angle ); + void move_bank_angle_select( double amt ); + void set_vertical_speed_select( double vs ); + void move_vertical_speed_select( double amt ); + void set_speed_select( double speed ); + void move_speed_select( double amt ); + void set_mach_select( double mach ); + void move_mach_select( double amt ); + void set_vertical_mode( int mode ); + void set_lateral_mode( int mode ); + + // controls/autoflight/autopilot[n]/ + void set_autopilot_engage( int ap, bool val ); + }; diff --git a/src/FDM/JSBSim/FGEngine.cpp b/src/FDM/JSBSim/FGEngine.cpp index 0117166d7..1baaa3d57 100644 --- a/src/FDM/JSBSim/FGEngine.cpp +++ b/src/FDM/JSBSim/FGEngine.cpp @@ -80,6 +80,8 @@ FGEngine::FGEngine(FGFDMExec* exec) Starter(false), FuelNeed(0.0), OxidizerNeed(0.0), Starved(false), Flameout(false), Running(false), Cranking(false), + Augmentation(false), Injection(false), Ignition(false), + Reversed(false), Cutoff(true), Nitrous(false), PctPower(0.0), EngineNumber(-1), TrimMode(false), diff --git a/src/FDM/JSBSim/FGEngine.h b/src/FDM/JSBSim/FGEngine.h index e17358f5f..1a23f2b07 100644 --- a/src/FDM/JSBSim/FGEngine.h +++ b/src/FDM/JSBSim/FGEngine.h @@ -135,8 +135,10 @@ public: virtual double GetNozzle(void) { return NozzlePosition; } virtual bool GetAugmentation(void) { return Augmentation; } virtual bool GetInjection(void) { return Injection; } - virtual bool GetIgnition(void) { return Ignition; } + virtual int GetIgnition(void) { return Ignition; } virtual bool GetReversed(void) { return Reversed; } + virtual bool GetCutoff(void) { return Cutoff; } + virtual bool GetNitrous(void) { return Nitrous; } virtual double getFuelFlow_gph () const { return FuelFlow_gph; @@ -162,15 +164,21 @@ public: return FuelFlow_pph; } - virtual void SetStarved(bool tt) {Starved = tt;} - virtual void SetStarved(void) {Starved = true;} + virtual void SetStarved(bool tt) { Starved = tt; } + virtual void SetStarved(void) { Starved = true; } virtual void SetRunning(bool bb) { Running=bb; } - virtual void SetName(string name) {Name = name;} + virtual void SetName(string name) { Name = name; } virtual void AddFeedTank(int tkID); virtual void SetMagnetos(int m) { Magnetos = m; } - virtual void SetStarter(bool s) { Starter = s;} + virtual void SetStarter(bool s) { Starter = s; } + virtual void SetAugmentation(bool a) { Augmentation = a; } + virtual void SetInjection(bool i) { Injection = i; } + virtual void SetIgnition(int ig) { Ignition = ig; } + virtual void SetReverse(bool r) { Reversed = r; } + virtual void SetCutoff(bool c) { Cutoff = c; } + virtual void SetNitrous(bool n) { Nitrous = n; } /** Calculates the thrust of the engine, and other engine functions. @param PowerRequired this is the power required to run the thrusting device @@ -251,8 +259,10 @@ protected: double NozzlePosition; bool Augmentation; bool Injection; - bool Ignition; + int Ignition; bool Reversed; + bool Cutoff; + bool Nitrous; FGFDMExec* FDMExec; FGState* State; diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index d28344263..aa2e86e92 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -166,9 +166,9 @@ FGJSBsim::FGJSBsim( double dt ) right_aileron_pos_pct =fgGetNode("/surface-positions/right-aileron-pos-norm",true); rudder_pos_pct=fgGetNode("/surface-positions/rudder-pos-norm",true); - speed_brake_pos_pct - =fgGetNode("/surface-positions/speed-brake-pos-norm",true); - spoiler_pos_pct=fgGetNode("/surface-positions/spoiler-pos-norm",true); + speedbrake_pos_pct + =fgGetNode("/surface-positions/speedbrake-pos-norm",true); + spoilers_pos_pct=fgGetNode("/surface-positions/spoilers-pos-norm",true); elevator_pos_pct->setDoubleValue(0); @@ -176,8 +176,8 @@ FGJSBsim::FGJSBsim( double dt ) right_aileron_pos_pct->setDoubleValue(0); rudder_pos_pct->setDoubleValue(0); flap_pos_pct->setDoubleValue(0); - speed_brake_pos_pct->setDoubleValue(0); - spoiler_pos_pct->setDoubleValue(0); + speedbrake_pos_pct->setDoubleValue(0); + spoilers_pos_pct->setDoubleValue(0); temperature = fgGetNode("/environment/temperature-degc",true); pressure = fgGetNode("/environment/pressure-inhg",true); @@ -375,15 +375,15 @@ bool FGJSBsim::copy_to_JSBsim() { FCS->SetDrCmd( -globals->get_controls()->get_rudder() ); FCS->SetYawTrimCmd( -globals->get_controls()->get_rudder_trim() ); FCS->SetDfCmd( globals->get_controls()->get_flaps() ); - FCS->SetDsbCmd( globals->get_controls()->get_speed_brake() ); - FCS->SetDspCmd( globals->get_controls()->get_spoilers() ); + FCS->SetDsbCmd( globals->get_controls()->get_speedbrake() ); + FCS->SetDspCmd( globals->get_controls()->get_spoilers() ); // Parking brake sets minimum braking // level for mains. double parking_brake = globals->get_controls()->get_parking_brake(); FCS->SetLBrake(FMAX(globals->get_controls()->get_brake(0), parking_brake)); FCS->SetRBrake(FMAX(globals->get_controls()->get_brake(1), parking_brake)); - FCS->SetCBrake( globals->get_controls()->get_brake( 2 ) ); + FCS->SetCBrake( globals->get_controls()->get_brake(2) ); FCS->SetGearCmd( globals->get_controls()->get_gear_down()); for (i = 0; i < Propulsion->GetNumEngines(); i++) { @@ -395,6 +395,12 @@ bool FGJSBsim::copy_to_JSBsim() { Propulsion->GetThruster(i)->SetRPM(node->getDoubleValue("rpm")); eng->SetMagnetos( globals->get_controls()->get_magnetos(i) ); eng->SetStarter( globals->get_controls()->get_starter(i) ); + eng->SetAugmentation( globals->get_controls()->get_augmentation(i) ); + eng->SetReverse( globals->get_controls()->get_reverser(i) ); + eng->SetInjection( globals->get_controls()->get_water_injection(i) ); + eng->SetIgnition( globals->get_controls()->get_ignition(i) ); + eng->SetCutoff( globals->get_controls()->get_cutoff(i) ); + eng->SetNitrous( globals->get_controls()->get_nitrous_injection(i) ); } _set_Runway_altitude( cur_fdm_state->get_Runway_altitude() ); @@ -543,8 +549,21 @@ bool FGJSBsim::copy_from_JSBsim() { node->setDoubleValue("cht-degf", eng->getCylinderHeadTemp_degF()); node->setDoubleValue("oil-temperature-degf", eng->getOilTemp_degF()); node->setDoubleValue("oil-pressure-psi", eng->getOilPressure_psi()); + node->setDoubleValue("thrust_lb", eng->GetThrust()); + node->setDoubleValue("N1", eng->GetN1()); + node->setDoubleValue("N2", eng->GetN2()); + node->setDoubleValue("EGT_degC", eng->GetEGT()); + node->setDoubleValue("fuel-flow_pph", eng->getFuelFlow_pph()); + node->setDoubleValue("nozzle-pos-norm", eng->GetNozzle()); + node->setDoubleValue("inlet-pos-norm", eng->GetInlet()); node->setBoolValue("running", eng->GetRunning()); node->setBoolValue("cranking", eng->GetCranking()); + node->setBoolValue("ignition", eng->GetIgnition()); + node->setBoolValue("augmentation", eng->GetAugmentation()); + node->setBoolValue("water-injection", eng->GetInjection()); + node->setBoolValue("reversed", eng->GetReversed()); + node->setBoolValue("cutoff", eng->GetCutoff()); + node->setBoolValue("nitrous", eng->GetNitrous()); } static const SGPropertyNode *fuel_freeze @@ -558,7 +577,8 @@ bool FGJSBsim::copy_from_JSBsim() { = fgGetNode("/consumables/fuel/tank", i, true); double contents = Propulsion->GetTank(i)->GetContents(); node->setDoubleValue("level-gal_us", contents/6.6); - // node->setDoubleValue("level-lb", contents); + node->setDoubleValue("level-lb", contents); + // node->setDoubleValue("temperature_degC", } } @@ -578,8 +598,8 @@ bool FGJSBsim::copy_from_JSBsim() { right_aileron_pos_pct->setDoubleValue( -1*FCS->GetDaLPos(ofNorm) ); rudder_pos_pct->setDoubleValue( -1*FCS->GetDrPos(ofNorm) ); flap_pos_pct->setDoubleValue( FCS->GetDfPos(ofNorm) ); - speed_brake_pos_pct->setDoubleValue( FCS->GetDsbPos(ofNorm) ); - spoiler_pos_pct->setDoubleValue( FCS->GetDspPos(ofNorm) ); + speedbrake_pos_pct->setDoubleValue( FCS->GetDsbPos(ofNorm) ); + spoilers_pos_pct->setDoubleValue( FCS->GetDspPos(ofNorm) ); return true; diff --git a/src/FDM/JSBSim/JSBSim.hxx b/src/FDM/JSBSim/JSBSim.hxx index cea17b86c..04a10b299 100644 --- a/src/FDM/JSBSim/JSBSim.hxx +++ b/src/FDM/JSBSim/JSBSim.hxx @@ -257,8 +257,8 @@ private: SGPropertyNode *right_aileron_pos_pct; SGPropertyNode *rudder_pos_pct; SGPropertyNode *flap_pos_pct; - SGPropertyNode *speed_brake_pos_pct; - SGPropertyNode *spoiler_pos_pct; + SGPropertyNode *speedbrake_pos_pct; + SGPropertyNode *spoilers_pos_pct; SGPropertyNode *gear_pos_pct; diff --git a/src/FDM/LaRCsim.cxx b/src/FDM/LaRCsim.cxx index b7bd00124..6a0764616 100644 --- a/src/FDM/LaRCsim.cxx +++ b/src/FDM/LaRCsim.cxx @@ -113,19 +113,19 @@ void FGLaRCsim::update( double dt ) { // Fake control-surface positions fgSetDouble("/surface-positions/flap-pos-norm", - fgGetDouble("/controls/flaps")); + fgGetDouble("/controls/flight/flaps")); // FIXME: ignoring trim fgSetDouble("/surface-positions/elevator-pos-norm", - fgGetDouble("/controls/elevator")); + fgGetDouble("/controls/flight/elevator")); // FIXME: ignoring trim fgSetDouble("/surface-positions/left-aileron-pos-norm", - fgGetDouble("/controls/aileron")); + fgGetDouble("/controls/flight/aileron")); // FIXME: ignoring trim fgSetDouble("/surface-positions/right-aileron-pos-norm", - -1 * fgGetDouble("/controls/aileron")); + -1 * fgGetDouble("/controls/flight/aileron")); // FIXME: ignoring trim fgSetDouble("/surface-positions/rudder-pos-norm", - fgGetDouble("/controls/rudder")); + fgGetDouble("/controls/flight/rudder")); // copy engine state values onto "bus" fgSetDouble("/engines/engine/rpm", eng.get_RPM()); diff --git a/src/FDM/YASim/YASim.cxx b/src/FDM/YASim/YASim.cxx index f993c9e86..f7f634165 100644 --- a/src/FDM/YASim/YASim.cxx +++ b/src/FDM/YASim/YASim.cxx @@ -48,7 +48,7 @@ void YASim::printDEBUG() // fgGetFloat("/engines/engine[0]/epr"), // fgGetFloat("/engines/engine[0]/egt")); -// printf("gear: %f\n", fgGetFloat("/controls/gear-down")); +// printf("gear: %f\n", fgGetFloat("/controls/gear/gear-down")); // printf("alpha %5.1f beta %5.1f\n", get_Alpha()*57.3, get_Beta()*57.3); @@ -170,20 +170,20 @@ void YASim::init() // for(i=0; inumThrusters(); i++) { // // Sanify the initial input conditions // char buf[64]; -// sprintf(buf, "/controls/throttle[%d]", i); fgSetFloat(buf, 0); -// sprintf(buf, "/controls/mixture[%d]", i); fgSetFloat(buf, 1); -// sprintf(buf, "/controls/propeller-pitch[%d]", i); fgSetFloat(buf, 1); -// sprintf(buf, "/controls/afterburner[%d]", i); fgSetFloat(buf, 0); +// sprintf(buf, "/controls/engines/engine[%d]/throttle", i); fgSetFloat(buf, 0); +// sprintf(buf, "/controls/engines/engine[%d]/mixture", i); fgSetFloat(buf, 1); +// sprintf(buf, "/controls/engines/engine[%d]/propeller-pitch", i); fgSetFloat(buf, 1); +// sprintf(buf, "/controls/engines/engine[%d]/augmentation", i); fgSetFloat(buf, 0); // } -// fgSetFloat("/controls/slats", 0); -// fgSetFloat("/controls/spoilers", 0); +// fgSetFloat("/controls/flight/slats", 0); +// fgSetFloat("/controls/flight/spoilers", 0); // Are we at ground level? If so, lift the plane up so the gear // clear the ground. double runway_altitude = get_Runway_altitude(); if(get_Altitude() - runway_altitude < 50) { - fgSetBool("/controls/gear-down", false); + fgSetBool("/controls/gear/gear-down", false); float minGearZ = 1e18; for(i=0; inumGear(); i++) { Gear* g = a->getGear(i); @@ -193,7 +193,7 @@ void YASim::init() minGearZ = pos[2]; } _set_Altitude(runway_altitude - minGearZ*M2FT); - fgSetBool("/controls/gear-down", true); + fgSetBool("/controls/gear/gear-down", true); } // The pilot's eyepoint diff --git a/src/Input/fgjs.cxx b/src/Input/fgjs.cxx index a5dcffa6c..c4cd037d9 100644 --- a/src/Input/fgjs.cxx +++ b/src/Input/fgjs.cxx @@ -39,9 +39,9 @@ string axes_humannames[8] = { "elevator", "ailerons", "rudder", "throttle", "longitudinal view" }; -string axes_propnames[8]={ "/controls/elevator","/controls/aileron", - "/controls/rudder","/controls/throttle", - "/controls/mixture","/controls/pitch", +string axes_propnames[8]={ "/controls/flight/elevator","/controls/flight/aileron", + "/controls/flight/rudder","/controls/engines/engine/throttle", + "/controls/engines/engine/mixture","/controls/engines/engine/pitch", "/sim/views/axes/lat","/sim/views/axes/long" }; @@ -54,10 +54,10 @@ string button_humannames[7]= { "apply all brakes", "apply left brake", "apply nose-down trim" }; -string button_propnames[7]={ "/controls/brakes/all", "/controls/brakes[0]", - "/controls/brakes[1]", "/controls/flaps", - "/controls/flaps","/controls/elevator-trim", - "/controls/elevator-trim" +string button_propnames[7]={ "/controls/gear/wheel[-1]/brake", "/controls/gear/wheel[0]/brake", + "/controls/gear/wheel[1]/brake", "/controls/flight/flaps", + "/controls/flight/flaps","/controls/flight/elevator-trim", + "/controls/flight/elevator-trim" }; diff --git a/src/Network/native_ctrls.cxx b/src/Network/native_ctrls.cxx index ecc6b68e9..f53dce08f 100644 --- a/src/Network/native_ctrls.cxx +++ b/src/Network/native_ctrls.cxx @@ -100,56 +100,65 @@ static void htond (double &x) // Populate the FGNetCtrls structure from the property tree. void FGProps2NetCtrls( FGNetCtrls *net, bool net_byte_order ) { int i; - - SGPropertyNode * node = fgGetNode("/controls", true); + bool b; + SGPropertyNode * node; + SGPropertyNode * tempnode; // fill in values + node = fgGetNode("/controls/flight", true); net->version = FG_NET_CTRLS_VERSION; net->aileron = node->getDoubleValue( "aileron" ); net->elevator = node->getDoubleValue( "elevator" ); net->elevator_trim = node->getDoubleValue( "elevator-trim" ); net->rudder = node->getDoubleValue( "rudder" ); net->flaps = node->getDoubleValue( "flaps" ); + node = fgGetNode("/controls", true); net->flaps_power = node->getDoubleValue( "/systems/electrical/outputs/flaps", 1.0 ) >= 1.0; net->num_engines = FGNetCtrls::FG_MAX_ENGINES; for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) { + node = fgGetNode("/controls/engines/engine", i ); net->throttle[i] = node->getDoubleValue( "throttle", 0.0 ); net->mixture[i] = node->getDoubleValue( "mixture", 0.0 ); - net->fuel_pump_power[i] - = node->getDoubleValue( "/systems/electrical/outputs/fuel-pump", - 1.0 ) >= 1.0; net->prop_advance[i] = node->getDoubleValue( "propeller-pitch", 0.0 ); net->magnetos[i] = node->getIntValue( "magnetos", 0 ); if ( i == 0 ) { // cout << "Magnetos -> " << node->getIntValue( "magnetos", 0 ); } + if ( i == 0 ) { + // cout << "Starter -> " << node->getIntValue( "starter", false ) + // << endl; + } + node = fgGetNode("/controls", true); + net->fuel_pump_power[i] + = node->getDoubleValue( "/systems/electrical/outputs/fuel-pump", + 1.0 ) >= 1.0; + net->starter_power[i] = node->getDoubleValue( "/systems/electrical/outputs/starter", 1.0 ) >= 1.0; - if ( i == 0 ) { - // cout << " Starter -> " << node->getIntValue( "stater", false ) - // << endl; - } } net->num_tanks = FGNetCtrls::FG_MAX_TANKS; for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) { - if ( node->getChild("fuel-selector", i) != 0 ) { + node = fgGetNode("/controls/fuel/tank", i); + if ( node->getChild("fuel-selector") != 0 ) { net->fuel_selector[i] - = node->getChild("fuel-selector", i)->getDoubleValue(); + = node->getChild("fuel-selector")->getBoolValue(); } else { net->fuel_selector[i] = false; } } net->num_wheels = FGNetCtrls::FG_MAX_WHEELS; + tempnode = fgGetNode("/controls/gear", true); for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) { - if ( node->getChild("brakes", i) != 0 ) { - if ( node->getChild("parking-brake")->getDoubleValue() > 0.0 ) { + node = fgGetNode("/controls/gear/wheel", i); + if ( node->getChild("brake") != 0 ) { + if ( tempnode->getChild("parking-brake")->getDoubleValue() > 0.0 ) { net->brake[i] = 1.0; } else { net->brake[i] - = node->getChild("brakes", i)->getDoubleValue(); + = node->getChild("brake")->getDoubleValue(); } } else { net->brake[i] = 0.0; @@ -227,7 +236,7 @@ void FGProps2NetCtrls( FGNetCtrls *net, bool net_byte_order ) { void FGNetCtrls2Props( FGNetCtrls *net, bool net_byte_order ) { int i; - SGPropertyNode * node = fgGetNode("/controls", true); + SGPropertyNode * node; if ( net_byte_order ) { // convert from network byte order @@ -274,7 +283,7 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool net_byte_order ) { "FlightGear needs version = " << FG_NET_CTRLS_VERSION << " but is receiving version = " << net->version ); } - + node = fgGetNode("/controls/flight", true); node->setDoubleValue( "aileron", net->aileron ); node->setDoubleValue( "elevator", net->elevator ); node->setDoubleValue( "elevator-trim", net->elevator_trim ); @@ -284,11 +293,12 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool net_byte_order ) { fgSetBool( "/systems/electrical/outputs/flaps", net->flaps_power ); for ( i = 0; i < FGNetCtrls::FG_MAX_ENGINES; ++i ) { - node->getChild( "throttle", i )->setDoubleValue( net->throttle[i] ); - node->getChild( "mixture", i )->setDoubleValue( net->mixture[i] ); - node->getChild( "propeller-pitch", i ) + node = fgGetNode("/controls/engines/engine", i); + node->getChild( "throttle" )->setDoubleValue( net->throttle[i] ); + node->getChild( "mixture" )->setDoubleValue( net->mixture[i] ); + node->getChild( "propeller-pitch" ) ->setDoubleValue( net->prop_advance[i] ); - node->getChild( "magnetos", i )->setDoubleValue( net->magnetos[i] ); + node->getChild( "magnetos" )->setDoubleValue( net->magnetos[i] ); } fgSetBool( "/systems/electrical/outputs/fuel-pump", @@ -297,13 +307,16 @@ void FGNetCtrls2Props( FGNetCtrls *net, bool net_byte_order ) { net->starter_power[0] ); for ( i = 0; i < FGNetCtrls::FG_MAX_TANKS; ++i ) { - node->getChild( "fuel-selector", i ) + node = fgGetNode( "/controls/fuel/tank", i ); + node->getChild( "fuel-selector" ) ->setBoolValue( net->fuel_selector[i] ); } for ( i = 0; i < FGNetCtrls::FG_MAX_WHEELS; ++i ) { - node->getChild( "brakes", i )->setDoubleValue( net->brake[i] ); + node = fgGetNode( "/controls/gear/wheel", i ); + node->getChild( "brake" )->setDoubleValue( net->brake[i] ); } + node = fgGetNode( "/controls/gear", true ); node->setBoolValue( "gear-down", net->gear_handle ); node = fgGetNode( "/controls/switches", true );