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