]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGFDMExec.cpp
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / JSBSim / FGFDMExec.cpp
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2
3  Module:       FGFDMExec.cpp
4  Author:       Jon S. Berndt
5  Date started: 11/17/98
6  Purpose:      Schedules and runs the model routines.
7
8  ------------- Copyright (C) 1999  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 This class wraps up the simulation scheduling routines.
31
32 HISTORY
33 --------------------------------------------------------------------------------
34 11/17/98   JSB   Created
35
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 COMMENTS, REFERENCES,  and NOTES
38 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 INCLUDES
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43
44 #ifdef FGFS
45 #  include <simgear/compiler.h>
46 #  include STL_IOSTREAM
47 #  include STL_ITERATOR
48 #else
49 #  if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
50 #    include <iostream.h>
51 #  else
52 #    include <iostream>
53 #  endif
54 #  include <iterator>
55 #endif
56
57 #include "FGFDMExec.h"
58 #include "FGState.h"
59 #include "FGAtmosphere.h"
60 #include "FGFCS.h"
61 #include "FGGroundCallback.h"
62 #include "FGPropulsion.h"
63 #include "FGMassBalance.h"
64 #include "FGGroundReactions.h"
65 #include "FGAerodynamics.h"
66 #include "FGInertial.h"
67 #include "FGAircraft.h"
68 #include "FGPropagate.h"
69 #include "FGAuxiliary.h"
70 #include "FGOutput.h"
71 #include "FGConfigFile.h"
72 #include "FGInitialCondition.h"
73 #include "FGPropertyManager.h"
74
75 namespace JSBSim {
76
77 static const char *IdSrc = "$Id$";
78 static const char *IdHdr = ID_FDMEXEC;
79
80 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81 GLOBAL DECLARATIONS
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
83
84 unsigned int FGFDMExec::FDMctr = 0;
85 FGPropertyManager* FGFDMExec::master=0;
86
87 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 CLASS IMPLEMENTATION
89 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
90
91 void checkTied ( FGPropertyManager *node )
92 {
93   int N = node->nChildren();
94   string name;
95
96   for (int i=0; i<N; i++) {
97     if (node->getChild(i)->nChildren() ) {
98       checkTied( (FGPropertyManager*)node->getChild(i) );
99     } else if ( node->getChild(i)->isTied() ) {
100       name = ((FGPropertyManager*)node->getChild(i))->GetFullyQualifiedName();
101       cerr << name << " is tied" << endl;
102     }
103   }
104 }
105
106 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 // Constructor
108
109 FGFDMExec::FGFDMExec(FGPropertyManager* root)
110 {
111
112   Frame           = 0;
113   FirstModel      = 0;
114   Error           = 0;
115   State           = 0;
116   Atmosphere      = 0;
117   FCS             = 0;
118   Propulsion      = 0;
119   MassBalance     = 0;
120   Aerodynamics    = 0;
121   Inertial        = 0;
122   GroundReactions = 0;
123   Aircraft        = 0;
124   GroundCallback  = 0;
125   Propagate       = 0;
126   Auxiliary       = 0;
127   Output          = 0;
128   IC              = 0;
129   Trim            = 0;
130
131   terminate = false;
132   frozen = false;
133   modelLoaded = false;
134   IsSlave = false;
135
136   // Multiple FDM's are stopped for now.  We need to ensure that
137   // the "user" instance always gets the zeroeth instance number,
138   // because there may be instruments or scripts tied to properties
139   // in the jsbsim[0] node.
140   IdFDM = FDMctr;
141   //FDMctr++;
142
143   try {
144     char* num = getenv("JSBSIM_DEBUG");
145     if (num) debug_lvl = atoi(num); // set debug level
146   } catch (...) {               // if error set to 1
147     debug_lvl = 1;
148   }
149
150   if (root == 0)  master= new FGPropertyManager;
151   else            master = root;
152
153   instance = master->GetNode("/fdm/jsbsim",IdFDM,true);
154
155
156   Debug(0);
157
158   // this is here to catch errors in binding member functions
159   // to the property tree.
160   try {
161     Allocate();
162   } catch ( string msg ) {
163     cout << "Caught error: " << msg << endl;
164     exit(1);
165   }
166 }
167
168 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169
170 FGFDMExec::~FGFDMExec()
171 {
172   try {
173     DeAllocate();
174     checkTied( instance );
175   } catch ( string msg ) {
176     cout << "Caught error: " << msg << endl;
177   }
178
179   for (unsigned int i=1; i<SlaveFDMList.size(); i++) delete SlaveFDMList[i]->exec;
180   SlaveFDMList.clear();
181
182   Debug(1);
183 }
184
185 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186
187 bool FGFDMExec::Allocate(void)
188 {
189   bool result=true;
190
191   Atmosphere      = new FGAtmosphere(this);
192   FCS             = new FGFCS(this);
193   Propulsion      = new FGPropulsion(this);
194   MassBalance     = new FGMassBalance(this);
195   Aerodynamics    = new FGAerodynamics (this);
196   Inertial        = new FGInertial(this);
197   GroundReactions = new FGGroundReactions(this);
198   Aircraft        = new FGAircraft(this);
199   GroundCallback  = new FGGroundCallback();
200   Propagate       = new FGPropagate(this);
201   Auxiliary       = new FGAuxiliary(this);
202   Output          = new FGOutput(this);
203
204   State        = new FGState(this); // This must be done here, as the FGState
205                                     // class needs valid pointers to the above
206                                     // model classes
207
208   // Initialize models so they can communicate with each other
209
210   if (!Atmosphere->InitModel()) {
211     cerr << fgred << "Atmosphere model init failed" << fgdef << endl;
212     Error+=1;}
213   if (!FCS->InitModel())        {
214     cerr << fgred << "FCS model init failed" << fgdef << endl;
215     Error+=2;}
216   if (!Propulsion->InitModel()) {
217     cerr << fgred << "FGPropulsion model init failed" << fgdef << endl;
218     Error+=4;}
219   if (!MassBalance->InitModel()) {
220     cerr << fgred << "FGMassBalance model init failed" << fgdef << endl;
221     Error+=8;}
222   if (!Aerodynamics->InitModel()) {
223     cerr << fgred << "FGAerodynamics model init failed" << fgdef << endl;
224     Error+=16;}
225   if (!Inertial->InitModel()) {
226     cerr << fgred << "FGInertial model init failed" << fgdef << endl;
227     Error+=32;}
228   if (!GroundReactions->InitModel())   {
229     cerr << fgred << "Ground Reactions model init failed" << fgdef << endl;
230     Error+=64;}
231   if (!Aircraft->InitModel())   {
232     cerr << fgred << "Aircraft model init failed" << fgdef << endl;
233     Error+=128;}
234   if (!Propagate->InitModel())   {
235     cerr << fgred << "Propagate model init failed" << fgdef << endl;
236     Error+=512;}
237   if (!Auxiliary->InitModel())  {
238     cerr << fgred << "Auxiliary model init failed" << fgdef << endl;
239     Error+=2058;}
240   if (!Output->InitModel())     {
241     cerr << fgred << "Output model init failed" << fgdef << endl;
242     Error+=4096;}
243
244   if (Error > 0) result = false;
245
246   IC = new FGInitialCondition(this);
247
248   // Schedule a model. The second arg (the integer) is the pass number. For
249   // instance, the atmosphere model gets executed every fifth pass it is called
250   // by the executive. Everything else here gets executed each pass.
251   // IC and Trim objects are NOT scheduled.
252
253   Schedule(Atmosphere,      1);
254   Schedule(FCS,             1);
255   Schedule(Propulsion,      1);
256   Schedule(MassBalance,     1);
257   Schedule(Aerodynamics,    1);
258   Schedule(Inertial,        1);
259   Schedule(GroundReactions, 1);
260   Schedule(Aircraft,        1);
261   Schedule(Propagate,       1);
262   Schedule(Auxiliary,       1);
263   Schedule(Output,          1);
264
265   modelLoaded = false;
266
267   return result;
268 }
269
270 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271
272 bool FGFDMExec::DeAllocate(void)
273 {
274   delete Atmosphere;
275   delete FCS;
276   delete Propulsion;
277   delete MassBalance;
278   delete Aerodynamics;
279   delete Inertial;
280   delete GroundReactions;
281   delete Aircraft;
282   delete Propagate;
283   delete Auxiliary;
284   delete Output;
285   delete State;
286
287   delete IC;
288   delete Trim;
289
290   delete GroundCallback;
291
292   FirstModel  = 0L;
293   Error       = 0;
294
295   State           = 0;
296   Atmosphere      = 0;
297   FCS             = 0;
298   Propulsion      = 0;
299   MassBalance     = 0;
300   Aerodynamics    = 0;
301   Inertial        = 0;
302   GroundReactions = 0;
303   Aircraft        = 0;
304   Propagate       = 0;
305   Auxiliary       = 0;
306   Output          = 0;
307
308   modelLoaded = false;
309   return modelLoaded;
310 }
311
312 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
313
314 int FGFDMExec::Schedule(FGModel* model, int rate)
315 {
316   FGModel* model_iterator;
317
318   model_iterator = FirstModel;
319
320   if (model_iterator == 0L) {                  // this is the first model
321
322     FirstModel = model;
323     FirstModel->NextModel = 0L;
324     FirstModel->SetRate(rate);
325
326   } else {                                     // subsequent model
327
328     while (model_iterator->NextModel != 0L) {
329       model_iterator = model_iterator->NextModel;
330     }
331     model_iterator->NextModel = model;
332     model_iterator->NextModel->SetRate(rate);
333
334   }
335
336   return 0;
337 }
338
339 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
340
341 bool FGFDMExec::Run(void)
342 {
343   FGModel* model_iterator;
344
345   if (frozen) return true;
346
347   model_iterator = FirstModel;
348   if (model_iterator == 0L) return false;
349
350   Debug(2);
351
352   for (unsigned int i=1; i<SlaveFDMList.size(); i++) {
353 //    SlaveFDMList[i]->exec->State->Initialize(); // Transfer state to the slave FDM
354 //    SlaveFDMList[i]->exec->Run();
355   }
356
357   while (model_iterator != 0L) {
358     model_iterator->Run();
359     model_iterator = model_iterator->NextModel;
360   }
361
362   frame = Frame++;
363   State->IncrTime();
364   return true;
365 }
366
367 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368
369 bool FGFDMExec::RunIC(void)
370 {
371   State->Suspend();
372   State->Initialize(IC);
373   Run();
374   State->Resume();
375
376   return true;
377 }
378
379 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380
381 void FGFDMExec::SetGroundCallback(FGGroundCallback* p) {
382   if (GroundCallback)
383     delete GroundCallback;
384   GroundCallback = p;
385 }
386
387 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
388
389 vector <string> FGFDMExec::EnumerateFDMs(void)
390 {
391   vector <string> FDMList;
392
393   FDMList.push_back(Aircraft->GetAircraftName());
394
395   for (unsigned int i=1; i<SlaveFDMList.size(); i++) {
396     FDMList.push_back(SlaveFDMList[i]->exec->GetAircraft()->GetAircraftName());
397   }
398
399   return FDMList;
400 }
401
402 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
403
404 bool FGFDMExec::LoadModel(string AircraftPath, string EnginePath, string model,
405                 bool addModelToPath)
406 {
407
408   FGFDMExec::AircraftPath = AircraftPath;
409   FGFDMExec::EnginePath = EnginePath;
410
411   return LoadModel(model, addModelToPath);
412 }
413
414 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
415
416
417 bool FGFDMExec::LoadModel(string model, bool addModelToPath)
418 {
419   
420   bool result = true;
421   string token;
422   string aircraftCfgFileName;
423
424   if( AircraftPath.empty() || EnginePath.empty() ) {
425     cerr << "Error: attempted to load aircraft with undefined ";
426     cerr << "aircraft and engine paths" << endl;
427     return false;
428   }
429
430   aircraftCfgFileName = AircraftPath;
431 # ifndef macintosh
432   if (addModelToPath) aircraftCfgFileName += "/" + model;
433   aircraftCfgFileName += "/" + model + ".xml";
434 # else
435   if (addModelToPath) aircraftCfgFileName += ";"  + model;
436   aircraftCfgFileName += ";"  + model + ".xml";
437 # endif
438
439   FGConfigFile AC_cfg(aircraftCfgFileName);
440   if (!AC_cfg.IsOpen()) return false;
441
442   modelName = model;
443
444   if (modelLoaded) {
445     DeAllocate();
446     Allocate();
447   }
448
449   if (!ReadPrologue(&AC_cfg)) return false;
450
451   while ((AC_cfg.GetNextConfigLine() != string("EOF")) &&
452          (token = AC_cfg.GetValue()) != string("/FDM_CONFIG")) {
453     if (token == "METRICS") {
454       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Metrics" << fgdef << endl;
455       if (!ReadMetrics(&AC_cfg)) result = false;
456     } else if (token == "SLAVE") {
457       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Slave flight vehicle: " << fgdef
458                                         << AC_cfg.GetValue("NAME") << endl;
459       if (!ReadSlave(&AC_cfg)) result = false;
460     } else if (token == "AERODYNAMICS") {
461       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Aerodynamics" << fgdef << endl;
462       if (!ReadAerodynamics(&AC_cfg)) result = false;
463     } else if (token == "UNDERCARRIAGE") {
464       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Landing Gear" << fgdef << endl;
465       if (!ReadUndercarriage(&AC_cfg)) result = false;
466     } else if (token == "PROPULSION") {
467       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Propulsion" << fgdef << endl;
468       if (!ReadPropulsion(&AC_cfg)) result = false;
469     } else if (token == "FLIGHT_CONTROL") {
470       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Flight Control" << fgdef << endl;
471       if (!ReadFlightControls(&AC_cfg)) result = false;
472     } else if (token == "AUTOPILOT") {
473       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Autopilot" << fgdef << endl;
474       if (!ReadFlightControls(&AC_cfg)) result = false;
475     } else if (token == "OUTPUT") {
476       if (debug_lvl > 0) cout << fgcyan << "\n  Reading Output directives" << fgdef << endl;
477       if (!ReadOutput(&AC_cfg)) result = false;
478     }
479   }
480
481   if (result) {
482     modelLoaded = true;
483     Debug(3);
484   } else {
485     cerr << fgred
486          << "  FGFDMExec: Failed to load aircraft and/or engine model"
487          << fgdef << endl;
488   }
489
490   return result;
491 }
492
493 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
494
495 bool FGFDMExec::ReadPrologue(FGConfigFile* AC_cfg)
496 {
497   string token = AC_cfg->GetValue();
498   string scratch;
499   string AircraftName;
500
501   AircraftName = AC_cfg->GetValue("NAME");
502   Aircraft->SetAircraftName(AircraftName);
503
504   if (debug_lvl > 0) cout << underon << "Reading Aircraft Configuration File"
505             << underoff << ": " << highint << AircraftName << normint << endl;
506   scratch = AC_cfg->GetValue("VERSION").c_str();
507
508   CFGVersion = AC_cfg->GetValue("VERSION");
509   Release    = AC_cfg->GetValue("RELEASE");
510
511   if (debug_lvl > 0)
512     cout << "                            Version: " << highint << CFGVersion
513                                                     << normint << endl;
514   if (CFGVersion != needed_cfg_version) {
515     cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
516             " RESULTS WILL BE UNPREDICTABLE !!" << endl;
517     cerr << "Current version needed is: " << needed_cfg_version << endl;
518     cerr << "         You have version: " << CFGVersion << endl << fgdef << endl;
519     return false;
520   }
521
522   if (Release == "ALPHA" && debug_lvl > 0) {
523 #ifndef _MSC_VER
524     system("banner ALPHA");
525 #endif
526     cout << endl << endl
527          << highint << "This aircraft model is an " << fgred << Release
528          << reset << highint << " release!!!" << endl << endl << reset
529          << "This aircraft model may not even properly load, and probably"
530          << " will not fly as expected." << endl << endl
531          << fgred << highint << "Use this model for development purposes ONLY!!!"
532          << normint << reset << endl << endl;
533   } else if (Release == "BETA" && debug_lvl > 0) {
534 #ifndef _MSC_VER
535     system("banner BETA");
536 #endif
537     cout << endl << endl
538          << highint << "This aircraft model is a " << fgred << Release
539          << reset << highint << " release!!!" << endl << endl << reset
540          << "This aircraft model probably will not fly as expected." << endl << endl
541          << fgblue << highint << "Use this model for development purposes ONLY!!!"
542          << normint << reset << endl << endl;
543   }
544
545   return true;
546 }
547
548 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
549
550 bool FGFDMExec::ReadSlave(FGConfigFile* AC_cfg)
551 {
552   // Add a new slaveData object to the slave FDM list
553   // Populate that slaveData element with a new FDMExec object
554   // Set the IsSlave flag for that FDMExec object
555   // Get the aircraft name
556   // set debug level to print out no additional data for slave objects
557   // Load the model given the aircraft name
558   // reset debug level to prior setting
559
560   int saved_debug_lvl = debug_lvl;
561   string token;
562
563   SlaveFDMList.push_back(new slaveData);
564   SlaveFDMList.back()->exec = new FGFDMExec();
565   SlaveFDMList.back()->exec->SetSlave();
566
567   string AircraftName = AC_cfg->GetValue("FILE");
568
569   debug_lvl = 0;                 // turn off debug output for slave vehicle
570
571   SlaveFDMList.back()->exec->SetAircraftPath( AircraftPath );
572   SlaveFDMList.back()->exec->SetEnginePath( EnginePath );
573   SlaveFDMList.back()->exec->LoadModel(AircraftName);
574   debug_lvl = saved_debug_lvl;   // turn debug output back on for master vehicle
575
576   AC_cfg->GetNextConfigLine();
577   while ((token = AC_cfg->GetValue()) != string("/SLAVE")) {
578     *AC_cfg >> token;
579     if      (token == "XLOC")  { *AC_cfg >> SlaveFDMList.back()->x;    }
580     else if (token == "YLOC")  { *AC_cfg >> SlaveFDMList.back()->y;    }
581     else if (token == "ZLOC")  { *AC_cfg >> SlaveFDMList.back()->z;    }
582     else if (token == "PITCH") { *AC_cfg >> SlaveFDMList.back()->pitch;}
583     else if (token == "YAW")   { *AC_cfg >> SlaveFDMList.back()->yaw;  }
584     else if (token == "ROLL")  { *AC_cfg >> SlaveFDMList.back()->roll;  }
585     else cerr << "Unknown identifier: " << token << " in slave vehicle definition" << endl;
586   }
587
588   if (debug_lvl > 0)  {
589     cout << "      X = " << SlaveFDMList.back()->x << endl;
590     cout << "      Y = " << SlaveFDMList.back()->y << endl;
591     cout << "      Z = " << SlaveFDMList.back()->z << endl;
592     cout << "      Pitch = " << SlaveFDMList.back()->pitch << endl;
593     cout << "      Yaw = " << SlaveFDMList.back()->yaw << endl;
594     cout << "      Roll = " << SlaveFDMList.back()->roll << endl;
595   }
596
597   return true;
598 }
599
600 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
601
602 bool FGFDMExec::ReadPropulsion(FGConfigFile* AC_cfg)
603 {
604   if (!Propulsion->Load(AC_cfg)) {
605     cerr << "  Propulsion not successfully loaded" << endl;
606     return false;
607   }
608   return true;
609 }
610
611 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
612
613 bool FGFDMExec::ReadFlightControls(FGConfigFile* AC_cfg)
614 {
615   if (!FCS->Load(AC_cfg)) {
616     cerr << "  Flight Controls not successfully loaded" << endl;
617     return false;
618   }
619   return true;
620 }
621
622 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
623
624 bool FGFDMExec::ReadAerodynamics(FGConfigFile* AC_cfg)
625 {
626   if (!Aerodynamics->Load(AC_cfg)) {
627     cerr << "  Aerodynamics not successfully loaded" << endl;
628     return false;
629   }
630   return true;
631 }
632
633 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
634
635 bool FGFDMExec::ReadUndercarriage(FGConfigFile* AC_cfg)
636 {
637   if (!GroundReactions->Load(AC_cfg)) {
638     cerr << "  Ground Reactions not successfully loaded" << endl;
639     return false;
640   }
641   return true;
642 }
643
644 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
645
646 bool FGFDMExec::ReadMetrics(FGConfigFile* AC_cfg)
647 {
648   if (!Aircraft->Load(AC_cfg)) {
649     cerr << "  Aircraft metrics not successfully loaded" << endl;
650     return false;
651   }
652   return true;
653 }
654
655 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
656
657 bool FGFDMExec::ReadOutput(FGConfigFile* AC_cfg)
658 {
659   if (!Output->Load(AC_cfg)) {
660     cerr << "  Output not successfully loaded" << endl;
661     return false;
662   }
663   return true;
664 }
665
666 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
667
668 FGPropertyManager* FGFDMExec::GetPropertyManager(void) {
669   return instance;
670 }
671
672 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
673
674 FGTrim* FGFDMExec::GetTrim(void) {
675   delete Trim;
676   Trim = new FGTrim(this,tNone);
677   return Trim;
678 }
679
680 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
681 //    The bitmasked value choices are as follows:
682 //    unset: In this case (the default) JSBSim would only print
683 //       out the normally expected messages, essentially echoing
684 //       the config files as they are read. If the environment
685 //       variable is not set, debug_lvl is set to 1 internally
686 //    0: This requests JSBSim not to output any messages
687 //       whatsoever.
688 //    1: This value explicity requests the normal JSBSim
689 //       startup messages
690 //    2: This value asks for a message to be printed out when
691 //       a class is instantiated
692 //    4: When this value is set, a message is displayed when a
693 //       FGModel object executes its Run() method
694 //    8: When this value is set, various runtime state variables
695 //       are printed out periodically
696 //    16: When set various parameters are sanity checked and
697 //       a message is printed out when they go out of bounds
698
699 void FGFDMExec::Debug(int from)
700 {
701   if (debug_lvl <= 0) return;
702
703   if (debug_lvl & 1 && IdFDM == 0) { // Standard console startup message output
704     if (from == 0) { // Constructor
705       cout << "\n\n     " << highint << underon << "JSBSim Flight Dynamics Model v"
706                                      << JSBSim_version << underoff << normint << endl;
707       cout << halfint << "            [cfg file spec v" << needed_cfg_version << "]\n\n";
708       cout << normint << "JSBSim startup beginning ...\n\n";
709     } else if (from == 3) {
710       cout << "\n\nJSBSim startup complete\n\n";
711     }
712   }
713   if (debug_lvl & 2 ) { // Instantiation/Destruction notification
714     if (from == 0) cout << "Instantiated: FGFDMExec" << endl;
715     if (from == 1) cout << "Destroyed:    FGFDMExec" << endl;
716   }
717   if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
718     if (from == 2) {
719       cout << "================== Frame: " << Frame << "  Time: "
720            << State->Getsim_time() << endl;
721     }
722   }
723   if (debug_lvl & 8 ) { // Runtime state variables
724   }
725   if (debug_lvl & 16) { // Sanity checking
726   }
727   if (debug_lvl & 64) {
728     if (from == 0) { // Constructor
729       cout << IdSrc << endl;
730       cout << IdHdr << endl;
731     }
732   }
733 }
734 }
735