Debian Codegraph @

src/Aircraft/controls.cxx

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