]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGAircraft.cpp
Sync with JSBSim cvs + Anders' patch to get it working with FlightGear.
[flightgear.git] / src / FDM / JSBSim / models / FGAircraft.cpp
index 463e902a2512ecdf8dae4b322e4b3a7dea23d2e1..0ed6ac74f33975f09d0dcdca72953d51d0e7ab09 100644 (file)
@@ -6,7 +6,7 @@
  Purpose:      Encapsulates an aircraft
  Called by:    FGFDMExec
 
- ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 1999  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
@@ -50,9 +50,13 @@ INCLUDES
 #include "FGExternalReactions.h"
 #include "FGBuoyantForces.h"
 #include "FGAerodynamics.h"
-#include <FGFDMExec.h>
+#include "FGFDMExec.h"
 #include "FGPropagate.h"
-#include <input_output/FGPropertyManager.h>
+#include "FGPropulsion.h"
+#include "input_output/FGPropertyManager.h"
+#include <iostream>
+
+using namespace std;
 
 namespace JSBSim {
 
@@ -64,7 +68,7 @@ DEFINITIONS
 GLOBAL DATA
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.28 2010/09/07 00:40:03 jberndt Exp $";
 static const char *IdHdr = ID_AIRCRAFT;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -110,6 +114,8 @@ bool FGAircraft::Run(void)
   if (FGModel::Run()) return true;
   if (FDMExec->Holding()) return false;
 
+  RunPreFunctions();
+
   vForces.InitMatrix();
   if (!HoldDown) {
     vForces += Aerodynamics->GetForces();
@@ -117,6 +123,9 @@ bool FGAircraft::Run(void)
     vForces += GroundReactions->GetForces();
     vForces += ExternalReactions->GetForces();
     vForces += BuoyantForces->GetForces();
+  } else {
+    const FGMatrix33& mTl2b = Propagate->GetTl2b();
+    vForces = mTl2b * FGColumnVector3(0,0,-MassBalance->GetWeight());
   }
 
   vMoments.InitMatrix();
@@ -130,10 +139,12 @@ bool FGAircraft::Run(void)
 
   vBodyAccel = vForces/MassBalance->GetMass();
 
-  vNcg = vBodyAccel/Inertial->gravity();
+  vNcg = vBodyAccel/Inertial->SLgravity();
 
   vNwcg = Aerodynamics->GetTb2w() * vNcg;
-  vNwcg(3) = -1*vNwcg(3) + 1;
+  vNwcg(3) = 1.0 - vNwcg(3);
+
+  RunPostFunctions();
 
   return false;
 }
@@ -152,6 +163,8 @@ bool FGAircraft::Load(Element* el)
   string element_name;
   Element* element;
 
+  FGModel::Load(el);
+
   if (el->FindElement("wingarea"))
     WingArea = el->FindElementValueAsNumberConvertTo("wingarea", "FT2");
   if (el->FindElement("wingspan"))
@@ -193,6 +206,8 @@ bool FGAircraft::Load(Element* el)
     }
   }
 
+  PostLoad(el, PropertyManager);
+
   Debug(2);
 
   return true;