Date started: 09/13/00
Purpose: Encapsulates the ground reaction forces (gear and collision)
- ------------- Copyright (C) 2000 Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 2000 Jon S. Berndt (jon@jsbsim.org) -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
#include <iomanip>
#include "FGGroundReactions.h"
-#include <input_output/FGPropertyManager.h>
+#include "FGFCS.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.32 2011/05/20 03:18:36 jberndt Exp $";
static const char *IdHdr = ID_GROUNDREACTIONS;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-CLASS IMPLEMENTATION
+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
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
FGGroundReactions::FGGroundReactions(FGFDMExec* fgex) : FGModel(fgex)
{
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();
// Perhaps there is some commonality for things which only need to be
// calculated once.
for (unsigned int i=0; i<lGear.size(); i++) {
- vForces += lGear[i]->Force();
- vMoments += lGear[i]->Moment();
+ vForces += lGear[i]->GetBodyForces();
+ 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++) {
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)
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
+ FDMExec->GetFCS()->AddGear(); // make the FCS aware of the landing gear
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;
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-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
{
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);