]> git.mxchange.org Git - flightgear.git/commitdiff
Synced with latest JSBSim as of June 5, 2001.
authorcurt <curt>
Tue, 5 Jun 2001 20:58:48 +0000 (20:58 +0000)
committercurt <curt>
Tue, 5 Jun 2001 20:58:48 +0000 (20:58 +0000)
66 files changed:
FlightGear.dsp
src/FDM/JSBSim.cxx
src/FDM/JSBSim.hxx
src/FDM/JSBSim/FGAerodynamics.cpp
src/FDM/JSBSim/FGAerodynamics.h
src/FDM/JSBSim/FGAircraft.cpp
src/FDM/JSBSim/FGAircraft.h
src/FDM/JSBSim/FGAuxiliary.cpp
src/FDM/JSBSim/FGAuxiliary.h
src/FDM/JSBSim/FGCoefficient.cpp
src/FDM/JSBSim/FGConfigFile.cpp
src/FDM/JSBSim/FGConfigFile.h
src/FDM/JSBSim/FGControls.cpp
src/FDM/JSBSim/FGControls.h
src/FDM/JSBSim/FGDefs.h
src/FDM/JSBSim/FGEngine.cpp
src/FDM/JSBSim/FGEngine.h
src/FDM/JSBSim/FGFCS.cpp
src/FDM/JSBSim/FGFCS.h
src/FDM/JSBSim/FGFDMExec.cpp
src/FDM/JSBSim/FGFDMExec.h
src/FDM/JSBSim/FGForce.cpp
src/FDM/JSBSim/FGGroundReactions.cpp
src/FDM/JSBSim/FGGroundReactions.h
src/FDM/JSBSim/FGInertial.cpp
src/FDM/JSBSim/FGInertial.h
src/FDM/JSBSim/FGLGear.cpp
src/FDM/JSBSim/FGLGear.h
src/FDM/JSBSim/FGMassBalance.cpp
src/FDM/JSBSim/FGMassBalance.h
src/FDM/JSBSim/FGMatrix.h
src/FDM/JSBSim/FGModel.cpp
src/FDM/JSBSim/FGModel.h
src/FDM/JSBSim/FGNozzle.cpp
src/FDM/JSBSim/FGNozzle.h
src/FDM/JSBSim/FGOutput.cpp
src/FDM/JSBSim/FGOutput.h
src/FDM/JSBSim/FGPiston.cpp
src/FDM/JSBSim/FGPosition.cpp
src/FDM/JSBSim/FGPosition.h
src/FDM/JSBSim/FGPropeller.cpp
src/FDM/JSBSim/FGPropeller.h
src/FDM/JSBSim/FGPropulsion.cpp
src/FDM/JSBSim/FGPropulsion.h
src/FDM/JSBSim/FGRocket.cpp
src/FDM/JSBSim/FGRotation.cpp
src/FDM/JSBSim/FGRotation.h
src/FDM/JSBSim/FGState.cpp
src/FDM/JSBSim/FGState.h
src/FDM/JSBSim/FGTank.cpp
src/FDM/JSBSim/FGTank.h
src/FDM/JSBSim/FGTranslation.cpp
src/FDM/JSBSim/FGTranslation.h
src/FDM/JSBSim/FGTrim.cpp
src/FDM/JSBSim/FGTrim.h
src/FDM/JSBSim/FGUtility.cpp
src/FDM/JSBSim/FGfdmSocket.h
src/FDM/JSBSim/JSBSim.cpp
src/FDM/JSBSim/Makefile.am
src/FDM/JSBSim/filtersjb/FGFilter.cpp
src/FDM/JSBSim/filtersjb/FGFlaps.cpp
src/FDM/JSBSim/filtersjb/FGFlaps.h
src/FDM/JSBSim/filtersjb/FGGain.cpp
src/FDM/JSBSim/filtersjb/FGGain.h
src/FDM/JSBSim/filtersjb/FGSummer.cpp
src/FDM/JSBSim/filtersjb/FGSummer.h

index 62678f17877ee0c6ccb30d39c13a1edfd4c97547..0bf3b821050b0e4460807c029a1d8295129d7688 100644 (file)
@@ -4450,40 +4450,6 @@ SOURCE=.\src\Input\input.hxx
 \r
 !ENDIF \r
 \r
-# End Source File\r
-# End Group\r
-# Begin Group "Lib_Joystick"\r
-\r
-# PROP Default_Filter ""\r
-# Begin Source File\r
-\r
-SOURCE=.\src\Joystick\joystick.cxx\r
-\r
-!IF  "$(CFG)" == "FlightGear - Win32 Release"\r
-\r
-# PROP Intermediate_Dir "Release\Lib_Joystick"\r
-\r
-!ELSEIF  "$(CFG)" == "FlightGear - Win32 Debug"\r
-\r
-# PROP Intermediate_Dir "Debug\Lib_Joystick"\r
-\r
-!ENDIF \r
-\r
-# End Source File\r
-# Begin Source File\r
-\r
-SOURCE=.\src\Joystick\joystick.hxx\r
-\r
-!IF  "$(CFG)" == "FlightGear - Win32 Release"\r
-\r
-# PROP Intermediate_Dir "Release\Lib_Joystick"\r
-\r
-!ELSEIF  "$(CFG)" == "FlightGear - Win32 Debug"\r
-\r
-# PROP Intermediate_Dir "Debug\Lib_Joystick"\r
-\r
-!ENDIF \r
-\r
 # End Source File\r
 # End Group\r
 # Begin Group "main"\r
index 901df669dbb49734b04a52978e567dfbf8de9e26..05fa4ec5d5d265eaabfbc957611ed36babc1c05b 100644 (file)
@@ -53,7 +53,8 @@
 #include <FDM/JSBSim/FGInitialCondition.h>
 #include <FDM/JSBSim/FGTrim.h>
 #include <FDM/JSBSim/FGAtmosphere.h>
-
+#include <FDM/JSBSim/FGMassBalance.h>
+#include <FDM/JSBSim/FGAerodynamics.h>
 #include "JSBSim.hxx"
 
 /******************************************************************************/
@@ -65,15 +66,17 @@ FGJSBsim::FGJSBsim( double dt )
    
     fdmex=new FGFDMExec;
     
-    State       = fdmex->GetState();
-    Atmosphere  = fdmex->GetAtmosphere();
-    FCS         = fdmex->GetFCS();
-    Propulsion  = fdmex->GetPropulsion();
-    Aircraft    = fdmex->GetAircraft();
-    Translation = fdmex->GetTranslation();
-    Rotation    = fdmex->GetRotation();
-    Position    = fdmex->GetPosition();
-    Auxiliary   = fdmex->GetAuxiliary();
+    State        = fdmex->GetState();
+    Atmosphere   = fdmex->GetAtmosphere();
+    FCS          = fdmex->GetFCS();
+    MassBalance  = fdmex->GetMassBalance();
+    Propulsion   = fdmex->GetPropulsion();
+    Aircraft     = fdmex->GetAircraft();
+    Translation  = fdmex->GetTranslation();
+    Rotation     = fdmex->GetRotation();
+    Position     = fdmex->GetPosition();
+    Auxiliary    = fdmex->GetAuxiliary();
+    Aerodynamics = fdmex->GetAerodynamics();
 
     fgic=new FGInitialCondition(fdmex);
     needTrim=true;
