]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGGroundReactions.cpp
Better fix for a compilation problem with MSVC 2012
[flightgear.git] / src / FDM / JSBSim / models / FGGroundReactions.cpp
index 36837004a6a387a682c019391ddefd0e0c59070f..b334851ced2b52416f26a78529ee891d5de3b4ce 100644 (file)
@@ -39,18 +39,20 @@ INCLUDES
 #include <iomanip>
 
 #include "FGGroundReactions.h"
+#include "FGLGear.h"
 #include "input_output/FGPropertyManager.h"
 
+using namespace std;
+
 namespace JSBSim {
 
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGGroundReactions.cpp,v 1.39 2012/04/01 17:05:51 bcoconni Exp $";
 static const char *IdHdr = ID_GROUNDREACTIONS;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-
 FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) : FGModel(fgex)
 {
   Name = "FGGroundReactions";
@@ -74,21 +76,23 @@ FGGroundReactions::~FGGroundReactions(void)
 
 bool FGGroundReactions::InitModel(void)
 {
-  if (!FGModel::InitModel()) return false;
-
   return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGGroundReactions::Run(void)
+bool FGGroundReactions::Run(bool Holding)
 {
-  if (FGModel::Run()) return true;
-  if (FDMExec->Holding()) return false;
+  if (FGModel::Run(Holding)) return true;
+  if (Holding) return false;
+
+  RunPreFunctions();
 
   vForces.InitMatrix();
   vMoments.InitMatrix();
 
+  multipliers.clear();
+
   // Sum forces and moments for all gear, here.
   // Some optimizations may be made here - or rather in the gear code itself.
   // The gear ::Run() method is called several times - once for each gear.
@@ -99,12 +103,14 @@ bool FGGroundReactions::Run(void)
     vMoments += lGear[i]->GetMoments();
   }
 
+  RunPostFunctions();
+
   return false;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGGroundReactions::GetWOW(void)
+bool FGGroundReactions::GetWOW(void) const
 {
   bool result = false;
   for (unsigned int i=0; i<lGear.size(); i++) {
@@ -124,23 +130,26 @@ bool FGGroundReactions::Load(Element* el)
 
   Debug(2);
 
+  unsigned int numContacts = el->GetNumElements("contact");
+  lGear.resize(numContacts);
   Element* contact_element = el->FindElement("contact");
-  while (contact_element) {
-    lGear.push_back(new FGLGear(contact_element, FDMExec, num++));
-    FCS->AddGear(); // make the FCS aware of the landing gear
+  for (unsigned int idx=0; idx<numContacts; idx++) {
+    lGear[idx] = new FGLGear(contact_element, FDMExec, num++, in);
     contact_element = el->FindNextElement("contact");
   }
-  
+
   FGModel::Load(el); // Perform base class Load
 
   for (unsigned int i=0; i<lGear.size();i++) lGear[i]->bind();
 
+  PostLoad(el, PropertyManager);
+
   return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGGroundReactions::GetGroundReactionStrings(string delimeter)
+string FGGroundReactions::GetGroundReactionStrings(string delimeter) const
 {
   std::ostringstream buf;
 
@@ -175,14 +184,14 @@ string FGGroundReactions::GetGroundReactionStrings(string delimeter)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-string FGGroundReactions::GetGroundReactionValues(string delimeter)
+string FGGroundReactions::GetGroundReactionValues(string delimeter) const
 {
   std::ostringstream buf;
 
   for (unsigned int i=0;i<lGear.size();i++) {
     if (lGear[i]->IsBogey()) {
       FGLGear *gear = lGear[i];
-      buf << (gear->GetWOW() ? "1, " : "0, ")
+      buf << (gear->GetWOW() ? "1" : "0") << delimeter
           << setprecision(5) << gear->GetCompLen() << delimeter
           << setprecision(6) << gear->GetCompVel() << delimeter
           << setprecision(10) << gear->GetCompForce() << delimeter
@@ -214,12 +223,7 @@ void FGGroundReactions::bind(void)
 {
   typedef double (FGGroundReactions::*PMF)(int) const;
   PropertyManager->Tie("gear/num-units", this, &FGGroundReactions::GetNumGearUnits);
-  PropertyManager->Tie("moments/l-gear-lbsft", this, eL, (PMF)&FGGroundReactions::GetMoments);
-  PropertyManager->Tie("moments/m-gear-lbsft", this, eM, (PMF)&FGGroundReactions::GetMoments);
-  PropertyManager->Tie("moments/n-gear-lbsft", this, eN, (PMF)&FGGroundReactions::GetMoments);
-  PropertyManager->Tie("forces/fbx-gear-lbs", this, eX, (PMF)&FGGroundReactions::GetForces);
-  PropertyManager->Tie("forces/fby-gear-lbs", this, eY, (PMF)&FGGroundReactions::GetForces);
-  PropertyManager->Tie("forces/fbz-gear-lbs", this, eZ, (PMF)&FGGroundReactions::GetForces);
+  PropertyManager->Tie("gear/wow", this, &FGGroundReactions::GetWOW);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%