1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7 ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) -------------
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
19 You should have received a copy of the GNU General Public License along with
20 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 Place - Suite 330, Boston, MA 02111-1307, USA.
23 Further information about the GNU General Public License can also be found on
24 the world wide web at http://www.gnu.org.
27 --------------------------------------------------------------------------------
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42 # include <simgear/compiler.h>
50 # include <simgear/constants.h>
58 # if defined(sgi) && !defined(__GNUC__)
67 # define M_PI 3.14159265358979323846
72 #if !defined(WIN32) || defined(__GNUC__)
76 #ifdef __FreeBSD__ // define gcvt on FreeBSD
80 static char *gcvt(double number, size_t ndigit, char *buf)
82 sprintf(buf, "%f", number);
87 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
91 #define ID_JSBBASE "$Id$"
93 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
98 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
99 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
102 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
106 /** JSBSim Base class.
107 @author Jon S. Berndt
111 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
113 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
119 /// Constructor for FGJSBBase.
122 /// Destructor for FGJSBBase.
123 virtual ~FGJSBBase() {};
125 /// JSBSim Message structure
128 unsigned int messageId;
131 enum mType {eText, eInteger, eDouble, eBool} type;
137 ///@name JSBSim Enums.
140 enum {eL = 1, eM, eN };
142 enum {eP = 1, eQ, eR };
143 /// Velocities U, V, W
144 enum {eU = 1, eV, eW };
145 /// Positions X, Y, Z
146 enum {eX = 1, eY, eZ };
147 /// Euler angles Phi, Theta, Psi
148 enum {ePhi = 1, eTht, ePsi };
149 /// Stability axis forces, Drag, Side force, Lift
150 enum {eDrag = 1, eSide, eLift };
151 /// Local frame orientation Roll, Pitch, Yaw
152 enum {eRoll = 1, ePitch, eYaw };
153 /// Local frame position North, East, Down
154 enum {eNorth = 1, eEast, eDown };
157 ///@name JSBSim console output highlighting terms.
160 static char highint[5];
161 /// low intensity text
162 static char halfint[5];
163 /// normal intensity text
164 static char normint[6];
165 /// resets text properties
166 static char reset[5];
168 static char underon[5];
170 static char underoff[6];
172 static char fgblue[6];
174 static char fgcyan[6];
176 static char fgred[6];
178 static char fggreen[6];
180 static char fgdef[6];
183 ///@name JSBSim Messaging functions
185 /** Places a Message structure on the Message queue.
186 @param msg pointer to a Message structure
187 @return pointer to a Message structure */
188 Message* PutMessage(Message* msg);
189 /** Creates a message with the given text and places it on the queue.
190 @param text message text
191 @return pointer to a Message structure */
192 Message* PutMessage(string text);
193 /** Creates a message with the given text and boolean value and places it on the queue.
194 @param text message text
195 @param bVal boolean value associated with the message
196 @return pointer to a Message structure */
197 Message* PutMessage(string text, bool bVal);
198 /** Creates a message with the given text and integer value and places it on the queue.
199 @param text message text
200 @param iVal integer value associated with the message
201 @return pointer to a Message structure */
202 Message* PutMessage(string text, int iVal);
203 /** Creates a message with the given text and double value and places it on the queue.
204 @param text message text
205 @param dVal double value associated with the message
206 @return pointer to a Message structure */
207 Message* PutMessage(string text, double dVal);
208 /** Reads the message on the queue (but does not delete it).
209 @return pointer to a Message structure (or NULL if no mesage) */
210 Message* ReadMessage(void);
211 /** Reads the message on the queue and removes it from the queue.
212 @return pointer to a Message structure (or NULL if no mesage) */
213 Message* ProcessMessage(void);
215 string GetVersion(void) {return JSBSim_version;}
217 void disableHighLighting(void);
220 static Message localMsg;
222 static std::queue <Message*> Messages;
224 virtual void Debug(int from) {};
226 static short debug_lvl;
227 static unsigned int frame;
228 static unsigned int messageId;
230 static const double radtodeg;
231 static const double degtorad;
232 static const double hptoftlbssec;
233 static const double psftoinhg;
234 static const double fpstokts;
235 static const double ktstofps;
236 static const double inchtoft;
237 static const double in3tom3;
238 static const double Reng; // Specific Gas Constant,ft^2/(sec^2*R)
239 static const double SHRatio;
240 static const string needed_cfg_version;
241 static const string JSBSim_version;
244 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%