]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGInitialCondition.cpp
Encapsulate the interpolstion version of FGEnvironment and fix some bugs
[flightgear.git] / src / FDM / JSBSim / FGInitialCondition.cpp
index 7cfa2303084512830feecec5cc84c43e77d4c5ff..16a912192476fa3d573d43461b2e1af126b1cb49 100644 (file)
@@ -46,6 +46,7 @@ INCLUDES
 #include "FGFDMExec.h"
 #include "FGState.h"
 #include "FGAtmosphere.h"
+#include "FGAerodynamics.h"
 #include "FGFCS.h"
 #include "FGAircraft.h"
 #include "FGTranslation.h"
@@ -56,6 +57,8 @@ INCLUDES
 #include "FGConfigFile.h"
 #include "FGPropertyManager.h"
 
+namespace JSBSim {
+
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_INITIALCONDITION;
 
@@ -509,8 +512,8 @@ bool FGInitialCondition::getAlpha(void) {
   if(vt < 0.01) return 0;
   
   xlo=xhi=0;
-  xmin=fdmex->GetAircraft()->GetAlphaCLMin();
-  xmax=fdmex->GetAircraft()->GetAlphaCLMax();
+  xmin=fdmex->GetAerodynamics()->GetAlphaCLMin();
+  xmax=fdmex->GetAerodynamics()->GetAlphaCLMax();
   sfunc=&FGInitialCondition::GammaEqOfAlpha;
   if(findInterval(0,guess)){
     if(solve(&alpha,0)){
@@ -717,19 +720,25 @@ double FGInitialCondition::GetWindDirDegIC(void) {
 
 //******************************************************************************
 
-bool FGInitialCondition::Load(string acpath, string acname, string rstfile)
+bool FGInitialCondition::Load(string rstfile, bool useStoredPath)
 {
   string resetDef;
   string token="";
 
   double temp;
-
-# ifndef macintosh
-  resetDef = acpath + "/" + acname + "/" + rstfile + ".xml";
-# else
-  resetDef = acpath + ";" + acname + ";" + rstfile + ".xml";
-# endif
-
+  # ifndef macintosh
+    string sep = "/";
+  # else
+    string sep = ";";
+  #endif     
+  
+  if( useStoredPath ) {
+    string acpath = fdmex->GetAircraftPath() + sep + fdmex->GetModelName();
+    resetDef = acpath + sep + rstfile + ".xml";
+  } else {
+    resetDef = rstfile;
+  }  
+  
   FGConfigFile resetfile(resetDef);
   if (!resetfile.IsOpen()) {
     cerr << "Failed to open reset file: " << resetDef << endl;
@@ -770,53 +779,12 @@ bool FGInitialCondition::Load(string acpath, string acname, string rstfile)
     resetfile >> token;
   }
 
-  fdmex->RunIC(this);
+  fdmex->RunIC();
   
   return true;
 }
 
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-//    The bitmasked value choices are as follows:
-//    unset: In this case (the default) JSBSim would only print
-//       out the normally expected messages, essentially echoing
-//       the config files as they are read. If the environment
-//       variable is not set, debug_lvl is set to 1 internally
-//    0: This requests JSBSim not to output any messages
-//       whatsoever.
-//    1: This value explicity requests the normal JSBSim
-//       startup messages
-//    2: This value asks for a message to be printed out when
-//       a class is instantiated
-//    4: When this value is set, a message is displayed when a
-//       FGModel object executes its Run() method
-//    8: When this value is set, various runtime state variables
-//       are printed out periodically
-//    16: When set various parameters are sanity checked and
-//       a message is printed out when they go out of bounds
-
-void FGInitialCondition::Debug(int from)
-{
-  if (debug_lvl <= 0) return;
-
-  if (debug_lvl & 1) { // Standard console startup message output
-  }
-  if (debug_lvl & 2 ) { // Instantiation/Destruction notification
-    if (from == 0) cout << "Instantiated: FGInitialCondition" << endl;
-    if (from == 1) cout << "Destroyed:    FGInitialCondition" << endl;
-  }
-  if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
-  }
-  if (debug_lvl & 8 ) { // Runtime state variables
-  }
-  if (debug_lvl & 16) { // Sanity checking
-  }
-  if (debug_lvl & 64) {
-    if (from == 0) { // Constructor
-      cout << IdSrc << endl;
-      cout << IdHdr << endl;
-    }
-  }
-}
+//******************************************************************************
 
 void FGInitialCondition::bind(void){
   PropertyManager->Tie("ic/vc-kts", this,
@@ -965,6 +933,8 @@ void FGInitialCondition::bind(void){
                        true);
 }
 
+//******************************************************************************
+
 void FGInitialCondition::unbind(void){
   PropertyManager->Untie("ic/vc-kts");
   PropertyManager->Untie("ic/ve-kts");
@@ -1010,3 +980,47 @@ void FGInitialCondition::unbind(void){
   PropertyManager->Untie("ic/lat-gc-rad");
   PropertyManager->Untie("ic/long-gc-rad");
 }
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//    The bitmasked value choices are as follows:
+//    unset: In this case (the default) JSBSim would only print
+//       out the normally expected messages, essentially echoing
+//       the config files as they are read. If the environment
+//       variable is not set, debug_lvl is set to 1 internally
+//    0: This requests JSBSim not to output any messages
+//       whatsoever.
+//    1: This value explicity requests the normal JSBSim
+//       startup messages
+//    2: This value asks for a message to be printed out when
+//       a class is instantiated
+//    4: When this value is set, a message is displayed when a
+//       FGModel object executes its Run() method
+//    8: When this value is set, various runtime state variables
+//       are printed out periodically
+//    16: When set various parameters are sanity checked and
+//       a message is printed out when they go out of bounds
+
+void FGInitialCondition::Debug(int from)
+{
+  if (debug_lvl <= 0) return;
+
+  if (debug_lvl & 1) { // Standard console startup message output
+  }
+  if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+    if (from == 0) cout << "Instantiated: FGInitialCondition" << endl;
+    if (from == 1) cout << "Destroyed:    FGInitialCondition" << endl;
+  }
+  if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+  }
+  if (debug_lvl & 8 ) { // Runtime state variables
+  }
+  if (debug_lvl & 16) { // Sanity checking
+  }
+  if (debug_lvl & 64) {
+    if (from == 0) { // Constructor
+      cout << IdSrc << endl;
+      cout << IdHdr << endl;
+    }
+  }
+}
+}