]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGJSBBase.cpp
Fix for X-15 crash.
[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 static const char *IdSrc = "$Id$";
41 static const char *IdHdr = ID_JSBBASE;
42
43 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
44 CLASS IMPLEMENTATION
45 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
46
47 char FGJSBBase::highint[5]  = {27, '[', '1', 'm', '\0'      };
48 char FGJSBBase::halfint[5]  = {27, '[', '2', 'm', '\0'      };
49 char FGJSBBase::normint[6]  = {27, '[', '2', '2', 'm', '\0' };
50 char FGJSBBase::reset[5]    = {27, '[', '0', 'm', '\0'      };
51 char FGJSBBase::underon[5]  = {27, '[', '4', 'm', '\0'      };
52 char FGJSBBase::underoff[6] = {27, '[', '2', '4', 'm', '\0' };
53 char FGJSBBase::fgblue[6]   = {27, '[', '3', '4', 'm', '\0' };
54 char FGJSBBase::fgcyan[6]   = {27, '[', '3', '6', 'm', '\0' };
55 char FGJSBBase::fgred[6]    = {27, '[', '3', '1', 'm', '\0' };
56 char FGJSBBase::fggreen[6]  = {27, '[', '3', '2', 'm', '\0' };
57 char FGJSBBase::fgdef[6]    = {27, '[', '3', '9', 'm', '\0' };
58
59 const double FGJSBBase::radtodeg = 57.29578;
60 const double FGJSBBase::degtorad = 1.745329E-2;
61 const double FGJSBBase::hptoftlbssec = 550.0;
62 const double FGJSBBase::psftoinhg = 0.014138;
63 const double FGJSBBase::fpstokts = 0.592484;
64 const double FGJSBBase::ktstofps = 1.68781;
65 const double FGJSBBase::inchtoft = 0.08333333;
66 const double FGJSBBase::in3tom3 = 1.638706E-5;
67 const double FGJSBBase::Reng = 1716.0;
68 const double FGJSBBase::SHRatio = 1.40;
69 const string FGJSBBase::needed_cfg_version = "1.60";
70 const string FGJSBBase::JSBSim_version = "0.9.2";
71
72 queue <FGJSBBase::Message*> FGJSBBase::Messages;
73 FGJSBBase::Message FGJSBBase::localMsg;
74 unsigned int FGJSBBase::messageId = 0; 
75 unsigned int FGJSBBase::frame = 0;
76
77 short FGJSBBase::debug_lvl  = 0;
78
79 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80
81 FGJSBBase::FGJSBBase()
82 {
83 }
84
85 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86
87 FGJSBBase::Message* FGJSBBase::PutMessage(Message* msg)
88 {
89   Messages.push(msg);
90   return msg;
91 }
92
93 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94
95 FGJSBBase::Message* FGJSBBase::PutMessage(string text)
96 {
97   Message *msg = new Message();
98   msg->text = text;
99   msg->messageId = messageId++;
100   msg->subsystem = "FDM";
101   msg->type = Message::eText;
102   Messages.push(msg);
103   return msg;
104 }
105
106 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107
108 FGJSBBase::Message* FGJSBBase::PutMessage(string text, bool bVal)
109 {
110   Message *msg = new Message();
111   msg->text = text;
112   msg->messageId = messageId++;
113   msg->subsystem = "FDM";
114   msg->type = Message::eBool;
115   msg->bVal = bVal;
116   Messages.push(msg);
117   return msg;
118 }
119
120 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121
122 FGJSBBase::Message* FGJSBBase::PutMessage(string text, int iVal)
123 {
124   Message *msg = new Message();
125   msg->text = text;
126   msg->messageId = messageId++;
127   msg->subsystem = "FDM";
128   msg->type = Message::eInteger;
129   msg->bVal = (iVal != 0);
130   Messages.push(msg);
131   return msg;
132 }
133
134 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135
136 FGJSBBase::Message* FGJSBBase::PutMessage(string text, double dVal)
137 {
138   Message *msg = new Message();
139   msg->text = text;
140   msg->messageId = messageId++;
141   msg->subsystem = "FDM";
142   msg->type = Message::eDouble;
143   msg->bVal = (dVal != 0.0);
144   Messages.push(msg);
145   return msg;
146 }
147
148 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
149
150 FGJSBBase::Message* FGJSBBase::ReadMessage(void)
151 {
152   if (!Messages.empty()) return Messages.front();
153   else                   return NULL;
154 }
155
156 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157
158 FGJSBBase::Message* FGJSBBase::ProcessMessage(void)
159 {
160   if (!Messages.empty())
161     localMsg = *(Messages.front());
162   else 
163     return NULL;
164   Messages.pop();
165   return &localMsg;
166 }
167
168 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169
170 void FGJSBBase::disableHighLighting(void) {
171   highint[0]='\0';
172   halfint[0]='\0';
173   normint[0]='\0';
174   reset[0]='\0';
175   underon[0]='\0';
176   underoff[0]='\0';
177   fgblue[0]='\0';
178   fgcyan[0]='\0';
179   fgred[0]='\0';
180   fggreen[0]='\0';
181   fgdef[0]='\0';
182 }
183
184 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185
186