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