]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGFDMExec.cpp
Encapsulate the interpolstion version of FGEnvironment and fix some bugs
[flightgear.git] / src / FDM / JSBSim / FGFDMExec.cpp
index 20cacbe6720dcbbba00bed3cc596ca2bbd305ef7..02e433047c5b71e3dae49d0d12afed0f9256935a 100644 (file)
@@ -46,7 +46,7 @@ INCLUDES
 #  include STL_IOSTREAM
 #  include STL_ITERATOR
 #else
-#  if defined(sgi) && !defined(__GNUC__)
+#  if defined(sgi) && !defined(__GNUC__) && (_COMPILER_VERSION < 740)
 #    include <iostream.h>
 #  else
 #    include <iostream>
@@ -73,6 +73,8 @@ INCLUDES
 #include "FGInitialCondition.h"
 #include "FGPropertyManager.h"
 
+namespace JSBSim {
+
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_FDMEXEC;
 
@@ -87,6 +89,22 @@ FGPropertyManager* FGFDMExec::master=0;
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+void checkTied ( FGPropertyManager *node )
+{
+  int N = node->nChildren();
+  string name;
+
+  for (int i=0; i<N; i++) {
+    if (node->getChild(i)->nChildren() ) {
+      checkTied( (FGPropertyManager*)node->getChild(i) );
+    } else if ( node->getChild(i)->isTied() ) {
+      name = ((FGPropertyManager*)node->getChild(i))->GetFullyQualifiedName();
+      cerr << name << " is tied" << endl;
+    } 
+  }
+}        
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 // Constructor
 
 FGFDMExec::FGFDMExec(FGPropertyManager* root)
@@ -122,8 +140,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root)
 
   try {
     char* num = getenv("JSBSIM_DEBUG");
-    if (!num) debug_lvl = 1;
-    else debug_lvl = atoi(num); // set debug level
+    if (num) debug_lvl = atoi(num); // set debug level
   } catch (...) {               // if error set to 1
     debug_lvl = 1;
   }
@@ -132,7 +149,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root)
   else            master = root;
 
   instance = master->GetNode("/fdm/jsbsim",IdFDM,true);
-  instance->SetDouble("zero",0);  
+
   
   Debug(0);
   
@@ -152,13 +169,14 @@ FGFDMExec::~FGFDMExec()
 {
   try {
     DeAllocate();
+    checkTied( instance );
   } catch ( string msg ) {
     cout << "Caught error: " << msg << endl;
   }    
-
+  
   for (unsigned int i=1; i<SlaveFDMList.size(); i++) delete SlaveFDMList[i]->exec;
   SlaveFDMList.clear();
+  
   Debug(1);
 }
 
@@ -231,12 +249,11 @@ bool FGFDMExec::Allocate(void)
   if (Error > 0) result = false;
   
   IC = new FGInitialCondition(this); 
-  //Trim is allocated as needed by GetTrim()                                 
-
   
   // Schedule a model. The second arg (the integer) is the pass number. For
   // instance, the atmosphere model gets executed every fifth pass it is called
   // by the executive. Everything else here gets executed each pass.
+  // IC and Trim objects are NOT scheduled.
 
   Schedule(Atmosphere,      1);
   Schedule(FCS,             1);
@@ -251,9 +268,6 @@ bool FGFDMExec::Allocate(void)
   Schedule(Position,        1);
   Schedule(Auxiliary,       1);
   Schedule(Output,          1);
-  //IC and Trim are *not* scheduled objects
-  
-  
 
   modelLoaded = false;
 
@@ -262,8 +276,8 @@ bool FGFDMExec::Allocate(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGFDMExec::DeAllocate(void) {
-
+bool FGFDMExec::DeAllocate(void)
+{
   delete Atmosphere;
   delete FCS;
   delete Propulsion;
@@ -281,7 +295,7 @@ bool FGFDMExec::DeAllocate(void) {
   
   delete IC;
   delete Trim;
-
+    
   FirstModel  = 0L;
   Error       = 0;
 
@@ -367,6 +381,7 @@ bool FGFDMExec::RunIC(void)
   State->Initialize(IC);
   Run();
   State->Resume();
+
   return true;
 }
 
@@ -387,9 +402,11 @@ vector <string> FGFDMExec::EnumerateFDMs(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGFDMExec::LoadModel(string AircraftPath, string EnginePath, string model) {
-  FGFDMExec::AircraftPath=AircraftPath;
-  FGFDMExec::EnginePath=EnginePath;
+bool FGFDMExec::LoadModel(string AircraftPath, string EnginePath, string model)
+{
+  FGFDMExec::AircraftPath = AircraftPath;
+  FGFDMExec::EnginePath = EnginePath;
+
   return LoadModel(model);
 }  
 
@@ -483,6 +500,7 @@ bool FGFDMExec::ReadPrologue(FGConfigFile* AC_cfg)
   scratch = AC_cfg->GetValue("VERSION").c_str();
 
   CFGVersion = AC_cfg->GetValue("VERSION");
+  Release    = AC_cfg->GetValue("RELEASE");
 
   if (debug_lvl > 0)
     cout << "                            Version: " << highint << CFGVersion
@@ -494,6 +512,25 @@ bool FGFDMExec::ReadPrologue(FGConfigFile* AC_cfg)
     cerr << "         You have version: " << CFGVersion << endl << fgdef << endl;
     return false;
   }
+  
+  if (Release == "ALPHA") {
+    system("banner ALPHA");
+    cout << endl << endl
+         << highint << "This aircraft model is an " << fgred << Release
+         << reset << highint << " release!!!" << endl << endl << reset
+         << "This aircraft model may not even properly load, and probably"
+         << " will not fly as expected." << endl << endl
+         << fgred << highint << "Use this model for development purposes ONLY!!!"
+         << normint << reset << endl << endl;
+  } else if (Release == "BETA") {
+    system("banner BETA");
+    cout << endl << endl
+         << highint << "This aircraft model is a " << fgred << Release
+         << reset << highint << " release!!!" << endl << endl << reset
+         << "This aircraft model probably will not fly as expected." << endl << endl
+         << fgblue << highint << "Use this model for development purposes ONLY!!!"
+         << normint << reset << endl << endl;
+  }
 
   return true;
 }
@@ -684,4 +721,5 @@ void FGFDMExec::Debug(int from)
     }
   }
 }
+}