]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/models/FGAircraft.cpp
Merge branch 'next' of gitorious.org:fg/flightgear into next
[flightgear.git] / src / FDM / JSBSim / models / FGAircraft.cpp
index c1d3ec86f0aa80cc711798c03be116f5bc615478..a433a56fa8812e30cc3657666452b5864c00a6af 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
@@ -40,34 +40,14 @@ INCLUDES
 
 #include <sys/stat.h>
 #include <sys/types.h>
-
-#ifdef FGFS
-#  ifndef __BORLANDC__
-#    include <simgear/compiler.h>
-#  endif
-#  ifdef SG_HAVE_STD_INCLUDES
-#    include <cmath>
-#  else
-#    include <math.h>
-#  endif
-#else
-#  if defined (sgi) && !defined(__GNUC__)
-#    include <math.h>
-#  else
-#    include <cmath>
-#  endif
-#endif
+#include <iostream>
+#include <cmath>
 
 #include "FGAircraft.h"
-#include "FGMassBalance.h"
-#include "FGInertial.h"
-#include "FGGroundReactions.h"
-#include "FGExternalReactions.h"
-#include "FGBuoyantForces.h"
-#include "FGAerodynamics.h"
-#include <FGFDMExec.h>
-#include "FGPropagate.h"
-#include <input_output/FGPropertyManager.h>
+#include "FGFDMExec.h"
+#include "input_output/FGPropertyManager.h"
+
+using namespace std;
 
 namespace JSBSim {
 
@@ -79,7 +59,7 @@ DEFINITIONS
 GLOBAL DATA
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGAircraft.cpp,v 1.33 2011/08/21 15:06:38 bcoconni Exp $";
 static const char *IdHdr = ID_AIRCRAFT;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -90,6 +70,8 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex)
 {
   Name = "FGAircraft";
   WingSpan = 0.0;
+  WingArea = 0.0;
+  cbar = 0.0;
   HTailArea = VTailArea = 0.0;
   HTailArm  = VTailArm  = 0.0;
   lbarh = lbarv = 0.0;
@@ -113,60 +95,52 @@ FGAircraft::~FGAircraft()
 
 bool FGAircraft::InitModel(void)
 {
-  if (!FGModel::InitModel()) return false;
-
   return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGAircraft::Run(void)
+bool FGAircraft::Run(bool Holding)
 {
-  if (FGModel::Run()) return true;
-  if (FDMExec->Holding()) return false;
+  if (FGModel::Run(Holding)) return true;
+  if (Holding) return false;
+
+  RunPreFunctions();
 
   vForces.InitMatrix();
   if (!HoldDown) {
-    vForces += Aerodynamics->GetForces();
-    vForces += Propulsion->GetForces();
-    vForces += GroundReactions->GetForces();
-    vForces += ExternalReactions->GetForces();
-    vForces += BuoyantForces->GetForces();
+    vForces += in.AeroForce;
+    vForces += in.PropForce;
+    vForces += in.GroundForce;
+    vForces += in.ExternalForce;
+    vForces += in.BuoyantForce;
+  } else {
+    vForces = in.Tl2b * FGColumnVector3(0,0,-in.Weight);
   }
 
   vMoments.InitMatrix();
   if (!HoldDown) {
-    vMoments += Aerodynamics->GetMoments();
-    vMoments += Propulsion->GetMoments();
-    vMoments += GroundReactions->GetMoments();
-    vMoments += ExternalReactions->GetMoments();
-    vMoments += BuoyantForces->GetMoments();
+    vMoments += in.AeroMoment;
+    vMoments += in.PropMoment;
+    vMoments += in.GroundMoment;
+    vMoments += in.ExternalMoment;
+    vMoments += in.BuoyantMoment;
   }
 
-  vBodyAccel = vForces/MassBalance->GetMass();
-
-  vNcg = vBodyAccel/Inertial->gravity();
-
-  vNwcg = Aerodynamics->GetTb2w() * vNcg;
-  vNwcg(3) = -1*vNwcg(3) + 1;
+  RunPostFunctions();
 
   return false;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-double FGAircraft::GetNlf(void)
-{
-  return -1*Aerodynamics->GetvFw(3)/MassBalance->GetWeight();
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
 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"))
@@ -208,6 +182,8 @@ bool FGAircraft::Load(Element* el)
     }
   }
 
+  PostLoad(el, PropertyManager);
+
   Debug(2);
 
   return true;
@@ -231,13 +207,6 @@ void FGAircraft::bind(void)
   PropertyManager->Tie("metrics/lv-norm", this, &FGAircraft::Getlbarv);
   PropertyManager->Tie("metrics/vbarh-norm", this, &FGAircraft::Getvbarh);
   PropertyManager->Tie("metrics/vbarv-norm", this, &FGAircraft::Getvbarv);
-  PropertyManager->Tie("forces/hold-down", this, &FGAircraft::GetHoldDown, &FGAircraft::SetHoldDown);
-  PropertyManager->Tie("moments/l-total-lbsft", this, eL, (PMF)&FGAircraft::GetMoments);
-  PropertyManager->Tie("moments/m-total-lbsft", this, eM, (PMF)&FGAircraft::GetMoments);
-  PropertyManager->Tie("moments/n-total-lbsft", this, eN, (PMF)&FGAircraft::GetMoments);
-  PropertyManager->Tie("forces/fbx-total-lbs", this, eX, (PMF)&FGAircraft::GetForces);
-  PropertyManager->Tie("forces/fby-total-lbs", this, eY, (PMF)&FGAircraft::GetForces);
-  PropertyManager->Tie("forces/fbz-total-lbs", this, eZ, (PMF)&FGAircraft::GetForces);
   PropertyManager->Tie("metrics/aero-rp-x-in", this, eX, (PMF)&FGAircraft::GetXYZrp);
   PropertyManager->Tie("metrics/aero-rp-y-in", this, eY, (PMF)&FGAircraft::GetXYZrp);
   PropertyManager->Tie("metrics/aero-rp-z-in", this, eZ, (PMF)&FGAircraft::GetXYZrp);
@@ -247,6 +216,7 @@ void FGAircraft::bind(void)
   PropertyManager->Tie("metrics/visualrefpoint-x-in", this, eX, (PMF)&FGAircraft::GetXYZvrp);
   PropertyManager->Tie("metrics/visualrefpoint-y-in", this, eY, (PMF)&FGAircraft::GetXYZvrp);
   PropertyManager->Tie("metrics/visualrefpoint-z-in", this, eZ, (PMF)&FGAircraft::GetXYZvrp);
+  PropertyManager->Tie("forces/hold-down", this, &FGAircraft::GetHoldDown, &FGAircraft::SetHoldDown);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%