Skip to content

Commit

Permalink
Fix a circular reference between FGMassBalance and FGForce.
Browse files Browse the repository at this point in the history
FGMassBalance needs not to use a direct reference to FGGroundReactions. Use the Mediator pattern instead (FGFDMExec being the mediator).
  • Loading branch information
bcoconni committed Dec 6, 2020
1 parent cdebbf2 commit 5530ed2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/FGFDMExec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ void FGFDMExec::LoadInputs(unsigned int idx)
MassBalance->in.TanksWeight = Propulsion->GetTanksWeight();
MassBalance->in.TanksMoment = Propulsion->GetTanksMoment();
MassBalance->in.TankInertia = Propulsion->CalculateTankInertias();
MassBalance->in.WOW = GroundReactions->GetWOW();
break;
case eAircraft:
Aircraft->in.AeroForce = Aerodynamics->GetForces();
Expand Down
6 changes: 2 additions & 4 deletions src/models/FGMassBalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ INCLUDES

#include "FGMassBalance.h"
#include "FGFDMExec.h"
#include "FGGroundReactions.h"
#include "input_output/FGXMLElement.h"

using namespace std;
Expand All @@ -55,7 +54,7 @@ CLASS IMPLEMENTATION


FGMassBalance::FGMassBalance(FGFDMExec* fdmex)
: FGModel(fdmex), GroundReactions(nullptr)
: FGModel(fdmex)
{
Name = "FGMassBalance";
Weight = EmptyWeight = Mass = 0.0;
Expand Down Expand Up @@ -90,7 +89,6 @@ bool FGMassBalance::InitModel(void)
{
if (!FGModel::InitModel()) return false;

GroundReactions = FDMExec->GetGroundReactions();
vLastXYZcg.InitMatrix();
vDeltaXYZcg.InitMatrix();

Expand Down Expand Up @@ -211,7 +209,7 @@ bool FGMassBalance::Run(bool Holding)

// Compensate displacements of the structural frame when the mass distribution
// is modified while the aircraft is in contact with the ground.
if (FDMExec->GetHoldDown() || GroundReactions->GetWOW())
if (FDMExec->GetHoldDown() || in.WOW)
Propagate->NudgeBodyLocation(vDeltaXYZcgBody);

// Calculate new total moments of inertia
Expand Down
2 changes: 1 addition & 1 deletion src/models/FGMassBalance.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ class FGMassBalance : public FGModel
FGMatrix33 GasInertia;
FGColumnVector3 TanksMoment;
FGMatrix33 TankInertia;
bool WOW;
} in;

private:
std::shared_ptr<FGPropagate> Propagate;
std::shared_ptr<FGGroundReactions> GroundReactions;
double Weight;
double EmptyWeight;
double Mass;
Expand Down

0 comments on commit 5530ed2

Please sign in to comment.