]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGBuoyantForces.cpp
Sync with JSBSim cvs + Anders' patch to get it working with FlightGear.
[flightgear.git] / src / FDM / JSBSim / models / FGBuoyantForces.cpp
index 44ecd65959a5f09f60d84165446d3ceca46430f4..1b9a63b74e5907eada749fa3607951babeee0afd 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.13 2010/09/07 00:40:03 jberndt Exp $";
 static const char *IdHdr = ID_BUOYANTFORCES;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -63,8 +63,6 @@ FGBuoyantForces::FGBuoyantForces(FGFDMExec* FDMExec) : FGModel(FDMExec)
 
   gasCellJ.InitMatrix();
 
-  bind();
-
   Debug(0);
 }
 
@@ -95,6 +93,8 @@ bool FGBuoyantForces::Run(void)
   if (FDMExec->Holding()) return false; // if paused don't execute
   if (NoneDefined) return true;
 
+  RunPreFunctions();
+
   vTotalForces.InitMatrix();
   vTotalMoments.InitMatrix();
 
@@ -104,6 +104,8 @@ bool FGBuoyantForces::Run(void)
     vTotalMoments += Cells[i]->GetMoments();
   }
 
+  RunPostFunctions();
+
   return false;
 }
 
@@ -135,6 +137,12 @@ bool FGBuoyantForces::Load(Element *element)
     gas_cell_element = document->FindNextElement("gas_cell");
   }
   
+  PostLoad(element, PropertyManager);
+
+  if (!NoneDefined) {
+    bind();
+  }
+
   return true;
 }
 
@@ -252,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);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%