#include <iomanip>
#include "FGGroundReactions.h"
-#include "FGFCS.h"
+#include "FGLGear.h"
#include "input_output/FGPropertyManager.h"
using namespace std;
namespace JSBSim {
-static const char *IdSrc = "$Id: FGGroundReactions.cpp,v 1.30 2010/09/07 00:40:03 jberndt Exp $";
+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 for MultiplierIterator (See below for FGGroundReactions)
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-
-MultiplierIterator::MultiplierIterator(FGGroundReactions* GndReactions)
-: GroundReactions(GndReactions),
- multiplier(NULL),
- gearNum(0),
- entry(0)
-{
- for (int i=0; i < GroundReactions->GetNumGearUnits(); i++) {
- FGLGear* gear = GroundReactions->GetGearUnit(i);
-
- if (!gear->GetWOW()) continue;
-
- gearNum = i;
- multiplier = gear->GetMultiplierEntry(0);
- break;
- }
-}
-
-MultiplierIterator& MultiplierIterator::operator++()
-{
- for (int i=gearNum; i < GroundReactions->GetNumGearUnits(); i++) {
- FGLGear* gear = GroundReactions->GetGearUnit(i);
-
- if (!gear->GetWOW()) continue;
-
- multiplier = gear->GetMultiplierEntry(++entry);
- if (multiplier) {
- gearNum = i;
- break;
- }
- else
- entry = -1;
- }
-
- return *this;
-}
-
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
CLASS IMPLEMENTATION
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
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.
return result;
}
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-// This function must be called after friction forces are resolved in order to
-// include them in the ground reactions total force and moment.
-void FGGroundReactions::UpdateForcesAndMoments(void)
-{
- vForces.InitMatrix();
- vMoments.InitMatrix();
-
- for (unsigned int i=0; i<lGear.size(); i++) {
- vForces += lGear[i]->UpdateForces();
- vMoments += lGear[i]->GetMoments();
- }
-}
-
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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();
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGGroundReactions::GetGroundReactionStrings(string delimeter)
+string FGGroundReactions::GetGroundReactionStrings(string delimeter) const
{
std::ostringstream buf;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-string FGGroundReactions::GetGroundReactionValues(string delimeter)
+string FGGroundReactions::GetGroundReactionValues(string delimeter) const
{
std::ostringstream buf;
typedef double (FGGroundReactions::*PMF)(int) const;
PropertyManager->Tie("gear/num-units", this, &FGGroundReactions::GetNumGearUnits);
PropertyManager->Tie("gear/wow", this, &FGGroundReactions::GetWOW);
- 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);
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%