X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FFDM%2FJSBSim%2Fmodels%2FFGBuoyantForces.cpp;h=1b9a63b74e5907eada749fa3607951babeee0afd;hb=68f54290481701429a04cd33c06be2674fc2b3a4;hp=341f16bd8c27e8abc2eebd204af09001de19b174;hpb=70be1629e61d9b751a2f73df30b83bb1be6ca4fe;p=flightgear.git diff --git a/src/FDM/JSBSim/models/FGBuoyantForces.cpp b/src/FDM/JSBSim/models/FGBuoyantForces.cpp index 341f16bd8..1b9a63b74 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 - 2009 Anders Gidenstam ------------- - ------------- Copyright (C) 2008 Jon S. Berndt (jsb@hal-pc.org) ------------- + ------------- Copyright (C) 2008 - 2010 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.13 2010/09/07 00:40:03 jberndt Exp $"; static const char *IdHdr = ID_BUOYANTFORCES; /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -60,8 +63,6 @@ FGBuoyantForces::FGBuoyantForces(FGFDMExec* FDMExec) : FGModel(FDMExec) gasCellJ.InitMatrix(); - bind(); - Debug(0); } @@ -72,10 +73,6 @@ FGBuoyantForces::~FGBuoyantForces() for (unsigned int i=0; iHolding()) return false; // if paused don't execute if (NoneDefined) return true; + RunPreFunctions(); + vTotalForces.InitMatrix(); vTotalMoments.InitMatrix(); @@ -105,6 +104,8 @@ bool FGBuoyantForces::Run(void) vTotalMoments += Cells[i]->GetMoments(); } + RunPostFunctions(); + return false; } @@ -127,28 +128,7 @@ bool FGBuoyantForces::Load(Element *element) document = element; } - Element *property_element = document->FindElement("property"); - if (property_element) - cout << endl << " Declared properties" << endl << endl; - while (property_element) { - string interface_property_string = property_element->GetDataLine(); - - if (PropertyManager->HasNode(interface_property_string)) { - cout << " Property " << interface_property_string << - " is already defined." << endl; - } else { - double value=0.0; - if ( ! property_element->GetAttributeValue("value").empty()) - value = property_element->GetAttributeValueAsNumber("value"); - interface_properties.push_back(new double(value)); - interface_property_string = property_element->GetDataLine(); - PropertyManager->Tie(interface_property_string, - interface_properties.back()); - cout << " " << interface_property_string << - " (initial value: " << value << ")" << endl; - } - property_element = document->FindNextElement("property"); - } + FGModel::Load(element); // Perform base class Load gas_cell_element = document->FindElement("gas_cell"); while (gas_cell_element) { @@ -157,6 +137,12 @@ bool FGBuoyantForces::Load(Element *element) gas_cell_element = document->FindNextElement("gas_cell"); } + PostLoad(element, PropertyManager); + + if (!NoneDefined) { + bind(); + } + return true; } @@ -274,6 +260,19 @@ string FGBuoyantForces::GetBuoyancyValues(string delimeter) void FGBuoyantForces::bind(void) { + typedef double (FGBuoyantForces::*PMF)(int) const; + PropertyManager->Tie("moments/l-buoyancy-lbsft", this, eL, + (PMF)&FGBuoyantForces::GetMoments); + PropertyManager->Tie("moments/m-buoyancy-lbsft", this, eM, + (PMF)&FGBuoyantForces::GetMoments); + PropertyManager->Tie("moments/n-buoyancy-lbsft", this, eN, + (PMF)&FGBuoyantForces::GetMoments); + PropertyManager->Tie("forces/fbx-buoyancy-lbs", this, eX, + (PMF)&FGBuoyantForces::GetForces); + PropertyManager->Tie("forces/fby-buoyancy-lbs", this, eY, + (PMF)&FGBuoyantForces::GetForces); + PropertyManager->Tie("forces/fbz-buoyancy-lbs", this, eZ, + (PMF)&FGBuoyantForces::GetForces); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%