@@ -292,15 +295,15 @@ bool FGJSBsim::copy_to_JSBsim() {
 bool FGJSBsim::copy_from_JSBsim() {
     unsigned int i, j;
 
-    _set_Inertias( Aircraft->GetMass(),
-                   Aircraft->GetIxx(),
-                   Aircraft->GetIyy(),
-                   Aircraft->GetIzz(),
-                   Aircraft->GetIxz() );
+    _set_Inertias( MassBalance->GetMass(),
+                   MassBalance->GetIxx(),
+                   MassBalance->GetIyy(),
+                   MassBalance->GetIzz(),
+                   MassBalance->GetIxz() );
 
-    _set_CG_Position( Aircraft->GetXYZcg(1),
-                      Aircraft->GetXYZcg(2),
-                      Aircraft->GetXYZcg(3) );
+    _set_CG_Position( MassBalance->GetXYZcg(1),
+                      MassBalance->GetXYZcg(2),
+                      MassBalance->GetXYZcg(3) );
 
     _set_Accels_Body( Translation->GetUVWdot(1),
                       Translation->GetUVWdot(2),
@@ -322,7 +325,7 @@ bool FGJSBsim::copy_from_JSBsim() {
     //                         Auxiliary->GetNpilot(2),
     //                         Auxiliary->GetNpilot(3) );
 
-    _set_Nlf( Aircraft->GetNlf() );
+    _set_Nlf( Aerodynamics->GetNlf() );
 
     // Velocities
 
index a25bb91b379b6ed53ed8dc21536aa35c29fb686a..28718a2b31d5ab6e98e0de21d3e042f79a17e976 100644 (file)
@@ -38,7 +38,7 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include <FDM/JSBSim/FGFDMExec.h>
-#include <FDM/JSBSim/FGInitialCondition.h>
+
 #undef MAX_ENGINES
 #include <Aircraft/aircraft.hxx>
 
@@ -202,15 +202,17 @@ private:
     FGInitialCondition *fgic;
     bool needTrim;
 
-    FGState*       State;
-    FGAtmosphere*  Atmosphere;
-    FGFCS*         FCS;
-    FGPropulsion*  Propulsion;
-    FGAircraft*    Aircraft;
-    FGTranslation* Translation;
-    FGRotation*    Rotation;
-    FGPosition*    Position;
-    FGAuxiliary*   Auxiliary;
+    FGState*        State;
+    FGAtmosphere*   Atmosphere;
+    FGFCS*          FCS;
+    FGPropulsion*   Propulsion;
+    FGMassBalance*  MassBalance;
+    FGAircraft*     Aircraft;
+    FGTranslation*  Translation;
+    FGRotation*     Rotation;
+    FGPosition*     Position;
+    FGAuxiliary*    Auxiliary;
+    FGAerodynamics* Aerodynamics;
 
     int runcount;
     float trim_elev;
index 6889ca27560588d48eaab0a83978a0ec9a9705f8..778dd95380f263e68d9e66c52ab8d9832a311a93 100644 (file)
@@ -30,6 +30,7 @@ FUNCTIONAL DESCRIPTION
 HISTORY
 --------------------------------------------------------------------------------
 09/13/00   JSB   Created
+04/22/01   JSB   Moved code into here from FGAircraft
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
@@ -47,8 +48,24 @@ CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 
-FGAerodynamics::FGAerodynamics(FGFDMExec* fgex) : FGModel(fgex)
+FGAerodynamics::FGAerodynamics(FGFDMExec* FDMExec) : FGModel(FDMExec),
+    vMoments(3),
+    vForces(3),
+    vFs(3),
+    vLastFs(3),
+    vDXYZcg(3)
 {
+  Name = "FGAerodynamics";
+
+  AxisIdx["DRAG"]  = 0;
+  AxisIdx["SIDE"]  = 1;
+  AxisIdx["LIFT"]  = 2;
+  AxisIdx["ROLL"]  = 3;
+  AxisIdx["PITCH"] = 4;
+  AxisIdx["YAW"]   = 5;
+
+  Coeff = new CoeffArray[6];
+
   if (debug_lvl & 2) cout << "Instantiated: FGAerodynamics" << endl;
 }
 
@@ -56,15 +73,56 @@ FGAerodynamics::FGAerodynamics(FGFDMExec* fgex) : FGModel(fgex)
 
 FGAerodynamics::~FGAerodynamics()
 {
+  unsigned int i,j;
+  for (i=0; i<6; i++) {
+    for (j=0; j<Coeff[i].size(); j++) {
+      delete Coeff[i][j];
+    }
+  }
+  delete[] Coeff;
+
   if (debug_lvl & 2) cout << "Destroyed:    FGAerodynamics" << endl;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGAerodynamics:: Run(void) {
+bool FGAerodynamics::Run(void)
+{
+  float alpha, beta;
+  unsigned int axis_ctr,ctr;
 
   if (!FGModel::Run()) {
 
+    alpha = Translation->Getalpha();
+    beta = Translation->Getbeta();
+
+    vLastFs = vFs;
+    vFs.InitMatrix();
+
+    for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
+      for (ctr=0; ctr < Coeff[axis_ctr].size(); ctr++) {
+        vFs(axis_ctr+1) += Coeff[axis_ctr][ctr]->TotalValue();
+      }
+    }
+
+    vForces = State->GetTs2b(alpha, beta)*vFs;
+
+    // see http://home.earthlink.net/~apeden/jsbsim_moments_due_to_forces.txt
+    // for details on this
+
+    vDXYZcg(eX) = -(Aircraft->GetXYZrp(eX) - MassBalance->GetXYZcg(eX))/12.0;
+    vDXYZcg(eY) =  (Aircraft->GetXYZrp(eY) - MassBalance->GetXYZcg(eY))/12.0;
+    vDXYZcg(eZ) = -(Aircraft->GetXYZrp(eZ) - MassBalance->GetXYZcg(eZ))/12.0;
+
+    vMoments(eL) = vForces(eZ)*vDXYZcg(eY) - vForces(eY)*vDXYZcg(eZ);
+    vMoments(eM) = vForces(eX)*vDXYZcg(eZ) - vForces(eZ)*vDXYZcg(eX);
+    vMoments(eN) = vForces(eY)*vDXYZcg(eX) - vForces(eX)*vDXYZcg(eY);
+
+    for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
+      for (ctr = 0; ctr < Coeff[axis_ctr+3].size(); ctr++) {
+        vMoments(axis_ctr+1) += Coeff[axis_ctr+3][ctr]->TotalValue();
+      }
+    }
     return false;
   } else {
     return true;
@@ -75,7 +133,104 @@ bool FGAerodynamics:: Run(void) {
 
 bool FGAerodynamics::LoadAerodynamics(FGConfigFile* AC_cfg)
 {
-//
+  string token, axis;
+
+  AC_cfg->GetNextConfigLine();
+
+  while ((token = AC_cfg->GetValue()) != string("/AERODYNAMICS")) {
+    if (token == "AXIS") {
+      CoeffArray ca;
+      axis = AC_cfg->GetValue("NAME");
+      AC_cfg->GetNextConfigLine();
+      while ((token = AC_cfg->GetValue()) != string("/AXIS")) {
+        ca.push_back(new FGCoefficient(FDMExec, AC_cfg));
+        if (debug_lvl > 0) DisplayCoeffFactors(ca.back()->Getmultipliers());
+      }
+      Coeff[AxisIdx[axis]] = ca;
+      AC_cfg->GetNextConfigLine();
+    }
+  }
+
+  return true;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGAerodynamics::DisplayCoeffFactors(vector <eParam> multipliers)
+{
+  unsigned int i;
+
+  cout << "   Non-Dimensionalized by: ";
+
+  for (i=0; i<multipliers.size();i++) cout << State->paramdef[multipliers[i]];
+
+  cout << endl;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGAerodynamics::GetCoefficientStrings(void)
+{
+  string CoeffStrings = "";
+  bool firstime = true;
+  unsigned int axis, sd;
+
+  for (axis = 0; axis < 6; axis++) {
+    for (sd = 0; sd < Coeff[axis].size(); sd++) {
+      if (firstime) {
+        firstime = false;
+      } else {
+        CoeffStrings += ", ";
+      }
+      CoeffStrings += Coeff[axis][sd]->Getname();
+    }
+  }
+
+  return CoeffStrings;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGAerodynamics::GetCoefficientValues(void)
+{
+  string SDValues = "";
+  char buffer[10];
+  bool firstime = true;
+
+  for (unsigned int axis = 0; axis < 6; axis++) {
+    for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
+      if (firstime) {
+        firstime = false;
+      } else {
+        SDValues += ", ";
+      }
+      sprintf(buffer, "%9.6f", Coeff[axis][sd]->GetSD());
+      SDValues += string(buffer);
+    }
+  }
+
+  return SDValues;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+float FGAerodynamics::GetNlf(void)
+{
+  if (fabs(Position->GetGamma()) < 1.57) {
+    return (vFs(eZ)/(MassBalance->GetWeight()*cos(Position->GetGamma())));
+  } else {
+    return 0.0;
+  }
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+float FGAerodynamics::GetLoD(void)
+{
+  float LoD;
+
+  if (vFs(1) != 0.00) return vFs(3)/vFs(1);
+  else                return 0.00;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index beb7d209f920ab24ef0ba4c4142dca272ed85499..5e97441c9e486652e914d1dc83947d7881a6ff38 100644 (file)
@@ -40,17 +40,24 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <vector>
+#    include <map>
 #  else
 #    include <vector.h>
+#    include <map.h>
 #  endif
 #else
 #  include <vector>
+#  include <map>
 #endif
 
 #include "FGModel.h"
 #include "FGConfigFile.h"
+#include "FGState.h"
+#include "FGMassBalance.h"
+#include "FGTranslation.h"
+#include "FGCoefficient.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
@@ -99,8 +106,50 @@ public:
   /** Loads the Aerodynamics model
       @return true if successful */
   bool LoadAerodynamics(FGConfigFile* AC_cfg);
-  
+
+  /** Outputs coefficient information.
+      Non-dimensionalizing parameter descriptions are output
+      for each aero coefficient defined.
+      @param multipliers the list of multipliers for this coefficient.*/
+  void DisplayCoeffFactors(vector <eParam> multipliers);
+
+  /** Gets the total aerodynamic force vector.
+      @return a force vector reference. */
+  FGColumnVector& GetForces(void) {return vForces;}
+
+  /** Gets the total aerodynamic moment vector.
+      @return a moment vector reference. */
+  FGColumnVector& GetMoments(void) {return vMoments;}
+
+  inline FGColumnVector GetvLastFs(void) { return vLastFs; }
+  inline float GetvLastFs(int axis) { return vLastFs(axis); }
+  inline FGColumnVector GetvFs(void) { return vFs; }
+  inline float GetvFs(int axis) { return vFs(axis); }
+  float GetLoD(void);
+
+    /** Gets the strings for the current set of coefficients.
+      @return a string containing the descriptive names for all coefficients */
+  string GetCoefficientStrings(void);
+
+  /** Gets the coefficient values.
+      @return a string containing the numeric values for the current set of
+      coefficients */
+  string GetCoefficientValues(void);
+
+  /// Gets the Normal Load Factor
+  float GetNlf(void);
+
 private:
+  typedef map<string,int> AxisIndex;
+  AxisIndex AxisIdx;
+  typedef vector<FGCoefficient*> CoeffArray;
+  CoeffArray* Coeff;
+  FGColumnVector vFs;
+  FGColumnVector vForces;
+  FGColumnVector vMoments;
+  FGColumnVector vLastFs;
+  FGColumnVector vDXYZcg;
+
   void Debug(void);
 };
 
index 6414a79b7dd4acb7c48d604433ddde51d0e614fe..19294eaaf7a3403082db180371d115e4e6152523 100644 (file)
@@ -5,7 +5,7 @@
  Date started: 12/12/98                                   
  Purpose:      Encapsulates an aircraft
  Called by:    FGFDMExec
+
  ------------- Copyright (C) 1999  Jon S. Berndt (jsb@hal-pc.org) -------------
  
  This program is free software; you can redistribute it and/or modify it under
@@ -109,7 +109,7 @@ INCLUDES
 #  ifndef __BORLANDC__
 #    include <simgear/compiler.h>
 #  endif
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <cmath>
 #  else
 #    include <math.h>
@@ -119,6 +119,9 @@ INCLUDES
 #endif
 
 #include "FGAircraft.h"
+#include "FGMassBalance.h"
+#include "FGInertial.h"
+#include "FGAerodynamics.h"
 #include "FGTranslation.h"
 #include "FGRotation.h"
 #include "FGAtmosphere.h"
@@ -161,28 +164,14 @@ CLASS IMPLEMENTATION
 FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
     vMoments(3),
     vForces(3),
-    vFs(3),
-    vLastFs(3),
     vXYZrp(3),
-    vbaseXYZcg(3),
-    vXYZcg(3),
     vXYZep(3),
     vEuler(3),
-    vXYZtank(3),
     vDXYZcg(3),
     vAeroBodyForces(3)
 {
   Name = "FGAircraft";
 
-  AxisIdx["DRAG"]  = 0;
-  AxisIdx["SIDE"]  = 1;
-  AxisIdx["LIFT"]  = 2;
-  AxisIdx["ROLL"]  = 3;
-  AxisIdx["PITCH"] = 4;
-  AxisIdx["YAW"]   = 5;
-
-  Coeff = new CoeffArray[6];
-
   GearUp = false;
 
   alphaclmin = alphaclmax = 0;
@@ -194,15 +183,8 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex),
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
-FGAircraft::~FGAircraft() {
-  unsigned int i,j;
-  for (i=0; i<6; i++) {
-    for (j=0; j<Coeff[i].size(); j++) {
-      delete Coeff[i][j];
-    }
-  }
-  delete[] Coeff;
-  
+FGAircraft::~FGAircraft()
+{
   if (debug_lvl & 2) cout << "Destroyed:    FGAircraft" << endl;
 }
 
@@ -231,22 +213,22 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
   while ((AC_cfg.GetNextConfigLine() != string("EOF")) &&
          (token = AC_cfg.GetValue()) != string("/FDM_CONFIG")) {
     if (token == "METRICS") {
-      cout << fgcyan << "\n  Reading Metrics" << fgdef << endl;
+      if (debug_lvl > 0) cout << fgcyan << "\n  Reading Metrics" << fgdef << endl;
       ReadMetrics(&AC_cfg);
     } else if (token == "AERODYNAMICS") {
-      cout << fgcyan << "\n  Reading Aerodynamics" << fgdef << endl;
+      if (debug_lvl > 0) cout << fgcyan << "\n  Reading Aerodynamics" << fgdef << endl;
       ReadAerodynamics(&AC_cfg);
     } else if (token == "UNDERCARRIAGE") {
-      cout << fgcyan << "\n  Reading Landing Gear" << fgdef << endl;
+      if (debug_lvl > 0) cout << fgcyan << "\n  Reading Landing Gear" << fgdef << endl;
       ReadUndercarriage(&AC_cfg);
     } else if (token == "PROPULSION") {
-      cout << fgcyan << "\n  Reading Propulsion" << fgdef << endl;
+      if (debug_lvl > 0) cout << fgcyan << "\n  Reading Propulsion" << fgdef << endl;
       ReadPropulsion(&AC_cfg);
     } else if (token == "FLIGHT_CONTROL") {
-      cout << fgcyan << "\n  Reading Flight Control" << fgdef << endl;
+      if (debug_lvl > 0) cout << fgcyan << "\n  Reading Flight Control" << fgdef << endl;
       ReadFlightControls(&AC_cfg);
     } else if (token == "OUTPUT") {
-      cout << fgcyan << "\n  Reading Output directives" << fgdef << endl;
+      if (debug_lvl > 0) cout << fgcyan << "\n  Reading Output directives" << fgdef << endl;
       ReadOutput(&AC_cfg);
     }
   }
@@ -256,160 +238,37 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGAircraft::Run(void) {
+bool FGAircraft::Run(void)
+{
   if (!FGModel::Run()) {                 // if false then execute this Run()
     GetState();
 
-    for (int i = 1; i <= 3; i++)  vForces(i) = vMoments(i) = 0.0;
+    vForces.InitMatrix();
+    vMoments.InitMatrix();
 
-    MassChange();
     FMProp();
     FMAero();
     FMMass();
     FMGear();
 
-    nlf = 0;
-    if (fabs(Position->GetGamma()) < 1.57) {
-        nlf = vFs(eZ)/(Weight*cos(Position->GetGamma()));
-    }    
-        
+    return false;
   } else {                               // skip Run() execution this time
+    return true;
   }
-
-
-  return false;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGAircraft::MassChange() {
-  float Tw;
-  float IXXt, IYYt, IZZt, IXZt;
-//  unsigned int t;
-//  unsigned int axis_ctr;
-/*
-  for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vXYZtank(axis_ctr) = 0.0;
-
-  // UPDATE TANK CONTENTS
-  //
-  // For each engine, cycle through the tanks and draw an equal amount of
-  // fuel (or oxidizer) from each active tank. The needed amount of fuel is
-  // determined by the engine in the FGEngine class. If more fuel is needed
-  // than is available in the tank, then that amount is considered a shortage,
-  // and will be drawn from the next tank. If the engine cannot be fed what it
-  // needs, it will be considered to be starved, and will shut down.
-
-  float Oshortage, Fshortage;
-
-  for (unsigned int e=0; e<numEngines; e++) {
-    Fshortage = Oshortage = 0.0;
-    for (t=0; t<numTanks; t++) {
-      switch(Engine[e]->GetType()) {
-      case FGEngine::etRocket:
-
-        switch(Tank[t]->GetType()) {
-        case FGTank::ttFUEL:
-          if (Tank[t]->GetSelected()) {
-            Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
-                                         numSelectedFuelTanks)*(dt*rate) + Fshortage);
-          }
-          break;
-        case FGTank::ttOXIDIZER:
-          if (Tank[t]->GetSelected()) {
-            Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
-                                         numSelectedOxiTanks)*(dt*rate) + Oshortage);
-          }
-          break;
-        }
-        break;
-
-      case FGEngine::etPiston:
-      case FGEngine::etTurboJet:
-      case FGEngine::etTurboProp:
-
-        if (Tank[t]->GetSelected()) {
-          Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
-                                       numSelectedFuelTanks)*(dt*rate) + Fshortage);
-        }
-        break;
-      }
-    }
-    if ((Fshortage <= 0.0) || (Oshortage <= 0.0)) Engine[e]->SetStarved();
-    else Engine[e]->SetStarved(false);
-  }
-*/
-  Weight = EmptyWeight;
-//  for (t=0; t<numTanks; t++)
-//    Weight += Tank[t]->GetContents();
-
-  Mass = Weight / GRAVITY;
-  // Calculate new CG here.
-
-  Tw = 0;
-//  for (t=0; t<numTanks; t++) {
-//    vXYZtank(eX) += Tank[t]->GetX()*Tank[t]->GetContents();
-//    vXYZtank(eY) += Tank[t]->GetY()*Tank[t]->GetContents();
-//    vXYZtank(eZ) += Tank[t]->GetZ()*Tank[t]->GetContents();
-//
-//    Tw += Tank[t]->GetContents();
-//  }
-
-  vXYZcg = (vXYZtank + EmptyWeight*vbaseXYZcg) / (Tw + EmptyWeight);
-
-  // Calculate new moments of inertia here
-
-  IXXt = IYYt = IZZt = IXZt = 0.0;
-//  for (t=0; t<numTanks; t++) {
-//    IXXt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetX() - vXYZcg(eX))/12.0)*Tank[t]->GetContents()/GRAVITY;
-//    IYYt += ((Tank[t]->GetY()-vXYZcg(eY))/12.0)*((Tank[t]->GetY() - vXYZcg(eY))/12.0)*Tank[t]->GetContents()/GRAVITY;
-//    IZZt += ((Tank[t]->GetZ()-vXYZcg(eZ))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
-//    IXZt += ((Tank[t]->GetX()-vXYZcg(eX))/12.0)*((Tank[t]->GetZ() - vXYZcg(eZ))/12.0)*Tank[t]->GetContents()/GRAVITY;
-//  }
-
-  Ixx = baseIxx + IXXt;
-  Iyy = baseIyy + IYYt;
-  Izz = baseIzz + IZZt;
-  Ixz = baseIxz + IXZt;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::FMAero(void) {
-  unsigned int axis_ctr,ctr;
-
-  vLastFs = vFs;
-  for (axis_ctr=1; axis_ctr<=3; axis_ctr++) vFs(axis_ctr) = 0.0;
-
-  for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
-    for (ctr=0; ctr < Coeff[axis_ctr].size(); ctr++) {
-      vFs(axis_ctr+1) += Coeff[axis_ctr][ctr]->TotalValue();
-    }
-  }
-
-  vAeroBodyForces = State->GetTs2b(alpha, beta)*vFs;
-  vForces += vAeroBodyForces;
-
-  // see http://home.earthlink.net/~apeden/jsbsim_moments_due_to_forces.txt
-  // for details on this
-  vDXYZcg(eX) = -(vXYZrp(eX) - vXYZcg(eX))/12.0;  //cg and rp values are in inches
-  vDXYZcg(eY) =  (vXYZrp(eY) - vXYZcg(eY))/12.0;
-  vDXYZcg(eZ) = -(vXYZrp(eZ) - vXYZcg(eZ))/12.0;
-
-  vMoments(eL) += vAeroBodyForces(eZ)*vDXYZcg(eY) - vAeroBodyForces(eY)*vDXYZcg(eZ); // rolling moment
-  vMoments(eM) += vAeroBodyForces(eX)*vDXYZcg(eZ) - vAeroBodyForces(eZ)*vDXYZcg(eX); // pitching moment
-  vMoments(eN) += vAeroBodyForces(eY)*vDXYZcg(eX) - vAeroBodyForces(eX)*vDXYZcg(eY); // yawing moment
-  
-  for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
-    for (ctr = 0; ctr < Coeff[axis_ctr+3].size(); ctr++) {
-      vMoments(axis_ctr+1) += Coeff[axis_ctr+3][ctr]->TotalValue();
-    }
-  }
+void FGAircraft::FMAero(void)
+{
+    vForces += Aerodynamics->GetForces();
+    vMoments += Aerodynamics->GetMoments();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::FMGear(void) {
-
+void FGAircraft::FMGear(void)
+{
   if ( !GearUp ) {
     vector <FGLGear>::iterator iGear = lGear.begin();
     while (iGear != lGear.end()) {
@@ -424,22 +283,23 @@ void FGAircraft::FMGear(void) {
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::FMMass(void) {
-  vForces(eX) += -GRAVITY*sin(vEuler(eTht)) * Mass;
-  vForces(eY) +=  GRAVITY*sin(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
-  vForces(eZ) +=  GRAVITY*cos(vEuler(ePhi))*cos(vEuler(eTht)) * Mass;
+void FGAircraft::FMMass(void)
+{
+  vForces += Inertial->GetForces();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::FMProp(void) {
-    vForces += Propulsion->GetForces();
-    vMoments += Propulsion->GetMoments();
+void FGAircraft::FMProp(void)
+{
+  vForces += Propulsion->GetForces();
+  vMoments += Propulsion->GetMoments();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::GetState(void) {
+void FGAircraft::GetState(void)
+{
   dt = State->Getdt();
 
   alpha = Translation->Getalpha();
@@ -449,53 +309,66 @@ void FGAircraft::GetState(void) {
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg) {
+void FGAircraft::ReadMetrics(FGConfigFile* AC_cfg)
+{
   string token = "";
   string parameter;
+  float EW, bixx, biyy, bizz, bixz, biyz;
+  FGColumnVector vbaseXYZcg(3);
 
   AC_cfg->GetNextConfigLine();
 
   while ((token = AC_cfg->GetValue()) != string("/METRICS")) {
     *AC_cfg >> parameter;
     if (parameter == string("AC_WINGAREA")) {
-        *AC_cfg >> WingArea;
-        cout << "    WingArea: " << WingArea  << endl; 
+      *AC_cfg >> WingArea;
+      if (debug_lvl > 0) cout << "    WingArea: " << WingArea  << endl;
     } else if (parameter == "AC_WINGSPAN") {
-        *AC_cfg >> WingSpan;
-        cout << "    WingSpan: " << WingSpan  << endl;
+      *AC_cfg >> WingSpan;
+      if (debug_lvl > 0) cout << "    WingSpan: " << WingSpan  << endl;
     } else if (parameter == "AC_CHORD") {
-        *AC_cfg >> cbar;
-        cout << "    Chord: " << cbar << endl;
+      *AC_cfg >> cbar;
+      if (debug_lvl > 0) cout << "    Chord: " << cbar << endl;
     } else if (parameter == "AC_IXX") {
-        *AC_cfg >> baseIxx;
-        cout << "    baseIxx: " << baseIxx << endl;
+      *AC_cfg >> bixx;
+      if (debug_lvl > 0) cout << "    baseIxx: " << bixx << endl;
+      MassBalance->SetBaseIxx(bixx);
     } else if (parameter == "AC_IYY") {
-        *AC_cfg >> baseIyy;
-        cout << "    baseIyy: " << baseIyy << endl;
-    } else if (parameter == "AC_IZZ") { 
-        *AC_cfg >> baseIzz;
-        cout << "    baseIzz: " << baseIzz << endl;
-    } else if (parameter == "AC_IXZ") { 
-        *AC_cfg >> baseIxz;
-        cout << "    baseIxz: " << baseIxz  << endl;
+      *AC_cfg >> biyy;
+      if (debug_lvl > 0) cout << "    baseIyy: " << biyy << endl;
+      MassBalance->SetBaseIyy(biyy);
+    } else if (parameter == "AC_IZZ") {
+      *AC_cfg >> bizz;
+      if (debug_lvl > 0) cout << "    baseIzz: " << bizz << endl;
+      MassBalance->SetBaseIzz(bizz);
+    } else if (parameter == "AC_IXZ") {
+      *AC_cfg >> bixz;
+      if (debug_lvl > 0) cout << "    baseIxz: " << bixz  << endl;
+      MassBalance->SetBaseIxz(bixz);
+    } else if (parameter == "AC_IYZ") {
+      *AC_cfg >> biyz;
+      if (debug_lvl > 0) cout << "    baseIyz: " << biyz  << endl;
+      MassBalance->SetBaseIyz(biyz);
     } else if (parameter == "AC_EMPTYWT") {
-        *AC_cfg >> EmptyWeight;
-        cout << "    EmptyWeight: " << EmptyWeight  << endl;
+      *AC_cfg >> EW;
+      MassBalance->SetEmptyWeight(EW);
+      if (debug_lvl > 0) cout << "    EmptyWeight: " << EW  << endl;
     } else if (parameter == "AC_CGLOC") {
-        *AC_cfg >> vbaseXYZcg(eX) >> vbaseXYZcg(eY) >> vbaseXYZcg(eZ);
-        cout << "    CG (x, y, z): " << vbaseXYZcg << endl;
+      *AC_cfg >> vbaseXYZcg(eX) >> vbaseXYZcg(eY) >> vbaseXYZcg(eZ);
+      MassBalance->SetBaseCG(vbaseXYZcg);
+      if (debug_lvl > 0) cout << "    CG (x, y, z): " << vbaseXYZcg << endl;
     } else if (parameter == "AC_EYEPTLOC") {
-        *AC_cfg >> vXYZep(eX) >> vXYZep(eY) >> vXYZep(eZ);
-        cout << "    Eyepoint (x, y, z): " << vXYZep << endl;
+      *AC_cfg >> vXYZep(eX) >> vXYZep(eY) >> vXYZep(eZ);
+      if (debug_lvl > 0) cout << "    Eyepoint (x, y, z): " << vXYZep << endl;
     } else if (parameter == "AC_AERORP") {
-        *AC_cfg >> vXYZrp(eX) >> vXYZrp(eY) >> vXYZrp(eZ);
-        cout << "    Ref Pt (x, y, z): " << vXYZrp << endl;
+      *AC_cfg >> vXYZrp(eX) >> vXYZrp(eY) >> vXYZrp(eZ);
+      if (debug_lvl > 0) cout << "    Ref Pt (x, y, z): " << vXYZrp << endl;
     } else if (parameter == "AC_ALPHALIMITS") {
-        *AC_cfg >> alphaclmin >> alphaclmax;
-        cout << "    Maximum Alpha: " << alphaclmax
-             << "    Minimum Alpha: " << alphaclmin 
+      *AC_cfg >> alphaclmin >> alphaclmax;
+      if (debug_lvl > 0) cout << "    Maximum Alpha: " << alphaclmax
+             << "    Minimum Alpha: " << alphaclmin
              << endl;
-    }         
+    }
   }
 }
 
@@ -517,24 +390,12 @@ void FGAircraft::ReadFlightControls(FGConfigFile* AC_cfg) {
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg) {
-  string token, axis;
-
-  AC_cfg->GetNextConfigLine();
-  
-  while ((token = AC_cfg->GetValue()) != string("/AERODYNAMICS")) {
-    if (token == "AXIS") {
-      CoeffArray ca;
-      axis = AC_cfg->GetValue("NAME");
-      AC_cfg->GetNextConfigLine();
-      while ((token = AC_cfg->GetValue()) != string("/AXIS")) {
-        ca.push_back(new FGCoefficient(FDMExec, AC_cfg));
-        DisplayCoeffFactors(ca.back()->Getmultipliers());
-      }
-      Coeff[AxisIdx[axis]]=ca;
-      AC_cfg->GetNextConfigLine();
-    }
+void FGAircraft::ReadAerodynamics(FGConfigFile* AC_cfg)
+{
+  if (!Aerodynamics->LoadAerodynamics(AC_cfg)) {
+    cerr << "Aerodynamics not successfully loaded" << endl;
   }
+
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -631,75 +492,21 @@ void FGAircraft::ReadPrologue(FGConfigFile* AC_cfg) {
   string token = AC_cfg->GetValue();
   string scratch;
   AircraftName = AC_cfg->GetValue("NAME");
-  cout << underon << "Reading Aircraft Configuration File" << underoff << ": "
-                       << highint << AircraftName << normint << endl;
+  if (debug_lvl > 0) cout << underon << "Reading Aircraft Configuration File"
+            << underoff << ": " << highint << AircraftName << normint << endl;
   scratch = AC_cfg->GetValue("VERSION").c_str();
 
   CFGVersion = AC_cfg->GetValue("VERSION");
-  cout << "                            Version: " << highint << CFGVersion
+
+  if (debug_lvl > 0)
+    cout << "                            Version: " << highint << CFGVersion
                                                              << normint << endl;
   if (CFGVersion != string(NEEDED_CFG_VERSION)) {
-    cout << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
-    " RESULTS WILL BE UNPREDICTABLE !!" << endl;
-    cout << "Current version needed is: " << NEEDED_CFG_VERSION << endl;
-    cout << "         You have version: " << CFGVersion << endl << fgdef << endl;
-    //exit(-1);
+    cerr << endl << fgred << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT."
+            " RESULTS WILL BE UNPREDICTABLE !!" << endl;
+    cerr << "Current version needed is: " << NEEDED_CFG_VERSION << endl;
+    cerr << "         You have version: " << CFGVersion << endl << fgdef << endl;
   }
-
-
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-void FGAircraft::DisplayCoeffFactors(vector <eParam> multipliers) {
-  cout << "   Non-Dimensionalized by: ";
-
-  for (unsigned int i=0; i<multipliers.size();i++)
-    cout << State->paramdef[multipliers[i]];
-
-  cout << endl;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-string FGAircraft::GetCoefficientStrings(void) {
-  string CoeffStrings = "";
-  bool firstime = true;
-
-  for (unsigned int axis = 0; axis < 6; axis++) {
-    for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
-      if (firstime) {
-        firstime = false;
-      } else {
-        CoeffStrings += ", ";
-      }
-      CoeffStrings += Coeff[axis][sd]->Getname();
-    }
-  }
-
-  return CoeffStrings;
-}
-
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-string FGAircraft::GetCoefficientValues(void) {
-  string SDValues = "";
-  char buffer[10];
-  bool firstime = true;
-
-  for (unsigned int axis = 0; axis < 6; axis++) {
-    for (unsigned int sd = 0; sd < Coeff[axis].size(); sd++) {
-      if (firstime) {
-        firstime = false;
-      } else {
-        SDValues += ", ";
-      }
-      sprintf(buffer, "%9.6f", Coeff[axis][sd]->GetSD());
-      SDValues += string(buffer);
-    }
-  }
-
-  return SDValues;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -749,14 +556,3 @@ void FGAircraft::Debug(void)
     //TODO: Add your source code here
 }
 
-//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-float FGAircraft::GetLoD(void) {
-  float LoD;
-  if (vFs(1) != 0.00)
-    LoD = vFs(3)/vFs(1);
-  else
-    LoD = 0.00;
-
-  return LoD;
-}
index 9bc51cc1dc5d7135f839f6103c2958183a1dff89..6d252e509164c3e88d4107401ce7a28b6146912a 100644 (file)
@@ -40,7 +40,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <vector>
 #    include <iterator>
 #    include <map>
@@ -56,7 +56,6 @@ INCLUDES
 #endif
 
 #include "FGModel.h"
-#include "FGCoefficient.h"
 #include "FGPropulsion.h"
 #include "FGConfigFile.h"
 #include "FGMatrix.h"
@@ -157,27 +156,14 @@ public:
   inline float GetWingSpan(void) { return WingSpan; }
   /// Gets the average wing chord
   inline float Getcbar(void) { return cbar; }
-  inline float GetWeight(void) { return Weight; }
-  inline float GetMass(void) { return Mass; }
   inline FGColumnVector GetMoments(void) { return vMoments; }
   inline FGColumnVector GetForces(void) { return vForces; }
   inline FGColumnVector GetAeroBodyForces(void) { return vAeroBodyForces; }
   inline float GetAeroBodyForces(int axis) { return vAeroBodyForces(axis); }
-  inline FGColumnVector GetvFs(void) { return vFs; }
-  inline float GetvFs(int axis) { return vFs(axis); }
-  inline FGColumnVector GetvLastFs(void) { return vLastFs; }
-  inline float GetvLastFs(int axis) { return vLastFs(axis); }
-  inline float GetIxx(void) { return Ixx; }
-  inline float GetIyy(void) { return Iyy; }
-  inline float GetIzz(void) { return Izz; }
-  inline float GetIxz(void) { return Ixz; }
-  inline FGColumnVector GetXYZcg(void) { return vXYZcg; }
   inline FGColumnVector GetXYZrp(void) { return vXYZrp; }
   inline FGColumnVector GetXYZep(void) { return vXYZep; }
-  inline float GetXYZcg(int idx) { return vXYZcg(idx); }
   inline float GetXYZrp(int idx) { return vXYZrp(idx); }
   inline float GetXYZep(int idx) { return vXYZep(idx); }
-  inline float GetNlf(void) { return nlf; }
   inline float GetAlphaCLMax(void) { return alphaclmax; }
   inline float GetAlphaCLMin(void) { return alphaclmin; }
 
@@ -185,9 +171,6 @@ public:
   inline void SetAlphaCLMax(float tt) { alphaclmax=tt; }
   inline void SetAlphaCLMin(float tt) { alphaclmin=tt; }
 
-  inline FGCoefficient* GetCoeff(int axis, int idx) { return Coeff[axis][idx]; }
-  string GetCoefficientStrings(void);
-  string GetCoefficientValues(void);
   string GetGroundReactionStrings(void);
   string GetGroundReactionValues(void);
 
@@ -216,41 +199,22 @@ private:
   void FMGear(void);
   void FMMass(void);
   void FMProp(void);
-  void MassChange(void);
   FGColumnVector vMoments;
   FGColumnVector vForces;
-  FGColumnVector vFs;
-  FGColumnVector vLastFs;
   FGColumnVector vXYZrp;
-  FGColumnVector vbaseXYZcg;
-  FGColumnVector vXYZcg;
   FGColumnVector vXYZep;
   FGColumnVector vEuler;
-  FGColumnVector vXYZtank;
   FGColumnVector vDXYZcg;
   FGColumnVector vAeroBodyForces;
-  float baseIxx, baseIyy, baseIzz, baseIxz, EmptyMass, Mass;
-  float Ixx, Iyy, Izz, Ixz;
   float alpha, beta;
   float WingArea, WingSpan, cbar;
-  float Weight, EmptyWeight;
-  float nlf,alphaclmax,alphaclmin;
+  float alphaclmax,alphaclmin;
   float dt;
   string CFGVersion;
   string AircraftName;
 
-  typedef map<string,int> AxisIndex;
-  AxisIndex AxisIdx;
-
-  typedef vector<FGCoefficient*> CoeffArray;
-
-  CoeffArray* Coeff;
-
-  void DisplayCoeffFactors(vector <eParam> multipliers);
-
   bool GearUp;
 
-  string Axis[6];
   vector <FGLGear> lGear;
 
   string AircraftPath;
index 0fdc0573245a1f95c883a3d8ae012460c84dfb1b..c8ddc8a3a2ddae52da3a3f903da522b7c10c89d6 100644 (file)
@@ -1,7 +1,7 @@
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  Module:       FGAuxiliary.cpp
- Author:       Jon Berndt
+ Author:       Tony Peden, Jon Berndt
  Date started: 01/26/99
  Purpose:      Calculates additional parameters needed by the visual system, etc.
  Called by:    FGSimExec
@@ -62,7 +62,10 @@ CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 
-FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex) {
+FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex),
+  vPilotAccel(3),
+  vToEyePt(3)
+{
   Name = "FGAuxiliary";
   vcas = veas = mach = qbar = pt = 0;
   psl = rhosl = 1;
@@ -80,14 +83,15 @@ FGAuxiliary::~FGAuxiliary()
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGAuxiliary::Run() {
+bool FGAuxiliary::Run()
+{
   float A,B,D;
 
   if (!FGModel::Run()) {
     GetState();
-    if(mach < 1)    //calculate total pressure assuming isentropic flow
+    if (mach < 1) {   //calculate total pressure assuming isentropic flow
       pt=p*pow((1 + 0.2*mach*mach),3.5);
-    else {
+    else {
       // shock in front of pitot tube, we'll assume its normal and use
       // the Rayleigh Pitot Tube Formula, i.e. the ratio of total
       // pressure behind the shock to the static pressure in front
@@ -105,49 +109,55 @@ bool FGAuxiliary::Run() {
     vcas = sqrt(7*psl/rhosl*(A-1));
     veas = sqrt(2*qbar/rhosl);
 
-    vPilotAccel = Translation->GetUVWdot() + Aircraft->GetXYZep() * Rotation->GetPQRdot();
+    // vPilotAccel = Translation->GetUVWdot() + Aircraft->GetXYZep() * Rotation->GetPQRdot();
+    
+    vToEyePt = Aircraft->GetXYZep() - MassBalance->GetXYZcg();
+    vPilotAccel = Translation->GetUVWdot()
+                    + Rotation->GetPQRdot() * vToEyePt
+                    + Rotation->GetPQR() * (Rotation->GetPQR() * vToEyePt);
 
     earthPosAngle += State->Getdt()*OMEGA_EARTH;
-
+    return false;
   } else {
+    return true;
   }
-
-  return false;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-float FGAuxiliary::GetHeadWind(void) {
-
+float FGAuxiliary::GetHeadWind(void)
+{
   float psiw,vw,psi;
 
   psiw = Atmosphere->GetWindPsi();
   psi = Rotation->Getpsi();
   vw = Atmosphere->GetWindNED().Magnitude();
+
   return -vw*cos(psiw - psi);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-float FGAuxiliary::GetCrossWind(void) {
-
+float FGAuxiliary::GetCrossWind(void)
+{
   float psiw,vw,psi;
 
   psiw = Atmosphere->GetWindPsi();
   psi = Rotation->Getpsi();
   vw = Atmosphere->GetWindNED().Magnitude();
+
   return  vw*sin(psiw - psi);
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAuxiliary::GetState(void) {
+void FGAuxiliary::GetState(void)
+{
   qbar = Translation->Getqbar();
   mach = Translation->GetMach();
   p = Atmosphere->GetPressure();
   rhosl = Atmosphere->GetDensitySL();
   psl = Atmosphere->GetPressureSL();
-
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 2210dd368ff39a2fc6366145e57d3d873b9a33d4..e52dc15b7b025ce047660f570f778aef4cf518b8 100644 (file)
@@ -97,10 +97,7 @@ public:
   
   float GetHeadWind(void);
   float GetCrossWind(void);
-  
  
-protected:
-
 private:
   float vcas;
   float veas;
@@ -115,9 +112,9 @@ private:
   // isentropic flow equations
 
   FGColumnVector vPilotAccel;
+  FGColumnVector vToEyePt;
   
   float earthPosAngle;
-  
 
   void GetState(void);
   void Debug(void);
index 61053881a56806009ec785f64625446d0680c62b..b8ec8528fae5daea17bab0553f4561dd30916136 100644 (file)
@@ -55,7 +55,7 @@ INCLUDES
 #endif
 
 static const char *IdSrc = "$Id$";
-static const char *IdHdr = "ID_COEFFICIENT";
+static const char *IdHdr = ID_COEFFICIENT;
 
 extern char highint[5];
 extern char halfint[5];
@@ -91,9 +91,11 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg)
     AC_cfg->GetNextConfigLine();
     *AC_cfg >> description;
 
-    cout << "\n   " << highint << underon << name << underoff << normint << endl;
-    cout << "   " << description << endl;
-    cout << "   " << method << endl;
+    if (debug_lvl > 0) {
+      cout << "\n   " << highint << underon << name << underoff << normint << endl;
+      cout << "   " << description << endl;
+      cout << "   " << method << endl;
+    }
 
     if      (method == "EQUATION") type = EQUATION;
     else if (method == "TABLE")    type = TABLE;
@@ -103,26 +105,26 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg)
 
     if (type == VECTOR || type == TABLE) {
       *AC_cfg >> rows;
-      cout << "   Rows: " << rows << " ";
+      if (debug_lvl > 0) cout << "   Rows: " << rows << " ";
       if (type == TABLE) {
         *AC_cfg >> columns;
-        cout << "Cols: " << columns;
+        if (debug_lvl > 0) cout << "Cols: " << columns;
         Table = new FGTable(rows, columns);
       } else {
         Table = new FGTable(rows);
       }
 
-      cout << endl;
+      if (debug_lvl > 0) cout << endl;
 
       *AC_cfg >> multparms;
       LookupR = State->GetParameterIndex(multparms);
-      cout << "   Row indexing parameter: " << multparms << endl;
+      if (debug_lvl > 0) cout << "   Row indexing parameter: " << multparms << endl;
     }
 
     if (type == TABLE) {
       *AC_cfg >> multparms;
       LookupC = State->GetParameterIndex(multparms);
-      cout << "   Column indexing parameter: " << multparms << endl;
+      if (debug_lvl > 0) cout << "   Column indexing parameter: " << multparms << endl;
     }
 
     // Here, read in the line of the form (e.g.) FG_MACH|FG_QBAR|FG_ALPHA
@@ -149,13 +151,12 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, FGConfigFile* AC_cfg)
     switch(type) {
     case VALUE:
       *AC_cfg >> StaticValue;
-      cout << "      Value = " << StaticValue << endl;
+      if (debug_lvl > 0) cout << "      Value = " << StaticValue << endl;
       break;
     case VECTOR:
     case TABLE:
       *Table << *AC_cfg;
-      Table->Print();
-
+      if (debug_lvl > 0) Table->Print();
       break;
     case EQUATION:
     case UNKNOWN:
index 51e22c4c7366c7f41535e95575323fe3572231d7..2aa97e12a11928c6561489d42f5d624ddef6f7f4 100644 (file)
@@ -22,7 +22,7 @@ INCLUDES
 #include <math.h>
 
 static const char *IdSrc = "$Id$";
-static const char *IdHdr = "ID_CONFIGFILE";
+static const char *IdHdr = ID_CONFIGFILE;
 
 extern short debug_lvl;
 
index e5064cbcbc957f974d72025597c0333d829b347e..5a458bea9137cb35dc9b970e0c87f7d3dba95b0d 100644 (file)
@@ -40,16 +40,31 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
-#    include <fstream>
-#  else
-#    include <fstream.h>
-#  endif
+#  include STL_STRING
+#  include STL_FSTREAM
+#  include STL_IOSTREAM
+   SG_USING_STD(string);
+   SG_USING_STD(ostream);
+   SG_USING_STD(istream);
+   SG_USING_STD(ifstream);
+   SG_USING_STD(cerr);
+   SG_USING_STD(endl);
+   SG_USING_STD(ios);
+   SG_USING_STD(cout);
 #else
 #  include <fstream>
+#  include <iostream>
+#  include <string>
+   using std::string;
+   using std::ostream;
+   using std::istream;
+   using std::ifstream;
+   using std::ios;
+   using std::cerr;
+   using std::endl;
+   using std::cout;
 #endif
 
-#include <string>
 #include "FGDefs.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -58,9 +73,6 @@ DEFINITIONS
 
 #define ID_CONFIGFILE "$Id$"
 
-using std::string;
-using std::ifstream;
-
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
index f35d82753a8a614fcde779dbb9a6e293763f2ab1..232f4b4f3352f1e613c5976e8aa17b678df22ab8 100644 (file)
@@ -53,8 +53,8 @@ FGControls::~FGControls() {
 
 
 // $Log$
-// Revision 1.25  2001/04/06 20:59:31  curt
-// More JSBSim updates.
+// Revision 1.26  2001/06/05 18:58:49  curt
+// Synced with latest JSBSim as of June 5, 2001.
 //
 // Revision 1.7  2001/03/22 14:10:24  jberndt
 // Fixed ID comment
index 3212f9839f4fbea86f4b444407ea1f65af9f106b..38ad206ac0ce460f5a75ed1dcaed68730abfe806 100644 (file)
@@ -178,8 +178,8 @@ extern FGControls controls;
 
 
 // $Log$
-// Revision 1.24  2001/04/06 20:59:31  curt
-// More JSBSim updates.
+// Revision 1.25  2001/06/05 18:58:49  curt
+// Synced with latest JSBSim as of June 5, 2001.
 //
 // Revision 1.10  2001/03/22 14:10:24  jberndt
 // Fixed ID comment
index f4d727a37cd0285f1e4cd9f51ebff46aa246979b..72ed411dd9de1955fae7e713e4c4baf936f8f2fc 100644 (file)
@@ -39,7 +39,6 @@ SENTRY
 #define GRAVITY         32.174
 #define INVGRAVITY      0.031081
 #define EARTHRAD        20925650.00       // feet, equatorial
-#define OMEGAEARTH      7.2685E-3         // rad/sec
 #define EARTHRADSQRD    437882827922500.0
 #define ONESECOND       4.848136811E-6
 #define ECCENT          0.996647186
@@ -54,8 +53,8 @@ SENTRY
 #define FPSTOKTS        0.592484
 #define INCHTOFT        0.08333333
 #define OMEGA_EARTH .00007272205217  
-#define NEEDED_CFG_VERSION "1.38"
-#define JSBSIM_VERSION  "0.8.2"
+#define NEEDED_CFG_VERSION "1.40"
+#define JSBSIM_VERSION  "0.8.6"
 
 #define HPTOFTLBSSEC 550
 #define METERS_TO_FEET 3.2808
index 7e94a01a747abdde80e8a38a235f454adcb8d6d2..47ff6da78c5ef714bd0d91fcc7e5cb4e79be58fb 100644 (file)
@@ -40,7 +40,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <fstream>
 #  else
 #    include <fstream.h>
@@ -53,7 +53,7 @@ INCLUDES
 #include "FGTank.h"
 
 static const char *IdSrc = "$Id$";
-static const char *IdHdr = "ID_ENGINE";
+static const char *IdHdr = ID_ENGINE;
 
 extern short debug_lvl;
 
index becf4a3d8bdd5282be9a35a2da986680540cbffd..12bfc7eafe08992aa189c4fe031dd7e7337e5728 100644 (file)
@@ -48,7 +48,7 @@ INCLUDES
 #  include <simgear/compiler.h>
 #  include STL_STRING
    SG_USING_STD(string);
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <vector>
 #  else
 #    include <vector.h>
index f97ecadffc291b02c14a499d9a457a62f8378297..bb92800b6dca62d46ae57d632ba1c686e2f3a626 100644 (file)
@@ -57,7 +57,7 @@ INCLUDES
 #include "filtersjb/FGFlaps.h"
 
 static const char *IdSrc = "$Id$";
-static const char *IdHdr = "ID_FCS";
+static const char *IdHdr = ID_FCS;
 
 extern short debug_lvl;
 
@@ -137,12 +137,14 @@ bool FGFCS::LoadFCS(FGConfigFile* AC_cfg)
   string token;
 
   FCSName = AC_cfg->GetValue("NAME");
-  cout << "    Control System Name: " << FCSName << endl;
+  if (debug_lvl > 0) cout << "    Control System Name: " << FCSName << endl;
   AC_cfg->GetNextConfigLine();
   while ((token = AC_cfg->GetValue()) != "/FLIGHT_CONTROL") {
     if (token == "COMPONENT") {
       token = AC_cfg->GetValue("TYPE");
-      cout << "    Loading Component \"" << AC_cfg->GetValue("NAME") << "\" of type: " << token << endl;
+      if (debug_lvl > 0) cout << "    Loading Component \""
+                              << AC_cfg->GetValue("NAME")
+                                               << "\" of type: " << token << endl;
       if ((token == "LAG_FILTER") ||
           (token == "LEAD_LAG_FILTER") ||
           (token == "SECOND_ORDER_FILTER") ||
index b21dc8add68aa218f3eebbdb74e00462b27edade..2dae2aa0dd72898bbf59c16edb09545c7b4a63d6 100644 (file)
@@ -40,7 +40,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <vector>
 #  else
 #    include <vector.h>
index dd5d275c2d56ce8f250bfe8ad3aae3154563c0e3..32359bb3c256befc175262b930331c7efabcb082 100644 (file)
@@ -44,15 +44,9 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
-#    include <iostream>
-#    include <ctime>
-#    include <iterator>
-#  else
-#    include <iostream.h>
-#    include <time.h>
-#    include <iterator.h>
-#  endif
+#  include STL_IOSTREAM
+#  include <time.h>
+#  include STL_ITERATOR
 #else
 #  include <iostream>
 #  include <ctime>
@@ -64,6 +58,9 @@ INCLUDES
 #include "FGAtmosphere.h"
 #include "FGFCS.h"
 #include "FGPropulsion.h"
+#include "FGMassBalance.h"
+#include "FGAerodynamics.h"
+#include "FGInertial.h"
 #include "FGAircraft.h"
 #include "FGTranslation.h"
 #include "FGRotation.h"
@@ -73,7 +70,7 @@ INCLUDES
 #include "FGConfigFile.h"
 
 static const char *IdSrc = "$Id$";
-static const char *IdHdr = "ID_FDMEXEC";
+static const char *IdHdr = ID_FDMEXEC;
 
 char highint[5]  = {27, '[', '1', 'm', '\0'      };
 char halfint[5]  = {27, '[', '2', 'm', '\0'      };
@@ -108,6 +105,8 @@ short debug_lvl;  // This describes to any interested entity the debug level
                   //    FGModel object executes its Run() method
                   // f) 8: When this value is set, various runtime state variables
                   //    are printed out periodically
+                  // g) 16: When set various parameters are sanity checked and
+                  //    a message is printed out when they go out of bounds.
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS IMPLEMENTATION
@@ -117,30 +116,28 @@ CLASS IMPLEMENTATION
 
 FGFDMExec::FGFDMExec(void)
 {
-  Frame       = 0;
-  FirstModel  = 0;
-  Error       = 0;
-  State       = 0;
-  Atmosphere  = 0;
-  FCS         = 0;
-  Propulsion  = 0;
-  Aircraft    = 0;
-  Translation = 0;
-  Rotation    = 0;
-  Position    = 0;
-  Auxiliary   = 0;
-  Output      = 0;
+  Frame        = 0;
+  FirstModel   = 0;
+  Error        = 0;
+  State        = 0;
+  Atmosphere   = 0;
+  FCS          = 0;
+  Propulsion   = 0;
+  MassBalance  = 0;
+  Aerodynamics = 0;
+  Inertial     = 0;
+  Aircraft     = 0;
+  Translation  = 0;
+  Rotation     = 0;
+  Position     = 0;
+  Auxiliary    = 0;
+  Output       = 0;
 
   terminate = false;
   frozen = false;
   modelLoaded = false;
   Scripted = false;
 
-  cout << "\n\n     " << highint << underon << "JSBSim Flight Dynamics Model v"
-                                 << JSBSIM_VERSION << underoff << normint << endl;
-  cout << halfint << "            [cfg file spec v" << NEEDED_CFG_VERSION << "]\n\n";
-  cout << normint << "JSBSim startup beginning ...\n\n";
-
   try {
     char* num = getenv("JSBSIM_DEBUG");
     if (!num) debug_lvl = 1;
@@ -149,6 +146,13 @@ FGFDMExec::FGFDMExec(void)
     debug_lvl = 1;
   }
 
+  if (debug_lvl > 0) {
+    cout << "\n\n     " << highint << underon << "JSBSim Flight Dynamics Model v"
+                                   << JSBSIM_VERSION << underoff << normint << endl;
+    cout << halfint << "            [cfg file spec v" << NEEDED_CFG_VERSION << "]\n\n";
+    cout << normint << "JSBSim startup beginning ...\n\n";
+  }
+
   if (debug_lvl & 2) cout << "Instantiated: FGFDMExec" << endl;
 
   Allocate();
@@ -167,19 +171,22 @@ bool FGFDMExec::Allocate(void) {
 
   bool result=true;
 
-  Atmosphere  = new FGAtmosphere(this);
-  FCS         = new FGFCS(this);
-  Propulsion  = new FGPropulsion(this);
-  Aircraft    = new FGAircraft(this);
-  Translation = new FGTranslation(this);
-  Rotation    = new FGRotation(this);
-  Position    = new FGPosition(this);
-  Auxiliary   = new FGAuxiliary(this);
-  Output      = new FGOutput(this);
-
-  State       = new FGState(this); // This must be done here, as the FGState
-                                   // class needs valid pointers to the above
-                                  // model classes
+  Atmosphere   = new FGAtmosphere(this);
+  FCS          = new FGFCS(this);
+  Propulsion   = new FGPropulsion(this);
+  MassBalance  = new FGMassBalance(this);
+  Aerodynamics = new FGAerodynamics (this);
+  Inertial     = new FGInertial(this);
+  Aircraft     = new FGAircraft(this);
+  Translation  = new FGTranslation(this);
+  Rotation     = new FGRotation(this);
+  Position     = new FGPosition(this);
+  Auxiliary    = new FGAuxiliary(this);
+  Output       = new FGOutput(this);
+
+  State        = new FGState(this); // This must be done here, as the FGState
+                                    // class needs valid pointers to the above
+  // model classes
 
   // Initialize models so they can communicate with each other
 
@@ -192,24 +199,33 @@ bool FGFDMExec::Allocate(void) {
   if (!Propulsion->InitModel()) {
     cerr << fgred << "FGPropulsion model init failed" << fgdef << endl;
     Error+=4;}
+  if (!MassBalance->InitModel()) {
+    cerr << fgred << "FGMassBalance model init failed" << fgdef << endl;
+    Error+=8;}
+  if (!Aerodynamics->InitModel()) {
+    cerr << fgred << "FGAerodynamics model init failed" << fgdef << endl;
+    Error+=16;}
+  if (!Inertial->InitModel()) {
+    cerr << fgred << "FGInertial model init failed" << fgdef << endl;
+    Error+=32;}
   if (!Aircraft->InitModel())   {
     cerr << fgred << "Aircraft model init failed" << fgdef << endl;
-    Error+=8;}
+    Error+=64;}
   if (!Translation->InitModel()){
     cerr << fgred << "Translation model init failed" << fgdef << endl;
-    Error+=16;}
+    Error+=128;}
   if (!Rotation->InitModel())   {
     cerr << fgred << "Rotation model init failed" << fgdef << endl;
-    Error+=32;}
+    Error+=256;}
   if (!Position->InitModel())   {
     cerr << fgred << "Position model init failed" << fgdef << endl;
-    Error+=64;}
+    Error+=512;}
   if (!Auxiliary->InitModel())  {
     cerr << fgred << "Auxiliary model init failed" << fgdef << endl;
-    Error+=128;}
+    Error+=1024;}
   if (!Output->InitModel())     {
     cerr << fgred << "Output model init failed" << fgdef << endl;
-    Error+=256;}
+    Error+=2048;}
 
   if (Error > 0) result = false;
 
@@ -217,15 +233,18 @@ bool FGFDMExec::Allocate(void) {
   // instance, the atmosphere model gets executed every fifth pass it is called
   // by the executive. Everything else here gets executed each pass.
 
-  Schedule(Atmosphere,  1);
-  Schedule(FCS,         1);
-  Schedule(Propulsion,  1);
-  Schedule(Aircraft,    1);
-  Schedule(Rotation,    1);
-  Schedule(Translation, 1);
-  Schedule(Position,    1);
-  Schedule(Auxiliary,   1);
-  Schedule(Output,     1);
+  Schedule(Atmosphere,   1);
+  Schedule(FCS,          1);
+  Schedule(Propulsion,   1);
+  Schedule(MassBalance,  1);
+  Schedule(Aerodynamics, 1);
+  Schedule(Inertial,     1);
+  Schedule(Aircraft,     1);
+  Schedule(Rotation,     1);
+  Schedule(Translation,  1);
+  Schedule(Position,     1);
+  Schedule(Auxiliary,    1);
+  Schedule(Output,       1);
 
   modelLoaded = false;
 
@@ -239,6 +258,9 @@ bool FGFDMExec::DeAllocate(void) {
   if ( Atmosphere != 0 )  delete Atmosphere;
   if ( FCS != 0 )         delete FCS;
   if ( Propulsion != 0)   delete Propulsion;
+  if ( MassBalance != 0)  delete MassBalance;
+  if ( Aerodynamics != 0) delete Aerodynamics;
+  if ( Inertial != 0)     delete Inertial;
   if ( Aircraft != 0 )    delete Aircraft;
   if ( Translation != 0 ) delete Translation;
   if ( Rotation != 0 )    delete Rotation;
@@ -250,16 +272,19 @@ bool FGFDMExec::DeAllocate(void) {
   FirstModel  = 0L;
   Error       = 0;
 
-  State       = 0;
-  Atmosphere  = 0;
-  FCS         = 0;
-  Propulsion  = 0;
-  Aircraft    = 0;
-  Translation = 0;
-  Rotation    = 0;
-  Position    = 0;
-  Auxiliary   = 0;
-  Output      = 0;
+  State        = 0;
+  Atmosphere   = 0;
+  FCS          = 0;
+  Propulsion   = 0;
+  MassBalance  = 0;
+  Aerodynamics = 0;
+  Inertial     = 0;
+  Aircraft     = 0;
+  Translation  = 0;
+  Rotation     = 0;
+  Position     = 0;
+  Auxiliary    = 0;
+  Output       = 0;
 
   modelLoaded = false;
   return modelLoaded;
@@ -302,7 +327,7 @@ bool FGFDMExec::Run(void)
   model_iterator = FirstModel;
   if (model_iterator == 0L) return false;
 
-  if (Scripted) {                                              
+  if (Scripted) {
     RunScript();
     if (State->Getsim_time() >= EndTime) return false;
   }
@@ -338,12 +363,12 @@ bool FGFDMExec::RunIC(FGInitialCondition *fgic)
 bool FGFDMExec::LoadModel(string APath, string EPath, string model)
 {
   bool result = false;
-  
+
   if (modelLoaded) {
     DeAllocate();
     Allocate();
   }
-  
+
   AircraftPath = APath;
   EnginePath   = EPath;
   result = Aircraft->LoadAircraft(AircraftPath, EnginePath, model);
@@ -356,7 +381,7 @@ bool FGFDMExec::LoadModel(string APath, string EPath, string model)
          << fgdef << endl;
   }
 
-  cout << "\n\nJSBSim startup complete\n\n";
+  if (debug_lvl > 0) cout << "\n\nJSBSim startup complete\n\n";
   return result;
 }
 
@@ -370,6 +395,7 @@ bool FGFDMExec::LoadScript(string script)
   string initialize="";
   bool result=false;
   float dt=0.0;
+  int i;
   struct condition *newCondition;
 
   if (!Script.IsOpen()) return false;
@@ -377,17 +403,17 @@ bool FGFDMExec::LoadScript(string script)
   Script.GetNextConfigLine();
   ScriptName = Script.GetValue("name");
   Scripted = true;
-  cout << "Reading Script File " << ScriptName << endl;
+  if (debug_lvl > 0) cout << "Reading Script File " << ScriptName << endl;
 
   while (Script.GetNextConfigLine() != "EOF" && Script.GetValue() != "/runscript") {
     token = Script.GetValue();
     if (token == "use") {
       if ((token = Script.GetValue("aircraft")) != "") {
         aircraft = token;
-        cout << "  Use aircraft: " << token << endl;
+        if (debug_lvl > 0) cout << "  Use aircraft: " << token << endl;
       } else if ((token = Script.GetValue("initialize")) != "") {
         initialize = token;
-        cout << "  Use reset file: " << token << endl;
+        if (debug_lvl > 0) cout << "  Use reset file: " << token << endl;
       } else {
         cerr << "Unknown 'use' keyword: \"" << token << "\"" << endl;
       }
@@ -461,76 +487,77 @@ bool FGFDMExec::LoadScript(string script)
     exit(-1);
   }
 
-  // print out conditions for double-checking
+  // print out conditions for double-checking if requested
 
-  vector <struct condition>::iterator iterConditions = Conditions.begin();
-
-  int count=0;
+  if (debug_lvl > 0) {
+    vector <struct condition>::iterator iterConditions = Conditions.begin();
+    int count=0;
 
-  cout << "\n  Script goes from " << StartTime << " to " << EndTime
-       << " with dt = " << dt << endl << endl;
+    cout << "\n  Script goes from " << StartTime << " to " << EndTime
+         << " with dt = " << dt << endl << endl;
 
-  while (iterConditions < Conditions.end()) {
-    cout << "  Condition: " << count++ << endl;
-    cout << "    if (";
+    while (iterConditions < Conditions.end()) {
+      cout << "  Condition: " << count++ << endl;
+      cout << "    if (";
 
-    for (int i=0; i<iterConditions->TestValue.size(); i++) {
-      if (i>0) cout << " and" << endl << "        ";
-      cout << "(" << State->paramdef[iterConditions->TestParam[i]]
-                  << iterConditions->Comparison[i] << " "
-                  << iterConditions->TestValue[i] << ")";
-    }
-    cout << ") then {" << endl;
-
-    for (int i=0; i<iterConditions->SetValue.size(); i++) {
-      cout << "      set" << State->paramdef[iterConditions->SetParam[i]]
-           << "to " << iterConditions->SetValue[i];
-
-      switch (iterConditions->Type[i]) {
-      case FG_VALUE:
-        cout << " (constant";
-        break;
-      case FG_DELTA:
-        cout << " (delta";
-        break;
-      case FG_BOOL:
-        cout << " (boolean";
-        break;
-      default:
-        cout << " (unspecified type";
+      for (i=0; i<iterConditions->TestValue.size(); i++) {
+        if (i>0) cout << " and" << endl << "        ";
+        cout << "(" << State->paramdef[iterConditions->TestParam[i]]
+                    << iterConditions->Comparison[i] << " "
+                    << iterConditions->TestValue[i] << ")";
       }
+      cout << ") then {" << endl;
 
-      switch (iterConditions->Action[i]) {
-      case FG_RAMP:
-        cout << " via ramp";
-        break;
-      case FG_STEP:
-        cout << " via step";
-        break;
-      case FG_EXP:
-        cout << " via exponential approach";
-        break;
-      default:
-        cout << " via unspecified action";
-      }
+      for (i=0; i<iterConditions->SetValue.size(); i++) {
+        cout << "      set" << State->paramdef[iterConditions->SetParam[i]]
+             << "to " << iterConditions->SetValue[i];
+
+        switch (iterConditions->Type[i]) {
+        case FG_VALUE:
+          cout << " (constant";
+          break;
+        case FG_DELTA:
+          cout << " (delta";
+          break;
+        case FG_BOOL:
+          cout << " (boolean";
+          break;
+        default:
+          cout << " (unspecified type";
+        }
+
+        switch (iterConditions->Action[i]) {
+        case FG_RAMP:
+          cout << " via ramp";
+          break;
+        case FG_STEP:
+          cout << " via step";
+          break;
+        case FG_EXP:
+          cout << " via exponential approach";
+          break;
+        default:
+          cout << " via unspecified action";
+        }
 
-      if (!iterConditions->Persistent[i]) cout << endl
-                         << "                              once";
-      else cout << endl
-                         << "                              repeatedly";
+        if (!iterConditions->Persistent[i]) cout << endl
+                           << "                              once";
+        else cout << endl
+                           << "                              repeatedly";
 
-      if (iterConditions->Action[i] == FG_RAMP ||
-          iterConditions->Action[i] == FG_EXP) cout << endl
-                         << "                              with time constant "
-                         << iterConditions->TC[i];
+        if (iterConditions->Action[i] == FG_RAMP ||
+            iterConditions->Action[i] == FG_EXP) cout << endl
+                           << "                              with time constant "
+                           << iterConditions->TC[i];
+      }
+      cout << ")" << endl << "    }" << endl << endl;
+
+      iterConditions++;
     }
-    cout << ")" << endl << "    }" << endl << endl;
 
-    iterConditions++;
+    cout << endl;
   }
 
-  cout << endl;
-
   result = LoadModel("aircraft", "engine", aircraft);
   if (!result) {
     cerr << "Aircraft file " << aircraft << " was not found" << endl;
@@ -549,6 +576,7 @@ void FGFDMExec::RunScript(void)
   vector <struct condition>::iterator iC = Conditions.begin();
   bool truth;
   bool WholeTruth;
+  int i;
 
   int count=0;
 
@@ -558,7 +586,7 @@ void FGFDMExec::RunScript(void)
   while (iC < Conditions.end()) {
     // determine whether the set of conditional tests for this condition equate
     // to true
-    for (int i=0; i<iC->TestValue.size(); i++) {
+    for (i=0; i<iC->TestValue.size(); i++) {
            if (iC->Comparison[i] == "lt")
               truth = State->GetParameter(iC->TestParam[i]) <  iC->TestValue[i];
       else if (iC->Comparison[i] == "le")
@@ -583,7 +611,7 @@ void FGFDMExec::RunScript(void)
     // if the conditions are true, do the setting of the desired parameters
 
     if (WholeTruth) {
-      for (int i=0; i<iC->SetValue.size(); i++) {
+      for (i=0; i<iC->SetValue.size(); i++) {
         if ( ! iC->Triggered[i]) {
           iC->OriginalValue[i] = State->GetParameter(iC->SetParam[i]);
           switch (iC->Type[i]) {
index 973bc37b3d559d9684c244a6ff28454f4d6356f5..93388f364bbcd746810c4d0f9bd6c85c3624a63d 100644 (file)
@@ -42,7 +42,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <vector>
 #  else
 #    include <vector.h>
@@ -68,6 +68,9 @@ class FGState;
 class FGAtmosphere;
 class FGFCS;
 class FGPropulsion;
+class FGMassBalance;
+class FGAerodynamics;
+class FGInertial;
 class FGAircraft;
 class FGTranslation;
 class FGRotation;
@@ -191,6 +194,8 @@ CLASS DOCUMENTATION
        FGModel object executes its Run() method</li>
     <li><b>8</b>: When this value is set, various runtime state variables
        are printed out periodically</li>
+    <li><b>16</b>: When set various parameters are sanity checked and
+       a message is printed out when they go out of bounds</li>
     </ol>
 
 */
@@ -275,6 +280,12 @@ public:
   /// Returns the FGPropulsion pointer.
   inline FGPropulsion* GetPropulsion(void)    {return Propulsion;}
   /// Returns the FGAircraft pointer.
+  inline FGMassBalance* GetMassBalance(void)  {return MassBalance;}
+  /// Returns the FGAerodynamics pointer
+  inline FGAerodynamics* GetAerodynamics(void){return Aerodynamics;}
+  /// Returns the FGInertial pointer.
+  inline FGInertial* GetInertial(void)        {return Inertial;}
+  /// Returns the FGAircraft pointer.
   inline FGAircraft* GetAircraft(void)        {return Aircraft;}
   /// Returns the FGTranslation pointer.
   inline FGTranslation* GetTranslation(void)  {return Translation;}
@@ -311,16 +322,19 @@ private:
   float  EndTime;
   vector <struct condition> Conditions;
 
-  FGState*       State;
-  FGAtmosphere*  Atmosphere;
-  FGFCS*         FCS;
-  FGPropulsion*  Propulsion;
-  FGAircraft*    Aircraft;
-  FGTranslation* Translation;
-  FGRotation*    Rotation;
-  FGPosition*    Position;
-  FGAuxiliary*   Auxiliary;
-  FGOutput*      Output;
+  FGState*        State;
+  FGAtmosphere*   Atmosphere;
+  FGFCS*          FCS;
+  FGPropulsion*   Propulsion;
+  FGMassBalance*  MassBalance;
+  FGAerodynamics* Aerodynamics;
+  FGInertial*     Inertial;
+  FGAircraft*     Aircraft;
+  FGTranslation*  Translation;
+  FGRotation*     Rotation;
+  FGPosition*     Position;
+  FGAuxiliary*    Auxiliary;
+  FGOutput*       Output;
 
   bool Allocate(void);
   bool DeAllocate(void);
index 572e7cb62d06686aa310e369ee6edda2cbaa2df7..aa762ac9320b07a0b51addc54231983a7b620ae3 100644 (file)
@@ -48,7 +48,7 @@ and the cg.
 #include "FGForce.h"
 
 static const char *IdSrc = "$Id$";
-static const char *IdHdr = "ID_FORCE";
+static const char *IdHdr = ID_FORCE;
 
 extern short debug_lvl;
 
@@ -88,9 +88,9 @@ FGColumnVector FGForce::GetBodyForces(void) {
 
   //find the distance from this vector's location to the cg
   //needs to be done like this to convert from structural to body coords
-  vDXYZ(1) = -(vXYZn(1) - fdmex->GetAircraft()->GetXYZcg(1))*INCHTOFT;
-  vDXYZ(2) =  (vXYZn(2) - fdmex->GetAircraft()->GetXYZcg(2))*INCHTOFT;  //cg and rp values are in inches
-  vDXYZ(3) = -(vXYZn(3) - fdmex->GetAircraft()->GetXYZcg(3))*INCHTOFT;
+  vDXYZ(1) = -(vXYZn(1) - fdmex->GetMassBalance()->GetXYZcg(1))*INCHTOFT;
+  vDXYZ(2) =  (vXYZn(2) - fdmex->GetMassBalance()->GetXYZcg(2))*INCHTOFT;  //cg and rp values are in inches
+  vDXYZ(3) = -(vXYZn(3) - fdmex->GetMassBalance()->GetXYZcg(3))*INCHTOFT;
 
   vM=vMn +vDXYZ*vFb;
 
index f215f247eafca87a2a2653a90ed9c5712c10144a..66ee85ef3f94229f43e87d7c3e945b55533d12e0 100644 (file)
@@ -69,6 +69,7 @@ bool FGGroundReactions:: Run(void) {
 bool FGGroundReactions::LoadGroundReactions(FGConfigFile* AC_cfg)
 {
 //
+  return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 29cafc5745dc809f32993318135135e156d86063..e4bc87fc6a8d28b5e6e9a8877a2c1ddb8ed7b420 100644 (file)
@@ -44,7 +44,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <vector>
 #  else
 #    include <vector.h>
index 026c9ca6bb7f8c788d3a2b10003f4d75754679d3..db9ffe46ece93d04a0085fc43dee447ceb27443d 100644 (file)
@@ -36,6 +36,8 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGInertial.h"
+#include "FGPosition.h"
+#include "FGMassBalance.h"
 
 static const char *IdSrc = "$Id$";
 static const char *IdHdr = ID_INERTIAL;
@@ -47,17 +49,62 @@ CLASS IMPLEMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 
-FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex)
+FGInertial::FGInertial(FGFDMExec* fgex) : FGModel(fgex),
+    vForces(3),
+    vOmegaLocal(3),
+    vRadius(3)
 {
+  Name = "FGInertial";
+
+  vRadius.InitMatrix();
+
   if (debug_lvl & 2) cout << "Instantiated: FGInertial" << endl;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGInertial:: Run(void) {
+FGInertial::~FGInertial(void)
+{
+  if (debug_lvl & 2) cout << "Destroyed:    FGInertial" << endl;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGInertial::Run(void)
+{
+  float stht, ctht, sphi, cphi;
 
   if (!FGModel::Run()) {
 
+    stht = sin(Rotation->GetEuler(eTht));
+    ctht = cos(Rotation->GetEuler(eTht));
+    sphi = sin(Rotation->GetEuler(ePhi));
+    cphi = cos(Rotation->GetEuler(ePhi));
+
+    vForces(eX) = -GRAVITY*stht;
+    vForces(eY) =  GRAVITY*sphi*ctht;
+    vForces(eZ) =  GRAVITY*cphi*ctht;
+    
+    // The following equation for vOmegaLocal terms shows the angular velocity
+    // calculation _for_the_local_frame_ given the earth's rotation (first set)
+    // at the current latitude, and also the component due to the aircraft
+    // motion over the curved surface of the earth (second set).
+
+    vOmegaLocal(eX) = OMEGA_EARTH * cos(Position->GetLatitude());
+    vOmegaLocal(eY) = 0.0;
+    vOmegaLocal(eZ) = OMEGA_EARTH * -sin(Position->GetLatitude());
+
+    vOmegaLocal(eX) +=  Position->GetVe() / Position->GetRadius();
+    vOmegaLocal(eY) += -Position->GetVn() / Position->GetRadius();
+    vOmegaLocal(eZ) +=  0.00;
+
+//    vForces = State->GetTl2b()*(-2.0*vOmegaLocal * Position->GetVel());
+
+    vRadius(3) = Position->GetRadius();
+    vForces += State->GetTl2b()*(vOmegaLocal * (vOmegaLocal * vRadius));
+
+    vForces *= MassBalance->GetMass(); // IMPORTANT !!!!!!!!!!!!!!!!!!!!!!!!!!!!
+    
     return false;
   } else {
     return true;
@@ -68,7 +115,7 @@ bool FGInertial:: Run(void) {
 
 bool FGInertial::LoadInertial(FGConfigFile* AC_cfg)
 {
-//
+  return true;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index d24d17ca8284643570ec07d32b1035ba0f40e4c4..a4cf900744cb9cb4bc6dc043e5be97502af693eb 100644 (file)
@@ -44,7 +44,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <vector>
 #  else
 #    include <vector.h>
@@ -55,6 +55,7 @@ INCLUDES
 
 #include "FGModel.h"
 #include "FGConfigFile.h"
+#include "FGMatrix.h"
 
 #define ID_INERTIAL "$Id$"
 
@@ -67,10 +68,17 @@ class FGInertial : public FGModel {
 
 public:
   FGInertial(FGFDMExec*);
-  ~FGInertial();
+  ~FGInertial(void);
 
   bool Run(void);
+  FGColumnVector GetForces(void) {return vForces;}
   bool LoadInertial(FGConfigFile* AC_cfg);
+
+private:
+  void Debug(void);
+  FGColumnVector vOmegaLocal;
+  FGColumnVector vForces;
+  FGColumnVector vRadius;
 };
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index 0f36ade4fd7de40cd6c3215542c0010b1261a44e..6be481e9dde5610b4122af82a8df738734d5d4f2 100644 (file)
@@ -69,16 +69,18 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
             >> kSpring >> bDamp>> dynamicFCoeff >> staticFCoeff
                   >> rollingFCoeff >> sSteerType >> sBrakeGroup >> maxSteerAngle;
 
-  cout << "    Name: " << name << endl;
-  cout << "      Location: " << vXYZ << endl;
-  cout << "      Spring Constant:  " << kSpring << endl;
-  cout << "      Damping Constant: " << bDamp << endl;
-  cout << "      Dynamic Friction: " << dynamicFCoeff << endl;
-  cout << "      Static Friction:  " << staticFCoeff << endl;
-  cout << "      Rolling Friction: " << rollingFCoeff << endl;
-  cout << "      Steering Type:    " << sSteerType << endl;
-  cout << "      Grouping:         " << sBrakeGroup << endl;
-  cout << "      Max Steer Angle:  " << maxSteerAngle << endl;
+  if (debug_lvl > 0) {
+    cout << "    Name: " << name << endl;
+    cout << "      Location: " << vXYZ << endl;
+    cout << "      Spring Constant:  " << kSpring << endl;
+    cout << "      Damping Constant: " << bDamp << endl;
+    cout << "      Dynamic Friction: " << dynamicFCoeff << endl;
+    cout << "      Static Friction:  " << staticFCoeff << endl;
+    cout << "      Rolling Friction: " << rollingFCoeff << endl;
+    cout << "      Steering Type:    " << sSteerType << endl;
+    cout << "      Grouping:         " << sBrakeGroup << endl;
+    cout << "      Max Steer Angle:  " << maxSteerAngle << endl;
+  }
 
   if      (sBrakeGroup == "LEFT"  ) eBrakeGrp = bgLeft;
   else if (sBrakeGroup == "RIGHT" ) eBrakeGrp = bgRight;
@@ -107,6 +109,7 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
   Position    = Exec->GetPosition();
   Rotation    = Exec->GetRotation();
   FCS         = Exec->GetFCS();
+  MassBalance = Exec->GetMassBalance();
 
   WOW = false;
   ReportEnable = true;
@@ -114,8 +117,9 @@ FGLGear::FGLGear(FGConfigFile* AC_cfg, FGFDMExec* fdmex) : vXYZ(3),
   Reported = false;
   DistanceTraveled = 0.0;
   MaximumStrutForce = MaximumStrutTravel = 0.0;
+  SinkRate = GroundSpeed = 0.0;
 
-  vWhlBodyVec     = (vXYZ - Aircraft->GetXYZcg()) / 12.0;
+  vWhlBodyVec     = (vXYZ - MassBalance->GetXYZcg()) / 12.0;
   vWhlBodyVec(eX) = -vWhlBodyVec(eX);
   vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
 
@@ -134,6 +138,7 @@ FGLGear::FGLGear(const FGLGear& lgear)
   Rotation = lgear.Rotation;
   Exec     = lgear.Exec;
   FCS      = lgear.FCS;
+  MassBalance = lgear.MassBalance;
 
   vXYZ = lgear.vXYZ;
   vMoment = lgear.vMoment;
@@ -187,7 +192,7 @@ FGColumnVector FGLGear::Force(void)
   FGColumnVector vLocalForce(3);
   FGColumnVector vWhlVelVec(3);     // Velocity of this wheel (Local)
 
-  vWhlBodyVec     = (vXYZ - Aircraft->GetXYZcg()) / 12.0;
+  vWhlBodyVec     = (vXYZ - MassBalance->GetXYZcg()) / 12.0;
   vWhlBodyVec(eX) = -vWhlBodyVec(eX);
   vWhlBodyVec(eZ) = -vWhlBodyVec(eZ);
 
@@ -380,6 +385,8 @@ FGColumnVector FGLGear::Force(void)
       MaximumStrutForce = MaximumStrutTravel = 0.0;
     }
 
+    compressLength = 0.0; // reset compressLength to zero for data output validity
+
     vForce.InitMatrix();
     vMoment.InitMatrix();
   }
@@ -389,7 +396,7 @@ FGColumnVector FGLGear::Force(void)
   }
 
   if (ReportEnable && Position->GetVel().Magnitude() <= 0.05 && !Reported) {
-    Report();
+    if (debug_lvl > 0) Report();
   }
 
   return vForce;
index 303e7239b9bd73a4d7c56c6b06d19c278d35722c..046853d5fb4718240d8267735416d7d32f411d77 100644 (file)
@@ -62,6 +62,7 @@ class FGPosition;
 class FGRotation;
 class FGFCS;
 class FGState;
+class FGMassBalance;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
@@ -257,6 +258,7 @@ private:
   FGPosition* Position;
   FGRotation* Rotation;
   FGFCS*      FCS;
+  FGMassBalance* MassBalance;
 
   void Report(void);
   void Debug(void);
@@ -266,6 +268,7 @@ private:
 #include "FGPosition.h"
 #include "FGRotation.h"
 #include "FGFCS.h"
+#include "FGMassBalance.h"
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
index dc380b128f0f5618caef65ddbab2b27f893bd769..b670b2176a9bc8bf7e7bb5d12b7440510249e413 100644 (file)
@@ -52,15 +52,41 @@ CLASS IMPLEMENTATION
 
 FGMassBalance::FGMassBalance(FGFDMExec* fdmex) : FGModel(fdmex)
 {
+  Name = "FGMassBalance";
+
   if (debug_lvl & 2) cout << "Instantiated: FGMassBalance" << endl;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bool FGMassBalance::Run(void) {
+FGMassBalance::~FGMassBalance()
+{
+  if (debug_lvl & 2) cout << "Destroyed:    FGMassBalance" << endl;
+}
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+bool FGMassBalance::Run(void)
+{
   if (!FGModel::Run()) {
 
+    Weight = EmptyWeight + Propulsion->GetTanksWeight();
+
+    Mass = Weight / GRAVITY;
+
+// Calculate new CG here.
+
+    vXYZcg = (Propulsion->GetTanksCG() + EmptyWeight*vbaseXYZcg) / Weight;
+
+// Calculate new moments of inertia here
+
+    Ixx = baseIxx + Propulsion->GetTanksIxx(vXYZcg);
+    Iyy = baseIyy + Propulsion->GetTanksIyy(vXYZcg);
+    Izz = baseIzz + Propulsion->GetTanksIzz(vXYZcg);
+    Ixz = baseIxz + Propulsion->GetTanksIxz(vXYZcg);
+
+    if (debug_lvl > 1) Debug();
+
     return false;
   } else {
     return true;
@@ -71,6 +97,13 @@ bool FGMassBalance::Run(void) {
 
 void FGMassBalance::Debug(void)
 {
-  // TODO: Add user code here
+  if (debug_lvl & 16) { // Sanity check variables
+    if (EmptyWeight <= 0.0 || EmptyWeight > 1e9)
+      cout << "MassBalance::EmptyWeight out of bounds: " << EmptyWeight << endl;
+    if (Weight <= 0.0 || Weight > 1e9)
+      cout << "MassBalance::Weight out of bounds: " << Weight << endl;
+    if (Mass <= 0.0 || Mass > 1e9)
+      cout << "MassBalance::Mass out of bounds: " << Mass << endl;
+  }
 }
 
index b182fb2e51537865c573f90084e798786a8ca0b5..8dc53da8407340e39de390271ef5e31f064b6898 100644 (file)
@@ -43,6 +43,7 @@ INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include "FGModel.h"
+#include "FGPropulsion.h"
 
 #define ID_MASSBALANCE "$Id$"
 
@@ -58,8 +59,42 @@ public:
   ~FGMassBalance();
 
   bool Run(void);
-  
-private:  
+
+  inline float GetMass(void) {return Mass;}
+  inline float GetWeight(void) {return Weight;}
+  inline float GetIxx(void) {return Ixx;}
+  inline float GetIyy(void) {return Iyy;}
+  inline float GetIzz(void) {return Izz;}
+  inline float GetIxz(void) {return Ixz;}
+  inline float GetIyz(void) {return Iyz;}
+  inline FGColumnVector& GetXYZcg(void) {return vXYZcg;}
+  inline float GetXYZcg(int axis) {return vXYZcg(axis);}
+
+  inline void SetEmptyWeight(float EW) { EmptyWeight = EW;}
+  inline void SetBaseIxx(float bixx)   { baseIxx = bixx;}
+  inline void SetBaseIyy(float biyy)   { baseIyy = biyy;}
+  inline void SetBaseIzz(float bizz)   { baseIzz = bizz;}
+  inline void SetBaseIxz(float bixz)   { baseIxz = bixz;}
+  inline void SetBaseIyz(float biyz)   { baseIyz = biyz;}
+  inline void SetBaseCG(const FGColumnVector& CG) {vbaseXYZcg = CG;}
+
+private:
+  float Weight;
+  float EmptyWeight;
+  float Mass;
+  float Ixx;
+  float Iyy;
+  float Izz;
+  float Ixz;
+  float Iyz;
+  float baseIxx;
+  float baseIyy;
+  float baseIzz;
+  float baseIxz;
+  float baseIyz;
+  FGColumnVector vXYZcg;
+  FGColumnVector vXYZtank;
+  FGColumnVector vbaseXYZcg;
   void Debug(void);
 };
 
index 8c92e871cb3a64760e2bf4b1488d2b0fd9142785..99673444ed604c2f8f37b2813fc04424bd460b03 100644 (file)
@@ -22,22 +22,17 @@ INCLUDES
 
 #include <stdlib.h>
 #ifdef FGFS
+#  include <math.h>
 #  include <simgear/compiler.h>
 #  include STL_STRING
+#  include STL_FSTREAM
+#  include STL_IOSTREAM
    SG_USING_STD(string);
    SG_USING_STD(ostream);
    SG_USING_STD(istream);
    SG_USING_STD(cerr);
+   SG_USING_STD(cout);
    SG_USING_STD(endl);
-#  ifdef FG_HAVE_STD_INCLUDES
-#    include <fstream>
-#    include <cmath>
-#    include <iostream>
-#  else
-#    include <fstream.h>
-#    include <math.h>
-#    include <iostream.h>
-#  endif
 #else
 #  include <fstream>
 #  include <cmath>
@@ -47,6 +42,7 @@ INCLUDES
    using std::ostream;
    using std::istream;
    using std::cerr;
+   using std::cout;
    using std::endl;
 #endif
 
index 5a0fc8412c42e39f94d6deee63ce7c27c44868a6..7006b1d0bb2711893d2d1cf266ad71697a3f9aad 100644 (file)
@@ -43,6 +43,10 @@ INCLUDES
 #include "FGFDMExec.h"
 #include "FGAtmosphere.h"
 #include "FGFCS.h"
+#include "FGPropulsion.h"
+#include "FGMassBalance.h"
+#include "FGAerodynamics.h"
+#include "FGInertial.h"
 #include "FGAircraft.h"
 #include "FGTranslation.h"
 #include "FGRotation.h"
@@ -68,16 +72,19 @@ FGModel::FGModel(FGFDMExec* fdmex)
   FDMExec     = fdmex;
   NextModel   = 0L;
 
-  State       = 0;
-  Atmosphere  = 0;
-  FCS         = 0;
-  Propulsion  = 0;
-  Aircraft    = 0;
-  Translation = 0;
-  Rotation    = 0;
-  Position    = 0;
-  Auxiliary   = 0;
-  Output      = 0;
+  State        = 0;
+  Atmosphere   = 0;
+  FCS          = 0;
+  Propulsion   = 0;
+  MassBalance  = 0;
+  Aerodynamics = 0;
+  Inertial     = 0;
+  Aircraft     = 0;
+  Translation  = 0;
+  Rotation     = 0;
+  Position     = 0;
+  Auxiliary    = 0;
+  Output       = 0;
 
   exe_ctr     = 1;
 
@@ -95,21 +102,27 @@ FGModel::~FGModel()
 
 bool FGModel::InitModel(void)
 {
-  State       = FDMExec->GetState();
-  Atmosphere  = FDMExec->GetAtmosphere();
-  FCS         = FDMExec->GetFCS();
-  Propulsion  = FDMExec->GetPropulsion();
-  Aircraft    = FDMExec->GetAircraft();
-  Translation = FDMExec->GetTranslation();
-  Rotation    = FDMExec->GetRotation();
-  Position    = FDMExec->GetPosition();
-  Auxiliary   = FDMExec->GetAuxiliary();
-  Output      = FDMExec->GetOutput();
+  State        = FDMExec->GetState();
+  Atmosphere   = FDMExec->GetAtmosphere();
+  FCS          = FDMExec->GetFCS();
+  Propulsion   = FDMExec->GetPropulsion();
+  MassBalance  = FDMExec->GetMassBalance();
+  Aerodynamics = FDMExec->GetAerodynamics();
+  Inertial     = FDMExec->GetInertial();
+  Aircraft     = FDMExec->GetAircraft();
+  Translation  = FDMExec->GetTranslation();
+  Rotation     = FDMExec->GetRotation();
+  Position     = FDMExec->GetPosition();
+  Auxiliary    = FDMExec->GetAuxiliary();
+  Output       = FDMExec->GetOutput();
 
   if (!State ||
       !Atmosphere ||
       !FCS ||
       !Propulsion ||
+      !MassBalance ||
+      !Aerodynamics ||
+      !Inertial ||
       !Aircraft ||
       !Translation ||
       !Rotation ||
index d8bc729c0ca10034843d6ab0ac5204f79d78bb7d..dcb08daca5cc05cfadabab327b27d45782f1f7c3 100644 (file)
@@ -42,7 +42,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <iostream>
 #  else
 #    include <iostream.h>
@@ -70,6 +70,9 @@ class FGState;
 class FGAtmosphere;
 class FGFCS;
 class FGPropulsion;
+class FGMassBalance;
+class FGAerodynamics;
+class FGInertial;
 class FGAircraft;
 class FGTranslation;
 class FGRotation;
@@ -129,6 +132,9 @@ protected:
   FGAtmosphere*   Atmosphere;
   FGFCS*          FCS;
   FGPropulsion*   Propulsion;
+  FGMassBalance*  MassBalance;
+  FGAerodynamics* Aerodynamics;
+  FGInertial*     Inertial;
   FGAircraft*     Aircraft;
   FGTranslation*  Translation;
   FGRotation*     Rotation;
index cf1ed5b0f639f77a52a7e0c0f34de87d7ae9cd59..f4cf9339378e48db7abcdb672b054192bf44562c 100644 (file)
@@ -52,29 +52,28 @@ FGNozzle::FGNozzle(FGFDMExec* FDMExec, FGConfigFile* Nzl_cfg) : FGThruster(FDMEx
   string token;
 
   Name = Nzl_cfg->GetValue("NAME");
-  cout << "      Nozzle Name: " << Name << endl;
   Nzl_cfg->GetNextConfigLine();
   while (Nzl_cfg->GetValue() != "/FG_NOZZLE") {
     *Nzl_cfg >> token;
-    if (token == "PE") {
-      *Nzl_cfg >> PE;
-      cout << "      Nozzle Exit Pressure = " << PE << endl;
-    } else if (token == "EXPR") {
-      *Nzl_cfg >> ExpR;
-      cout << "      Nozzle Expansion Ratio = " << ExpR << endl;
-    } else if (token == "NZL_EFF") {
-      *Nzl_cfg >> nzlEff;
-      cout << "      Nozzle Efficiency = " << nzlEff << endl;
-    } else if (token == "DIAM") {
-      *Nzl_cfg >> Diameter;
-      cout << "      Nozzle Diameter = " << Diameter << endl;
-    } else {
-      cout << "Unhandled token in Nozzle config file: " << token << endl;
-    }
+    if      (token == "PE")      *Nzl_cfg >> PE;
+    else if (token == "EXPR")    *Nzl_cfg >> ExpR;
+    else if (token == "NZL_EFF") *Nzl_cfg >> nzlEff;
+    else if (token == "DIAM")    *Nzl_cfg >> Diameter;
+    else cerr << "Unhandled token in Nozzle config file: " << token << endl;
+  }
+
+  if (debug_lvl > 0) {
+    cout << "      Nozzle Name: " << Name << endl;
+    cout << "      Nozzle Exit Pressure = " << PE << endl;
+    cout << "      Nozzle Expansion Ratio = " << ExpR << endl;
+    cout << "      Nozzle Efficiency = " << nzlEff << endl;
+    cout << "      Nozzle Diameter = " << Diameter << endl;
   }
 
   Thrust = 0;
   Type = ttNozzle;
+  Area2 = (Diameter*Diameter/4.0)*M_PI;
+  AreaT = Area2/ExpR;
 
   if (debug_lvl & 2) cout << "Instantiated: FGNozzle" << endl;
 }
@@ -91,8 +90,8 @@ FGNozzle::~FGNozzle()
 float FGNozzle::Calculate(float CfPc)
 {
   float pAtm = fdmex->GetAtmosphere()->GetPressure();
-  
-  Thrust = (CfPc + (PE - pAtm)*ExpR) * (Diameter / ExpR) * nzlEff;
+  Thrust = (CfPc * AreaT + (PE - pAtm)*Area2) * nzlEff;
+  vFn(1) = Thrust;
 
   return Thrust;
 }
index 78dfb1e466ab8583f7ec9793a530e06afc6eac2e..d8737e0596d8ac53bab1e08d1bc78d042ed7a77e 100644 (file)
@@ -27,10 +27,6 @@ HISTORY
 --------------------------------------------------------------------------------
 08/24/00  JSB  Created
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-COMMENTS, REFERENCES,  and NOTES
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -44,8 +40,32 @@ INCLUDES
 
 #include "FGThruster.h"
 
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
 #define ID_NOZZLE "$Id$";
 
+#ifndef M_PI
+#  include <simgear/constants.h>
+#  define M_PI SG_PI
+#endif
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+FORWARD DECLARATIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS DOCUMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
+/** Models a rocket nozzle.
+    */
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -53,7 +73,9 @@ CLASS DECLARATION
 class FGNozzle : public FGThruster {
 
 public:
+  /// Constructor
   FGNozzle(FGFDMExec* exec, FGConfigFile* AC_cfg);
+  /// Destructor
   ~FGNozzle();
 
   float Calculate(float CfPc);
@@ -64,6 +86,8 @@ private:
   float ExpR;
   float nzlEff;
   float Diameter;
+  float AreaT;
+  float Area2;
   void Debug(void);
 };
 
index f7ed98b62b951e52ba673d4edfcc6682a7fd28a0..e03f0266ef3aafcb3b76ef71a41baf4e289a33b6 100644 (file)
@@ -43,7 +43,9 @@ INCLUDES
 #include "FGFDMExec.h"
 #include "FGAtmosphere.h"
 #include "FGFCS.h"
+#include "FGAerodynamics.h"
 #include "FGAircraft.h"
+#include "FGMassBalance.h"
 #include "FGTranslation.h"
 #include "FGRotation.h"
 #include "FGPosition.h"
@@ -194,7 +196,7 @@ void FGOutput::DelimitedOutput(void)
     }
     if (SubSystems & FGAircraft::ssCoefficients) {
       cout << ", ";
-      cout << Aircraft->GetCoefficientStrings();
+      cout << Aerodynamics->GetCoefficientStrings();
     }
     if (SubSystems & FGAircraft::ssGroundReactions) {
       cout << ", ";
@@ -235,8 +237,8 @@ void FGOutput::DelimitedOutput(void)
   }
   if (SubSystems & FGAircraft::ssForces) {
     cout << ", ";
-    cout << Aircraft->GetvFs() << ", ";
-    cout << Aircraft->GetLoD() << ", ";
+    cout << Aerodynamics->GetvFs() << ", ";
+    cout << Aerodynamics->GetLoD() << ", ";
     cout << Aircraft->GetForces();
   }
   if (SubSystems & FGAircraft::ssMoments) {
@@ -249,12 +251,12 @@ void FGOutput::DelimitedOutput(void)
   }
   if (SubSystems & FGAircraft::ssMassProps) {
     cout << ", ";
-    cout << Aircraft->GetIxx() << ", ";
-    cout << Aircraft->GetIyy() << ", ";
-    cout << Aircraft->GetIzz() << ", ";
-    cout << Aircraft->GetIxz() << ", ";
-    cout << Aircraft->GetMass() << ", ";
-    cout << Aircraft->GetXYZcg();
+    cout << MassBalance->GetIxx() << ", ";
+    cout << MassBalance->GetIyy() << ", ";
+    cout << MassBalance->GetIzz() << ", ";
+    cout << MassBalance->GetIxz() << ", ";
+    cout << MassBalance->GetMass() << ", ";
+    cout << MassBalance->GetXYZcg();
   }
   if (SubSystems & FGAircraft::ssPosition) {
     cout << ", ";
@@ -268,7 +270,7 @@ void FGOutput::DelimitedOutput(void)
   }
   if (SubSystems & FGAircraft::ssCoefficients) {
     cout << ", ";
-    cout << Aircraft->GetCoefficientValues();
+    cout << Aerodynamics->GetCoefficientValues();
   }
   if (SubSystems & FGAircraft::ssGroundReactions) {
     cout << ", ";
@@ -348,7 +350,7 @@ void FGOutput::DelimitedOutput(string fname)
     }
     if (SubSystems & FGAircraft::ssCoefficients) {
       datafile << ", ";
-      datafile << Aircraft->GetCoefficientStrings();
+      datafile << Aerodynamics->GetCoefficientStrings();
     }
     if (SubSystems & FGAircraft::ssGroundReactions) {
       datafile << ", ";
@@ -392,8 +394,8 @@ void FGOutput::DelimitedOutput(string fname)
   }
   if (SubSystems & FGAircraft::ssForces) {
     datafile << ", ";
-    datafile << Aircraft->GetvFs() << ", ";
-    datafile << Aircraft->GetLoD() << ", ";
+    datafile << Aerodynamics->GetvFs() << ", ";
+    datafile << Aerodynamics->GetLoD() << ", ";
     datafile << Aircraft->GetForces();
   }
   if (SubSystems & FGAircraft::ssMoments) {
@@ -406,12 +408,12 @@ void FGOutput::DelimitedOutput(string fname)
   }
   if (SubSystems & FGAircraft::ssMassProps) {
     datafile << ", ";
-    datafile << Aircraft->GetIxx() << ", ";
-    datafile << Aircraft->GetIyy() << ", ";
-    datafile << Aircraft->GetIzz() << ", ";
-    datafile << Aircraft->GetIxz() << ", ";
-    datafile << Aircraft->GetMass() << ", ";
-    datafile << Aircraft->GetXYZcg();
+    datafile << MassBalance->GetIxx() << ", ";
+    datafile << MassBalance->GetIyy() << ", ";
+    datafile << MassBalance->GetIzz() << ", ";
+    datafile << MassBalance->GetIxz() << ", ";
+    datafile << MassBalance->GetMass() << ", ";
+    datafile << MassBalance->GetXYZcg();
   }
   if (SubSystems & FGAircraft::ssPosition) {
     datafile << ", ";
@@ -425,7 +427,7 @@ void FGOutput::DelimitedOutput(string fname)
   }
   if (SubSystems & FGAircraft::ssCoefficients) {
     datafile << ", ";
-    datafile << Aircraft->GetCoefficientValues();
+    datafile << Aerodynamics->GetCoefficientValues();
   }
   if (SubSystems & FGAircraft::ssGroundReactions) {
     datafile << ", ";
index 96aafb63f0508711e003b6853f40fed20d304824..6638a89bbe81a721caabc4580fee7aff17d44e06 100644 (file)
@@ -42,13 +42,8 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
-#    include <iostream>
-#    include <fstream>
-#  else
-#    include <iostream.h>
-#    include <fstream.h>
-#  endif
+#  include STL_IOSTREAM
+#  include STL_FSTREAM
 #else
 #  include <iostream>
 #  include <fstream>
index 5cd169293a99dbaeff191a8aa736563b68248f12..e60a65fa39f3e8fc63631b2fca3fc4364998ee2c 100644 (file)
@@ -54,34 +54,28 @@ FGPiston::FGPiston(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec)
   string token;
 
   Name = Eng_cfg->GetValue("NAME");
-  cout << "\n    Engine Name: " << Name << endl;
   Eng_cfg->GetNextConfigLine();
   while (Eng_cfg->GetValue() != "/FG_PISTON") {
     *Eng_cfg >> token;
-    if (token == "BRAKEHORSEPOWER") {
-      *Eng_cfg >> BrakeHorsePower;
-      cout << "      BrakeHorsePower = " << BrakeHorsePower << endl;
-    } else if (token == "MAXTHROTTLE") {
-      *Eng_cfg >> MaxThrottle;
-      cout << "      MaxThrottle = " << MaxThrottle << endl;
-    } else if (token == "MINTHROTTLE") {
-      *Eng_cfg >> MinThrottle;
-      cout << "      MinThrottle = " << MinThrottle << endl;
-    } else if (token == "SLFUELFLOWMAX") {
-      *Eng_cfg >> SLFuelFlowMax;
-      cout << "      SLFuelFlowMax = " << SLFuelFlowMax << endl;
-    } else if (token == "SPEEDSLOPE") {
-      *Eng_cfg >> SpeedSlope;
-      cout << "      SpeedSlope = " << SpeedSlope << endl;
-    } else if (token == "SPEEDINTERCEPT") {
-      *Eng_cfg >> SpeedIntercept;
-      cout << "      SpeedIntercept = " << SpeedIntercept << endl;
-    } else if (token == "ALTITUDESLOPE") {
-      *Eng_cfg >> AltitudeSlope;
-      cout << "      AltitudeSlope = " << AltitudeSlope << endl;
-    } else {
-      cout << "Unhandled token in Engine config file: " << token << endl;
-    }
+    if      (token == "BRAKEHORSEPOWER") *Eng_cfg >> BrakeHorsePower;
+    else if (token == "MAXTHROTTLE")     *Eng_cfg >> MaxThrottle;
+    else if (token == "MINTHROTTLE")     *Eng_cfg >> MinThrottle;
+    else if (token == "SLFUELFLOWMAX")   *Eng_cfg >> SLFuelFlowMax;
+    else if (token == "SPEEDSLOPE")      *Eng_cfg >> SpeedSlope;
+    else if (token == "SPEEDINTERCEPT")  *Eng_cfg >> SpeedIntercept;
+    else if (token == "ALTITUDESLOPE")   *Eng_cfg >> AltitudeSlope;
+    else cerr << "Unhandled token in Engine config file: " << token << endl;
+  }
+
+  if (debug_lvl > 0) {
+    cout << "\n    Engine Name: " << Name << endl;
+    cout << "      BrakeHorsePower = " << BrakeHorsePower << endl;
+    cout << "      MaxThrottle = " << MaxThrottle << endl;
+    cout << "      MinThrottle = " << MinThrottle << endl;
+    cout << "      SLFuelFlowMax = " << SLFuelFlowMax << endl;
+    cout << "      SpeedSlope = " << SpeedSlope << endl;
+    cout << "      SpeedIntercept = " << SpeedIntercept << endl;
+    cout << "      AltitudeSlope = " << AltitudeSlope << endl;
   }
 
   Type = etPiston;
index 984e1bc7b5b690616eb261900c51e2a651a1f3dd..e8e09b867c0fc43e1a38954c5a76b00fd97672b3 100644 (file)
@@ -55,7 +55,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <cmath>
 #    include <iomanip>
 #  else
@@ -73,6 +73,7 @@ INCLUDES
 #include "FGFDMExec.h"
 #include "FGFCS.h"
 #include "FGAircraft.h"
+#include "FGMassBalance.h"
 #include "FGTranslation.h"
 #include "FGRotation.h"
 #include "FGAuxiliary.h"
@@ -140,7 +141,7 @@ bool FGPosition:: Run(void) {
     if(psigt < 0.0)
       psigt += 2*M_PI;
 
-    invMass   = 1.0 / Aircraft->GetMass();
+    invMass   = 1.0 / MassBalance->GetMass();
     Radius    = h + SeaLevelRadius;
     invRadius = 1.0 / Radius;
 
index 8d2d45e85e0e24f313e65d8cac429719f9142d51..acb7c265b7234e8c3913452f17812af8a243d797 100644 (file)
@@ -97,6 +97,7 @@ public:
   inline double GetLongitudeDot(void) { return LongitudeDot; }
   inline double GetRunwayRadius(void) { return RunwayRadius; }
   inline double GetDistanceAGL(void)  { return DistanceAGL; }
+  inline double GetRadius(void) { return Radius; }
   inline FGColumnVector GetRunwayNormal(void) { return vRunwayNormal; }
   
   inline double GetGamma(void) { return gamma; }
index 54321871fc727f28249d93d17e879309a20db7a8..650654047d46b9819ebee550e996a7484dd2e060 100644 (file)
@@ -52,50 +52,61 @@ FGPropeller::FGPropeller(FGFDMExec* exec, FGConfigFile* Prop_cfg) : FGThruster(e
   string token;
   int rows, cols;
 
+  MaxPitch = MinPitch = 0.0;
+
   Name = Prop_cfg->GetValue("NAME");
-  cout << "\n    Propeller Name: " << Name << endl;
   Prop_cfg->GetNextConfigLine();
   while (Prop_cfg->GetValue() != "/FG_PROPELLER") {
     *Prop_cfg >> token;
     if (token == "IXX") {
       *Prop_cfg >> Ixx;
-      cout << "      IXX = " << Ixx << endl;
     } else if (token == "DIAMETER") {
       *Prop_cfg >> Diameter;
       Diameter /= 12.0;
-      cout << "      Diameter = " << Diameter << " ft." << endl;
     } else if (token == "NUMBLADES") {
       *Prop_cfg >> numBlades;
-      cout << "      Number of Blades  = " << numBlades << endl;
+    } else if (token == "MINPITCH") {
+      *Prop_cfg >> MinPitch;
+    } else if (token == "MAXPITCH") {
+      *Prop_cfg >> MaxPitch;
     } else if (token == "EFFICIENCY") {
-       *Prop_cfg >> rows >> cols;
-       if (cols == 1) Efficiency = new FGTable(rows);
-            else           Efficiency = new FGTable(rows, cols);
-       *Efficiency << *Prop_cfg;
-       cout << "      Efficiency: " <<  endl;
-       Efficiency->Print();
+      *Prop_cfg >> rows >> cols;
+      if (cols == 1) Efficiency = new FGTable(rows);
+           else           Efficiency = new FGTable(rows, cols);
+      *Efficiency << *Prop_cfg;
     } else if (token == "C_THRUST") {
-       *Prop_cfg >> rows >> cols;
-       if (cols == 1) cThrust = new FGTable(rows);
-            else           cThrust = new FGTable(rows, cols);
-       *cThrust << *Prop_cfg;
-       cout << "      Thrust Coefficient: " <<  endl;
-       cThrust->Print();
+      *Prop_cfg >> rows >> cols;
+      if (cols == 1) cThrust = new FGTable(rows);
+           else           cThrust = new FGTable(rows, cols);
+      *cThrust << *Prop_cfg;
     } else if (token == "C_POWER") {
-       *Prop_cfg >> rows >> cols;
-       if (cols == 1) cPower = new FGTable(rows);
-            else           cPower = new FGTable(rows, cols);
-       *cPower << *Prop_cfg;
-       cout << "      Power Coefficient: " <<  endl;
-       cPower->Print();
+      *Prop_cfg >> rows >> cols;
+      if (cols == 1) cPower = new FGTable(rows);
+           else           cPower = new FGTable(rows, cols);
+      *cPower << *Prop_cfg;
     } else if (token == "EOF") {
-       cout << "      End of file reached" <<  endl;
-       break;
+      cerr << "      End of file reached" <<  endl;
+      break;
     } else {
-      cout << "Unhandled token in Propeller config file: " << token << endl;
+      cerr << "Unhandled token in Propeller config file: " << token << endl;
     }
   }
 
+  if (debug_lvl > 0) {
+    cout << "\n    Propeller Name: " << Name << endl;
+    cout << "      IXX = " << Ixx << endl;
+    cout << "      Diameter = " << Diameter << " ft." << endl;
+    cout << "      Number of Blades  = " << numBlades << endl;
+    cout << "      Minimum Pitch  = " << MinPitch << endl;
+    cout << "      Maximum Pitch  = " << MaxPitch << endl;
+    cout << "      Efficiency: " <<  endl;
+    Efficiency->Print();
+    cout << "      Thrust Coefficient: " <<  endl;
+    cThrust->Print();
+    cout << "      Power Coefficient: " <<  endl;
+    cPower->Print();
+  }
+
   Type = ttPropeller;
   RPM = 0;
 
index cd014c76fa47d034683ba8fd8fec0c183f5600a6..34dc2e9005cf747ad29ee38ed97a2c6e9fde7d70 100644 (file)
@@ -48,6 +48,11 @@ DEFINITIONS
 
 #define ID_PROPELLER "$Id$"
 
+#ifndef M_PI
+#  include <simgear/constants.h>
+#  define M_PI SG_PI
+#endif
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
index 555887df1b0167ac4f5accfcfc4247b34b576c74..f31f1ed34606cff5714b24f0ef0d976fb106c4de 100644 (file)
@@ -167,8 +167,8 @@ bool FGPropulsion::LoadPropulsion(FGConfigFile* AC_cfg)
 
       engineFileName = AC_cfg->GetValue("FILE");
 
-      cout << "\n    Reading engine from file: " << fullpath
-                                                   + engineFileName + ".xml"<< endl;
+      if (debug_lvl > 0) cout << "\n    Reading engine from file: " << fullpath
+                                                + engineFileName + ".xml"<< endl;
       FGConfigFile Eng_cfg(fullpath + engineFileName + ".xml");
 
       if (Eng_cfg.IsOpen()) {
@@ -194,19 +194,27 @@ bool FGPropulsion::LoadPropulsion(FGConfigFile* AC_cfg)
         AC_cfg->GetNextConfigLine();
         while ((token = AC_cfg->GetValue()) != "/AC_ENGINE") {
           *AC_cfg >> token;
-          if (token == "XLOC") { *AC_cfg >> xLoc; cout << "      X = " << xLoc << endl;}
-          else if (token == "YLOC") { *AC_cfg >> yLoc; cout << "      Y = " << yLoc << endl;}
-          else if (token == "ZLOC") { *AC_cfg >> zLoc; cout << "      Z = " << zLoc << endl;}
-          else if (token == "PITCH") { *AC_cfg >> Pitch; cout << "      Pitch = " << Pitch << endl;}
-          else if (token == "YAW") { *AC_cfg >> Yaw; cout << "      Yaw = " << Yaw << endl;}
-          else if (token == "FEED") {
+          if      (token == "XLOC")  { *AC_cfg >> xLoc; }
+          else if (token == "YLOC")  { *AC_cfg >> yLoc; }
+          else if (token == "ZLOC")  { *AC_cfg >> zLoc; }
+          else if (token == "PITCH") { *AC_cfg >> Pitch;}
+          else if (token == "YAW")   { *AC_cfg >> Yaw;}
+          else if (token == "FEED")  {
             *AC_cfg >> Feed;
             Engines[numEngines]->AddFeedTank(Feed);
-            cout << "      Feed tank: " << Feed << endl;
+            if (debug_lvl > 0) cout << "      Feed tank: " << Feed << endl;
           } else cerr << "Unknown identifier: " << token << " in engine file: "
                                                         << engineFileName << endl;
         }
 
+        if (debug_lvl > 0)  {
+          cout << "      X = " << xLoc << endl;
+          cout << "      Y = " << yLoc << endl;
+          cout << "      Z = " << zLoc << endl;
+          cout << "      Pitch = " << Pitch << endl;
+          cout << "      Yaw = " << Yaw << endl;
+       }
+       
         Engines[numEngines]->SetPlacement(xLoc, yLoc, zLoc, Pitch, Yaw);
         numEngines++;
 
@@ -219,7 +227,7 @@ bool FGPropulsion::LoadPropulsion(FGConfigFile* AC_cfg)
 
     } else if (token == "AC_TANK") {              // ============== READING TANKS
 
-      cout << "\n    Reading tank definition" << endl;
+      if (debug_lvl > 0) cout << "\n    Reading tank definition" << endl;
       Tanks.push_back(new FGTank(AC_cfg));
       switch(Tanks[numTanks]->GetType()) {
       case FGTank::ttFUEL:
@@ -238,8 +246,8 @@ bool FGPropulsion::LoadPropulsion(FGConfigFile* AC_cfg)
 
       thrusterFileName = AC_cfg->GetValue("FILE");
 
-      cout << "\n    Reading thruster from file: " <<
-                                       fullpath + thrusterFileName + ".xml" << endl;
+      if (debug_lvl > 0) cout << "\n    Reading thruster from file: " <<
+                                    fullpath + thrusterFileName + ".xml" << endl;
       FGConfigFile Thruster_cfg(fullpath + thrusterFileName + ".xml");
 
       if (Thruster_cfg.IsOpen()) {
@@ -382,6 +390,100 @@ string FGPropulsion::GetPropulsionValues(void)
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+FGColumnVector& FGPropulsion::GetTanksCG(void)
+{
+  iTank = Tanks.begin();
+  vXYZtank.InitMatrix();
+  while (iTank < Tanks.end()) {
+    vXYZtank(eX) += (*iTank)->GetX()*(*iTank)->GetContents();
+    vXYZtank(eY) += (*iTank)->GetY()*(*iTank)->GetContents();
+    vXYZtank(eZ) += (*iTank)->GetZ()*(*iTank)->GetContents();
+    iTank++;
+  }
+  return vXYZtank;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+float FGPropulsion::GetTanksWeight(void)
+{
+  float Tw = 0.0;
+
+  iTank = Tanks.begin();
+  while (iTank < Tanks.end()) {
+    Tw += (*iTank)->GetContents();
+    iTank++;
+  }
+  return Tw;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+float FGPropulsion::GetTanksIxx(const FGColumnVector& vXYZcg)
+{
+  float I = 0.0;
+  iTank = Tanks.begin();
+  while (iTank < Tanks.end()) {
+    I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetX() - vXYZcg(eX)) * (*iTank)->GetContents()/(144.0*GRAVITY);
+    iTank++;
+  }
+  return I;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+float FGPropulsion::GetTanksIyy(const FGColumnVector& vXYZcg)
+{
+  float I = 0.0;
+  iTank = Tanks.begin();
+  while (iTank < Tanks.end()) {
+    I += ((*iTank)->GetY() - vXYZcg(eY))*((*iTank)->GetY() - vXYZcg(eY)) * (*iTank)->GetContents()/(144.0*GRAVITY);
+    iTank++;
+  }
+  return I;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+float FGPropulsion::GetTanksIzz(const FGColumnVector& vXYZcg)
+{
+  float I = 0.0;
+  iTank = Tanks.begin();
+  while (iTank < Tanks.end()) {
+    I += ((*iTank)->GetZ() - vXYZcg(eZ))*((*iTank)->GetZ() - vXYZcg(eZ)) * (*iTank)->GetContents()/(144.0*GRAVITY);
+    iTank++;
+  }
+  return I;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+float FGPropulsion::GetTanksIxz(const FGColumnVector& vXYZcg)
+{
+  float I = 0.0;
+  iTank = Tanks.begin();
+  while (iTank < Tanks.end()) {
+    I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetZ() - vXYZcg(eZ)) * (*iTank)->GetContents()/(144.0*GRAVITY);
+    iTank++;
+  }
+  return I;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+float FGPropulsion::GetTanksIxy(const FGColumnVector& vXYZcg)
+{
+  float I = 0.0;
+  iTank = Tanks.begin();
+  while (iTank != Tanks.end()) {
+    I += ((*iTank)->GetX() - vXYZcg(eX))*((*iTank)->GetY() - vXYZcg(eY)) * (*iTank)->GetContents()/(144.0*GRAVITY);
+    iTank++;
+  }
+  return I;
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
 void FGPropulsion::Debug(void)
 {
     //TODO: Add your source code here
index 049f489466ac6b890ae519733d576a14251aa006..524cfefcbafa0a1bcd2315401be8c5c1c243ce08 100644 (file)
@@ -40,13 +40,16 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <vector>
+#    include <iterator>
 #  else
 #    include <vector.h>
+#    include <iterator.h>
 #  endif
 #else
 #  include <vector>
+#  include <iterator>
 #endif
 
 #include "FGModel.h"
@@ -162,10 +165,20 @@ public:
 
   inline FGColumnVector& GetForces(void)  {return *Forces; }
   inline FGColumnVector& GetMoments(void) {return *Moments;}
+  
+  FGColumnVector& GetTanksCG(void);
+  float GetTanksWeight(void);
+
+  float GetTanksIxx(const FGColumnVector& vXYZcg);
+  float GetTanksIyy(const FGColumnVector& vXYZcg);
+  float GetTanksIzz(const FGColumnVector& vXYZcg);
+  float GetTanksIxz(const FGColumnVector& vXYZcg);
+  float GetTanksIxy(const FGColumnVector& vXYZcg);
 
 private:
   vector <FGEngine*>   Engines;
   vector <FGTank*>     Tanks;
+  vector <FGTank*>::iterator iTank;
   vector <FGThruster*> Thrusters;
   unsigned int numSelectedFuelTanks;
   unsigned int numSelectedOxiTanks;
@@ -177,6 +190,7 @@ private:
   float dt;
   FGColumnVector *Forces;
   FGColumnVector *Moments;
+  FGColumnVector vXYZtank;
   void Debug(void);
 };
 
index 0befe8c775e1918db29ea6dcbf79a01497a07bc5..080dff9d5cd825334f2a51085bfd27ca2debcad1 100644 (file)
@@ -54,42 +54,37 @@ FGRocket::FGRocket(FGFDMExec* exec, FGConfigFile* Eng_cfg) : FGEngine(exec)
   string token;
 
   Name = Eng_cfg->GetValue("NAME");
-  cout << "      Engine Name: " << Name << endl;
   Eng_cfg->GetNextConfigLine();
+
   while (Eng_cfg->GetValue() != "/FG_ROCKET") {
     *Eng_cfg >> token;
-    if (token == "SHR") {
-      *Eng_cfg >> SHR;
-      cout << "      Specific Heat Ratio = " << SHR << endl;
-    } else if (token == "MAX_PC") {
-      *Eng_cfg >> maxPC;
-      cout << "      Maximum Chamber Pressure = " << maxPC << endl;
-    } else if (token == "PROP_EFF") {
-      *Eng_cfg >> propEff;
-      cout << "      Propulsive Efficiency = " << propEff << endl;
-    } else if (token == "MAXTHROTTLE") {
-      *Eng_cfg >> MaxThrottle;
-      cout << "      MaxThrottle = " << MaxThrottle << endl;
-    } else if (token == "MINTHROTTLE") {
-      *Eng_cfg >> MinThrottle;
-      cout << "      MinThrottle = " << MinThrottle << endl;
-    } else if (token == "SLFUELFLOWMAX") {
-      *Eng_cfg >> SLFuelFlowMax;
-      cout << "      FuelFlowMax = " << SLFuelFlowMax << endl;
-    } else if (token == "SLOXIFLOWMAX") {
-      *Eng_cfg >> SLOxiFlowMax;
-      cout << "      OxiFlowMax = " << SLOxiFlowMax << endl;
-    } else if (token == "VARIANCE") {
-      *Eng_cfg >> Variance;
-      cout << "      Variance = " << Variance << endl;
-    } else {
-      cout << "Unhandled token in Engine config file: " << token << endl;
-    }
+    if      (token == "SHR")           *Eng_cfg >> SHR;
+    else if (token == "MAX_PC")        *Eng_cfg >> maxPC;
+    else if (token == "PROP_EFF")      *Eng_cfg >> propEff;
+    else if (token == "MAXTHROTTLE")   *Eng_cfg >> MaxThrottle;
+    else if (token == "MINTHROTTLE")   *Eng_cfg >> MinThrottle;
+    else if (token == "SLFUELFLOWMAX") *Eng_cfg >> SLFuelFlowMax;
+    else if (token == "SLOXIFLOWMAX")  *Eng_cfg >> SLOxiFlowMax;
+    else if (token == "VARIANCE")      *Eng_cfg >> Variance;
+    else cerr << "Unhandled token in Engine config file: " << token << endl;
+  }
+
+  if (debug_lvl > 0) {
+    cout << "      Engine Name: " << Name << endl;
+    cout << "      Specific Heat Ratio = " << SHR << endl;
+    cout << "      Maximum Chamber Pressure = " << maxPC << endl;
+    cout << "      Propulsive Efficiency = " << propEff << endl;
+    cout << "      MaxThrottle = " << MaxThrottle << endl;
+    cout << "      MinThrottle = " << MinThrottle << endl;
+    cout << "      FuelFlowMax = " << SLFuelFlowMax << endl;
+    cout << "      OxiFlowMax = " << SLOxiFlowMax << endl;
+    cout << "      Variance = " << Variance << endl;
   }
 
   EngineNumber = 0;
   Type = etRocket;
 
+  PC = 0.0;
   kFactor = (2.0*SHR*SHR/(SHR-1.0))*pow(2.0/(SHR+1), (SHR+1)/(SHR-1));
 
   if (debug_lvl & 2) cout << "Instantiated: FGRocket" << endl;
@@ -106,17 +101,16 @@ FGRocket::~FGRocket()
 
 float FGRocket::Calculate(float pe)
 {
-  float lastThrust;
   float Cf;
 
   ConsumeFuel();
 
   Throttle = FCS->GetThrottlePos(EngineNumber);
-  lastThrust = Thrust;                 // last actual thrust
 
   if (Throttle < MinThrottle || Starved) {
     PctPower = Thrust = 0.0; // desired thrust
     Flameout = true;
+    PC = 0.0;
   } else {
     PctPower = Throttle / MaxThrottle;
     PC = maxPC*PctPower * (1.0 + Variance * ((float)rand()/(float)RAND_MAX - 0.5));
@@ -124,11 +118,7 @@ float FGRocket::Calculate(float pe)
     Flameout = false;
   }
 
-  if (State->Getdt() > 0.0) {  // actual thrust - if not in freeze
-    Thrust -= 0.8*(Thrust - lastThrust);
-  }
-
-  return Cf*maxPC*PctPower;
+  return Cf*maxPC*PctPower*propEff;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
index d9fbb03015fdacd42222a4a0b7e62c75e5eb7a21..0a3df1f64de7089ad984b505ca54ef96f1ff5c9f 100644 (file)
@@ -61,6 +61,7 @@ INCLUDES
 #include "FGFDMExec.h"
 #include "FGFCS.h"
 #include "FGAircraft.h"
+#include "FGMassBalance.h"
 #include "FGTranslation.h"
 #include "FGPosition.h"
 #include "FGAuxiliary.h"
@@ -102,60 +103,70 @@ FGRotation::~FGRotation()
 
 bool FGRotation::Run(void)
 {
-    float L2, N1;
-    float tTheta;
-
-    if (!FGModel::Run()) {
-        GetState();
-
-        L2 = vMoments(eL) + Ixz*vPQR(eP)*vPQR(eQ) - (Izz-Iyy)*vPQR(eR)*vPQR(eQ);
-        N1 = vMoments(eN) - (Iyy-Ixx)*vPQR(eP)*vPQR(eQ) - Ixz*vPQR(eR)*vPQR(eQ);
-
-        vPQRdot(eP) = (L2*Izz - N1*Ixz) / (Ixx*Izz - Ixz*Ixz);
-        vPQRdot(eQ) = (vMoments(eM) - (Ixx-Izz)*vPQR(eP)*vPQR(eR) - Ixz*(vPQR(eP)*vPQR(eP) - vPQR(eR)*vPQR(eR)))/Iyy;
-        vPQRdot(eR) = (N1*Ixx + L2*Ixz) / (Ixx*Izz - Ixz*Ixz);
-
-        vPQR += dt*rate*(vlastPQRdot + vPQRdot)/2.0;
-
-        State->IntegrateQuat(vPQR, rate);
-        State->CalcMatrices();
-        vEuler = State->CalcEuler();
-        
-        cTht = cos(vEuler(eTht));   sTht = sin(vEuler(eTht));
-        cPhi = cos(vEuler(ePhi));   sPhi = sin(vEuler(ePhi));
-        cPsi = cos(vEuler(ePsi));   sPsi = sin(vEuler(ePsi));
-
-        vEulerRates(eTht) = vPQR(2)*cPhi - vPQR(3)*sPhi;
-        if (cTht != 0.0) {
-          tTheta = sTht/cTht;       // what's cheaper: / or tan() ?
-          vEulerRates(ePhi) = vPQR(1) + (vPQR(2)*sPhi + vPQR(3)*cPhi)*tTheta;
-          vEulerRates(ePsi) = (vPQR(2)*sPhi + vPQR(3)*cPhi)/cTht;
-        }
-        
-        vlastPQRdot = vPQRdot;
-
-    } else {
+  float L2, N1;
+  float tTheta;
+
+  if (!FGModel::Run()) {
+    GetState();
+
+    L2 = vMoments(eL) + Ixz*vPQR(eP)*vPQR(eQ) - (Izz-Iyy)*vPQR(eR)*vPQR(eQ);
+    N1 = vMoments(eN) - (Iyy-Ixx)*vPQR(eP)*vPQR(eQ) - Ixz*vPQR(eR)*vPQR(eQ);
+
+    vPQRdot(eP) = (L2*Izz - N1*Ixz) / (Ixx*Izz - Ixz*Ixz);
+    vPQRdot(eQ) = (vMoments(eM) - (Ixx-Izz)*vPQR(eP)*vPQR(eR) - Ixz*(vPQR(eP)*vPQR(eP) - vPQR(eR)*vPQR(eR)))/Iyy;
+    vPQRdot(eR) = (N1*Ixx + L2*Ixz) / (Ixx*Izz - Ixz*Ixz);
+
+    vPQR += dt*rate*(vlastPQRdot + vPQRdot)/2.0;
+
+    State->IntegrateQuat(vPQR, rate);
+    State->CalcMatrices();
+    vEuler = State->CalcEuler();
+
+    cTht = cos(vEuler(eTht));   sTht = sin(vEuler(eTht));
+    cPhi = cos(vEuler(ePhi));   sPhi = sin(vEuler(ePhi));
+    cPsi = cos(vEuler(ePsi));   sPsi = sin(vEuler(ePsi));
+
+    vEulerRates(eTht) = vPQR(2)*cPhi - vPQR(3)*sPhi;
+    if (cTht != 0.0) {
+      tTheta = sTht/cTht;       // what's cheaper: / or tan() ?
+      vEulerRates(ePhi) = vPQR(1) + (vPQR(2)*sPhi + vPQR(3)*cPhi)*tTheta;
+      vEulerRates(ePsi) = (vPQR(2)*sPhi + vPQR(3)*cPhi)/cTht;
     }
+
+    vlastPQRdot = vPQRdot;
+
+    if (debug_lvl > 1) Debug();
+
     return false;
+  } else {
+    return true;
+  }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 void FGRotation::GetState(void)
 {
-    dt = State->Getdt();
-    vMoments = Aircraft->GetMoments();
+  dt = State->Getdt();
+  vMoments = Aircraft->GetMoments();
 
-    Ixx = Aircraft->GetIxx();
-    Iyy = Aircraft->GetIyy();
-    Izz = Aircraft->GetIzz();
-    Ixz = Aircraft->GetIxz();
+  Ixx = MassBalance->GetIxx();
+  Iyy = MassBalance->GetIyy();
+  Izz = MassBalance->GetIzz();
+  Ixz = MassBalance->GetIxz();
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 void FGRotation::Debug(void)
 {
-    //TODO: Add your source code here
+  if (debug_lvl & 16) { // Sanity check variables
+    if (fabs(vPQR(eP)) > 100)
+      cout << "FGRotation::P (Roll Rate) out of bounds: " << vPQR(eP) << endl;
+    if (fabs(vPQR(eQ)) > 100)
+      cout << "FGRotation::Q (Pitch Rate) out of bounds: " << vPQR(eQ) << endl;
+    if (fabs(vPQR(eR)) > 100)
+      cout << "FGRotation::R (Yaw Rate) out of bounds: " << vPQR(eR) << endl;
+  }
 }
 
index 2c943bce9ecde05dba761445a728ce9b597509b0..3f64a254656dc28543a51c7aa687e9c3bb2d5de5 100644 (file)
@@ -58,18 +58,14 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
-#    include <cmath>
-#  else
-#    include <math.h>
-#  endif
+#  include <math.h>
 #else
 #  include <cmath>
 #endif
 
 #ifndef M_PI
 #  include <simgear/constants.h>
-#  define M_PI FG_PI
+#  define M_PI SG_PI
 #endif
 
 #include "FGModel.h"
index 8c7bcedd6a3d65fbac4e759b21a51592f753a696..58ca50ab5c1a8f6318534c54a9732d3da4a12bb5 100644 (file)
@@ -38,18 +38,14 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
-#    include <cmath>
-#  else
-#    include <math.h>
-#  endif
+#  include <math.h>
 #else
 #  include <cmath>
 #endif
 
 #ifndef M_PI 
 #  include <simgear/constants.h>
-#  define M_PI FG_PI
+#  define M_PI SG_PI
 #endif
 
 #include "FGState.h"
@@ -92,13 +88,14 @@ FGState::FGState(FGFDMExec* fdex) : mTb2l(3,3),
   dt = 1.0/120.0;
   ActiveEngine = -1;
 
-  Aircraft    = FDMExec->GetAircraft();
-  Translation = FDMExec->GetTranslation();
-  Rotation    = FDMExec->GetRotation();
-  Position    = FDMExec->GetPosition();
-  FCS         = FDMExec->GetFCS();
-  Output      = FDMExec->GetOutput();
-  Atmosphere  = FDMExec->GetAtmosphere();
+  Aircraft     = FDMExec->GetAircraft();
+  Translation  = FDMExec->GetTranslation();
+  Rotation     = FDMExec->GetRotation();
+  Position     = FDMExec->GetPosition();
+  FCS          = FDMExec->GetFCS();
+  Output       = FDMExec->GetOutput();
+  Atmosphere   = FDMExec->GetAtmosphere();
+  Aerodynamics = FDMExec->GetAerodynamics();
 
   RegisterVariable(FG_TIME,           " time "           );
   RegisterVariable(FG_QBAR,           " qbar "           );
@@ -190,7 +187,7 @@ float FGState::GetParameter(eParam val_idx) {
     return Rotation->GetPQR(eR);
   case FG_CL_SQRD:
     if (Translation->Getqbar() > 0.00)
-      scratch = Aircraft->GetvLastFs(eLift)/(Aircraft->GetWingArea()*Translation->Getqbar());
+      scratch = Aerodynamics->GetvLastFs(eLift)/(Aircraft->GetWingArea()*Translation->Getqbar());
     else
       scratch = 0.0;
     return scratch*scratch;                                       
index 9061357f42fcae9c727d833179741f6dd0a960e2..e494d280986cfd256727ee30ef4d0ca508e21569 100644 (file)
@@ -46,7 +46,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <fstream>
 #  else
 #    include <fstream.h>
@@ -165,6 +165,7 @@ private:
   FGOutput* Output;
   FGAtmosphere* Atmosphere;
   FGFCS* FCS;
+  FGAerodynamics* Aerodynamics;
 
   typedef map<string, eParam> CoeffMap;
   CoeffMap coeffdef;
@@ -184,7 +185,7 @@ private:
 #include "FGTranslation.h"
 #include "FGRotation.h"
 #include "FGPosition.h"
-//#include "FGAuxiliary.h"
+#include "FGAerodynamics.h"
 #include "FGOutput.h"
 #include "FGAircraft.h"
 
index 2559b38b16aa94bb8ccd2b75a63bc9f63192f34b..7162dd88ec48e9131c28ebddee3737abea84e87a 100644 (file)
@@ -80,10 +80,12 @@ FGTank::FGTank(FGConfigFile* AC_cfg)
     PctFull  = 0;
   }     
 
-  cout << "      " << type << " tank holds " << Capacity << " lbs. " << type << endl;
-  cout << "      currently at " << PctFull << "% of maximum capacity" << endl;
-  cout << "      Tank location (X, Y, Z): " << X << ", " << Y << ", " << Z << endl;
-  cout << "      Effective radius: " << Radius << " inches" << endl;
+  if (debug_lvl > 0) {
+    cout << "      " << type << " tank holds " << Capacity << " lbs. " << type << endl;
+    cout << "      currently at " << PctFull << "% of maximum capacity" << endl;
+    cout << "      Tank location (X, Y, Z): " << X << ", " << Y << ", " << Z << endl;
+    cout << "      Effective radius: " << Radius << " inches" << endl;
+  }
 
   if (debug_lvl & 2) cout << "Instantiated: FGTank" << endl;
 }
index cd7a2ecac6b4cef613ee3b887b7ea5f1fde956cd..05790440a93079644bf4686f4111983e9d9f2c29 100644 (file)
@@ -44,13 +44,23 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
+#include "FGConfigFile.h"
+
 #ifdef FGFS
 #  include <simgear/compiler.h>
+#  include STL_STRING
+  SG_USING_STD(string);
+  SG_USING_STD(cerr);
+  SG_USING_STD(endl);
+  SG_USING_STD(cout);
+#else
+# include <string>
+  using std::string;
+  using std::cerr;
+  using std::endl;
+  using std::cout;
 #endif
 
-#include <string>
-#include "FGConfigFile.h"
-
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
index d19b18525f2db9820110c2c6a4c934575063ead7..40b37267b81a3d52137d2445474a7831c6bcb46a 100644 (file)
@@ -63,6 +63,7 @@ INCLUDES
 #include "FGState.h"
 #include "FGFDMExec.h"
 #include "FGFCS.h"
+#include "FGMassBalance.h"
 #include "FGAircraft.h"
 #include "FGPosition.h"
 #include "FGAuxiliary.h"
@@ -158,9 +159,12 @@ bool FGTranslation::Run(void) {
 
     vlastUVWdot = vUVWdot;
 
-  } else {}
+    if (debug_lvl > 1) Debug();
 
-  return false;
+    return false;
+  } else {
+    return true;
+  }
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -171,7 +175,7 @@ void FGTranslation::GetState(void) {
   vPQR = Rotation->GetPQR();
   vForces = Aircraft->GetForces();
 
-  Mass = Aircraft->GetMass();
+  Mass = MassBalance->GetMass();
   rho = Atmosphere->GetDensity();
 
   vEuler = Rotation->GetEuler();
@@ -181,6 +185,23 @@ void FGTranslation::GetState(void) {
 
 void FGTranslation::Debug(void)
 {
-    //TODO: Add your source code here
+  if (debug_lvl & 16) { // Sanity check variables
+    if (fabs(vUVW(eU)) > 1e6)
+      cout << "FGTranslation::U velocity out of bounds: " << vUVW(eU) << endl;
+    if (fabs(vUVW(eV)) > 1e6)
+      cout << "FGTranslation::V velocity out of bounds: " << vUVW(eV) << endl;
+    if (fabs(vUVW(eW)) > 1e6)
+      cout << "FGTranslation::W velocity out of bounds: " << vUVW(eW) << endl;
+    if (fabs(vUVWdot(eU)) > 1e4)
+      cout << "FGTranslation::U acceleration out of bounds: " << vUVWdot(eU) << endl;
+    if (fabs(vUVWdot(eV)) > 1e4)
+      cout << "FGTranslation::V acceleration out of bounds: " << vUVWdot(eV) << endl;
+    if (fabs(vUVWdot(eW)) > 1e4)
+      cout << "FGTranslation::W acceleration out of bounds: " << vUVWdot(eW) << endl;
+    if (Mach > 100 || Mach < 0.00)
+      cout << "FGTranslation::Mach is out of bounds: " << Mach << endl;
+    if (qbar > 1e6 || qbar < 0.00)
+      cout << "FGTranslation::qbar is out of bounds: " << qbar << endl;
+  }
 }
 
index 680cab4d7c32a6d2faac2e833e5ec491c661e45b..08e85453ee18723dd51590c623096355d31ba5e6 100644 (file)
@@ -58,7 +58,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <cmath>
 #  else
 #    include <math.h>
index 6f32949f69553c5b55cf4441d1a32832eaabad55..d9542e1e568ebece7e32ef5d2f37724043fd9fee 100644 (file)
@@ -51,7 +51,8 @@ INCLUDES
 #include "FGInitialCondition.h"
 #include "FGTrim.h"
 #include "FGAircraft.h"
-
+#include "FGMassBalance.h"
+#include "FGAerodynamics.h"
 #if _MSC_VER
 #pragma warning (disable : 4786 4788)
 #endif
@@ -164,10 +165,10 @@ void FGTrim::ReportState(void) {
   
   cout << endl << "  JSBSim State" << endl;
   sprintf(out,"    Weight: %7.0f lbs.  CG: %5.1f, %5.1f, %5.1f inches\n",
-                   fdmex->GetAircraft()->GetWeight(),
-                   fdmex->GetAircraft()->GetXYZcg(1),
-                   fdmex->GetAircraft()->GetXYZcg(2),
-                   fdmex->GetAircraft()->GetXYZcg(3));
+                   fdmex->GetMassBalance()->GetWeight(),
+                   fdmex->GetMassBalance()->GetXYZcg(1),
+                   fdmex->GetMassBalance()->GetXYZcg(2),
+                   fdmex->GetMassBalance()->GetXYZcg(3));
   cout << out;             
   if( fdmex->GetFCS()->GetDfPos() <= 0.01)
     sprintf(flap,"Up");
@@ -197,7 +198,7 @@ void FGTrim::ReportState(void) {
                     fdmex->GetPosition()->Gethdot()*60 );
   cout << out;                  
   sprintf(out, "    Normal Load Factor: %4.2f g's  Pitch Rate: %5.2f deg/s\n",
-                    fdmex->GetAircraft()->GetNlf(),
+                    fdmex->GetAerodynamics()->GetNlf(),
                     fdmex->GetState()->GetParameter(FG_PITCHRATE)*RADTODEG );
   cout << out;
   sprintf(out, "    Heading: %3.0f deg true  Sideslip: %5.2f deg\n",
index f8469f97d6409a1d0f7d67ce875f460884a9bffb..de1b02cf0201a79ee733a1d90b4c29e0fffa6d0f 100644 (file)
@@ -162,7 +162,7 @@ private:
   FGFDMExec* fdmex;
   FGInitialCondition* fgic;
    
-   bool solve(void);
+  bool solve(void);
   
   /** @return false if there is no change in the current axis accel
       between accel(control_min) and accel(control_max). If there is a
index 892db1cebb778ec427ee04bee227ce2f8de61290..c32abed4efd84ae80aebf653505affb2a8ca361c 100644 (file)
@@ -44,7 +44,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <cmath>
 #  else
 #    include <math.h>
index 0507a69f18c798fbc61b40e894a685a0922bfd0f..803c01f5747364e35e1b187ee01aa9f31cc73622 100644 (file)
@@ -47,15 +47,10 @@ INCLUDES
 #ifdef FGFS
 #  include <simgear/compiler.h>
 #  include STL_STRING
+#  include STL_IOSTREAM
+#  include STL_FSTREAM
    SG_USING_STD(cout);
    SG_USING_STD(endl);
-#  ifdef FG_HAVE_STD_INCLUDES
-#    include <iostream>
-#    include <fstream>
-#  else
-#    include <iostream.h>
-#    include <fstream.h>
-#  endif
 #else
 #  include <iostream>
 #  include <fstream>
index 499be681732646519a6074bbfa9a4cce612ec18d..400b6088b63ea20f2e47e9170d9874eb303e2735 100644 (file)
@@ -54,7 +54,7 @@ INCLUDES
 #ifdef FGFS
 #include <simgear/compiler.h>
 #include STL_IOSTREAM
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <ctime>
 #  else
 #    include <time.h>
@@ -64,6 +64,57 @@ INCLUDES
 #include <ctime>
 #endif
 
+#if __BORLANDC__ > 0x540
+#include <condefs.h>
+USEUNIT("FGUtility.cpp");
+USEUNIT("FGAircraft.cpp");
+USEUNIT("FGAtmosphere.cpp");
+USEUNIT("FGAuxiliary.cpp");
+USEUNIT("FGCoefficient.cpp");
+USEUNIT("FGConfigFile.cpp");
+USEUNIT("FGEngine.cpp");
+USEUNIT("FGFCS.cpp");
+USEUNIT("FGFDMExec.cpp");
+USEUNIT("FGfdmSocket.cpp");
+USEUNIT("FGForce.cpp");
+USEUNIT("FGGroundReactions.cpp");
+USEUNIT("FGInertial.cpp");
+USEUNIT("FGInitialCondition.cpp");
+USEUNIT("FGLGear.cpp");
+USEUNIT("FGMassBalance.cpp");
+USEUNIT("FGMatrix.cpp");
+USEUNIT("FGModel.cpp");
+USEUNIT("FGNozzle.cpp");
+USEUNIT("FGOutput.cpp");
+USEUNIT("FGPiston.cpp");
+USEUNIT("FGPosition.cpp");
+USEUNIT("FGPropeller.cpp");
+USEUNIT("FGPropulsion.cpp");
+USEUNIT("FGRocket.cpp");
+USEUNIT("FGRotation.cpp");
+USEUNIT("FGRotor.cpp");
+USEUNIT("FGState.cpp");
+USEUNIT("FGTable.cpp");
+USEUNIT("FGTank.cpp");
+USEUNIT("FGThruster.cpp");
+USEUNIT("FGTranslation.cpp");
+USEUNIT("FGTrim.cpp");
+USEUNIT("FGTrimAxis.cpp");
+USEUNIT("FGTurboJet.cpp");
+USEUNIT("FGTurboProp.cpp");
+USEUNIT("FGTurboShaft.cpp");
+USEUNIT("FGAerodynamics.cpp");
+USEUNIT("filtersjb\FGSwitch.cpp");
+USEUNIT("filtersjb\FGFCSComponent.cpp");
+USEUNIT("filtersjb\FGFilter.cpp");
+USEUNIT("filtersjb\FGFlaps.cpp");
+USEUNIT("filtersjb\FGGain.cpp");
+USEUNIT("filtersjb\FGGradient.cpp");
+USEUNIT("filtersjb\FGSummer.cpp");
+USEUNIT("filtersjb\FGDeadBand.cpp");
+//---------------------------------------------------------------------------
+#endif
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
index ce6d9dbc80c1e8e87b37b7f39dfd057718701241..c05a09327cf60156e1ca5f433a6441a38341c1b6 100644 (file)
@@ -4,10 +4,7 @@ EXTRA_DIST = JSBSim.cpp Makefile.solo
 
 noinst_LIBRARIES = libJSBSim.a
 
-# FGAerodynamics.cpp FGAerodynamics.h \
 # FGGroundReactions.cpp FGGroundReactions.h \
-# FGInertial.cpp FGInertial.h \
-# FGMassBalance.cpp FGMassBalance.h \
 # FGPiston.cpp FGPiston.h \
 # FGPropulsion.cpp FGPropulsion.h \
 # FGRocket.cpp FGRocket.h \
@@ -15,6 +12,7 @@ noinst_LIBRARIES = libJSBSim.a
 # FGTurboShaft.cpp FGTurboShaft.h \
 
 libJSBSim_a_SOURCES = \
+        FGAerodynamics.cpp FGAerodynamics.h \
        FGAircraft.cpp FGAircraft.h \
        FGAtmosphere.cpp FGAtmosphere.h \
        FGAuxiliary.cpp FGAuxiliary.h \
@@ -25,8 +23,10 @@ libJSBSim_a_SOURCES = \
        FGFCS.cpp FGFCS.h \
        FGFDMExec.cpp FGFDMExec.h \
        FGForce.cpp FGForce.h \
+        FGInertial.cpp FGInertial.h \
        FGInitialCondition.cpp FGInitialCondition.h \
        FGLGear.cpp FGLGear.h \
+        FGMassBalance.cpp FGMassBalance.h \
        FGMatrix.cpp FGMatrix.h \
        FGModel.cpp FGModel.h \
        FGNozzle.cpp FGNozzle.h \
index fe57b1b43186be58106c4098baab332f7bee3e60..2c2cabbea0b51feb75a79ea3b84e5e93d0b9893c 100644 (file)
@@ -70,10 +70,15 @@ FGFilter::FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
 
   while ((token = AC_cfg->GetValue()) != string("/COMPONENT")) {
     *AC_cfg >> token;
-    if (token == "ID") {
-      *AC_cfg >> ID;
-      cout << "      ID: " << ID << endl;
-    } else if (token == "INPUT") {
+    if      (token == "ID")     *AC_cfg >> ID;
+    else if (token == "C1")     *AC_cfg >> C1;
+    else if (token == "C2")     *AC_cfg >> C2;
+    else if (token == "C3")     *AC_cfg >> C3;
+    else if (token == "C4")     *AC_cfg >> C4;
+    else if (token == "C5")     *AC_cfg >> C5;
+    else if (token == "C6")     *AC_cfg >> C6;
+    else if (token == "INPUT")
+    {
       token = AC_cfg->GetValue("INPUT");
       if (token.find("FG_") != token.npos) {
         *AC_cfg >> token;
@@ -83,31 +88,14 @@ FGFilter::FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
         *AC_cfg >> InputIdx;
         InputType = itFCS;
       }
-      cout << "      INPUT: " << token << endl;
-    } else if (token == "C1") {
-      *AC_cfg >> C1;
-      cout << "      C1: " << C1 << endl;
-    } else if (token == "C2") {
-      *AC_cfg >> C2;
-      cout << "      C2: " << C2 << endl;
-    } else if (token == "C3") {
-      *AC_cfg >> C3;
-      cout << "      C3: " << C3 << endl;
-    } else if (token == "C4") {
-      *AC_cfg >> C4;
-      cout << "      C4: " << C4 << endl;
-    } else if (token == "C5") {
-      *AC_cfg >> C5;
-      cout << "      C5: " << C5 << endl;
-    } else if (token == "C6") {
-      *AC_cfg >> C6;
-      cout << "      C6: " << C6 << endl;
-    } else if (token == "OUTPUT") {
+    }
+    else if (token == "OUTPUT")
+    {
       IsOutput = true;
       *AC_cfg >> sOutputIdx;
       OutputIdx = fcs->GetState()->GetParameterIndex(sOutputIdx);
-      cout << "      OUTPUT: " << sOutputIdx << endl;
     }
+    else cerr << "Unknown filter type: " << token << endl;
   }
 
   Initialize = true;
@@ -136,6 +124,18 @@ FGFilter::FGFilter(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
       break;
   }
 
+  if (debug_lvl > 0) {
+      cout << "      ID: " << ID << endl;
+      cout << "      INPUT: " << InputIdx << endl;
+      cout << "      C1: " << C1 << endl;
+      cout << "      C2: " << C2 << endl;
+      cout << "      C3: " << C3 << endl;
+      cout << "      C4: " << C4 << endl;
+      cout << "      C5: " << C5 << endl;
+      cout << "      C6: " << C6 << endl;
+      if (IsOutput) cout << "      OUTPUT: " << sOutputIdx << endl;
+  }
+
   if (debug_lvl & 2) cout << "Instantiated: FGFilter" << endl;
 }
 
index 0ac76d357da68745f31ef825f6f6cb81673f3df9..ba743ee066a68458c880e54bee6851cde8a24ff7 100644 (file)
@@ -65,10 +65,8 @@ AC_cfg(AC_cfg) {
     *AC_cfg >> token;
     if (token == "ID") {
       *AC_cfg >> ID;
-      cout << "      ID: " << ID << endl;
     } else if (token == "INPUT") {
       token = AC_cfg->GetValue("INPUT");
-      cout << "      INPUT: " << token << endl;
       if (token.find("FG_") != token.npos) {
         *AC_cfg >> token;
         InputIdx = fcs->GetState()->GetParameterIndex(token);
@@ -76,23 +74,30 @@ AC_cfg(AC_cfg) {
       }
     } else if ( token == "DETENTS" ) {
       *AC_cfg >> NumDetents;
-      cout << "      DETENTS: " << NumDetents << endl;
       for(int i=0;i<NumDetents;i++) {
         *AC_cfg >> tmpDetent;
         *AC_cfg >> tmpTime;
         Detents.push_back(tmpDetent);
         TransitionTimes.push_back(tmpTime);
-        cout << "        " << Detents[i] << " " << TransitionTimes[i] << endl;
       }
     } else if (token == "OUTPUT") {
 
       IsOutput = true;
       *AC_cfg >> sOutputIdx;
-      cout << "      OUTPUT: " <<sOutputIdx << endl;
       OutputIdx = fcs->GetState()->GetParameterIndex(sOutputIdx);
     }
   }
 
+  if (debug_lvl > 1) {
+    cout << "      ID: " << ID << endl;
+    cout << "      INPUT: " << InputIdx << endl;
+    cout << "      DETENTS: " << NumDetents << endl;
+    for(int i=0;i<NumDetents;i++) {
+      cout << "        " << Detents[i] << " " << TransitionTimes[i] << endl;
+    }
+    if (IsOutput) cout << "      OUTPUT: " <<sOutputIdx << endl;
+  }
+
   if (debug_lvl & 2) cout << "Instantiated: FGFlaps" << endl;
 }
 
index 4b26437522d14912670cb5022cfa21875a78da81..4ec0e3bfaca88f5a1c2229bd93bb4bc00dc86706 100644 (file)
@@ -1,6 +1,6 @@
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
- Header:       FGFlap.h
+ Header:       FGFlaps.h
  Author:       Tony Peden, for flight control system authored by Jon S. Berndt
  Date started: 5/11/00 
  
@@ -34,8 +34,8 @@ COMMENTS, REFERENCES,  and NOTES
 SENTRY
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#ifndef FGFlap_H
-#define FGFlap_H
+#ifndef FGFLAPS_H
+#define FGFLAPS_H
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
@@ -43,7 +43,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <vector>
 #  else
 #    include <vector.h>
@@ -67,6 +67,12 @@ CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 class FGFlaps  : public FGFCSComponent {
+public:
+  FGFlaps(FGFCS* fcs, FGConfigFile* AC_cfg);
+  ~FGFlaps();
+  bool Run (void );
+  
+private:
   FGConfigFile* AC_cfg;
   vector<float> Detents;
   vector<float> TransitionTimes;
@@ -76,12 +82,6 @@ class FGFlaps  : public FGFCSComponent {
   float Flap_Position;
   bool  Flaps_In_Transit;
 
-public:
-  FGFlaps(FGFCS* fcs, FGConfigFile* AC_cfg);
-  ~FGFlaps();
-  bool Run (void );
-  
-private:
   void Debug(void);
 };
 
index ada0b3db679d3cecb6d36364d0533c23c2a3bc26..48505338b659cd9b39ecda8771ad885756369b03 100644 (file)
@@ -55,10 +55,11 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
   string token;
   string strScheduledBy;
 
-  lookup = NULL;
-  Schedule.clear();
+  State = fcs->GetState();
+
   Gain = 1.000;
-  Min = Max = 0;
+  Rows = 0;
+  Min = Max = 0.0;
   ScheduledBy = FG_UNDEF;
 
   Type = AC_cfg->GetValue("TYPE");
@@ -69,13 +70,11 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
     *AC_cfg >> token;
     if (token == "ID") {
       *AC_cfg >> ID;
-      cout << "      ID: " << ID << endl;
     } else if (token == "INPUT") {
       token = AC_cfg->GetValue("INPUT");
-      cout << "      INPUT: " << token << endl;
       if (token.find("FG_") != token.npos) {
         *AC_cfg >> token;
-        InputIdx = fcs->GetState()->GetParameterIndex(token);
+        InputIdx = State->GetParameterIndex(token);
         InputType = itPilotAC;
       } else {
         *AC_cfg >> InputIdx;
@@ -83,34 +82,41 @@ FGGain::FGGain(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
       }
     } else if (token == "GAIN") {
       *AC_cfg >> Gain;
-      cout << "      GAIN: " << Gain << endl;
     } else if (token == "MIN") {
       *AC_cfg >> Min;
-      cout << "      MIN: " << Min << endl;
     } else if (token == "MAX") {
       *AC_cfg >> Max;
-      cout << "      MAX: " << Max << endl;
+    } else if (token == "ROWS") {
+      *AC_cfg >> Rows;
+      Table = new FGTable(Rows);
     } else if (token == "SCHEDULED_BY") {
       token = AC_cfg->GetValue("SCHEDULED_BY");
       if (token.find("FG_") != token.npos) {
         *AC_cfg >> strScheduledBy;
-        ScheduledBy = fcs->GetState()->GetParameterIndex(strScheduledBy);
-        cout << "      Scheduled by parameter: " << token << endl;
+        ScheduledBy = State->GetParameterIndex(strScheduledBy);
       } else {
         *AC_cfg >> ScheduledBy;
-        cout << "      Scheduled by FCS output: " << ScheduledBy << endl;
       }
     } else if (token == "OUTPUT") {
       IsOutput = true;
       *AC_cfg >> sOutputIdx;
-      OutputIdx = fcs->GetState()->GetParameterIndex(sOutputIdx);
-      cout << "      OUTPUT: " << sOutputIdx << endl;
+      OutputIdx = State->GetParameterIndex(sOutputIdx);
     } else {
       AC_cfg->ResetLineIndexToZero();
-      lookup = new float[2];
-      *AC_cfg >> lookup[0] >> lookup[1];
-      cout << "        " << lookup[0] << "  " << lookup[1] << endl;
-      Schedule.push_back(lookup);
+      *Table << *AC_cfg;
+    }
+  }
+
+  if (debug_lvl > 0) {
+    cout << "      ID: " << ID << endl;
+    cout << "      INPUT: " << InputIdx << endl;
+    cout << "      GAIN: " << Gain << endl;
+    if (IsOutput) cout << "      OUTPUT: " << sOutputIdx << endl;
+    cout << "      MIN: " << Min << endl;
+    cout << "      MAX: " << Max << endl;
+    if (ScheduledBy != FG_UNDEF) {
+      cout << "      Scheduled by parameter: " << ScheduledBy << endl;
+      Table->Print();
     }
   }
 
@@ -129,40 +135,19 @@ FGGain::~FGGain()
 bool FGGain::Run(void )
 {
   float SchedGain = 1.0;
+  float LookupVal = 0;
 
   FGFCSComponent::Run(); // call the base class for initialization of Input
 
   if (Type == "PURE_GAIN") {
-
     Output = Gain * Input;
-
   } else if (Type == "SCHEDULED_GAIN") {
-
-    float LookupVal = fcs->GetState()->GetParameter(ScheduledBy);
-    unsigned int last = Schedule.size()-1;
-    float lowVal = Schedule[0][0], hiVal = Schedule[last][0];
-    float factor = 1.0;
-
-    if (LookupVal <= lowVal) Output = Gain * Schedule[0][1] * Input;
-    else if (LookupVal >= hiVal) Output = Gain * Schedule[last][1] * Input;
-    else {
-      for (unsigned int ctr = 1; ctr < last; ctr++) {
-        if (LookupVal < Schedule[ctr][0]) {
-          hiVal = Schedule[ctr][0];
-          lowVal = Schedule[ctr-1][0];
-          factor = (LookupVal - lowVal) / (hiVal - lowVal);
-          SchedGain = Schedule[ctr-1][1] + factor*(Schedule[ctr][1] - Schedule[ctr-1][1]);
-          Output = Gain * SchedGain * Input;
-          break;
-        }
-      }
-    }
-
+    LookupVal = State->GetParameter(ScheduledBy);
+         SchedGain = Table->GetValue(LookupVal);
+    Output = Gain * SchedGain * Input;
   } else if (Type == "AEROSURFACE_SCALE") {
-
     if (Output >= 0.0) Output = Input * Max;
     else Output = Input * (-Min);
-
     Output *= Gain;
   }
 
index 44f66e6338cd1a4dc7d4205505b846e3725c16b3..2ac84589685f3471e5c0856d010097af7a891a41 100644 (file)
@@ -43,18 +43,15 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
-#    include <vector>
-#  else
-#    include <vector.h>
-#  endif
+#  include STL_STRING
+   SG_USING_STD(string);
 #else
-#  include <vector>
+#  include <string>
 #endif
 
-#include <string>
 #include "FGFCSComponent.h"
 #include "../FGConfigFile.h"
+#include "../FGTable.h"
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINES
@@ -78,10 +75,11 @@ public:
 
 private:
   FGConfigFile* AC_cfg;
+  FGTable* Table;
+  FGState* State;
   float Gain;
-  float* lookup;
-  vector < float* > Schedule;
   float Min, Max;
+  int Rows;
   eParam ScheduledBy;
 
   void Debug(void);
index b73af9af8badf45ab1866d0a3dcac6e979208a78..431a6bacf77ffd0d645b4b2a9d281009572af633 100644 (file)
@@ -67,14 +67,9 @@ FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
     *AC_cfg >> token;
 
     if (token == "ID") {
-
       *AC_cfg >> ID;
-      cout << "      ID: " << ID << endl;
-
     } else if (token == "INPUT") {
-
       token = AC_cfg->GetValue("INPUT");
-      cout << "      INPUT: " << token << endl;
       if (token.find("FG_") != token.npos) {
         *AC_cfg >> token;
         tmpInputIndex = fcs->GetState()->GetParameterIndex(token);
@@ -85,24 +80,29 @@ FGSummer::FGSummer(FGFCS* fcs, FGConfigFile* AC_cfg) : FGFCSComponent(fcs),
         InputIndices.push_back(tmpInputIndex);
         InputTypes.push_back(itFCS);
       }
-
     } else if (token == "CLIPTO") {
-
       *AC_cfg >> clipmin >> clipmax;
       if (clipmax > clipmin) {
         clip = true;
-        cout << "      CLIPTO: " << clipmin << ", " << clipmax << endl;
       }
-
     } else if (token == "OUTPUT") {
-
       IsOutput = true;
       *AC_cfg >> sOutputIdx;
-      cout << "      OUTPUT: " <<sOutputIdx <<  endl;
       OutputIdx = fcs->GetState()->GetParameterIndex(sOutputIdx);
     }
   }
 
+  if (debug_lvl > 0) {
+    cout << "      ID: " << ID << endl;
+    cout << "      INPUTS: " << endl;
+    for (int i=0;i<InputIndices.size();i++) {
+      cout << "        " << InputIndices[i] << endl;
+    }
+    if (clipmax > clipmin) cout << "      CLIPTO: " << clipmin 
+                                << ", " << clipmax << endl;
+    if (IsOutput) cout << "      OUTPUT: " <<sOutputIdx <<  endl;
+  }
+
   if (debug_lvl & 2) cout << "Instantiated: FGSummer" << endl;
 }
 
index 1a91e40840690fe37725699c6c0b92de35ef38dd..e07d53aa1d6927fc7309a4e66026f90886ae06f1 100644 (file)
@@ -43,7 +43,7 @@ INCLUDES
 
 #ifdef FGFS
 #  include <simgear/compiler.h>
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <vector>
 #  else
 #    include <vector.h>