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