X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGGroundReactions.cpp;h=9126c9f812ec768d4a50468a347ab027585cc8d0;hb=53e8fbfcbb3ddac0dc261043fea7bd24dfa6e62d;hp=36837004a6a387a682c019391ddefd0e0c59070f;hpb=0f0f25512d4b5a4c1b56de2ad975abc7285c9bf5;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGGroundReactions.cpp b/src/FDM/JSBSim/models/FGGroundReactions.cpp index 36837004a..9126c9f81 100644 --- a/src/FDM/JSBSim/models/FGGroundReactions.cpp +++ b/src/FDM/JSBSim/models/FGGroundReactions.cpp @@ -39,17 +39,59 @@ INCLUDES #include #include "FGGroundReactions.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.31 2010/11/18 12:38:06 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) { @@ -86,6 +128,8 @@ bool FGGroundReactions::Run(void) if (FGModel::Run()) return true; if (FDMExec->Holding()) return false; + RunPreFunctions(); + vForces.InitMatrix(); vMoments.InitMatrix(); @@ -99,12 +143,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; iUpdateForces(); + vMoments += lGear[i]->GetMoments(); + } +} + //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bool FGGroundReactions::Load(Element* el) @@ -127,7 +187,7 @@ 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"); } @@ -135,12 +195,14 @@ bool FGGroundReactions::Load(Element* el) for (unsigned int i=0; ibind(); + PostLoad(el, PropertyManager); + return true; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGGroundReactions::GetGroundReactionStrings(string delimeter) +string FGGroundReactions::GetGroundReactionStrings(string delimeter) const { std::ostringstream buf; @@ -175,14 +237,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;iIsBogey()) { 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,6 +276,7 @@ void FGGroundReactions::bind(void) { 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);