]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGInitialCondition.cpp
Latest JSBSim changes, including some gear tweaking from Jon and some
[flightgear.git] / src / FDM / JSBSim / FGInitialCondition.cpp
index 31be45a1ebdcf0b573aa852b526de1fe542f9f1a..29dc1f10f6329f3650d3d34e77b09343c7c7c19b 100644 (file)
@@ -91,14 +91,14 @@ FGInitialCondition::FGInitialCondition(FGFDMExec *FDMExec)
     cout << "FGInitialCondition: This class requires a pointer to a valid FGFDMExec object" << endl;
   }
 
-  if (debug_lvl & 2) cout << "Instantiated: FGInitialCondition" << endl;
+  Debug(0);
 }
 
 //******************************************************************************
 
 FGInitialCondition::~FGInitialCondition()
 {
-  if (debug_lvl & 2) cout << "Destroyed:    FGInitialCondition" << endl;
+  Debug(1);
 }
 
 //******************************************************************************
@@ -366,6 +366,8 @@ void FGInitialCondition::calcWindUVW(void) {
         wnorth=whead*cos(psi) + wcross*cos(psi+M_PI/2);
         weast=whead*sin(psi) + wcross*sin(psi+M_PI/2);
       break;
+      case setwned:
+      break;
     }    
     uw=wnorth*ctheta*cpsi +
        weast*ctheta*spsi -
@@ -536,7 +538,7 @@ bool FGInitialCondition::getTheta(void) {
 //******************************************************************************
 
 double FGInitialCondition::GammaEqOfTheta(double Theta) {
-  double a,b,c,d;
+  double a,b,c;
   double sTheta,cTheta;
 
   //theta=Theta; stheta=sin(theta); ctheta=cos(theta);
@@ -551,7 +553,7 @@ double FGInitialCondition::GammaEqOfTheta(double Theta) {
 //******************************************************************************
 
 double FGInitialCondition::GammaEqOfAlpha(double Alpha) {
-  double a,b,c,d;
+  double a,b,c;
   double sAlpha,cAlpha;
 
   sAlpha=sin(Alpha); cAlpha=cos(Alpha);
@@ -654,7 +656,7 @@ bool FGInitialCondition::solve(double *y,double x)
 
   //initializations
   d=1;
-
+  x2 = 0;
   x1=xlo;x3=xhi;
   f1=(this->*sfunc)(x1)-x;
   f3=(this->*sfunc)(x3)-x;
@@ -664,8 +666,8 @@ bool FGInitialCondition::solve(double *y,double x)
   i=0;
   while ((fabs(d) > eps) && (i < 100)) {
     d=(x3-x1)/d0;
-    x2=x1-d*d0*f1/(f3-f1);
-
+    x2 = x1-d*d0*f1/(f3-f1);
+    
     f2=(this->*sfunc)(x2)-x;
     //cout << "solve x1,x2,x3: " << x1 << "," << x2 << "," << x3 << endl;
     //cout << "                " << f1 << "," << f2 << "," << f3 << endl;
@@ -720,7 +722,10 @@ bool FGInitialCondition::Load(string acpath, string acname, string rstfile)
 # endif
 
   FGConfigFile resetfile(resetDef);
-  if (!resetfile.IsOpen()) return false;
+  if (!resetfile.IsOpen()) {
+    cerr << "Failed to open reset file: " << resetDef << endl;
+    return false;
+  }  
 
   resetfile.GetNextConfigLine();
   token = resetfile.GetValue();
@@ -759,4 +764,48 @@ bool FGInitialCondition::Load(string acpath, string acname, string rstfile)
   fdmex->RunIC(this);
   
   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;
+    }
+  }
+}
+