]> git.mxchange.org Git - flightgear.git/blob - src/Main/bfi.hxx
David Megginson's changes:
[flightgear.git] / src / Main / bfi.hxx
1 // bfi.hxx - Big Flat Interface
2 //
3 // Written by David Megginson, started February, 2000.
4 //
5 // Copyright (C) 2000  David Megginson - david@megginson.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 #include <time.h>
24 #include <string>
25
26 #include <simgear/compiler.h>
27
28 FG_USING_NAMESPACE(std);
29
30
31 /**
32  * Big Flat Interface
33  *
34  * This class implements the Facade design pattern (GOF p.185) to provide
35  * a single, (deceptively) simple flat interface for the FlightGear
36  * subsystems.  
37  *
38  * To help cut down on interdependence, subsystems should
39  * use the BFI whenever possible for inter-system communication.
40  *
41  * TODO:
42  * - add selectors to switch the current plane, throttle, brake, etc.
43  * - add more autopilot settings
44  */
45 class FGBFI
46 {
47 public:
48
49                                 // Initialize before first use.
50   static void init ();
51
52                                 // Reinit if necessary.
53   static void update ();
54
55                                 // Simulation
56   static int getFlightModel ();
57   static const string getAircraft ();
58   static const string getAircraftDir ();
59   static time_t getTimeGMT ();
60   static bool getHUDVisible ();
61   static bool getPanelVisible ();
62
63   static void setFlightModel (int flightModel);
64   static void setAircraft (const string &aircraft);
65   static void setAircraftDir (const string &aircraftDir);
66   static void setTimeGMT (time_t time);
67   static void setHUDVisible (bool hudVisible);
68   static void setPanelVisible (bool panelVisible);
69
70
71                                 // Position
72   static double getLatitude ();
73   static double getLongitude ();
74   static double getAltitude ();
75   static double getAGL ();
76
77   static void setLatitude (double latitude);
78   static void setLongitude (double longitude);
79   static void setAltitude (double altitude);
80
81
82                                 // Attitude
83   static double getHeading ();    // true heading
84   static double getHeadingMag (); // exact magnetic heading
85   static double getPitch ();
86   static double getRoll ();
87
88   static void setHeading (double heading);
89   static void setPitch (double pitch);
90   static void setRoll (double roll);
91
92
93                                 // Velocities
94   static double getAirspeed ();
95   static double getSideSlip ();
96   static double getVerticalSpeed ();
97   static double getSpeedNorth ();
98   static double getSpeedEast ();
99   static double getSpeedDown ();
100
101   static void setSpeedNorth (double speed);
102   static void setSpeedEast (double speed);
103   static void setSpeedDown (double speed);
104
105
106                                 // Controls
107   static double getThrottle ();
108   static double getFlaps ();
109   static double getAileron ();
110   static double getRudder ();
111   static double getElevator ();
112   static double getElevatorTrim ();
113   static double getBrakes ();
114   static double getLeftBrake ();
115   static double getRightBrake ();
116   static double getCenterBrake ();
117
118   static void setThrottle (double throttle);
119   static void setFlaps (double flaps);
120   static void setAileron (double aileron);
121   static void setRudder (double rudder);
122   static void setElevator (double elevator);
123   static void setElevatorTrim (double trim);
124   static void setBrakes (double brake);
125   static void setLeftBrake (double brake);
126   static void setRightBrake (double brake);
127   static void setCenterBrake (double brake);
128
129
130                                 // Autopilot
131   static bool getAPAltitudeLock ();
132   static double getAPAltitude ();
133   static bool getAPHeadingLock ();
134   static double getAPHeading ();
135   static double getAPHeadingMag ();
136
137   static void setAPAltitudeLock (bool lock);
138   static void setAPAltitude (double altitude);
139   static void setAPHeadingLock (bool lock);
140   static void setAPHeading (double heading);
141   static void setAPHeadingMag (double heading);
142
143   static bool getAPNAV1Lock ();
144   static void setAPNAV1Lock (bool lock);
145
146                                 // Radio Navigation
147   static double getNAV1Freq ();
148   static double getNAV1AltFreq ();
149   static double getNAV1Radial ();
150   static double getNAV1SelRadial ();
151   static double getNAV1DistDME ();
152   static bool getNAV1InRange ();
153   static bool getNAV1DMEInRange ();
154
155   static double getNAV2Freq ();
156   static double getNAV2AltFreq ();
157   static double getNAV2Radial ();
158   static double getNAV2SelRadial ();
159   static double getNAV2DistDME ();
160   static bool getNAV2InRange ();
161   static bool getNAV2DMEInRange ();
162
163   static double getADFFreq ();
164   static double getADFAltFreq ();
165   static double getADFRotation ();
166
167   static void setNAV1Freq (double freq);
168   static void setNAV1AltFreq (double freq);
169   static void setNAV1SelRadial (double radial);
170
171   static void setNAV2Freq (double freq);
172   static void setNAV2AltFreq (double freq);
173   static void setNAV2SelRadial (double radial);
174
175   static void setADFFreq (double freq);
176   static void setADFAltFreq (double freq);
177   static void setADFRotation (double rot);
178
179                                 // GPS
180   static const string getTargetAirport ();
181   static bool getGPSLock ();
182   static double getGPSTargetLatitude ();
183   static double getGPSTargetLongitude ();
184
185   static void setTargetAirport (const string &targetAirport);
186   static void setGPSLock (bool lock);
187   static void setGPSTargetLatitude (double latitude);
188   static void setGPSTargetLongitude (double longitude);
189
190
191                                 // Weather
192   static double getVisibility ();
193   static bool getClouds ();
194   static double getCloudsASL ();
195
196   static void setVisibility (double visiblity);
197   static void setClouds (bool clouds);
198   static void setCloudsASL (double cloudsASL);
199
200
201                                 // Time (this varies with time) huh, huh
202   static double getMagVar (); 
203   static double getMagDip (); 
204
205
206 private:
207                                 // Will cause a linking error if invoked.
208   FGBFI ();
209
210   static void reinit ();
211   static void needReinit () { _needReinit = true; }
212   static bool _needReinit;
213 };
214
215 // end of bfi.hxx