]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/FGAuxiliary.cpp
Sync. with JSBSim CVS
[flightgear.git] / src / FDM / JSBSim / models / FGAuxiliary.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGAuxiliary.cpp
4  Author:       Tony Peden, Jon Berndt
5  Date started: 01/26/99
6  Purpose:      Calculates additional parameters needed by the visual system, etc.
7  Called by:    FGFDMExec
8
9  ------------- Copyright (C) 1999  Jon S. Berndt (jon@jsbsim.org) -------------
10
11  This program is free software; you can redistribute it and/or modify it under
12  the terms of the GNU Lesser General Public License as published by the Free Software
13  Foundation; either version 2 of the License, or (at your option) any later
14  version.
15
16  This program is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
19  details.
20
21  You should have received a copy of the GNU Lesser General Public License along with
22  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23  Place - Suite 330, Boston, MA  02111-1307, USA.
24
25  Further information about the GNU Lesser General Public License can also be found on
26  the world wide web at http://www.gnu.org.
27
28 FUNCTIONAL DESCRIPTION
29 --------------------------------------------------------------------------------
30 This class calculates various auxiliary parameters.
31
32 REFERENCES
33   Anderson, John D. "Introduction to Flight", 3rd Edition, McGraw-Hill, 1989
34                     pgs. 112-126
35 HISTORY
36 --------------------------------------------------------------------------------
37 01/26/99   JSB   Created
38
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 INCLUDES
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
42
43 #include "FGAuxiliary.h"
44 #include "FGAerodynamics.h"
45 #include "FGPropagate.h"
46 #include "FGAtmosphere.h"
47 #include "FGFDMExec.h"
48 #include "FGAircraft.h"
49 #include "FGInertial.h"
50 #include "FGExternalReactions.h"
51 #include "FGBuoyantForces.h"
52 #include "FGGroundReactions.h"
53 #include "FGPropulsion.h"
54 #include "FGMassBalance.h"
55 #include "input_output/FGPropertyManager.h"
56 #include <iostream>
57
58 using namespace std;
59
60 namespace JSBSim {
61
62 static const char *IdSrc = "$Id: FGAuxiliary.cpp,v 1.45 2010/11/18 12:38:06 jberndt Exp $";
63 static const char *IdHdr = ID_AUXILIARY;
64
65 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 CLASS IMPLEMENTATION
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
68
69
70 FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
71 {
72   Name = "FGAuxiliary";
73   vcas = veas = pt = tat = 0;
74   psl = rhosl = 1;
75   qbar = 0;
76   qbarUW = 0.0;
77   qbarUV = 0.0;
78   Re = 0.0;
79   Mach = 0.0;
80   alpha = beta = 0.0;
81   adot = bdot = 0.0;
82   gamma = Vt = Vground = 0.0;
83   psigt = 0.0;
84   day_of_year = 1;
85   seconds_in_day = 0.0;
86   hoverbmac = hoverbcg = 0.0;
87   tatc = RankineToCelsius(tat);
88
89   vPilotAccel.InitMatrix();
90   vPilotAccelN.InitMatrix();
91   vToEyePt.InitMatrix();
92   vAeroPQR.InitMatrix();
93   vEulerRates.InitMatrix();
94
95   bind();
96
97   Debug(0);
98 }
99
100 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101
102 bool FGAuxiliary::InitModel(void)
103 {
104   if (!FGModel::InitModel()) return false;
105
106   vcas = veas = pt = tat = 0;
107   psl = rhosl = 1;
108   qbar = 0;
109   qbarUW = 0.0;
110   qbarUV = 0.0;
111   Mach = 0.0;
112   alpha = beta = 0.0;
113   adot = bdot = 0.0;
114   gamma = Vt = Vground = 0.0;
115   psigt = 0.0;
116   day_of_year = 1;
117   seconds_in_day = 0.0;
118   hoverbmac = hoverbcg = 0.0;
119
120   vPilotAccel.InitMatrix();
121   vPilotAccelN.InitMatrix();
122   vToEyePt.InitMatrix();
123   vAeroPQR.InitMatrix();
124   vEulerRates.InitMatrix();
125
126   return true;
127 }
128   
129 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
130
131 FGAuxiliary::~FGAuxiliary()
132 {
133   Debug(1);
134 }
135
136 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
137
138 bool FGAuxiliary::Run()
139 {
140   double A,B,D;
141
142   if (FGModel::Run()) return true; // return true if error returned from base class
143   if (FDMExec->Holding()) return false;
144
145   RunPreFunctions();
146
147   const double density = FDMExec->GetAtmosphere()->GetDensity();
148   const double soundspeed = FDMExec->GetAtmosphere()->GetSoundSpeed();
149   const double DistanceAGL = FDMExec->GetPropagate()->GetDistanceAGL();
150   const double wingspan = FDMExec->GetAircraft()->GetWingSpan();
151   const FGMatrix33& Tl2b = FDMExec->GetPropagate()->GetTl2b();
152   const FGMatrix33& Tb2l = FDMExec->GetPropagate()->GetTb2l();
153
154   const FGColumnVector3& vPQR = FDMExec->GetPropagate()->GetPQR();
155   const FGColumnVector3& vUVW = FDMExec->GetPropagate()->GetUVW();
156   const FGColumnVector3& vUVWdot = FDMExec->GetPropagate()->GetUVWdot();
157   const FGColumnVector3& vVel = FDMExec->GetPropagate()->GetVel();
158
159   p = FDMExec->GetAtmosphere()->GetPressure();
160   rhosl = FDMExec->GetAtmosphere()->GetDensitySL();
161   psl = FDMExec->GetAtmosphere()->GetPressureSL();
162   sat = FDMExec->GetAtmosphere()->GetTemperature();
163
164 // Rotation
165
166   double cTht = FDMExec->GetPropagate()->GetCosEuler(eTht);
167   double sTht = FDMExec->GetPropagate()->GetSinEuler(eTht);
168   double cPhi = FDMExec->GetPropagate()->GetCosEuler(ePhi);
169   double sPhi = FDMExec->GetPropagate()->GetSinEuler(ePhi);
170
171   vEulerRates(eTht) = vPQR(eQ)*cPhi - vPQR(eR)*sPhi;
172   if (cTht != 0.0) {
173     vEulerRates(ePsi) = (vPQR(eQ)*sPhi + vPQR(eR)*cPhi)/cTht;
174     vEulerRates(ePhi) = vPQR(eP) + vEulerRates(ePsi)*sTht;
175   }
176
177 // Combine the wind speed with aircraft speed to obtain wind relative speed
178   FGColumnVector3 wind = Tl2b*FDMExec->GetAtmosphere()->GetTotalWindNED();
179   vAeroPQR = vPQR - FDMExec->GetAtmosphere()->GetTurbPQR();
180   vAeroUVW = vUVW - wind;
181
182   Vt = vAeroUVW.Magnitude();
183   if ( Vt > 1.0 ) {
184     if (vAeroUVW(eW) != 0.0)
185       alpha = vAeroUVW(eU)*vAeroUVW(eU) > 0.0 ? atan2(vAeroUVW(eW), vAeroUVW(eU)) : 0.0;
186     if (vAeroUVW(eV) != 0.0)
187       beta = vAeroUVW(eU)*vAeroUVW(eU)+vAeroUVW(eW)*vAeroUVW(eW) > 0.0 ? atan2(vAeroUVW(eV),
188              sqrt(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW))) : 0.0;
189
190     double mUW = (vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW));
191     double signU=1;
192     if (vAeroUVW(eU) < 0.0) signU=-1;
193
194     if ( mUW < 1.0 ) {
195       adot = 0.0;
196       bdot = 0.0;
197     } else {
198       adot = (vAeroUVW(eU)*vUVWdot(eW) - vAeroUVW(eW)*vUVWdot(eU))/mUW;
199       bdot = (signU*mUW*vUVWdot(eV) - vAeroUVW(eV)*(vAeroUVW(eU)*vUVWdot(eU)
200               + vAeroUVW(eW)*vUVWdot(eW)))/(Vt*Vt*sqrt(mUW));
201     }
202   } else {
203     alpha = beta = adot = bdot = 0;
204   }
205
206   Re = Vt * FDMExec->GetAircraft()->Getcbar() / FDMExec->GetAtmosphere()->GetKinematicViscosity();
207
208   qbar = 0.5*density*Vt*Vt;
209   qbarUW = 0.5*density*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eW)*vAeroUVW(eW));
210   qbarUV = 0.5*density*(vAeroUVW(eU)*vAeroUVW(eU) + vAeroUVW(eV)*vAeroUVW(eV));
211   Mach = Vt / soundspeed;
212   MachU = vMachUVW(eU) = vAeroUVW(eU) / soundspeed;
213   vMachUVW(eV) = vAeroUVW(eV) / soundspeed;
214   vMachUVW(eW) = vAeroUVW(eW) / soundspeed;
215
216 // Position
217
218   Vground = sqrt( vVel(eNorth)*vVel(eNorth) + vVel(eEast)*vVel(eEast) );
219
220   psigt = atan2(vVel(eEast), vVel(eNorth));
221   if (psigt < 0.0) psigt += 2*M_PI;
222   gamma = atan2(-vVel(eDown), Vground);
223
224   tat = sat*(1 + 0.2*Mach*Mach); // Total Temperature, isentropic flow
225   tatc = RankineToCelsius(tat);
226
227   if (MachU < 1) {   // Calculate total pressure assuming isentropic flow
228     pt = p*pow((1 + 0.2*MachU*MachU),3.5);
229   } else {
230     // Use Rayleigh pitot tube formula for normal shock in front of pitot tube
231     B = 5.76*MachU*MachU/(5.6*MachU*MachU - 0.8);
232     D = (2.8*MachU*MachU-0.4)*0.4167;
233     pt = p*pow(B,3.5)*D;
234   }
235
236   A = pow(((pt-p)/psl+1),0.28571);
237   if (MachU > 0.0) {
238     vcas = sqrt(7*psl/rhosl*(A-1));
239     veas = sqrt(2*qbar/rhosl);
240   } else {
241     vcas = veas = 0.0;
242   }
243
244   const double SLgravity = FDMExec->GetInertial()->SLgravity();
245
246   vPilotAccel.InitMatrix();
247   if ( Vt > 1.0 ) {
248      vAircraftAccel = FDMExec->GetAircraft()->GetBodyAccel();
249      // Nz is Acceleration in "g's", along normal axis (-Z body axis)
250      Nz = -vAircraftAccel(eZ)/SLgravity;
251      vToEyePt = FDMExec->GetMassBalance()->StructuralToBody(FDMExec->GetAircraft()->GetXYZep());
252      vPilotAccel = vAircraftAccel + FDMExec->GetPropagate()->GetPQRdot() * vToEyePt;
253      vPilotAccel += vPQR * (vPQR * vToEyePt);
254   } else {
255      // The line below handles low velocity (and on-ground) cases, basically
256      // representing the opposite of the force that the landing gear would
257      // exert on the ground (which is just the total weight). This eliminates
258      // any jitter that could be introduced by the landing gear. Theoretically,
259      // this branch could be eliminated, with a penalty of having a short
260      // transient at startup (lasting only a fraction of a second).
261      vPilotAccel = Tl2b * FGColumnVector3( 0.0, 0.0, -SLgravity );
262      Nz = -vPilotAccel(eZ)/SLgravity;
263   }
264
265   vPilotAccelN = vPilotAccel/SLgravity;
266
267   // VRP computation
268   const FGLocation& vLocation = FDMExec->GetPropagate()->GetLocation();
269   const FGColumnVector3& vrpStructural = FDMExec->GetAircraft()->GetXYZvrp();
270   const FGColumnVector3 vrpBody = FDMExec->GetMassBalance()->StructuralToBody( vrpStructural );
271   const FGColumnVector3 vrpLocal = Tb2l * vrpBody;
272   vLocationVRP = vLocation.LocalToLocation( vrpLocal );
273
274   // Recompute some derived values now that we know the dependent parameters values ...
275   hoverbcg = DistanceAGL / wingspan;
276
277   FGColumnVector3 vMac = Tb2l*FDMExec->GetMassBalance()->StructuralToBody(FDMExec->GetAircraft()->GetXYZrp());
278   hoverbmac = (DistanceAGL + vMac(3)) / wingspan;
279
280   // when all model are executed, 
281   // please calculate the distance from the initial point
282
283   CalculateRelativePosition();
284
285   RunPostFunctions();
286
287   return false;
288 }
289
290 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
291 //
292 // A positive headwind is blowing with you, a negative headwind is blowing against you.
293 // psi is the direction the wind is blowing *towards*.
294
295 double FGAuxiliary::GetHeadWind(void) const
296 {
297   double psiw,vw;
298
299   psiw = FDMExec->GetAtmosphere()->GetWindPsi();
300   vw = FDMExec->GetAtmosphere()->GetTotalWindNED().Magnitude();
301
302   return vw*cos(psiw - FDMExec->GetPropagate()->GetEuler(ePsi));
303 }
304
305 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306 //
307 // A positive crosswind is blowing towards the right (from teh perspective of the
308 // pilot). A negative crosswind is blowing towards the -Y direction (left).
309 // psi is the direction the wind is blowing *towards*.
310
311 double FGAuxiliary::GetCrossWind(void) const
312 {
313   double psiw,vw;
314
315   psiw = FDMExec->GetAtmosphere()->GetWindPsi();
316   vw = FDMExec->GetAtmosphere()->GetTotalWindNED().Magnitude();
317
318   return  vw*sin(psiw - FDMExec->GetPropagate()->GetEuler(ePsi));
319 }
320
321 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
322
323 double FGAuxiliary::GethVRP(void) const
324 {
325   return vLocationVRP.GetRadius() - FDMExec->GetPropagate()->GetSeaLevelRadius();
326 }
327
328 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
329
330 void FGAuxiliary::bind(void)
331 {
332   typedef double (FGAuxiliary::*PMF)(int) const;
333   typedef double (FGAuxiliary::*PF)(void) const;
334   PropertyManager->Tie("propulsion/tat-r", this, &FGAuxiliary::GetTotalTemperature);
335   PropertyManager->Tie("propulsion/tat-c", this, &FGAuxiliary::GetTAT_C);
336   PropertyManager->Tie("propulsion/pt-lbs_sqft", this, &FGAuxiliary::GetTotalPressure);
337   PropertyManager->Tie("velocities/vc-fps", this, &FGAuxiliary::GetVcalibratedFPS);
338   PropertyManager->Tie("velocities/vc-kts", this, &FGAuxiliary::GetVcalibratedKTS);
339   PropertyManager->Tie("velocities/ve-fps", this, &FGAuxiliary::GetVequivalentFPS);
340   PropertyManager->Tie("velocities/ve-kts", this, &FGAuxiliary::GetVequivalentKTS);
341   PropertyManager->Tie("velocities/machU", this, &FGAuxiliary::GetMachU);
342   PropertyManager->Tie("velocities/p-aero-rad_sec", this, eX, (PMF)&FGAuxiliary::GetAeroPQR);
343   PropertyManager->Tie("velocities/q-aero-rad_sec", this, eY, (PMF)&FGAuxiliary::GetAeroPQR);
344   PropertyManager->Tie("velocities/r-aero-rad_sec", this, eZ, (PMF)&FGAuxiliary::GetAeroPQR);
345   PropertyManager->Tie("velocities/phidot-rad_sec", this, ePhi, (PMF)&FGAuxiliary::GetEulerRates);
346   PropertyManager->Tie("velocities/thetadot-rad_sec", this, eTht, (PMF)&FGAuxiliary::GetEulerRates);
347   PropertyManager->Tie("velocities/psidot-rad_sec", this, ePsi, (PMF)&FGAuxiliary::GetEulerRates);
348   PropertyManager->Tie("velocities/u-aero-fps", this, eU, (PMF)&FGAuxiliary::GetAeroUVW);
349   PropertyManager->Tie("velocities/v-aero-fps", this, eV, (PMF)&FGAuxiliary::GetAeroUVW);
350   PropertyManager->Tie("velocities/w-aero-fps", this, eW, (PMF)&FGAuxiliary::GetAeroUVW);
351   PropertyManager->Tie("velocities/vt-fps", this, &FGAuxiliary::GetVt, &FGAuxiliary::SetVt, true);
352   PropertyManager->Tie("velocities/mach", this, &FGAuxiliary::GetMach, &FGAuxiliary::SetMach, true);
353   PropertyManager->Tie("velocities/vg-fps", this, &FGAuxiliary::GetVground);
354   PropertyManager->Tie("accelerations/a-pilot-x-ft_sec2", this, eX, (PMF)&FGAuxiliary::GetPilotAccel);
355   PropertyManager->Tie("accelerations/a-pilot-y-ft_sec2", this, eY, (PMF)&FGAuxiliary::GetPilotAccel);
356   PropertyManager->Tie("accelerations/a-pilot-z-ft_sec2", this, eZ, (PMF)&FGAuxiliary::GetPilotAccel);
357   PropertyManager->Tie("accelerations/n-pilot-x-norm", this, eX, (PMF)&FGAuxiliary::GetNpilot);
358   PropertyManager->Tie("accelerations/n-pilot-y-norm", this, eY, (PMF)&FGAuxiliary::GetNpilot);
359   PropertyManager->Tie("accelerations/n-pilot-z-norm", this, eZ, (PMF)&FGAuxiliary::GetNpilot);
360   PropertyManager->Tie("accelerations/Nz", this, &FGAuxiliary::GetNz);
361   /* PropertyManager->Tie("atmosphere/headwind-fps", this, &FGAuxiliary::GetHeadWind, true);
362   PropertyManager->Tie("atmosphere/crosswind-fps", this, &FGAuxiliary::GetCrossWind, true); */
363   PropertyManager->Tie("aero/alpha-rad", this, (PF)&FGAuxiliary::Getalpha, &FGAuxiliary::Setalpha, true);
364   PropertyManager->Tie("aero/beta-rad", this, (PF)&FGAuxiliary::Getbeta, &FGAuxiliary::Setbeta, true);
365   PropertyManager->Tie("aero/mag-beta-rad", this, (PF)&FGAuxiliary::GetMagBeta);
366   PropertyManager->Tie("aero/alpha-deg", this, inDegrees, (PMF)&FGAuxiliary::Getalpha);
367   PropertyManager->Tie("aero/beta-deg", this, inDegrees, (PMF)&FGAuxiliary::Getbeta);
368   PropertyManager->Tie("aero/mag-beta-deg", this, inDegrees, (PMF)&FGAuxiliary::GetMagBeta);
369   PropertyManager->Tie("aero/Re", this, &FGAuxiliary::GetReynoldsNumber);
370   PropertyManager->Tie("aero/qbar-psf", this, &FGAuxiliary::Getqbar, &FGAuxiliary::Setqbar, true);
371   PropertyManager->Tie("aero/qbarUW-psf", this, &FGAuxiliary::GetqbarUW, &FGAuxiliary::SetqbarUW, true);
372   PropertyManager->Tie("aero/qbarUV-psf", this, &FGAuxiliary::GetqbarUV, &FGAuxiliary::SetqbarUV, true);
373   PropertyManager->Tie("aero/alphadot-rad_sec", this, (PF)&FGAuxiliary::Getadot, &FGAuxiliary::Setadot, true);
374   PropertyManager->Tie("aero/betadot-rad_sec", this, (PF)&FGAuxiliary::Getbdot, &FGAuxiliary::Setbdot, true);
375   PropertyManager->Tie("aero/alphadot-deg_sec", this, inDegrees, (PMF)&FGAuxiliary::Getadot);
376   PropertyManager->Tie("aero/betadot-deg_sec", this, inDegrees, (PMF)&FGAuxiliary::Getbdot);
377   PropertyManager->Tie("aero/h_b-cg-ft", this, &FGAuxiliary::GetHOverBCG);
378   PropertyManager->Tie("aero/h_b-mac-ft", this, &FGAuxiliary::GetHOverBMAC);
379   PropertyManager->Tie("flight-path/gamma-rad", this, &FGAuxiliary::GetGamma, &FGAuxiliary::SetGamma);
380   PropertyManager->Tie("flight-path/psi-gt-rad", this, &FGAuxiliary::GetGroundTrack);
381
382   PropertyManager->Tie("position/distance-from-start-lon-mt", this, &FGAuxiliary::GetLongitudeRelativePosition);
383   PropertyManager->Tie("position/distance-from-start-lat-mt", this, &FGAuxiliary::GetLatitudeRelativePosition);
384   PropertyManager->Tie("position/distance-from-start-mag-mt", this, &FGAuxiliary::GetDistanceRelativePosition);
385   PropertyManager->Tie("position/vrp-gc-latitude_deg", &vLocationVRP, &FGLocation::GetLatitudeDeg);
386   PropertyManager->Tie("position/vrp-longitude_deg", &vLocationVRP, &FGLocation::GetLongitudeDeg);
387   PropertyManager->Tie("position/vrp-radius-ft", &vLocationVRP, &FGLocation::GetRadius);
388 }
389
390 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
391
392 void FGAuxiliary::CalculateRelativePosition(void)
393
394   const double earth_radius_mt = FDMExec->GetInertial()->GetRefRadius()*fttom;
395   lat_relative_position=(FDMExec->GetPropagate()->GetLatitude()  - FDMExec->GetIC()->GetLatitudeDegIC() *degtorad)*earth_radius_mt;
396   lon_relative_position=(FDMExec->GetPropagate()->GetLongitude() - FDMExec->GetIC()->GetLongitudeDegIC()*degtorad)*earth_radius_mt;
397   relative_position = sqrt(lat_relative_position*lat_relative_position + lon_relative_position*lon_relative_position);
398 };
399
400 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
401
402 double FGAuxiliary::BadUnits(void) const
403 {
404   cerr << "Bad units" << endl; return 0.0;
405 }
406
407 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
408 //    The bitmasked value choices are as follows:
409 //    unset: In this case (the default) JSBSim would only print
410 //       out the normally expected messages, essentially echoing
411 //       the config files as they are read. If the environment
412 //       variable is not set, debug_lvl is set to 1 internally
413 //    0: This requests JSBSim not to output any messages
414 //       whatsoever.
415 //    1: This value explicity requests the normal JSBSim
416 //       startup messages
417 //    2: This value asks for a message to be printed out when
418 //       a class is instantiated
419 //    4: When this value is set, a message is displayed when a
420 //       FGModel object executes its Run() method
421 //    8: When this value is set, various runtime state variables
422 //       are printed out periodically
423 //    16: When set various parameters are sanity checked and
424 //       a message is printed out when they go out of bounds
425
426 void FGAuxiliary::Debug(int from)
427 {
428   if (debug_lvl <= 0) return;
429
430   if (debug_lvl & 1) { // Standard console startup message output
431     if (from == 0) { // Constructor
432
433     }
434   }
435   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
436     if (from == 0) cout << "Instantiated: FGAuxiliary" << endl;
437     if (from == 1) cout << "Destroyed:    FGAuxiliary" << endl;
438   }
439   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
440   }
441   if (debug_lvl & 8 ) { // Runtime state variables
442   }
443   if (debug_lvl & 16) { // Sanity checking
444     if (Mach > 100 || Mach < 0.00)
445       cout << "FGPropagate::Mach is out of bounds: " << Mach << endl;
446     if (qbar > 1e6 || qbar < 0.00)
447       cout << "FGPropagate::qbar is out of bounds: " << qbar << endl;
448   }
449   if (debug_lvl & 64) {
450     if (from == 0) { // Constructor
451       cout << IdSrc << endl;
452       cout << IdHdr << endl;
453     }
454   }
455 }
456
457 } // namespace JSBSim