]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/propulsion/FGPropeller.cpp
Andreas Gaeb: fix #222 (JSBSIm reset problems)
[flightgear.git] / src / FDM / JSBSim / models / propulsion / FGPropeller.cpp
index 8204bb9d21cd88bd127071fee4da1e5eb43a419b..f83f961b8e7aea224b62c5dab8fb1e1cd62ae11e 100644 (file)
@@ -48,7 +48,7 @@ using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.30 2010/05/02 15:10:07 jberndt Exp $";
+static const char *IdSrc = "$Id: FGPropeller.cpp,v 1.32 2010/10/21 03:27:40 jberndt Exp $";
 static const char *IdHdr = ID_PROPELLER;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -105,16 +105,20 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num)
   for (int i=0; i<2; i++) {
     table_element = prop_element->FindNextElement("table");
     name = table_element->GetAttributeValue("name");
-    if (name == "C_THRUST") {
-      cThrust = new FGTable(PropertyManager, table_element);
-    } else if (name == "C_POWER") {
-      cPower = new FGTable(PropertyManager, table_element);
-    } else if (name == "CT_MACH") {
-      CtMach = new FGTable(PropertyManager, table_element);
-    } else if (name == "CP_MACH") {
-      CpMach = new FGTable(PropertyManager, table_element);
-    } else {
-      cerr << "Unknown table type: " << name << " in propeller definition." << endl;
+    try {
+      if (name == "C_THRUST") {
+        cThrust = new FGTable(PropertyManager, table_element);
+      } else if (name == "C_POWER") {
+        cPower = new FGTable(PropertyManager, table_element);
+      } else if (name == "CT_MACH") {
+        CtMach = new FGTable(PropertyManager, table_element);
+      } else if (name == "CP_MACH") {
+        CpMach = new FGTable(PropertyManager, table_element);
+      } else {
+        cerr << "Unknown table type: " << name << " in propeller definition." << endl;
+      }
+    } catch (std::string str) {
+      throw("Error loading propeller table:" + name + ". " + str);
     }
   }
 
@@ -334,7 +338,7 @@ double FGPropeller::GetPowerRequired(void)
      if (CL > 1.5) CL = 1.5;
      double BladeArea = Diameter * Diameter / 32.0 * numBlades;
      vTorque(eX) = -Sense*BladeArea*Diameter*Vel*Vel*rho*0.19*CL;
-     PowerRequired = vTorque(eX)*0.2*M_PI;
+     PowerRequired = fabs(vTorque(eX))*0.2*M_PI;
   }
 
   return PowerRequired;