]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGJSBBase.h
Updates from JSBSim, including new turbine engine model from David Culp
[flightgear.git] / src / FDM / JSBSim / FGJSBBase.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Header:       FGJSBBase.h
4  Author:       Jon S. Berndt
5  Date started: 07/01/01
6
7  ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.org) -------------
8
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
12  version.
13
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
17  details.
18
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.
22
23  Further information about the GNU General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25
26 HISTORY
27 --------------------------------------------------------------------------------
28 07/01/01  JSB  Created
29
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33
34 #ifndef FGJSBBASE_H
35 #define FGJSBBASE_H
36
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40
41 #ifdef FGFS
42 #  include <simgear/compiler.h>
43 #  include <math.h>
44 #  include <queue>
45 #  include STL_STRING
46
47 SG_USING_STD(string);
48 SG_USING_STD(queue);
49
50 # ifndef M_PI
51 #  include <simgear/constants.h>
52 #  define M_PI SG_PI
53 # endif
54
55 #else
56
57 #  include <queue>
58 #  include <string>
59 #  if defined(sgi) && !defined(__GNUC__)
60 #    include <math.h>
61 #  else
62 #    include <cmath>
63 #  endif
64
65 using std::string;
66 using std::queue;
67
68 # ifndef M_PI
69 #  define M_PI 3.14159265358979323846
70 # endif
71
72 #endif
73
74
75 using std::max;
76
77 #ifdef __FreeBSD__ // define gcvt on FreeBSD
78
79 #include <stdio.h>
80
81 static char *gcvt(double number, size_t ndigit, char *buf)
82 {
83      sprintf(buf, "%f", number);
84      return buf;
85 }
86 #endif
87
88 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 DEFINITIONS
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
91
92 #define ID_JSBBASE "$Id$"
93
94 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 FORWARD DECLARATIONS
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
97
98
99 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
102
103 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 CLASS DOCUMENTATION
105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
106
107 /** JSBSim Base class.
108     @author Jon S. Berndt
109     @version $Id$
110 */
111
112 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
113 CLASS DECLARATION
114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
115
116 namespace JSBSim {
117
118 class FGJSBBase {
119 public:
120   /// Constructor for FGJSBBase.
121   FGJSBBase();
122
123   /// Destructor for FGJSBBase.
124   virtual ~FGJSBBase() {};
125
126   /// JSBSim Message structure
127   typedef struct Msg {
128     unsigned int fdmId;
129     unsigned int messageId;
130     string text;
131     string subsystem;
132     enum mType {eText, eInteger, eDouble, eBool} type;
133     bool bVal;
134     int  iVal;
135     double dVal;
136   } Message;
137
138   ///@name JSBSim Enums.
139   //@{
140   /// Moments L, M, N
141   enum {eL     = 1, eM,     eN    };
142   /// Rates P, Q, R
143   enum {eP     = 1, eQ,     eR    };
144   /// Velocities U, V, W
145   enum {eU     = 1, eV,     eW    };
146   /// Positions X, Y, Z
147   enum {eX     = 1, eY,     eZ    };
148   /// Euler angles Phi, Theta, Psi
149   enum {ePhi   = 1, eTht,   ePsi  };
150   /// Stability axis forces, Drag, Side force, Lift
151   enum {eDrag  = 1, eSide,  eLift };
152   /// Local frame orientation Roll, Pitch, Yaw
153   enum {eRoll  = 1, ePitch, eYaw  };
154   /// Local frame position North, East, Down
155   enum {eNorth = 1, eEast,  eDown };
156   //@}
157   
158   ///@name JSBSim console output highlighting terms.
159   //@{
160   /// highlights text
161   static char highint[5];
162   /// low intensity text
163   static char halfint[5];
164   /// normal intensity text
165   static char normint[6];
166   /// resets text properties
167   static char reset[5];
168   /// underlines text
169   static char underon[5];
170   /// underline off
171   static char underoff[6];
172   /// blue text
173   static char fgblue[6];
174   /// cyan text
175   static char fgcyan[6];
176   /// red text
177   static char fgred[6];
178   /// green text
179   static char fggreen[6];
180   /// default text
181   static char fgdef[6];
182   //@}
183
184   ///@name JSBSim Messaging functions
185   //@{
186   /** Places a Message structure on the Message queue.
187       @param msg pointer to a Message structure
188       @return pointer to a Message structure */
189   Message* PutMessage(Message* msg);
190   /** Creates a message with the given text and places it on the queue.
191       @param text message text
192       @return pointer to a Message structure */
193   Message* PutMessage(string text);
194   /** Creates a message with the given text and boolean value and places it on the queue.
195       @param text message text
196       @param bVal boolean value associated with the message
197       @return pointer to a Message structure */
198   Message* PutMessage(string text, bool bVal);
199   /** Creates a message with the given text and integer value and places it on the queue.
200       @param text message text
201       @param iVal integer value associated with the message
202       @return pointer to a Message structure */
203   Message* PutMessage(string text, int iVal);
204   /** Creates a message with the given text and double value and places it on the queue.
205       @param text message text
206       @param dVal double value associated with the message
207       @return pointer to a Message structure */
208   Message* PutMessage(string text, double dVal);
209   /** Reads the message on the queue (but does not delete it).
210       @return pointer to a Message structure (or NULL if no mesage) */
211   Message* ReadMessage(void);
212   /** Reads the message on the queue and removes it from the queue.
213       @return pointer to a Message structure (or NULL if no mesage) */
214   Message* ProcessMessage(void);
215   //@}
216   string GetVersion(void) {return JSBSim_version;}
217   
218   void disableHighLighting(void);
219
220 protected:
221   static Message localMsg;
222   
223   static queue <Message*> Messages;
224
225   virtual void Debug(int from) {};
226
227   static short debug_lvl;
228   static unsigned int frame;
229   static unsigned int messageId;
230   
231   static const double radtodeg;
232   static const double degtorad;
233   static const double hptoftlbssec;
234   static const double psftoinhg;
235   static const double fpstokts;
236   static const double ktstofps;
237   static const double inchtoft;
238   static const double in3tom3;
239   static const double Reng;         // Specific Gas Constant,ft^2/(sec^2*R)
240   static const double SHRatio;
241   static const string needed_cfg_version;
242   static const string JSBSim_version;
243 };
244 }
245 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246 #endif
247