X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGGroundReactions.cpp;h=7f92cec411f4af3e41b072a32c6fea44dbb91214;hb=a302cdc1cbb3c147e7c862b484cdd5d86f30a29c;hp=c8afc723b711578848d01d2dd4b6cad3f31977d9;hpb=50c1fe2d3e8bbfdb54873b213eb3a148cfa1f00d;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGGroundReactions.cpp b/src/FDM/JSBSim/models/FGGroundReactions.cpp index c8afc723b..7f92cec41 100644 --- a/src/FDM/JSBSim/models/FGGroundReactions.cpp +++ b/src/FDM/JSBSim/models/FGGroundReactions.cpp @@ -46,13 +46,52 @@ 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) { @@ -77,17 +116,15 @@ 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(); @@ -111,7 +148,7 @@ bool FGGroundReactions::Run(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -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) @@ -134,7 +185,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"); } @@ -142,14 +193,14 @@ bool FGGroundReactions::Load(Element* el) for (unsigned int i=0; ibind(); - FGModel::PostLoad(el); + PostLoad(el, PropertyManager); return true; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGGroundReactions::GetGroundReactionStrings(string delimeter) +string FGGroundReactions::GetGroundReactionStrings(string delimeter) const { std::ostringstream buf; @@ -184,7 +235,7 @@ string FGGroundReactions::GetGroundReactionStrings(string delimeter) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGGroundReactions::GetGroundReactionValues(string delimeter) +string FGGroundReactions::GetGroundReactionValues(string delimeter) const { std::ostringstream buf; @@ -223,6 +274,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);