X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGBuoyantForces.cpp;h=b5081760850183e647859ae7b12e9147b969d9d7;hb=1575fad886a0b18825363d41d53a287e8d36b9c8;hp=2bb3623c75f7a1725ce92a9a2ccbbc5bc0187449;hpb=4b40e725cd40d8c9a5ba3230e0bc8654e179bfc1;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGBuoyantForces.cpp b/src/FDM/JSBSim/models/FGBuoyantForces.cpp index 2bb3623c7..b50817608 100644 --- a/src/FDM/JSBSim/models/FGBuoyantForces.cpp +++ b/src/FDM/JSBSim/models/FGBuoyantForces.cpp @@ -5,8 +5,8 @@ Date started: 01/21/08 Purpose: Encapsulates the buoyant forces - ------------- Copyright (C) 2008 Anders Gidenstam ------------- - ------------- Copyright (C) 2008 Jon S. Berndt (jsb@hal-pc.org) ------------- + ------------- Copyright (C) 2008 - 2011 Anders Gidenstam ------------- + ------------- Copyright (C) 2008 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 @@ -38,11 +38,14 @@ INCLUDES #include "FGBuoyantForces.h" #include "FGMassBalance.h" -#include // Need? +#include "input_output/FGPropertyManager.h" +#include + +using namespace std; namespace JSBSim { -static const char *IdSrc = "$Id$"; +static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.21 2011/10/31 14:54:41 bcoconni Exp $"; static const char *IdHdr = ID_BUOYANTFORCES; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -60,8 +63,6 @@ FGBuoyantForces::FGBuoyantForces(FGFDMExec* FDMExec) : FGModel(FDMExec) gasCellJ.InitMatrix(); - bind(); - Debug(0); } @@ -72,8 +73,6 @@ FGBuoyantForces::~FGBuoyantForces() for (unsigned int i=0; iHolding()) return false; // if paused don't execute + if (FGModel::Run(Holding)) return true; + if (Holding) return false; // if paused don't execute if (NoneDefined) return true; + RunPreFunctions(); + vTotalForces.InitMatrix(); vTotalMoments.InitMatrix(); @@ -103,6 +102,8 @@ bool FGBuoyantForces::Run(void) vTotalMoments += Cells[i]->GetMoments(); } + RunPostFunctions(); + return false; } @@ -125,19 +126,27 @@ bool FGBuoyantForces::Load(Element *element) document = element; } + FGModel::Load(element); // Perform base class Load + gas_cell_element = document->FindElement("gas_cell"); while (gas_cell_element) { NoneDefined = false; - Cells.push_back(new FGGasCell(FDMExec, gas_cell_element, Cells.size())); + Cells.push_back(new FGGasCell(FDMExec, gas_cell_element, Cells.size(), in)); gas_cell_element = document->FindNextElement("gas_cell"); } + PostLoad(element, PropertyManager); + + if (!NoneDefined) { + bind(); + } + return true; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -double FGBuoyantForces::GetGasMass(void) +double FGBuoyantForces::GetGasMass(void) const { double Gw = 0.0; @@ -150,7 +159,7 @@ double FGBuoyantForces::GetGasMass(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGColumnVector3& FGBuoyantForces::GetGasMassMoment(void) +const FGColumnVector3& FGBuoyantForces::GetGasMassMoment(void) { vXYZgasCell_arm.InitMatrix(); for (unsigned int i = 0; i < Cells.size(); i++) { @@ -161,7 +170,7 @@ FGColumnVector3& FGBuoyantForces::GetGasMassMoment(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGMatrix33& FGBuoyantForces::GetGasMassInertia(void) +const FGMatrix33& FGBuoyantForces::GetGasMassInertia(void) { const unsigned int size = Cells.size(); @@ -170,16 +179,7 @@ FGMatrix33& FGBuoyantForces::GetGasMassInertia(void) gasCellJ = FGMatrix33(); for (unsigned int i=0; i < size; i++) { - FGColumnVector3 v = MassBalance->StructuralToBody( Cells[i]->GetXYZ() ); - // Body basis is in FT. - const double mass = Cells[i]->GetMass(); - - // FIXME: Verify that this is the correct way to change between the - // coordinate frames. - gasCellJ += Cells[i]->GetInertia() + - FGMatrix33( 0, - mass*v(1)*v(2), - mass*v(1)*v(3), - - mass*v(2)*v(1), 0, - mass*v(2)*v(3), - - mass*v(3)*v(1), - mass*v(3)*v(2), 0 ); + gasCellJ += Cells[i]->GetInertia(); } return gasCellJ; @@ -187,11 +187,11 @@ FGMatrix33& FGBuoyantForces::GetGasMassInertia(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGBuoyantForces::GetBuoyancyStrings(string delimeter) +string FGBuoyantForces::GetBuoyancyStrings(const string& delimeter) { string CoeffStrings = ""; - bool firstime = true; /* + bool firstime = true; for (sd = 0; sd < variables.size(); sd++) { if (firstime) { firstime = false; @@ -202,13 +202,13 @@ string FGBuoyantForces::GetBuoyancyStrings(string delimeter) } for (axis = 0; axis < 6; axis++) { - for (sd = 0; sd < Coeff[axis].size(); sd++) { + for (sd = 0; sd < AeroFunctions[axis].size(); sd++) { if (firstime) { firstime = false; } else { CoeffStrings += delimeter; } - CoeffStrings += Coeff[axis][sd]->GetName(); + CoeffStrings += AeroFunctions[axis][sd]->GetName(); } } */ @@ -217,11 +217,11 @@ string FGBuoyantForces::GetBuoyancyStrings(string delimeter) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -string FGBuoyantForces::GetBuoyancyValues(string delimeter) +string FGBuoyantForces::GetBuoyancyValues(const string& delimeter) { string SDValues = ""; - bool firstime = true; /* + bool firstime = true; for (sd = 0; sd < variables.size(); sd++) { if (firstime) { firstime = false; @@ -232,13 +232,13 @@ string FGBuoyantForces::GetBuoyancyValues(string delimeter) } for (unsigned int axis = 0; axis < 6; axis++) { - for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) { + for (unsigned int sd = 0; sd < AeroFunctions[axis].size(); sd++) { if (firstime) { firstime = false; } else { SDValues += delimeter; } - SDValues += Coeff[axis][sd]->GetValueAsString(); + SDValues += AeroFunctions[axis][sd]->GetValueAsString(); } } */ @@ -249,12 +249,20 @@ string FGBuoyantForces::GetBuoyancyValues(string delimeter) void FGBuoyantForces::bind(void) { -} - -//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -void FGBuoyantForces::unbind(void) -{ + typedef double (FGBuoyantForces::*PGF)(int) const; + typedef void (FGBuoyantForces::*PSF)(int, double); + PropertyManager->Tie("moments/l-buoyancy-lbsft", this, eL, + (PGF)&FGBuoyantForces::GetMoments, (PSF)0, false); + PropertyManager->Tie("moments/m-buoyancy-lbsft", this, eM, + (PGF)&FGBuoyantForces::GetMoments, (PSF)0, false); + PropertyManager->Tie("moments/n-buoyancy-lbsft", this, eN, + (PGF)&FGBuoyantForces::GetMoments, (PSF)0, false); + PropertyManager->Tie("forces/fbx-buoyancy-lbs", this, eX, + (PGF)&FGBuoyantForces::GetForces, (PSF)0, false); + PropertyManager->Tie("forces/fby-buoyancy-lbs", this, eY, + (PGF)&FGBuoyantForces::GetForces, (PSF)0, false); + PropertyManager->Tie("forces/fbz-buoyancy-lbs", this, eZ, + (PGF)&FGBuoyantForces::GetForces, (PSF)0, false); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%