]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGBuoyantForces.cpp
Merge branch 'next' into durk-atc
[flightgear.git] / src / FDM / JSBSim / models / FGBuoyantForces.cpp
index 49d9cb2e5069402f35c9db616e99debf5bd6a17f..d12777478c1ada31484e00e1cb588b97bb38c17a 100644 (file)
@@ -5,7 +5,7 @@
  Date started: 01/21/08
  Purpose:      Encapsulates the buoyant forces
 
- ------------- Copyright (C) 2008 - 2009  Anders Gidenstam        -------------
+ ------------- 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
@@ -38,14 +38,14 @@ INCLUDES
 
 #include "FGBuoyantForces.h"
 #include "FGMassBalance.h"
-#include "input_output/FGPropertyManager.h"  // Need?
+#include "input_output/FGPropertyManager.h"
 #include <iostream>
 
 using namespace std;
 
 namespace JSBSim {
 
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGBuoyantForces.cpp,v 1.16 2011/03/23 11:58:29 jberndt Exp $";
 static const char *IdHdr = ID_BUOYANTFORCES;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -63,8 +63,6 @@ FGBuoyantForces::FGBuoyantForces(FGFDMExec* FDMExec) : FGModel(FDMExec)
 
   gasCellJ.InitMatrix();
 
-  bind();
-
   Debug(0);
 }
 
@@ -139,7 +137,11 @@ bool FGBuoyantForces::Load(Element *element)
     gas_cell_element = document->FindNextElement("gas_cell");
   }
   
-  FGModel::PostLoad(element);
+  PostLoad(element, PropertyManager);
+
+  if (!NoneDefined) {
+    bind();
+  }
 
   return true;
 }
@@ -179,7 +181,7 @@ const FGMatrix33& FGBuoyantForces::GetGasMassInertia(void)
   gasCellJ = FGMatrix33();
 
   for (unsigned int i=0; i < size; i++) {
-    FGColumnVector3 v = MassBalance->StructuralToBody( Cells[i]->GetXYZ() );
+    FGColumnVector3 v = FDMExec->GetMassBalance()->StructuralToBody( Cells[i]->GetXYZ() );
     // Body basis is in FT. 
     const double mass = Cells[i]->GetMass();
     
@@ -211,13 +213,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();
     }
   }
 */
@@ -241,13 +243,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();
     }
   }
 */
@@ -258,6 +260,20 @@ string FGBuoyantForces::GetBuoyancyValues(string delimeter)
 
 void FGBuoyantForces::bind(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);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%