1 // bfi.hxx - Big Flat Interface
3 // Written by David Megginson, started February, 2000.
5 // Copyright (C) 2000 David Megginson - david@megginson.com
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.
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.
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.
26 #include <simgear/compiler.h>
28 FG_USING_NAMESPACE(std);
34 * This class implements the Facade design pattern (GOF p.185) to provide
35 * a single, (deceptively) simple flat interface for the FlightGear
38 * To help cut down on interdependence, subsystems should
39 * use the BFI whenever possible for inter-system communication.
42 * - add selectors to switch the current plane, throttle, brake, etc.
43 * - add more autopilot settings
49 // Initialize before first use.
52 // Reinit if necessary.
53 static void update ();
56 static int getFlightModel ();
57 static const string getAircraft ();
58 static const string getAircraftDir ();
59 static time_t getTimeGMT ();
60 static const string &getGMTString ();
61 static bool getHUDVisible ();
62 static bool getPanelVisible ();
64 static void setFlightModel (int flightModel);
65 static void setAircraft (const string &aircraft);
66 static void setAircraftDir (const string &aircraftDir);
67 static void setTimeGMT (time_t time);
68 static void setHUDVisible (bool hudVisible);
69 static void setPanelVisible (bool panelVisible);
73 static double getLatitude ();
74 static double getLongitude ();
75 static double getAltitude ();
76 static double getAGL ();
78 static void setLatitude (double latitude);
79 static void setLongitude (double longitude);
80 static void setAltitude (double altitude);
84 static double getHeading (); // true heading
85 static double getHeadingMag (); // exact magnetic heading
86 static double getPitch ();
87 static double getRoll ();
89 static void setHeading (double heading);
90 static void setPitch (double pitch);
91 static void setRoll (double roll);
94 static double getRPM ();
95 static void setRPM ( double rpm );
96 static double getEGT ();
97 static double getCHT ();
100 static double getAirspeed ();
101 static double getSideSlip ();
102 static double getVerticalSpeed ();
103 static double getSpeedNorth ();
104 static double getSpeedEast ();
105 static double getSpeedDown ();
107 static void setSpeedNorth (double speed);
108 static void setSpeedEast (double speed);
109 static void setSpeedDown (double speed);
113 static double getThrottle ();
114 static double getMixture ();
115 static double getPropAdvance ();
116 static double getFlaps ();
117 static double getAileron ();
118 static double getRudder ();
119 static double getElevator ();
120 static double getElevatorTrim ();
121 static double getBrakes ();
122 static double getLeftBrake ();
123 static double getRightBrake ();
124 static double getCenterBrake ();
126 static void setThrottle (double throttle);
127 static void setMixture (double mixture);
128 static void setPropAdvance (double pitch);
129 static void setFlaps (double flaps);
130 static void setAileron (double aileron);
131 static void setRudder (double rudder);
132 static void setElevator (double elevator);
133 static void setElevatorTrim (double trim);
134 static void setBrakes (double brake);
135 static void setLeftBrake (double brake);
136 static void setRightBrake (double brake);
137 static void setCenterBrake (double brake);
141 static bool getAPAltitudeLock ();
142 static double getAPAltitude ();
143 static bool getAPHeadingLock ();
144 static double getAPHeading ();
145 static double getAPHeadingMag ();
147 static void setAPAltitudeLock (bool lock);
148 static void setAPAltitude (double altitude);
149 static void setAPHeadingLock (bool lock);
150 static void setAPHeading (double heading);
151 static void setAPHeadingMag (double heading);
153 static bool getAPNAV1Lock ();
154 static void setAPNAV1Lock (bool lock);
157 static double getNAV1Freq ();
158 static double getNAV1AltFreq ();
159 static double getNAV1Radial ();
160 static double getNAV1SelRadial ();
161 static double getNAV1DistDME ();
162 static bool getNAV1TO ();
163 static bool getNAV1FROM ();
164 static bool getNAV1InRange ();
165 static bool getNAV1DMEInRange ();
167 static double getNAV2Freq ();
168 static double getNAV2AltFreq ();
169 static double getNAV2Radial ();
170 static double getNAV2SelRadial ();
171 static double getNAV2DistDME ();
172 static bool getNAV2TO ();
173 static bool getNAV2FROM ();
174 static bool getNAV2InRange ();
175 static bool getNAV2DMEInRange ();
177 static double getADFFreq ();
178 static double getADFAltFreq ();
179 static double getADFRotation ();
181 static void setNAV1Freq (double freq);
182 static void setNAV1AltFreq (double freq);
183 static void setNAV1SelRadial (double radial);
185 static void setNAV2Freq (double freq);
186 static void setNAV2AltFreq (double freq);
187 static void setNAV2SelRadial (double radial);
189 static void setADFFreq (double freq);
190 static void setADFAltFreq (double freq);
191 static void setADFRotation (double rot);
194 static const string &getTargetAirport ();
195 static bool getGPSLock ();
196 static double getGPSTargetLatitude ();
197 static double getGPSTargetLongitude ();
199 static void setTargetAirport (const string &targetAirport);
200 static void setGPSLock (bool lock);
203 static double getVisibility ();
204 static bool getClouds ();
205 static double getCloudsASL ();
207 static void setVisibility (double visiblity);
208 static void setClouds (bool clouds);
209 static void setCloudsASL (double cloudsASL);
212 // Time (this varies with time) huh, huh
213 static double getMagVar ();
214 static double getMagDip ();
218 // Will cause a linking error if invoked.
221 static void reinit ();
222 static void needReinit () { _needReinit = true; }
223 static bool _needReinit;