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