]> git.mxchange.org Git - flightgear.git/blob - src/Aircraft/controls.hxx
Merge branch 'ehofman/sound'
[flightgear.git] / src / Aircraft / controls.hxx
1 // controls.hxx -- 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
24 #ifndef _CONTROLS_HXX
25 #define _CONTROLS_HXX
26
27 #include <simgear/structure/subsystem_mgr.hxx>
28
29 // Define a structure containing the control parameters
30
31 class FGControls : public SGSubsystem
32 {
33
34 public:
35
36     enum {
37         ALL_ENGINES = -1,
38         MAX_ENGINES = 12
39     };
40
41     enum {
42         ALL_WHEELS = -1,
43         MAX_WHEELS = 3
44     };
45
46     enum {
47         ALL_TANKS = -1,
48         MAX_TANKS = 8
49     };
50
51     enum {
52         ALL_BOOSTPUMPS = -1,
53         MAX_BOOSTPUMPS = 2
54     };
55
56     enum {
57         ALL_HYD_SYSTEMS = -1,
58         MAX_HYD_SYSTEMS = 4
59     };
60
61     enum {
62         ALL_PACKS = -1,
63         MAX_PACKS = 4
64     };
65
66     enum {
67         ALL_LIGHTS = -1,
68         MAX_LIGHTS = 4
69     };
70
71     enum {
72         ALL_STATIONS = -1,
73         MAX_STATIONS = 12
74     };
75
76     enum {
77         ALL_AUTOPILOTS = -1,
78         MAX_AUTOPILOTS = 3
79     };
80
81     enum {
82         ALL_EJECTION_SEATS = -1,
83         MAX_EJECTION_SEATS = 10
84     };
85    
86     enum {
87         SEAT_SAFED = -1,
88         SEAT_ARMED = 0,
89         SEAT_FAIL = 1
90     };
91    
92     enum { 
93         CMD_SEL_NORM = -1,
94         CMD_SEL_AFT = 0,
95         CMD_SEL_SOLO = 1
96     };
97     
98 private:
99     // controls/flight/
100     double aileron;
101     double aileron_trim;
102     double elevator;
103     double elevator_trim;
104     double rudder;
105     double rudder_trim;
106     double flaps;
107     double slats;
108     bool BLC;          // Boundary Layer Control
109     double spoilers;
110     double speedbrake;
111     double wing_sweep;
112     bool wing_fold;
113     bool drag_chute;
114
115     // controls/engines/
116     bool throttle_idle;
117
118     // controls/engines/engine[n]/
119     double throttle[MAX_ENGINES];
120     bool starter[MAX_ENGINES];
121     bool fuel_pump[MAX_ENGINES];
122     bool fire_switch[MAX_ENGINES];
123     bool fire_bottle_discharge[MAX_ENGINES];
124     bool cutoff[MAX_ENGINES];
125     double mixture[MAX_ENGINES];
126     double prop_advance[MAX_ENGINES];
127     int magnetos[MAX_ENGINES];
128     int feed_tank[MAX_ENGINES];
129     bool nitrous_injection[MAX_ENGINES];  // War Emergency Power
130     double cowl_flaps_norm[MAX_ENGINES];
131     bool feather[MAX_ENGINES];
132     int ignition[MAX_ENGINES];
133     bool augmentation[MAX_ENGINES];
134     bool reverser[MAX_ENGINES];
135     bool water_injection[MAX_ENGINES];
136     double condition[MAX_ENGINES];           // turboprop speed select
137
138     // controls/fuel/
139     bool dump_valve;
140
141     // controls/fuel/tank[n]/
142     bool fuel_selector[MAX_TANKS];
143     int to_engine[MAX_TANKS];
144     int to_tank[MAX_TANKS];
145     
146     // controls/fuel/tank[n]/pump[p]/
147     bool boost_pump[MAX_TANKS * MAX_BOOSTPUMPS];
148
149     // controls/gear/
150     double brake_left;
151     double brake_right;
152     double copilot_brake_left;
153     double copilot_brake_right;
154     double brake_parking;
155     double steering;
156     bool nose_wheel_steering;
157     bool gear_down;
158     bool antiskid;
159     bool tailhook;
160     bool launchbar;
161     bool catapult_launch_cmd;
162     bool tailwheel_lock;
163
164     // controls/gear/wheel[n]/
165     bool alternate_extension[MAX_WHEELS];
166
167     // controls/anti-ice/
168     bool wing_heat;
169     bool pitot_heat;
170     int wiper;
171     bool window_heat;
172
173     // controls/anti-ice/engine[n]/
174     bool carb_heat[MAX_ENGINES];
175     bool inlet_heat[MAX_ENGINES];
176     
177     // controls/hydraulic/system[n]/
178     bool engine_pump[MAX_HYD_SYSTEMS];
179     bool electric_pump[MAX_HYD_SYSTEMS];
180
181     // controls/electric/
182     bool battery_switch;
183     bool external_power;
184     bool APU_generator;
185
186     // controls/electric/engine[n]/
187     bool generator_breaker[MAX_ENGINES];
188     bool bus_tie[MAX_ENGINES];
189
190     // controls/pneumatic/
191     bool APU_bleed;
192
193     // controls/pneumatic/engine[n]/
194     bool engine_bleed[MAX_ENGINES];
195     
196     // controls/pressurization/
197     int mode;
198     bool dump;
199     double outflow_valve;
200
201     // controls/pressurization/pack[n]/
202     bool pack_on[MAX_PACKS];
203
204     // controls/lighting/
205     bool landing_lights;
206     bool turn_off_lights;
207     bool taxi_light;
208     bool logo_lights;
209     bool nav_lights;
210     bool beacon;
211     bool strobe;
212     double panel_norm;
213     double instruments_norm;
214     double dome_norm;
215
216     // controls/armament/
217     bool master_arm;
218     int station_select;
219     bool release_ALL;
220
221     // controls/armament/station[n]/
222     int stick_size[MAX_STATIONS];
223     bool release_stick[MAX_STATIONS];
224     bool release_all[MAX_STATIONS];
225     bool jettison_all[MAX_STATIONS];
226
227     // controls/seat/
228     double vertical_adjust;
229     double fore_aft_adjust;
230     bool eject[MAX_EJECTION_SEATS];
231     int eseat_status[MAX_EJECTION_SEATS];
232     int cmd_selector_valve;
233
234     // controls/APU/
235     int off_start_run;
236     bool APU_fire_switch;
237
238     // controls/autoflight/autopilot[n]/
239     bool autopilot_engage[MAX_AUTOPILOTS];
240
241     // controls/autoflight/
242     bool autothrottle_arm;
243     bool autothrottle_engage;
244     double heading_select;
245     double altitude_select;
246     double bank_angle_select;
247     double vertical_speed_select;
248     double speed_select;
249     double mach_select; 
250     int vertical_mode;
251     int lateral_mode;
252      
253
254     SGPropertyNode_ptr auto_coordination;
255
256 public:
257
258     FGControls();
259     ~FGControls();
260
261     // Implementation of SGSubsystem.
262     void init ();
263     void bind ();
264     void unbind ();
265     void update (double dt);
266
267     // Reset function
268     void reset_all(void);
269         
270     // Query functions
271     // controls/flight/
272     inline double get_aileron() const { return aileron; }
273     inline double get_aileron_trim() const { return aileron_trim; }
274     inline double get_elevator() const { return elevator; }
275     inline double get_elevator_trim() const { return elevator_trim; }
276     inline double get_rudder() const { return rudder; }
277     inline double get_rudder_trim() const { return rudder_trim; }
278     inline double get_flaps() const { return flaps; }
279     inline double get_slats() const { return slats; }
280     inline bool get_BLC() const { return BLC; }  
281     inline double get_spoilers() const { return spoilers; }
282     inline double get_speedbrake() const { return speedbrake; }
283     inline double get_wing_sweep() const { return wing_sweep; }
284     inline bool get_wing_fold() const { return wing_fold; }
285     inline bool get_drag_chute() const { return drag_chute; }
286
287     // controls/engines/
288     inline bool get_throttle_idle() const { return throttle_idle; }
289
290     // controls/engines/engine[n]/
291     inline double get_throttle(int engine) const { return throttle[engine]; }
292     inline bool get_starter(int engine) const { return starter[engine]; }
293     inline bool get_fuel_pump(int engine) const { return fuel_pump[engine]; }
294     inline bool get_fire_switch(int engine) const { return fire_switch[engine]; }
295     inline bool get_fire_bottle_discharge(int engine) const {
296         return fire_bottle_discharge[engine];
297     }
298     inline bool get_cutoff(int engine) const { return cutoff[engine]; }
299     inline double get_mixture(int engine) const { return mixture[engine]; }
300     inline double get_prop_advance(int engine) const {
301         return prop_advance[engine];
302     }
303     inline int get_magnetos(int engine) const { return magnetos[engine]; }
304     inline int get_feed_tank(int engine) const { return feed_tank[engine]; }
305     inline bool get_nitrous_injection(int engine) const { 
306         return nitrous_injection[engine];
307     }
308     inline double get_cowl_flaps_norm(int engine) const {
309         return cowl_flaps_norm[engine];
310     }
311     inline bool get_feather(int engine) const { return feather[engine]; }
312     inline int get_ignition(int engine) const { return ignition[engine]; }
313     inline bool get_augmentation(int engine) const { return augmentation[engine]; }
314     inline bool get_reverser(int engine) const { return reverser[engine]; }
315     inline bool get_water_injection(int engine) const { 
316         return water_injection[engine]; 
317     }
318     inline double get_condition(int engine) const { return condition[engine]; }
319
320     // controls/fuel/
321     inline bool get_dump_valve() const { return dump_valve; }
322
323     // controls/fuel/tank[n]/
324     inline bool get_fuel_selector(int tank) const {
325         return fuel_selector[tank];
326     }
327     inline int get_to_engine(int tank) const { return to_engine[tank]; }
328     inline int get_to_tank(int tank) const { return to_tank[tank]; }
329
330     // controls/fuel/tank[n]/pump[p]/
331     inline bool get_boost_pump(int index) const {
332         return boost_pump[index];
333     }
334
335     // controls/gear/
336     inline double get_brake_left() const { return brake_left; }
337     inline double get_brake_right() const { return brake_right; }
338     inline double get_copilot_brake_left() const { return copilot_brake_left; }
339     inline double get_copilot_brake_right() const { return copilot_brake_right; }
340     inline double get_brake_parking() const { return brake_parking; }
341     inline double get_steering() const { return steering; }
342     inline bool get_nose_wheel_steering() const { return nose_wheel_steering; }
343     inline bool get_gear_down() const { return gear_down; }
344     inline bool get_antiskid() const { return antiskid; }
345     inline bool get_tailhook() const { return tailhook; }
346     inline bool get_launchbar() const { return launchbar; }
347     inline bool get_catapult_launch_cmd() const { return catapult_launch_cmd; }
348     inline bool get_tailwheel_lock() const { return tailwheel_lock; }
349
350     // controls/gear/wheel[n]/
351     inline bool get_alternate_extension(int wheel) const {
352         return alternate_extension[wheel];
353     }
354
355     // controls/anti-ice/
356     inline bool get_wing_heat() const { return wing_heat; }
357     inline bool get_pitot_heat() const { return pitot_heat; }
358     inline int get_wiper() const { return wiper; }
359     inline bool get_window_heat() const { return window_heat; }
360
361     // controls/anti-ice/engine[n]/
362     inline bool get_carb_heat(int engine) const { return carb_heat[engine]; }
363     inline bool get_inlet_heat(int engine) const { return inlet_heat[engine]; }
364
365     // controls/hydraulic/system[n]/
366     inline bool get_engine_pump(int system) const { return engine_pump[system]; }
367     inline bool get_electric_pump(int system) const { return electric_pump[system]; }
368
369     // controls/electric/
370     inline bool get_battery_switch() const { return battery_switch; }
371     inline bool get_external_power() const { return external_power; }
372     inline bool get_APU_generator() const { return APU_generator; }
373
374     // controls/electric/engine[n]/
375     inline bool get_generator_breaker(int engine) const { 
376         return generator_breaker[engine];
377     }
378     inline bool get_bus_tie(int engine) const { return bus_tie[engine]; }
379
380     // controls/pneumatic/
381     inline bool get_APU_bleed() const { return APU_bleed; }
382
383     // controls/pneumatic/engine[n]/
384     inline bool get_engine_bleed(int engine) const { return engine_bleed[engine]; }
385     
386     // controls/pressurization/
387     inline int get_mode() const { return mode; }
388     inline double get_outflow_valve() const { return outflow_valve; }
389     inline bool get_dump() const { return dump; }
390
391     // controls/pressurization/pack[n]/
392     inline bool get_pack_on(int pack) const { return pack_on[pack]; }
393
394     // controls/lighting/
395     inline bool get_landing_lights() const { return landing_lights; }
396     inline bool get_turn_off_lights() const { return  turn_off_lights; }
397     inline bool get_taxi_light() const { return taxi_light; }
398     inline bool get_logo_lights() const { return logo_lights; }
399     inline bool get_nav_lights() const { return nav_lights; }
400     inline bool get_beacon() const { return beacon; }
401     inline bool get_strobe() const { return strobe; }
402     inline double get_panel_norm() const { return panel_norm; }
403     inline double get_instruments_norm() const { return instruments_norm; }
404     inline double get_dome_norm() const { return dome_norm; }
405
406     // controls/armament/
407     inline bool get_master_arm() const { return master_arm; }
408     inline int get_station_select() const { return station_select; }
409     inline bool get_release_ALL() const { return release_ALL; }
410
411       // controls/armament/station[n]/
412     inline int get_stick_size(int station) const { return stick_size[station]; }
413     inline bool get_release_stick(int station) const { return release_stick[station]; }
414     inline bool get_release_all(int station) const { return release_all[station]; }
415     inline bool get_jettison_all(int station) const { return jettison_all[station]; }
416
417     // controls/seat/
418     inline double get_vertical_adjust() const { return vertical_adjust; }
419     inline double get_fore_aft_adjust() const { return fore_aft_adjust; }
420     inline bool get_ejection_seat( int which_seat ) const {
421         return eject[which_seat];
422     }
423     inline int get_eseat_status( int which_seat ) const {
424         return eseat_status[which_seat];
425     }
426     inline int get_cmd_selector_valve() const { return cmd_selector_valve; }
427     
428
429     // controls/APU/
430     inline int get_off_start_run() const { return off_start_run; }
431     inline bool get_APU_fire_switch() const { return APU_fire_switch; }
432
433     // controls/autoflight/
434     inline bool get_autothrottle_arm() const { return autothrottle_arm; }
435     inline bool get_autothrottle_engage() const { return autothrottle_engage; }
436     inline double get_heading_select() const { return heading_select; }
437     inline double get_altitude_select() const { return altitude_select; }
438     inline double get_bank_angle_select() const { return bank_angle_select; }
439     inline double get_vertical_speed_select() const { 
440         return vertical_speed_select; 
441     }
442     inline double get_speed_select() const { return speed_select; }
443     inline double get_mach_select() const { return mach_select; } 
444     inline int get_vertical_mode() const { return vertical_mode; }
445     inline int get_lateral_mode() const { return lateral_mode; }
446
447     // controls/autoflight/autopilot[n]/
448     inline bool get_autopilot_engage(int ap) const { 
449         return autopilot_engage[ap];
450     }
451      
452
453     // Update functions
454     // controls/flight/
455     void set_aileron( double pos );
456     void move_aileron( double amt );
457     void set_aileron_trim( double pos );
458     void move_aileron_trim( double amt );
459     void set_elevator( double pos );
460     void move_elevator( double amt );
461     void set_elevator_trim( double pos );
462     void move_elevator_trim( double amt );
463     void set_rudder( double pos );
464     void move_rudder( double amt );
465     void set_rudder_trim( double pos );
466     void move_rudder_trim( double amt );
467     void set_flaps( double pos );
468     void move_flaps( double amt );
469     void set_slats( double pos );
470     void move_slats( double amt );
471     void set_BLC( bool val ); 
472     void set_spoilers( double pos );
473     void move_spoilers( double amt );
474     void set_speedbrake( double pos );
475     void move_speedbrake( double amt );
476     void set_wing_sweep( double pos );
477     void move_wing_sweep( double amt );
478     void set_wing_fold( bool val );   
479     void set_drag_chute( bool val );
480
481     // controls/engines/
482     void set_throttle_idle( bool val );
483
484     // controls/engines/engine[n]/
485     void set_throttle( int engine, double pos );
486     void move_throttle( int engine, double amt );
487     void set_starter( int engine, bool flag );
488     void set_fuel_pump( int engine, bool val );
489     void set_fire_switch( int engine, bool val );
490     void set_fire_bottle_discharge( int engine, bool val );
491     void set_cutoff( int engine, bool val );
492     void set_mixture( int engine, double pos );
493     void move_mixture( int engine, double amt );
494     void set_prop_advance( int engine, double pos );
495     void move_prop_advance( int engine, double amt );
496     void set_magnetos( int engine, int pos );
497     void move_magnetos( int engine, int amt );
498     void set_feed_tank( int engine, int tank );
499     void set_nitrous_injection( int engine, bool val );
500     void set_cowl_flaps_norm( int engine, double pos );
501     void move_cowl_flaps_norm( int engine, double amt );
502     void set_feather( int engine, bool val );
503     void set_ignition( int engine, int val );
504     void set_augmentation( int engine, bool val );
505     void set_reverser( int engine, bool val );
506     void set_water_injection( int engine, bool val );
507     void set_condition( int engine, double val );    
508
509     // controls/fuel
510     void set_dump_valve( bool val );
511
512     // controls/fuel/tank[n]/
513     void set_fuel_selector( int tank, bool pos );
514     void set_to_engine( int tank, int engine );
515     void set_to_tank( int tank, int dest_tank );
516
517     // controls/fuel/tank[n]/pump[p]
518     void set_boost_pump( int index, bool val );
519
520     // controls/gear/
521     void set_brake_left( double pos );
522     void move_brake_left( double amt );
523     void set_brake_right( double pos );
524     void move_brake_right( double amt );
525     void set_copilot_brake_left( double pos );
526     void set_copilot_brake_right( double pos );
527     void set_brake_parking( double pos );
528     void set_steering( double pos );
529     void move_steering( double amt );
530     void set_nose_wheel_steering( bool nws );
531     void set_gear_down( bool gear );
532     void set_antiskid( bool val );
533     void set_tailhook( bool val );
534     void set_launchbar( bool val );
535     void set_catapult_launch_cmd( bool val );
536     void set_tailwheel_lock( bool val );
537
538     // controls/gear/wheel[n]/
539     void set_alternate_extension( int wheel, bool val );
540
541     // controls/anti-ice/
542     void set_wing_heat( bool val );
543     void set_pitot_heat( bool val );
544     void set_wiper( int speed );
545     void set_window_heat( bool val );
546
547     // controls/anti-ice/engine[n]/
548     void set_carb_heat( int engine, bool val );
549     void set_inlet_heat( int engine, bool val );
550
551     // controls/hydraulic/system[n]/
552     void set_engine_pump( int system, bool val );
553     void set_electric_pump( int system, bool val );
554
555     // controls/electric/
556     void set_battery_switch( bool val );
557     void set_external_power( bool val );
558     void set_APU_generator( bool val );
559
560     // controls/electric/engine[n]/
561     void set_generator_breaker( int engine, bool val );
562     void set_bus_tie( int engine, bool val );
563
564     // controls/pneumatic/
565     void set_APU_bleed( bool val );
566
567     // controls/pneumatic/engine[n]/
568     void set_engine_bleed( int engine, bool val );
569     
570     // controls/pressurization/
571     void set_mode( int mode );
572     void set_outflow_valve( double pos );
573     void move_outflow_valve( double amt );
574     void set_dump( bool val );
575
576     // controls/pressurization/pack[n]/
577     void set_pack_on( int pack, bool val );
578
579     // controls/lighting/
580     void set_landing_lights( bool val );
581     void set_turn_off_lights( bool val );
582     void set_taxi_light( bool val );
583     void set_logo_lights( bool val );
584     void set_nav_lights( bool val );
585     void set_beacon( bool val );
586     void set_strobe( bool val );
587     void set_panel_norm( double intensity );
588     void move_panel_norm( double amt );
589     void set_instruments_norm( double intensity );
590     void move_instruments_norm( double amt );
591     void set_dome_norm( double intensity );
592     void move_dome_norm( double amt );
593
594     // controls/armament/
595     void set_master_arm( bool val );
596     void set_station_select( int station );
597     void set_release_ALL( bool val );
598
599     // controls/armament/station[n]/
600     void set_stick_size( int station, int size );
601     void set_release_stick( int station, bool val );
602     void set_release_all( int station, bool val );
603     void set_jettison_all( int station, bool val );
604
605     // controls/seat/
606     void set_vertical_adjust( double pos );
607     void move_vertical_adjust( double amt );
608     void set_fore_aft_adjust( double pos );
609     void move_fore_aft_adjust( double amt );
610     void set_ejection_seat( int which_seat, bool val );
611     void set_eseat_status( int which_seat, int val );
612     void set_cmd_selector_valve( int val );
613
614     // controls/APU/
615     void set_off_start_run( int pos );
616     void set_APU_fire_switch( bool val );
617
618     // controls/autoflight/
619     void set_autothrottle_arm( bool val );
620     void set_autothrottle_engage( bool val );
621     void set_heading_select( double heading );
622     void move_heading_select( double amt );
623     void set_altitude_select( double altitude );
624     void move_altitude_select( double amt );
625     void set_bank_angle_select( double angle );
626     void move_bank_angle_select( double amt );
627     void set_vertical_speed_select( double vs );
628     void move_vertical_speed_select( double amt );
629     void set_speed_select( double speed );
630     void move_speed_select( double amt );
631     void set_mach_select( double mach ); 
632     void move_mach_select( double amt ); 
633     void set_vertical_mode( int mode );
634     void set_lateral_mode( int mode );
635
636     // controls/autoflight/autopilot[n]/
637     void set_autopilot_engage( int ap, bool val );
638
639 };
640
641
642 #endif // _CONTROLS_HXX
643
644