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