]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/models/propulsion/FGTurboProp.cpp
Sync w. JSBSim CVS (merge from PRE_OSG_PLIB_20061029 branch)
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGTurboProp.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGTurboProp.cpp
4  Author:       Jiri "Javky" Javurek
5                based on SimTurbine and Turbine engine from David Culp
6  Date started: 05/14/2004
7  Purpose:      This module models a turbo propeller engine.
8
9  ------------- Copyright (C) 2004  (javky@email.cz) ---------
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
31 This class descends from the FGEngine class and models a Turbo propeller engine
32 based on parameters given in the engine config file for this class
33
34 HISTORY
35 --------------------------------------------------------------------------------
36 05/14/2004  Created
37
38 //JVK (mark)
39
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 INCLUDES
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43
44 #include <vector>
45 #include <sstream>
46 #include "FGTurboProp.h"
47
48 #include "FGPropeller.h"
49
50 namespace JSBSim {
51
52 static const char *IdSrc = "$Id$";
53 static const char *IdHdr = ID_TURBOPROP;
54
55 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56 CLASS IMPLEMENTATION
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
58
59 FGTurboProp::FGTurboProp(FGFDMExec* exec, Element *el, int engine_number)
60   : FGEngine(exec, el, engine_number)
61 {
62   SetDefaults();
63
64   Load(exec, el);
65   Debug(0);
66 }
67
68 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69
70 FGTurboProp::~FGTurboProp()
71 {
72   Debug(1);
73 }
74
75 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76
77 bool FGTurboProp::Load(FGFDMExec* exec, Element *el)
78 {
79   char property_prefix[80];
80   snprintf(property_prefix, 80, "propulsion/engine[%u]/", EngineNumber);
81
82   IdleFF=-1;
83   MaxStartingTime = 999999; //very big timeout -> infinite
84   Ielu_max_torque=-1;
85
86 // ToDo: Need to make sure units are properly accounted for below.
87
88   if (el->FindElement("milthrust"))
89     MilThrust = el->FindElementValueAsNumberConvertTo("milthrust","LBS");
90   if (el->FindElement("idlen1"))
91     IdleN1 = el->FindElementValueAsNumber("idlen1");
92   if (el->FindElement("idlen2"))
93     IdleN2 = el->FindElementValueAsNumber("idlen1");
94   if (el->FindElement("maxn1"))
95     MaxN1 = el->FindElementValueAsNumber("maxn1");
96   if (el->FindElement("maxn2"))
97     MaxN2 = el->FindElementValueAsNumber("maxn2");
98   if (el->FindElement("betarangeend"))
99     BetaRangeThrottleEnd = el->FindElementValueAsNumber("betarangeend")/100.0;
100   if (el->FindElement("reversemaxpower"))
101     ReverseMaxPower = el->FindElementValueAsNumber("reversemaxpower")/100.0;
102
103   if (el->FindElement("maxpower"))
104     MaxPower = el->FindElementValueAsNumber("maxpower");
105   if (el->FindElement("idlefuelflow"))
106     IdleFF = el->FindElementValueAsNumber("idlefuelflow");
107   if (el->FindElement("psfc"))
108     PSFC = el->FindElementValueAsNumber("psfc");
109   if (el->FindElement("n1idle_max_delay"))
110     Idle_Max_Delay = el->FindElementValueAsNumber("n1idle_max_delay");
111   if (el->FindElement("maxstartingtime"))
112     MaxStartingTime = el->FindElementValueAsNumber("maxstartingtime");
113   if (el->FindElement("startern1"))
114     StarterN1 = el->FindElementValueAsNumber("startern1");
115   if (el->FindElement("ielumaxtorque"))
116     Ielu_max_torque = el->FindElementValueAsNumber("ielumaxtorque");
117   if (el->FindElement("itt_delay"))
118     ITT_Delay = el->FindElementValueAsNumber("itt_delay");
119
120   Element *table_element;
121   string name;
122   FGPropertyManager* PropertyManager = exec->GetPropertyManager();
123
124   while (true) {
125     table_element = el->FindNextElement("table");
126     if (!table_element) break;
127     name = table_element->GetAttributeValue("name");
128     if (name == "EnginePowerVC") {
129       EnginePowerVC = new FGTable(PropertyManager, table_element);
130     } else if (name == "EnginePowerRPM_N1") {
131       EnginePowerRPM_N1 = new FGTable(PropertyManager, table_element);
132     } else if (name == "ITT_N1") {
133       ITT_N1 = new FGTable(PropertyManager, table_element);
134     } else {
135       cerr << "Unknown table type: " << name << " in turbine definition." <<
136       endl;
137     }
138   }
139
140   // Pre-calculations and initializations
141
142   delay=1;
143   N1_factor = MaxN1 - IdleN1;
144   N2_factor = MaxN2 - IdleN2;
145   OilTemp_degK = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556 + 273.0;
146   if (IdleFF==-1) IdleFF = pow(MilThrust, 0.2) * 107.0;  // just an estimate
147
148   cout << "ENG POWER:" << EnginePowerRPM_N1->GetValue(1200,90) << "\n";
149
150   return true;
151 }
152
153 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
154 // The main purpose of Calculate() is to determine what phase the engine should
155 // be in, then call the corresponding function.
156
157 double FGTurboProp::Calculate(void)
158 {
159   TAT = (Auxiliary->GetTotalTemperature() - 491.69) * 0.5555556;
160   dt = State->Getdt() * Propulsion->GetRate();
161
162   ThrottleCmd = FCS->GetThrottleCmd(EngineNumber);
163
164   Prop_RPM = Thruster->GetRPM() * Thruster->GetGearRatio();
165   if (Thruster->GetType() == FGThruster::ttPropeller) {
166     ((FGPropeller*)Thruster)->SetAdvance(FCS->GetPropAdvance(EngineNumber));
167     ((FGPropeller*)Thruster)->SetFeather(FCS->GetPropFeather(EngineNumber));
168     ((FGPropeller*)Thruster)->SetReverse(Reversed);
169     if (Reversed) {
170       ((FGPropeller*)Thruster)->SetReverseCoef(ThrottleCmd);
171     } else {
172       ((FGPropeller*)Thruster)->SetReverseCoef(0.0);
173     }
174   }
175
176   if (Reversed) {
177     if (ThrottleCmd < BetaRangeThrottleEnd) {
178         ThrottleCmd = 0.0;  // idle when in Beta-range
179     } else {
180       // when reversed:
181       ThrottleCmd = (ThrottleCmd-BetaRangeThrottleEnd)/(1-BetaRangeThrottleEnd) * ReverseMaxPower;
182     }
183   }
184
185   // When trimming is finished check if user wants engine OFF or RUNNING
186   if ((phase == tpTrim) && (dt > 0)) {
187     if (Running && !Starved) {
188       phase = tpRun;
189       N2 = IdleN2;
190       N1 = IdleN1;
191       OilTemp_degK = 366.0;
192       Cutoff = false;
193     } else {
194       phase = tpOff;
195       Cutoff = true;
196       Eng_ITT_degC = TAT;
197       Eng_Temperature = TAT;
198       OilTemp_degK = TAT+273.15;
199     }
200   }
201
202   if (!Running && Starter) {
203     if (phase == tpOff) {
204       phase = tpSpinUp;
205       if (StartTime < 0) StartTime=0;
206     }
207   }
208   if (!Running && !Cutoff && (N1 > 15.0)) {
209     phase = tpStart;
210     StartTime = -1;
211   }
212   if (Cutoff && (phase != tpSpinUp)) phase = tpOff;
213   if (dt == 0) phase = tpTrim;
214   if (Starved) phase = tpOff;
215   if (Condition >= 10) {
216     phase = tpOff;
217     StartTime=-1;
218   }
219
220   if (Condition < 1) {
221     if (Ielu_max_torque > 0
222       && -Ielu_max_torque > ((FGPropeller*)(Thruster))->GetTorque()
223       && ThrottleCmd >= OldThrottle ) {
224       ThrottleCmd = OldThrottle - 0.1 * dt; //IELU down
225       Ielu_intervent = true;
226     } else if (Ielu_max_torque > 0 && Ielu_intervent && ThrottleCmd >= OldThrottle) {
227       ThrottleCmd = OldThrottle;
228       ThrottleCmd = OldThrottle + 0.05 * dt; //IELU up
229       Ielu_intervent = true;
230     } else {
231       Ielu_intervent = false;
232     }
233   } else {
234     Ielu_intervent = false;
235   }
236   OldThrottle = ThrottleCmd;
237
238   switch (phase) {
239     case tpOff:    Eng_HP = Off(); break;
240     case tpRun:    Eng_HP = Run(); break;
241     case tpSpinUp: Eng_HP = SpinUp(); break;
242     case tpStart:  Eng_HP = Start(); break;
243     default: Eng_HP = 0;
244   }
245
246   //printf ("EngHP: %lf / Requi: %lf\n",Eng_HP,Prop_Required_Power);
247   return Thruster->Calculate((Eng_HP * hptoftlbssec)-Thruster->GetPowerRequired());
248 }
249
250 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
251
252 double FGTurboProp::Off(void)
253 {
254   double qbar = Auxiliary->Getqbar();
255   Running = false; EngStarting = false;
256
257   FuelFlow_pph = Seek(&FuelFlow_pph, 0, 800.0, 800.0);
258
259   //allow the air turn with generator
260   N1 = ExpSeek(&N1, qbar/15.0, Idle_Max_Delay*2.5, Idle_Max_Delay * 5);
261
262   OilTemp_degK = ExpSeek(&OilTemp_degK,273.15 + TAT, 400 , 400);
263
264   Eng_Temperature = ExpSeek(&Eng_Temperature,TAT,300,400);
265   double ITT_goal = ITT_N1->GetValue(N1,0.1) + ((N1>20) ? 0.0 : (20-N1)/20.0 * Eng_Temperature);
266   Eng_ITT_degC  = ExpSeek(&Eng_ITT_degC,ITT_goal,ITT_Delay,ITT_Delay*1.2);
267
268   OilPressure_psi = (N1/100.0*0.25+(0.1-(OilTemp_degK-273.15)*0.1/80.0)*N1/100.0) / 7692.0e-6; //from MPa to psi
269
270   ConsumeFuel(); // for possible setting Starved = false when fuel tank
271                  // is refilled (fuel crossfeed etc.)
272
273   if (Prop_RPM>5) return -0.012; // friction in engine when propeller spining (estimate)
274   return 0.0;
275 }
276
277 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278
279 double FGTurboProp::Run(void)
280 {
281   double thrust = 0.0, EngPower_HP, eff_coef;
282   Running = true; Starter = false; EngStarting = false;
283
284 //---
285   double old_N1 = N1;
286   N1 = ExpSeek(&N1, IdleN1 + ThrottleCmd * N1_factor, Idle_Max_Delay, Idle_Max_Delay * 2.4);
287
288   EngPower_HP = EnginePowerRPM_N1->GetValue(Prop_RPM,N1);
289   EngPower_HP *= EnginePowerVC->GetValue();
290   if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
291
292   eff_coef = 9.333 - (N1)/12; // 430%Fuel at 60%N1
293   FuelFlow_pph = PSFC * EngPower_HP * eff_coef;
294
295   Eng_Temperature = ExpSeek(&Eng_Temperature,Eng_ITT_degC,300,400);
296   double ITT_goal = ITT_N1->GetValue((N1-old_N1)*300+N1,1);
297   Eng_ITT_degC  = ExpSeek(&Eng_ITT_degC,ITT_goal,ITT_Delay,ITT_Delay*1.2);
298
299   OilPressure_psi = (N1/100.0*0.25+(0.1-(OilTemp_degK-273.15)*0.1/80.0)*N1/100.0) / 7692.0e-6; //from MPa to psi
300 //---
301   EPR = 1.0 + thrust/MilThrust;
302
303   OilTemp_degK = Seek(&OilTemp_degK, 353.15, 0.4-N1*0.001, 0.04);
304
305   ConsumeFuel();
306
307   if (Cutoff) phase = tpOff;
308   if (Starved) phase = tpOff;
309
310   return EngPower_HP;
311 }
312
313 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
314
315 double FGTurboProp::SpinUp(void)
316 {
317   double EngPower_HP;
318   Running = false; EngStarting = true;
319   FuelFlow_pph = 0.0;
320
321   if (!GeneratorPower) {
322     EngStarting=false;
323     phase=tpOff;
324     StartTime = -1;
325     return 0.0;
326   }
327
328   N1 = ExpSeek(&N1, StarterN1, Idle_Max_Delay * 6, Idle_Max_Delay * 2.4);
329
330   Eng_Temperature = ExpSeek(&Eng_Temperature,TAT,300,400);
331   double ITT_goal = ITT_N1->GetValue(N1,0.1) + ((N1>20) ? 0.0 : (20-N1)/20.0 * Eng_Temperature);
332   Eng_ITT_degC  = ExpSeek(&Eng_ITT_degC,ITT_goal,ITT_Delay,ITT_Delay*1.2);
333
334   OilTemp_degK = ExpSeek(&OilTemp_degK,273.15 + TAT, 400 , 400);
335
336   OilPressure_psi = (N1/100.0*0.25+(0.1-(OilTemp_degK-273.15)*0.1/80.0)*N1/100.0) / 7692.0e-6; //from MPa to psi
337   NozzlePosition = 1.0;
338
339   EngPower_HP = EnginePowerRPM_N1->GetValue(Prop_RPM,N1);
340   EngPower_HP *= EnginePowerVC->GetValue();
341   if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
342
343   if (StartTime>=0) StartTime+=dt;
344   if (StartTime > MaxStartingTime && MaxStartingTime > 0) { //start failed due timeout
345     phase = tpOff;
346     StartTime = -1;
347   }
348
349   ConsumeFuel(); // for possible setting Starved = false when fuel tank
350                  // is refilled (fuel crossfeed etc.)
351
352   return EngPower_HP;
353 }
354
355 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
356
357 double FGTurboProp::Start(void)
358 {
359   double EngPower_HP,eff_coef;
360   EngStarting = false;
361   if ((N1 > 15.0) && !Starved) {       // minimum 15% N2 needed for start
362     double old_N1 = N1;
363     Cranking = true;                   // provided for sound effects signal
364     if (N1 < IdleN1) {
365       EngPower_HP = EnginePowerRPM_N1->GetValue(Prop_RPM,N1);
366       EngPower_HP *= EnginePowerVC->GetValue();
367       if (EngPower_HP > MaxPower) EngPower_HP = MaxPower;
368       N1 = ExpSeek(&N1, IdleN1*1.1, Idle_Max_Delay*4, Idle_Max_Delay * 2.4);
369       eff_coef = 9.333 - (N1)/12; // 430%Fuel at 60%N1
370       FuelFlow_pph = PSFC * EngPower_HP * eff_coef;
371       Eng_Temperature = ExpSeek(&Eng_Temperature,Eng_ITT_degC,300,400);
372       double ITT_goal = ITT_N1->GetValue((N1-old_N1)*300+N1,1);
373       Eng_ITT_degC  = ExpSeek(&Eng_ITT_degC,ITT_goal,ITT_Delay,ITT_Delay*1.2);
374
375       OilPressure_psi = (N1/100.0*0.25+(0.1-(OilTemp_degK-273.15)*0.1/80.0)*N1/100.0) / 7692.0e-6; //from MPa to psi
376       OilTemp_degK = Seek(&OilTemp_degK, 353.15, 0.4-N1*0.001, 0.04);
377
378     } else {
379       phase = tpRun;
380       Running = true;
381       Starter = false;
382       Cranking = false;
383       FuelFlow_pph = 0;
384       EngPower_HP=0.0;
385     }
386   } else {                 // no start if N2 < 15% or Starved
387     phase = tpOff;
388     Starter = false;
389   }
390
391   ConsumeFuel();
392
393   return EngPower_HP;
394 }
395
396
397 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
398
399 double FGTurboProp::CalcFuelNeed(void)
400 {
401   return FuelFlow_pph /3600 * State->Getdt() * Propulsion->GetRate();
402 }
403
404 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
405
406 double FGTurboProp::Seek(double *var, double target, double accel, double decel)
407 {
408   double v = *var;
409   if (v > target) {
410     v -= dt * decel;
411     if (v < target) v = target;
412   } else if (v < target) {
413     v += dt * accel;
414     if (v > target) v = target;
415   }
416   return v;
417 }
418
419 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
420
421 double FGTurboProp::ExpSeek(double *var, double target, double accel_tau, double decel_tau)
422 {
423 // exponential delay instead of the linear delay used in Seek
424   double v = *var;
425   if (v > target) {
426     v = (v - target) * exp ( -dt / decel_tau) + target;
427   } else if (v < target) {
428     v = (target - v) * (1 - exp ( -dt / accel_tau)) + v;
429   }
430   return v;
431 }
432
433 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
434
435 void FGTurboProp::SetDefaults(void)
436 {
437   Name = "Not defined";
438   N1 = N2 = 0.0;
439   Type = etTurboprop;
440   MilThrust = 10000.0;
441   IdleN1 = 30.0;
442   IdleN2 = 60.0;
443   MaxN1 = 100.0;
444   MaxN2 = 100.0;
445   ThrottleCmd = 0.0;
446   InletPosition = 1.0;
447   NozzlePosition = 1.0;
448   Reversed = false;
449   Cutoff = true;
450   phase = tpOff;
451   Stalled = false;
452   Seized = false;
453   Overtemp = false;
454   Fire = false;
455   Eng_ITT_degC = 0.0;
456
457   GeneratorPower=true;
458   Condition = 0;
459   Ielu_intervent=false;
460
461   Idle_Max_Delay = 1.0;
462 }
463
464 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
465
466
467 string FGTurboProp::GetEngineLabels(string delimeter)
468 {
469   std::ostringstream buf;
470
471   buf << Name << "_N1[" << EngineNumber << "]" << delimeter
472       << Name << "_N2[" << EngineNumber << "]" << delimeter
473       << Name << "__PwrAvailJVK[" << EngineNumber << "]" << delimeter
474       << Thruster->GetThrusterLabels(EngineNumber, delimeter);
475
476   return buf.str();
477 }
478
479 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
480
481 string FGTurboProp::GetEngineValues(string delimeter)
482 {
483   std::ostringstream buf;
484
485   buf << N1 << delimeter
486       << N2 << delimeter
487       << Thruster->GetThrusterValues(EngineNumber,delimeter);
488
489   return buf.str();
490 }
491
492 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
493
494 void FGTurboProp::bindmodel()
495 {
496   char property_name[80];
497
498 // ToDo: Do a proper Tie here, this should be read only.
499
500   snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber);
501   PropertyManager->Tie( property_name, &N1);
502   snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber);
503   PropertyManager->Tie( property_name, &N2);
504   snprintf(property_name, 80, "propulsion/engine[%u]/reverser", EngineNumber);
505   PropertyManager->Tie( property_name, &Reversed);
506
507 }
508
509 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
510
511 void FGTurboProp::unbind()
512 {
513   char property_name[80];
514
515   snprintf(property_name, 80, "propulsion/engine[%u]/n1", EngineNumber);
516   PropertyManager->Untie(property_name);
517   snprintf(property_name, 80, "propulsion/engine[%u]/n2", EngineNumber);
518   PropertyManager->Untie(property_name);
519   snprintf(property_name, 80, "propulsion/engine[%u]/reverser", EngineNumber);
520   PropertyManager->Untie(property_name);
521 }
522
523
524 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
525 //    The bitmasked value choices are as follows:
526 //    unset: In this case (the default) JSBSim would only print
527 //       out the normally expected messages, essentially echoing
528 //       the config files as they are read. If the environment
529 //       variable is not set, debug_lvl is set to 1 internally
530 //    0: This requests JSBSim not to output any messages
531 //       whatsoever.
532 //    1: This value explicity requests the normal JSBSim
533 //       startup messages
534 //    2: This value asks for a message to be printed out when
535 //       a class is instantiated
536 //    4: When this value is set, a message is displayed when a
537 //       FGModel object executes its Run() method
538 //    8: When this value is set, various runtime state variables
539 //       are printed out periodically
540 //    16: When set various parameters are sanity checked and
541 //       a message is printed out when they go out of bounds
542
543 void FGTurboProp::Debug(int from)
544 {
545   if (debug_lvl <= 0) return;
546
547   if (debug_lvl & 1) { // Standard console startup message output
548     if (from == 0) { // Constructor
549
550     }
551     if (from == 2) { // called from Load()
552       cout << "\n ****MUJ MOTOR TURBOPROP****\n";
553       cout << "\n    Engine Name: "         << Name << endl;
554       cout << "      MilThrust:   "         << MilThrust << endl;
555       cout << "      IdleN1:      "         << IdleN1 << endl;
556       cout << "      MaxN1:       "         << MaxN1 << endl;
557
558       cout << endl;
559     }
560   }
561   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
562     if (from == 0) cout << "Instantiated: FGTurboProp" << endl;
563     if (from == 1) cout << "Destroyed:    FGTurboProp" << endl;
564   }
565   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
566   }
567   if (debug_lvl & 8 ) { // Runtime state variables
568   }
569   if (debug_lvl & 16) { // Sanity checking
570   }
571   if (debug_lvl & 64) {
572     if (from == 0) { // Constructor
573       cout << IdSrc << endl;
574       cout << IdHdr << endl;
575     }
576   }
577 }
578 }