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