]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGJSBBase.h
Sync with latest JSBSim CVS
[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   SG_USING_STD(queue);
47 #else
48 #  if defined(sgi) && !defined(__GNUC__)
49 #    include <math.h>
50 #    include <queue.h>
51 #    include <string.h>
52 #  else
53 #    include <cmath>
54 #    include <queue>
55 #    include <string>
56 #  endif
57 #endif
58
59 #ifndef M_PI 
60 #  include <simgear/constants.h>
61 #  define M_PI SG_PI
62 #endif
63
64 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 DEFINITIONS
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
67
68 #define ID_JSBBASE "$Id$"
69
70 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71 FORWARD DECLARATIONS
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
73
74 enum eParam {
75   FG_UNDEF = 0,
76   FG_TIME,
77   FG_QBAR,
78   FG_WINGAREA,
79   FG_WINGSPAN,
80   FG_CBAR,
81   FG_ALPHA,
82   FG_ALPHADOT,
83   FG_BETA,
84   FG_ABETA,
85   FG_BETADOT,
86   FG_PHI,
87   FG_THT,
88   FG_PSI,
89   FG_PITCHRATE,
90   FG_ROLLRATE,
91   FG_YAWRATE,
92   FG_CL_SQRD,
93   FG_MACH,
94   FG_ALTITUDE,
95   FG_BI2VEL,
96   FG_CI2VEL,
97   FG_ELEVATOR_POS,
98   FG_AILERON_POS,
99   FG_RUDDER_POS,
100   FG_SPDBRAKE_POS,
101   FG_SPOILERS_POS,
102   FG_FLAPS_POS,
103   FG_ELEVATOR_CMD,
104   FG_AILERON_CMD,
105   FG_RUDDER_CMD,
106   FG_SPDBRAKE_CMD,
107   FG_SPOILERS_CMD,
108   FG_FLAPS_CMD,
109   FG_THROTTLE_CMD,
110   FG_THROTTLE_POS,
111   FG_MIXTURE_CMD,
112   FG_MIXTURE_POS,
113   FG_MAGNETO_CMD,
114   FG_STARTER_CMD,
115   FG_ACTIVE_ENGINE,
116   FG_HOVERB,
117   FG_PITCH_TRIM_CMD,
118   FG_YAW_TRIM_CMD,
119   FG_ROLL_TRIM_CMD,
120   FG_LEFT_BRAKE_CMD,
121   FG_CENTER_BRAKE_CMD,
122   FG_RIGHT_BRAKE_CMD,
123   FG_SET_LOGGING,
124   FG_ALPHAH,
125   FG_ALPHAW,
126   FG_LBARH,     //normalized horizontal tail arm
127   FG_LBARV,     //normalized vertical tail arm
128   FG_HTAILAREA,
129   FG_VTAILAREA,
130   FG_VBARH,    //horizontal tail volume 
131   FG_VBARV     //vertical tail volume 
132 };
133
134 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
137
138 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139 CLASS DOCUMENTATION
140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
141
142 /** JSBSim Base class.
143     @author Jon S. Berndt
144     @version $Id$
145 */
146
147 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148 CLASS DECLARATION
149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
150
151 class FGJSBBase {
152 public:
153   /// Constructor for FGJSBBase.
154   FGJSBBase();
155
156   /// Destructor for FGJSBBase.
157   virtual ~FGJSBBase() {};
158
159   /// JSBSim Message structure
160   struct Message {
161     unsigned int fdmId;
162     unsigned int messageId;
163     string text;
164     string subsystem;
165     enum mType {eText, eInteger, eDouble, eBool} type;
166     bool bVal;
167     int  iVal;
168     double dVal;
169   };
170
171   ///@name JSBSim Enums.
172   //@{
173   /// Moments L, M, N
174   enum {eL     = 1, eM,     eN    };
175   /// Rates P, Q, R
176   enum {eP     = 1, eQ,     eR    };
177   /// Velocities U, V, W
178   enum {eU     = 1, eV,     eW    };
179   /// Positions X, Y, Z
180   enum {eX     = 1, eY,     eZ    };
181   /// Euler angles Phi, Theta, Psi
182   enum {ePhi   = 1, eTht,   ePsi  };
183   /// Stability axis forces, Drag, Side force, Lift
184   enum {eDrag  = 1, eSide,  eLift };
185   /// Local frame orientation Roll, Pitch, Yaw
186   enum {eRoll  = 1, ePitch, eYaw  };
187   /// Local frame position North, East, Down
188   enum {eNorth = 1, eEast,  eDown };
189   //@}
190   
191   ///@name JSBSim console output highlighting terms.
192   //@{
193   /// highlights text
194   static char highint[5];
195   /// low intensity text
196   static char halfint[5];
197   /// normal intensity text
198   static char normint[6];
199   /// resets text properties
200   static char reset[5];
201   /// underlines text
202   static char underon[5];
203   /// underline off
204   static char underoff[6];
205   /// blue text
206   static char fgblue[6];
207   /// cyan text
208   static char fgcyan[6];
209   /// red text
210   static char fgred[6];
211   /// green text
212   static char fggreen[6];
213   /// default text
214   static char fgdef[6];
215   //@}
216
217   ///@name JSBSim Messaging functions
218   //@{
219   /** Places a Message structure on the Message queue.
220       @param msg pointer to a Message structure
221       @return pointer to a Message structure */
222   struct Message* PutMessage(struct Message* msg);
223   /** Creates a message with the given text and places it on the queue.
224       @param text message text
225       @return pointer to a Message structure */
226   struct Message* PutMessage(string text);
227   /** Creates a message with the given text and boolean value and places it on the queue.
228       @param text message text
229       @param bVal boolean value associated with the message
230       @return pointer to a Message structure */
231   struct Message* PutMessage(string text, bool bVal);
232   /** Creates a message with the given text and integer value and places it on the queue.
233       @param text message text
234       @param iVal integer value associated with the message
235       @return pointer to a Message structure */
236   struct Message* PutMessage(string text, int iVal);
237   /** Creates a message with the given text and double value and places it on the queue.
238       @param text message text
239       @param dVal double value associated with the message
240       @return pointer to a Message structure */
241   struct Message* PutMessage(string text, double dVal);
242   /** Reads the message on the queue (but does not delete it).
243       @return pointer to a Message structure (or NULL if no mesage) */
244   struct Message* ReadMessage(void);
245   /** Reads the message on the queue and removes it from the queue.
246       @return pointer to a Message structure (or NULL if no mesage) */
247   struct Message* ProcessMessage(void);
248   //@}
249
250 protected:
251   static struct Message localMsg;
252   
253   static queue <struct Message*> Messages;
254
255   virtual void Debug(void) {};
256
257   static short debug_lvl;
258   static int frame;
259   static unsigned int messageId;
260   
261   static const double radtodeg;
262   static const double degtorad;
263   static const double hptoftlbssec;
264   static const double fpstokts;
265   static const double ktstofps;
266   static const double inchtoft;
267   static const double Reng;         // Specific Gas Constant,ft^2/(sec^2*R)
268   static const double SHRatio;
269   static const string needed_cfg_version;
270   static const string JSBSim_version;
271 };
272
273 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
274 #endif
275