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