]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGJSBBase.cpp
latest changes for JSBSim (1.0 prerelease)
[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 Lesser 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 Lesser General Public License for more
18  details.
19
20  You should have received a copy of the GNU Lesser 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 Lesser 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 #define BASE
39
40 #include "FGJSBBase.h"
41
42 namespace JSBSim {
43
44 static const char *IdSrc = "$Id$";
45 static const char *IdHdr = ID_JSBBASE;
46
47 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48 CLASS IMPLEMENTATION
49 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
50
51 #ifndef _MSC_VER
52     char FGJSBBase::highint[5]  = {27, '[', '1', 'm', '\0'      };
53     char FGJSBBase::halfint[5]  = {27, '[', '2', 'm', '\0'      };
54     char FGJSBBase::normint[6]  = {27, '[', '2', '2', 'm', '\0' };
55     char FGJSBBase::reset[5]    = {27, '[', '0', 'm', '\0'      };
56     char FGJSBBase::underon[5]  = {27, '[', '4', 'm', '\0'      };
57     char FGJSBBase::underoff[6] = {27, '[', '2', '4', 'm', '\0' };
58     char FGJSBBase::fgblue[6]   = {27, '[', '3', '4', 'm', '\0' };
59     char FGJSBBase::fgcyan[6]   = {27, '[', '3', '6', 'm', '\0' };
60     char FGJSBBase::fgred[6]    = {27, '[', '3', '1', 'm', '\0' };
61     char FGJSBBase::fggreen[6]  = {27, '[', '3', '2', 'm', '\0' };
62     char FGJSBBase::fgdef[6]    = {27, '[', '3', '9', 'm', '\0' };
63 #else
64     char FGJSBBase::highint[5]  = {'\0' };
65     char FGJSBBase::halfint[5]  = {'\0' };
66     char FGJSBBase::normint[6]  = {'\0' };
67     char FGJSBBase::reset[5]    = {'\0' };
68     char FGJSBBase::underon[5]  = {'\0' };
69     char FGJSBBase::underoff[6] = {'\0' };
70     char FGJSBBase::fgblue[6]   = {'\0' };
71     char FGJSBBase::fgcyan[6]   = {'\0' };
72     char FGJSBBase::fgred[6]    = {'\0' };
73     char FGJSBBase::fggreen[6]  = {'\0' };
74     char FGJSBBase::fgdef[6]    = {'\0' };
75 #endif
76
77 const double FGJSBBase::radtodeg = 57.29578;
78 const double FGJSBBase::degtorad = 1.745329E-2;
79 const double FGJSBBase::hptoftlbssec = 550.0;
80 const double FGJSBBase::psftoinhg = 0.014138;
81 const double FGJSBBase::psftopa = 47.88;
82 const double FGJSBBase::fpstokts = 0.592484;
83 const double FGJSBBase::ktstofps = 1.68781;
84 const double FGJSBBase::inchtoft = 0.08333333;
85 const double FGJSBBase::in3tom3 = 1.638706E-5;
86 const double FGJSBBase::m3toft3 = 1.0/(fttom*fttom*fttom);
87 const double FGJSBBase::inhgtopa = 3386.38;
88 const double FGJSBBase::fttom = 0.3048;
89 double FGJSBBase::Reng = 1716.0;
90 const double FGJSBBase::SHRatio = 1.40;
91
92 // Note that definition of lbtoslug by the inverse of slugtolb and not
93 // to a different constant you can also get from some tables will make
94 // lbtoslug*slugtolb == 1 up to the magnitude of roundoff. So converting from
95 // slug to lb and back will yield to the original value you started with up
96 // to the magnitude of roundoff.
97 // Taken from units gnu commandline tool
98 const double FGJSBBase::slugtolb = 32.174049;
99 const double FGJSBBase::lbtoslug = 1.0/slugtolb;
100 const double FGJSBBase::kgtolb = 2.20462;
101 const double FGJSBBase::kgtoslug = 0.06852168;
102
103 const string FGJSBBase::needed_cfg_version = "2.0";
104 const string FGJSBBase::JSBSim_version = "1.0 "__DATE__" "__TIME__;
105
106 std::queue <FGJSBBase::Message> FGJSBBase::Messages;
107 FGJSBBase::Message FGJSBBase::localMsg;
108 unsigned int FGJSBBase::messageId = 0;
109
110 short FGJSBBase::debug_lvl  = 1;
111
112 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
113
114 void FGJSBBase::PutMessage(const Message& msg)
115 {
116   Messages.push(msg);
117 }
118
119 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120
121 void FGJSBBase::PutMessage(const string& text)
122 {
123   Message msg;
124   msg.text = text;
125   msg.messageId = messageId++;
126   msg.subsystem = "FDM";
127   msg.type = Message::eText;
128   Messages.push(msg);
129 }
130
131 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132
133 void FGJSBBase::PutMessage(const string& text, bool bVal)
134 {
135   Message msg;
136   msg.text = text;
137   msg.messageId = messageId++;
138   msg.subsystem = "FDM";
139   msg.type = Message::eBool;
140   msg.bVal = bVal;
141   Messages.push(msg);
142 }
143
144 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145
146 void FGJSBBase::PutMessage(const string& text, int iVal)
147 {
148   Message msg;
149   msg.text = text;
150   msg.messageId = messageId++;
151   msg.subsystem = "FDM";
152   msg.type = Message::eInteger;
153   msg.bVal = (iVal != 0);
154   Messages.push(msg);
155 }
156
157 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158
159 void FGJSBBase::PutMessage(const string& text, double dVal)
160 {
161   Message msg;
162   msg.text = text;
163   msg.messageId = messageId++;
164   msg.subsystem = "FDM";
165   msg.type = Message::eDouble;
166   msg.bVal = (dVal != 0.0);
167   Messages.push(msg);
168 }
169
170 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
171
172 int FGJSBBase::SomeMessages(void)
173 {
174   return !Messages.empty();
175 }
176
177 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
178
179 FGJSBBase::Message* FGJSBBase::ProcessMessage(void)
180 {
181   if (Messages.empty()) return NULL;
182   localMsg = Messages.front();
183   Messages.pop();
184   return &localMsg;
185 }
186
187 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
188
189 void FGJSBBase::disableHighLighting(void) {
190   highint[0]='\0';
191   halfint[0]='\0';
192   normint[0]='\0';
193   reset[0]='\0';
194   underon[0]='\0';
195   underoff[0]='\0';
196   fgblue[0]='\0';
197   fgcyan[0]='\0';
198   fgred[0]='\0';
199   fggreen[0]='\0';
200   fgdef[0]='\0';
201 }
202
203 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
204
205 } // namespace JSBSim
206