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