]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGFDMExec.cpp
Updates from JSBSim, including new turbine engine model from David Culp
[flightgear.git] / src / FDM / JSBSim / FGFDMExec.cpp
index 20cacbe6720dcbbba00bed3cc596ca2bbd305ef7..ee6386705eab9641124d7dcfd75005a6f8af0548 100644 (file)
@@ -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)
@@ -132,7 +150,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root)
   else            master = root;
 
   instance = master->GetNode("/fdm/jsbsim",IdFDM,true);
-  instance->SetDouble("zero",0);  
+
   
   Debug(0);
   
@@ -152,13 +170,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 +250,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 +269,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 +277,8 @@ bool FGFDMExec::Allocate(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGFDMExec::DeAllocate(void) {
-
+bool FGFDMExec::DeAllocate(void)
+{
   delete Atmosphere;
   delete FCS;
   delete Propulsion;
@@ -281,7 +296,7 @@ bool FGFDMExec::DeAllocate(void) {
   
   delete IC;
   delete Trim;
-
+    
   FirstModel  = 0L;
   Error       = 0;
 
@@ -367,6 +382,7 @@ bool FGFDMExec::RunIC(void)
   State->Initialize(IC);
   Run();
   State->Resume();
+
   return true;
 }
 
@@ -387,9 +403,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);
 }  
 
@@ -684,4 +702,5 @@ void FGFDMExec::Debug(int from)
     }
   }
 }
+}