]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGGroundReactions.cpp
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / JSBSim / FGGroundReactions.cpp
index c95b42edb80c9c1cc06b1bcb67ee19d17e75e8d6..a075a1c2c267c1d9c633ce3dc44551c70385d556 100644 (file)
@@ -35,21 +35,17 @@ HISTORY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include <sstream>
+#include <iomanip>
+
 #include "FGGroundReactions.h"
 #include "FGPropertyManager.h"
 
+namespace JSBSim {
+
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_GROUNDREACTIONS;
 
-#if defined (__APPLE__)
-/* Not all systems have the gcvt function */
-inline char* gcvt (double value, int ndigits, char *buf) {
-    /* note that this is not exactly what gcvt is supposed to do! */
-    snprintf (buf, ndigits+1, "%f", value);
-    return buf;
-}
-#endif
-
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -58,7 +54,7 @@ CLASS IMPLEMENTATION
 FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) : FGModel(fgex)
 {
   Name = "FGGroundReactions";
-  
+
   bind();
 
   Debug(0);
@@ -82,7 +78,7 @@ bool FGGroundReactions::Run(void)
     vMoments.InitMatrix();
 
     // Only execute gear force code below 300 feet
-    if ( Position->GetDistanceAGL() < 300.0 ) {
+    if ( Propagate->GetDistanceAGL() < 300.0 ) {
       vector <FGLGear>::iterator iGear = lGear.begin();
       // Sum forces and moments for all gear, here.
       // Some optimizations may be made here - or rather in the gear code itself.
@@ -114,7 +110,15 @@ bool FGGroundReactions::Load(FGConfigFile* AC_cfg)
   AC_cfg->GetNextConfigLine();
 
   while ((token = AC_cfg->GetValue()) != string("/UNDERCARRIAGE")) {
-    lGear.push_back(FGLGear(AC_cfg, FDMExec));
+    string type;
+    *AC_cfg >> type;
+    if (type == "AC_GEAR") {
+      int num = lGear.size();
+      lGear.push_back(FGLGear(AC_cfg, FDMExec, num));
+      FCS->AddGear();
+    } else {
+      cerr << "Unknown undercarriage type \"" << type << "\"" << endl;
+    }
   }
 
   return true;
@@ -122,63 +126,73 @@ bool FGGroundReactions::Load(FGConfigFile* AC_cfg)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGGroundReactions::GetGroundReactionStrings(void)
+string FGGroundReactions::GetGroundReactionStrings(string delimeter)
 {
-  string GroundReactionStrings = "";
-  bool firstime = true;
+  std::ostringstream buf;
 
   for (unsigned int i=0;i<lGear.size();i++) {
-    if (!firstime) GroundReactionStrings += ", ";
-    GroundReactionStrings += (lGear[i].GetName() + "_WOW, ");
-    GroundReactionStrings += (lGear[i].GetName() + "_stroke, ");
-    GroundReactionStrings += (lGear[i].GetName() + "_strokeVel, ");
-    GroundReactionStrings += (lGear[i].GetName() + "_CompressForce, ");
-    GroundReactionStrings += (lGear[i].GetName() + "_WhlSideForce, ");
-    GroundReactionStrings += (lGear[i].GetName() + "_WhlRollForce, ");
-    GroundReactionStrings += (lGear[i].GetName() + "_BodyXForce, ");
-    GroundReactionStrings += (lGear[i].GetName() + "_BodyYForce, ");
-    GroundReactionStrings += (lGear[i].GetName() + "_WhlSlipDegrees");
-
-    firstime = false;
+    string name = lGear[i].GetName();
+    buf << name << "_WOW" << delimeter
+        << name << "_stroke" << delimeter
+        << name << "_strokeVel" << delimeter
+        << name << "_CompressForce" << delimeter
+        << name << "_WhlSideForce" << delimeter
+        << name << "_WhlVelVecX" << delimeter
+        << name << "_WhlVelVecY" << delimeter
+        << name << "_WhlRollForce" << delimeter
+        << name << "_BodyXForce" << delimeter
+        << name << "_BodyYForce" << delimeter
+        << name << "_WhlSlipDegrees" << delimeter;
   }
 
-  return GroundReactionStrings;
+  buf << "TotalGearForce_X" << delimeter
+      << "TotalGearForce_Y" << delimeter
+      << "TotalGearForce_Z" << delimeter
+      << "TotalGearMoment_L" << delimeter
+      << "TotalGearMoment_M" << delimeter
+      << "TotalGearMoment_N";
+
+  return buf.str();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGGroundReactions::GetGroundReactionValues(void)
+string FGGroundReactions::GetGroundReactionValues(string delimeter)
 {
-  char buff[20];
-  string GroundReactionValues = "";
-
-  bool firstime = true;
+  std::ostringstream buf;
 
   for (unsigned int i=0;i<lGear.size();i++) {
-    if (!firstime) GroundReactionValues += ", ";
-    GroundReactionValues += string( lGear[i].GetWOW()?"1":"0" ) + ", ";
-    GroundReactionValues += (string(gcvt(lGear[i].GetCompLen(),    5, buff)) + ", ");
-    GroundReactionValues += (string(gcvt(lGear[i].GetCompVel(),    6, buff)) + ", ");
-    GroundReactionValues += (string(gcvt(lGear[i].GetCompForce(), 10, buff)) + ", ");
-    GroundReactionValues += (string(gcvt(lGear[i].GetWheelSideForce(), 6, buff)) + ", ");
-    GroundReactionValues += (string(gcvt(lGear[i].GetWheelRollForce(), 6, buff)) + ", ");
-    GroundReactionValues += (string(gcvt(lGear[i].GetBodyXForce(), 6, buff)) + ", ");
-    GroundReactionValues += (string(gcvt(lGear[i].GetBodyYForce(), 6, buff)) + ", ");
-    GroundReactionValues += (string(gcvt(lGear[i].GetWheelSlipAngle(), 6, buff)));
-
-    firstime = false;
+    FGLGear& gear = lGear[i];
+    buf << (gear.GetWOW() ? "1, " : "0, ")
+        << setprecision(5) << gear.GetCompLen() << delimeter
+        << setprecision(6) << gear.GetCompVel() << delimeter
+        << setprecision(10) << gear.GetCompForce() << delimeter
+        << setprecision(6) << gear.GetWheelVel(eX) << delimeter
+        << gear.GetWheelVel(eY) << delimeter
+        << gear.GetWheelSideForce() << delimeter
+        << gear.GetWheelRollForce() << delimeter
+        << gear.GetBodyXForce() << delimeter
+        << gear.GetBodyYForce() << delimeter
+        << gear.GetWheelSlipAngle() << delimeter;
   }
 
-  return GroundReactionValues;
+  buf << vForces(eX) << delimeter
+      << vForces(eY) << delimeter
+      << vForces(eZ) << delimeter
+      << vMoments(eX) << delimeter
+      << vMoments(eY) << delimeter
+      << vMoments(eZ);
+
+  return buf.str();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 void FGGroundReactions::bind(void)
-{ 
+{
   typedef double (FGGroundReactions::*PMF)(int) const;
   PropertyManager->Tie("gear/num-units", this,
-                       &FGGroundReactions::GetNumGearUnits);  
+                       &FGGroundReactions::GetNumGearUnits);
   PropertyManager->Tie("moments/l-gear-lbsft", this,1,
                        (PMF)&FGGroundReactions::GetMoments);
   PropertyManager->Tie("moments/m-gear-lbsft", this,2,
@@ -251,4 +265,4 @@ void FGGroundReactions::Debug(int from)
     }
   }
 }
-
+}