]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGJSBBase.cpp
Frederic Bouvier:
[flightgear.git] / src / FDM / JSBSim / FGJSBBase.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGJSBBase.cpp
4  Author:       Jon S. Berndt
5  Date started: 07/01/01
6  Purpose:      Encapsulates the JSBBase object
7
8  ------------- Copyright (C) 2001  Jon S. Berndt (jsb@hal-pc.org) -------------
9
10  This program is free software; you can redistribute it and/or modify it under
11  the terms of the GNU General Public License as published by the Free Software
12  Foundation; either version 2 of the License, or (at your option) any later
13  version.
14
15  This program is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18  details.
19
20  You should have received a copy of the GNU General Public License along with
21  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  Place - Suite 330, Boston, MA  02111-1307, USA.
23
24  Further information about the GNU General Public License can also be found on
25  the world wide web at http://www.gnu.org.
26
27 FUNCTIONAL DESCRIPTION
28 --------------------------------------------------------------------------------
29
30 HISTORY
31 --------------------------------------------------------------------------------
32 07/01/01  JSB  Created
33
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 INCLUDES
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
37
38 #include "FGJSBBase.h"
39
40 namespace JSBSim {
41
42 static const char *IdSrc = "$Id$";
43 static const char *IdHdr = ID_JSBBASE;
44
45 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
46 CLASS IMPLEMENTATION
47 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
48
49 #ifndef _MSC_VER
50     char FGJSBBase::highint[5]  = {27, '[', '1', 'm', '\0'      };
51     char FGJSBBase::halfint[5]  = {27, '[', '2', 'm', '\0'      };
52     char FGJSBBase::normint[6]  = {27, '[', '2', '2', 'm', '\0' };
53     char FGJSBBase::reset[5]    = {27, '[', '0', 'm', '\0'      };
54     char FGJSBBase::underon[5]  = {27, '[', '4', 'm', '\0'      };
55     char FGJSBBase::underoff[6] = {27, '[', '2', '4', 'm', '\0' };
56     char FGJSBBase::fgblue[6]   = {27, '[', '3', '4', 'm', '\0' };
57     char FGJSBBase::fgcyan[6]   = {27, '[', '3', '6', 'm', '\0' };
58     char FGJSBBase::fgred[6]    = {27, '[', '3', '1', 'm', '\0' };
59     char FGJSBBase::fggreen[6]  = {27, '[', '3', '2', 'm', '\0' };
60     char FGJSBBase::fgdef[6]    = {27, '[', '3', '9', 'm', '\0' };
61 #else
62     char FGJSBBase::highint[5]  = {'\0' };
63     char FGJSBBase::halfint[5]  = {'\0' };
64     char FGJSBBase::normint[6]  = {'\0' };
65     char FGJSBBase::reset[5]    = {'\0' };
66     char FGJSBBase::underon[5]  = {'\0' };
67     char FGJSBBase::underoff[6] = {'\0' };
68     char FGJSBBase::fgblue[6]   = {'\0' };
69     char FGJSBBase::fgcyan[6]   = {'\0' };
70     char FGJSBBase::fgred[6]    = {'\0' };
71     char FGJSBBase::fggreen[6]  = {'\0' };
72     char FGJSBBase::fgdef[6]    = {'\0' };
73 #endif
74
75 const double FGJSBBase::radtodeg = 57.29578;
76 const double FGJSBBase::degtorad = 1.745329E-2;
77 const double FGJSBBase::hptoftlbssec = 550.0;
78 const double FGJSBBase::psftoinhg = 0.014138;
79 const double FGJSBBase::fpstokts = 0.592484;
80 const double FGJSBBase::ktstofps = 1.68781;
81 const double FGJSBBase::inchtoft = 0.08333333;
82 const double FGJSBBase::in3tom3 = 1.638706E-5;
83 double FGJSBBase::Reng = 1716.0;
84 const double FGJSBBase::SHRatio = 1.40;
85
86 // Note that definition of lbtoslug by the inverse of slugtolb and not
87 // to a different constant you can also get from some tables will make
88 // lbtoslug*slugtolb == 1 up to the magnitude of roundoff. So converting from
89 // slug to lb and back will yield to the original value you started with up
90 // to the magnitude of roundoff.
91 // Taken from units gnu commandline tool
92 const double FGJSBBase::slugtolb = 32.174049;
93 const double FGJSBBase::lbtoslug = 1.0/slugtolb;
94
95 const string FGJSBBase::needed_cfg_version = "1.65";
96 const string FGJSBBase::JSBSim_version = "0.9.5";
97
98 std::queue <FGJSBBase::Message*> FGJSBBase::Messages;
99 FGJSBBase::Message FGJSBBase::localMsg;
100 unsigned int FGJSBBase::messageId = 0;
101 unsigned int FGJSBBase::frame = 0;
102
103 short FGJSBBase::debug_lvl  = 1;
104
105 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106
107 FGJSBBase::Message* FGJSBBase::PutMessage(Message* msg)
108 {
109   Messages.push(msg);
110   return msg;
111 }
112
113 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114
115 FGJSBBase::Message* FGJSBBase::PutMessage(const string& text)
116 {
117   Message *msg = new Message();
118   msg->text = text;
119   msg->messageId = messageId++;
120   msg->subsystem = "FDM";
121   msg->type = Message::eText;
122   Messages.push(msg);
123   return msg;
124 }
125
126 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127
128 FGJSBBase::Message* FGJSBBase::PutMessage(const string& text, bool bVal)
129 {
130   Message *msg = new Message();
131   msg->text = text;
132   msg->messageId = messageId++;
133   msg->subsystem = "FDM";
134   msg->type = Message::eBool;
135   msg->bVal = bVal;
136   Messages.push(msg);
137   return msg;
138 }
139
140 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141
142 FGJSBBase::Message* FGJSBBase::PutMessage(const string& text, int iVal)
143 {
144   Message *msg = new Message();
145   msg->text = text;
146   msg->messageId = messageId++;
147   msg->subsystem = "FDM";
148   msg->type = Message::eInteger;
149   msg->bVal = (iVal != 0);
150   Messages.push(msg);
151   return msg;
152 }
153
154 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
155
156 FGJSBBase::Message* FGJSBBase::PutMessage(const string& text, double dVal)
157 {
158   Message *msg = new Message();
159   msg->text = text;
160   msg->messageId = messageId++;
161   msg->subsystem = "FDM";
162   msg->type = Message::eDouble;
163   msg->bVal = (dVal != 0.0);
164   Messages.push(msg);
165   return msg;
166 }
167
168 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169
170 FGJSBBase::Message* FGJSBBase::ReadMessage(void)
171 {
172   if (!Messages.empty()) return Messages.front();
173   else                   return NULL;
174 }
175
176 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177
178 FGJSBBase::Message* FGJSBBase::ProcessMessage(void)
179 {
180   if (!Messages.empty())
181     localMsg = *(Messages.front());
182   else
183     return NULL;
184   Messages.pop();
185   return &localMsg;
186 }
187
188 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
189
190 void FGJSBBase::disableHighLighting(void) {
191   highint[0]='\0';
192   halfint[0]='\0';
193   normint[0]='\0';
194   reset[0]='\0';
195   underon[0]='\0';
196   underoff[0]='\0';
197   fgblue[0]='\0';
198   fgcyan[0]='\0';
199   fgred[0]='\0';
200   fggreen[0]='\0';
201   fgdef[0]='\0';
202 }
203
204 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205
206 } // namespace JSBSim
207