]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGAircraft.cpp
Updated to match changes in radiostack.[ch]xx
[flightgear.git] / src / FDM / JSBSim / FGAircraft.cpp
index f49e9dd98877db0717f63a95c87c68dea513f93e..5ee4979c07952e1642e4ab89ba3d2b043731f021 100644 (file)
@@ -1,5 +1,5 @@
-/*******************************************************************************
-
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  Module:       FGAircraft.cpp
  Author:       Jon S. Berndt
  Date started: 12/12/98                                   
@@ -7,30 +7,29 @@
  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
  the terms of the GNU General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.
-
  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  details.
-
  You should have received a copy of the GNU General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  Place - Suite 330, Boston, MA  02111-1307, USA.
-
  Further information about the GNU General Public License can also be found on
  the world wide web at http://www.gnu.org.
-
 FUNCTIONAL DESCRIPTION
 --------------------------------------------------------------------------------
 Models the aircraft reactions and forces. This class is instantiated by the
-FGFDMExec class and scheduled as an FDM entry. LoadAircraft() is supplied with a
-name of a valid, registered aircraft, and the data file is parsed.
-
+FGFDMExec class and scheduled as an FDM entry. 
 HISTORY
 --------------------------------------------------------------------------------
 12/12/98   JSB   Created
@@ -39,85 +38,41 @@ HISTORY
 05/03/99   JSB   Changed (for the better?) the way configurations are read in.
 9/17/99     TP   Combined force and moment functions. Added aero reference 
                  point to config file. Added calculations for moments due to 
-                                difference in cg and aero reference point
-
-********************************************************************************
+                 difference in cg and aero reference point
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 COMMENTS, REFERENCES,  and NOTES
-********************************************************************************
-[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
-      Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420  Naval Postgraduate
-      School, January 1994
-[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
-      JSC 12960, July 1977
-[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
-      NASA-Ames", NASA CR-2497, January 1975
-[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
-      Wiley & Sons, 1979 ISBN 0-471-03032-5
-[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
-      1982 ISBN 0-471-08936-2
-
-The aerodynamic coefficients used in this model are:
-
-Longitudinal
-  CL0 - Reference lift at zero alpha
-  CD0 - Reference drag at zero alpha
-  CDM - Drag due to Mach
-  CLa - Lift curve slope (w.r.t. alpha)
-  CDa - Drag curve slope (w.r.t. alpha)
-  CLq - Lift due to pitch rate
-  CLM - Lift due to Mach
-  CLadt - Lift due to alpha rate
-
-  Cmadt - Pitching Moment due to alpha rate
-  Cm0 - Reference Pitching moment at zero alpha
-  Cma - Pitching moment slope (w.r.t. alpha)
-  Cmq - Pitch damping (pitch moment due to pitch rate)
-  CmM - Pitch Moment due to Mach
-
-Lateral
-  Cyb - Side force due to sideslip
-  Cyr - Side force due to yaw rate
-
-  Clb - Dihedral effect (roll moment due to sideslip)
-  Clp - Roll damping (roll moment due to roll rate)
-  Clr - Roll moment due to yaw rate
-  Cnb - Weathercocking stability (yaw moment due to sideslip)
-  Cnp - Rudder adverse yaw (yaw moment due to roll rate)
-  Cnr - Yaw damping (yaw moment due to yaw rate)
-
-Control
-  CLDe - Lift due to elevator
-  CDDe - Drag due to elevator
-  CyDr - Side force due to rudder
-  CyDa - Side force due to aileron
-
-  CmDe - Pitch moment due to elevator
-  ClDa - Roll moment due to aileron
-  ClDr - Roll moment due to rudder
-  CnDr - Yaw moment due to rudder
-  CnDa - Yaw moment due to aileron
-
-********************************************************************************
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
-*******************************************************************************/
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #include <sys/stat.h>
 #include <sys/types.h>
 
 #ifdef FGFS
-# ifndef __BORLANDC__
-#  include <Include/compiler.h>
-# endif
-#  ifdef FG_HAVE_STD_INCLUDES
+#  ifndef __BORLANDC__
+#    include <simgear/compiler.h>
+#  endif
+#  ifdef SG_HAVE_STD_INCLUDES
 #    include <cmath>
 #  else
 #    include <math.h>
 #  endif
 #else
-#  include <cmath>
+#  if defined (sgi) && !defined(__GNUC__)
+#    include <math.h>
+#  else
+#    include <cmath>
+#  endif
 #endif
 
 #include "FGAircraft.h"
+#include "FGMassBalance.h"
+#include "FGInertial.h"
+#include "FGGroundReactions.h"
+#include "FGAerodynamics.h"
 #include "FGTranslation.h"
 #include "FGRotation.h"
 #include "FGAtmosphere.h"
@@ -127,399 +82,300 @@ INCLUDES
 #include "FGPosition.h"
 #include "FGAuxiliary.h"
 #include "FGOutput.h"
+#include "FGPropertyManager.h"
 
-/*******************************************************************************
-************************************ CODE **************************************
-*******************************************************************************/
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex)
-{
-  int i;
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+GLOBAL DATA
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-  Name = "FGAircraft";
+static const char *IdSrc = "$Id$";
+static const char *IdHdr = ID_AIRCRAFT;
 
-  for (i=0;i<6;i++) coeff_ctr[i] = 0;
-}
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+CLASS IMPLEMENTATION
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-
-FGAircraft::~FGAircraft(void)
-{
-}
-
-bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string fname)
+FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex)
 {
-  string path;
-  string fullpath;
-  string filename;
-  string aircraftDef;
-  string tag;
-  string holding_string;
-  char scratch[128];
-  ifstream coeffInFile;
-  streampos gpos;
-  int axis;
-  string axis_descript;
-
-  axis = -1;
-  aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".cfg";
-  ifstream aircraftfile(aircraftDef.c_str());
-  cout << "Reading Aircraft Configuration File: " << aircraftDef << endl;
-  Output->SocketStatusOutput("Reading Aircraft Configuration File: " + aircraftDef);
-
-  numTanks = numEngines = 0;
-  numSelectedOxiTanks = numSelectedFuelTanks = 0;
-
-  while (!aircraftfile.fail()) {
-    holding_string.erase();
-    aircraftfile >> holding_string;
-#if defined(__BORLANDC__) || defined(FG_HAVE_NATIVE_SGI_COMPILERS) || defined(_MSC_VER)
-    if (holding_string.compare(0, 2, "//") != 0) {
-#else
-    if (holding_string.compare("//",0,2) != 0) {
-#endif
-      if (holding_string == "CFG_VERSION") {
-        aircraftfile >> CFGVersion;
-        cout << "Config file version: " << CFGVersion << endl;
-        if (CFGVersion < NEEDED_CFG_VERSION) {
-          cout << endl << "YOU HAVE AN OLD CFG FILE FOR THIS AIRCRAFT."
-                          " RESULTS WILL BE UNPREDICTABLE !!" << endl << endl;
-        }
-      } else if (holding_string == "AIRCRAFT") {
-        cout << "Reading in Aircraft parameters ..." << endl;
-      } else if (holding_string == "AERODYNAMICS") {
-        cout << "Reading in Aerodynamic parameters ..." << endl;
-      } else if (holding_string == "AC_NAME") {
-        aircraftfile >> AircraftName;   // String with no embedded spaces
-        cout << "Aircraft Name: " << AircraftName << endl;
-      } else if (holding_string == "AC_WINGAREA") {
-        aircraftfile >> WingArea;
-        cout << "Aircraft Wing Area: " << WingArea << endl;
-      } else if (holding_string == "AC_WINGSPAN") {
-        aircraftfile >> WingSpan;
-        cout << "Aircraft WingSpan: " << WingSpan << endl;
-      } else if (holding_string == "AC_CHORD") {
-        aircraftfile >> cbar;
-        cout << "Aircraft Chord: " << cbar << endl;
-      } else if (holding_string == "AC_IXX") {
-        aircraftfile >> baseIxx;
-        cout << "Aircraft Base Ixx: " << baseIxx << endl;
-      } else if (holding_string == "AC_IYY") {
-        aircraftfile >> baseIyy;
-        cout << "Aircraft Base Iyy: " << baseIyy << endl;
-      } else if (holding_string == "AC_IZZ") {
-        aircraftfile >> baseIzz;
-        cout << "Aircraft Base Izz: " << baseIzz << endl;
-      } else if (holding_string == "AC_IXZ") {
-        aircraftfile >> baseIxz;
-        cout << "Aircraft Base Ixz: " << baseIxz << endl;
-      } else if (holding_string == "AC_EMPTYWT") {
-        aircraftfile >> EmptyWeight;
-        EmptyMass = EmptyWeight / GRAVITY;
-        cout << "Aircraft Empty Weight: " << EmptyWeight << endl;
-      } else if (holding_string == "AC_AERORP") {
-        aircraftfile >> Xrp >> Yrp >> Zrp;
-        cout << "Aerodynamic Reference Point: " << Xrp << " " << Yrp << " " << Zrp << endl;
-      } else if (holding_string == "AC_CGLOC") {
-        aircraftfile >> baseXcg >> baseYcg >> baseZcg;
-        cout << "Aircraft Base C.G.: " << baseXcg << " " << baseYcg << " " << baseZcg << endl;
-      } else if (holding_string == "AC_EYEPTLOC") {
-        aircraftfile >> Xep >> Yep >> Zep;
-        cout << "Pilot Eyepoint: " << Xep << " " << Yep << " " << Zep << endl;
-      } else if (holding_string == "AC_TANK") {
-        Tank[numTanks] = new FGTank(aircraftfile);
-        switch(Tank[numTanks]->GetType()) {
-        case FGTank::ttFUEL:
-          numSelectedFuelTanks++;
-          cout << "Reading in Fuel Tank #" << numSelectedFuelTanks << " parameters ..." << endl;
-          break;
-        case FGTank::ttOXIDIZER:
-          numSelectedOxiTanks++;
-          cout << "Reading in Oxidizer Tank #" << numSelectedOxiTanks << " parameters ..." << endl;
-          break;
-        }
-        numTanks++;
-
-      } else if (holding_string == "AC_GEAR") {
-
-        lGear.push_back(new FGLGear(aircraftfile));
-
-      } else if (holding_string == "AC_ENGINE") {
-
-        aircraftfile >> tag;
-        cout << "Reading in " << tag << " Engine parameters ..." << endl;
-        Engine[numEngines] = new FGEngine(FDMExec, engine_path, tag, numEngines);
-        numEngines++;
-
-      } else if (holding_string == "}") {
-
-      } else if (holding_string == "{") {
-
-      } else if (holding_string == "LIFT") {
-
-        axis_descript = "   Lift Coefficients ...";
-        axis = LiftCoeff;
-
-      } else if (holding_string == "DRAG") {
-
-        axis_descript = "   Drag Coefficients ...";
-        axis = DragCoeff;
-
-      } else if (holding_string == "SIDE") {
-
-        axis_descript = "   Side Coefficients ...";
-        axis = SideCoeff;
-
-      } else if (holding_string == "ROLL") {
-
-        axis_descript = "   Roll Coefficients ...";
-        axis = RollCoeff;
-
-      } else if (holding_string == "PITCH") {
-
-        axis_descript = "   Pitch Coefficients ...";
-        axis = PitchCoeff;
-
-      } else if (holding_string == "YAW") {
+  Name = "FGAircraft";
+  HTailArea = VTailArea = 0.0;
+  HTailArm  = VTailArm  = 0.0;
+  lbarh = lbarv = 0.0;
+  vbarh = vbarv = 0.0;
 
-        axis_descript = "   Yaw Coefficients ...";
-        axis = YawCoeff;
+  bind();
 
-      }
+  Debug(0);
+}
 
-      if (axis >= 0) {
-        cout << axis_descript << endl;
-        aircraftfile >> tag;
-        gpos = aircraftfile.tellg();
-        aircraftfile >> tag;
-        if ( !(tag == "}") ) {
-          while ( !(tag == "}") ) {
-            aircraftfile.seekg(gpos);
-            Coeff[axis][coeff_ctr[axis]] = new FGCoefficient(FDMExec, aircraftfile);
-            coeff_ctr[axis]++;
-            aircraftfile >> tag;
-            gpos = aircraftfile.tellg();
-            aircraftfile >> tag;
-          }
-        } else {
-          cout << "      None found ..." << endl;
-        }
-      }
-      axis = -1;
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-    } else {
-      aircraftfile.getline(scratch, 127);
-    }
-  }
-  cout << "End of Configuration File Parsing." << endl;
-
-  return true;
+FGAircraft::~FGAircraft()
+{
+  unbind();
+  Debug(1);
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 bool FGAircraft::Run(void)
 {
   if (!FGModel::Run()) {                 // if false then execute this Run()
-    GetState();
-
-    for (int i = 0; i < 3; i++)  Forces[i] = Moments[i] = 0.0;
-
-    MassChange();
-
-    FMProp(); FMAero(); FMGear(); FMMass();
-
-    PutState();
+    vForces.InitMatrix();
+    vForces += Aerodynamics->GetForces();
+    vForces += Inertial->GetForces();
+    vForces += Propulsion->GetForces();
+    vForces += GroundReactions->GetForces();
+
+    vMoments.InitMatrix();
+    vMoments += Aerodynamics->GetMoments();
+    vMoments += Propulsion->GetMoments();
+    vMoments += GroundReactions->GetMoments();
+    
+    vBodyAccel = vForces/MassBalance->GetMass();
+    
+    vNcg = vBodyAccel/Inertial->gravity();
+
+    vNwcg = State->GetTb2s() * vNcg;
+    vNwcg(3) = -1*vNwcg(3) + 1;
+    
+    return false;
   } else {                               // skip Run() execution this time
+    return true;
   }
-  return false;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::MassChange()
+float FGAircraft::GetNlf(void)
 {
-  float Xt, Xw, Yt, Yw, Zt, Zw, Tw;
-  float IXXt, IYYt, IZZt, IXZt;
-  int t;
-
-  // 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 (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.
-
-  Xt = Yt = Zt = Tw = 0;
-  Xw = Yw = Zw = 0;
-  for (t=0; t<numTanks; t++) {
-    Xt += Tank[t]->GetX()*Tank[t]->GetContents();
-    Yt += Tank[t]->GetY()*Tank[t]->GetContents();
-    Zt += Tank[t]->GetZ()*Tank[t]->GetContents();
-
-    Tw += Tank[t]->GetContents();
-  }
-
-  Xcg = (Xt + EmptyWeight*baseXcg) / (Tw + EmptyWeight);
-  Ycg = (Yt + EmptyWeight*baseYcg) / (Tw + EmptyWeight);
-  Zcg = (Zt + EmptyWeight*baseZcg) / (Tw + EmptyWeight);
-
-  // Calculate new moments of inertia here
-
-  IXXt = IYYt = IZZt = IXZt = 0.0;
-  for (t=0; t<numTanks; t++) {
-    IXXt += ((Tank[t]->GetX()-Xcg)/12.0)*((Tank[t]->GetX() - Xcg)/12.0)*Tank[t]->GetContents()/GRAVITY;
-    IYYt += ((Tank[t]->GetY()-Ycg)/12.0)*((Tank[t]->GetY() - Ycg)/12.0)*Tank[t]->GetContents()/GRAVITY;
-    IZZt += ((Tank[t]->GetZ()-Zcg)/12.0)*((Tank[t]->GetZ() - Zcg)/12.0)*Tank[t]->GetContents()/GRAVITY;
-    IXZt += ((Tank[t]->GetX()-Xcg)/12.0)*((Tank[t]->GetZ() - Zcg)/12.0)*Tank[t]->GetContents()/GRAVITY;
-  }
-
-  Ixx = baseIxx + IXXt;
-  Iyy = baseIyy + IYYt;
-  Izz = baseIzz + IZZt;
-  Ixz = baseIxz + IXZt;
-
+  return -1*Aerodynamics->GetvFs(3)/MassBalance->GetWeight();
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::FMAero(void)
+bool FGAircraft::Load(FGConfigFile* AC_cfg)
 {
-  float F[3];
-  float Fxaero,Fyaero,Fzaero;
-  float dxcg,dycg,dzcg;
-  int axis_ctr,ctr;
-  F[0] = F[1] = F[2] = 0.0;
-
-  for (axis_ctr = 0; axis_ctr < 3; axis_ctr++)
-    for (ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++)
-      F[axis_ctr] += Coeff[axis_ctr][ctr]->TotalValue();
-
-  Fxaero = - F[DragCoeff]*cos(alpha)*cos(beta)
-           - F[SideCoeff]*cos(alpha)*sin(beta)
-           + F[LiftCoeff]*sin(alpha);
-  Fyaero =   F[DragCoeff]*sin(beta)
-             + F[SideCoeff]*cos(beta);
-  Fzaero = - F[DragCoeff]*sin(alpha)*cos(beta)
-           - F[SideCoeff]*sin(alpha)*sin(beta)
-           - F[LiftCoeff]*cos(alpha);
-
-  Forces[0] += - F[DragCoeff]*cos(alpha)*cos(beta)
-               - F[SideCoeff]*cos(alpha)*sin(beta)
-               + F[LiftCoeff]*sin(alpha);
-  Forces[1] +=   F[DragCoeff]*sin(beta)
-                 + F[SideCoeff]*cos(beta);
-  Forces[2] += - F[DragCoeff]*sin(alpha)*cos(beta)
-               - F[SideCoeff]*sin(alpha)*sin(beta)
-               - F[LiftCoeff]*cos(alpha);
-
-  // The d*cg distances below, given in inches, are the distances FROM the c.g.
-  // TO the reference point. Since the c.g. and ref point are given in inches in
-  // the structural system (X positive rearwards) and the body coordinate system
-  // is given with X positive out the nose, the dxcg and dzcg values are
-  // *rotated* 180 degrees about the Y axis.
-
-  dxcg = -(Xrp - Xcg)/12; //cg and rp values are in inches
-  dycg =  (Yrp - Ycg)/12;
-  dzcg = -(Zrp - Zcg)/12;
-
-  Moments[0] +=  Fzaero*dycg - Fyaero*dzcg; //rolling moment
-  Moments[1] +=  Fxaero*dzcg - Fzaero*dxcg; //pitching moment
-  Moments[2] += -Fxaero*dycg + Fyaero*dxcg; //yawing moment
-
-  for (axis_ctr = 0; axis_ctr < 3; axis_ctr++) {
-    for (ctr = 0; ctr < coeff_ctr[axis_ctr+3]; ctr++) {
-      Moments[axis_ctr] += Coeff[axis_ctr+3][ctr]->TotalValue();
+  string token = "";
+  string parameter;
+  double EW, bixx, biyy, bizz, bixy, bixz;
+  double pmWt, pmX, pmY, pmZ;
+  FGColumnVector3 vbaseXYZcg;
+
+  AC_cfg->GetNextConfigLine();
+
+  while ((token = AC_cfg->GetValue()) != string("/METRICS")) {
+    *AC_cfg >> parameter;
+    if (parameter == "AC_WINGAREA") {
+      *AC_cfg >> WingArea;
+      if (debug_lvl > 0) cout << "    WingArea: " << WingArea  << endl;
+    } else if (parameter == "AC_WINGSPAN") {
+      *AC_cfg >> WingSpan;
+      if (debug_lvl > 0) cout << "    WingSpan: " << WingSpan  << endl;
+    } else if (parameter == "AC_WINGINCIDENCE") {
+      *AC_cfg >> WingIncidence;
+      if (debug_lvl > 0) cout << "    Chord: " << cbar << endl;
+    } else if (parameter == "AC_CHORD") {
+      *AC_cfg >> cbar;
+      if (debug_lvl > 0) cout << "    Chord: " << cbar << endl;
+    } else if (parameter == "AC_HTAILAREA") {
+      *AC_cfg >> HTailArea;
+      if (debug_lvl > 0) cout << "    H. Tail Area: " << HTailArea << endl;
+    } else if (parameter == "AC_HTAILARM") {
+      *AC_cfg >> HTailArm;
+      if (debug_lvl > 0) cout << "    H. Tail Arm: " << HTailArm << endl;
+    } else if (parameter == "AC_VTAILAREA") {
+      *AC_cfg >> VTailArea;
+      if (debug_lvl > 0) cout << "    V. Tail Area: " << VTailArea << endl;
+    } else if (parameter == "AC_VTAILARM") {
+      *AC_cfg >> VTailArm;
+      if (debug_lvl > 0) cout << "    V. Tail Arm: " << VTailArm << endl;
+    } else if (parameter == "AC_IXX") {
+      *AC_cfg >> bixx;
+      if (debug_lvl > 0) cout << "    baseIxx: " << bixx << endl;
+      MassBalance->SetBaseIxx(bixx);
+    } else if (parameter == "AC_IYY") {
+      *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_IXY") {
+      *AC_cfg >> bixy;
+      if (debug_lvl > 0) cout << "    baseIxy: " << bixy  << endl;
+      MassBalance->SetBaseIxy(bixy);
+    } else if (parameter == "AC_IXZ") {
+      *AC_cfg >> bixz;
+      if (debug_lvl > 0) cout << "    baseIxz: " << bixz  << endl;
+      MassBalance->SetBaseIxz(bixz);
+    } else if (parameter == "AC_EMPTYWT") {
+      *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);
+      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);
+      if (debug_lvl > 0) cout << "    Eyepoint (x, y, z): " << vXYZep << endl;
+    } else if (parameter == "AC_AERORP") {
+      *AC_cfg >> vXYZrp(eX) >> vXYZrp(eY) >> vXYZrp(eZ);
+      if (debug_lvl > 0) cout << "    Ref Pt (x, y, z): " << vXYZrp << endl;
+    } else if (parameter == "AC_POINTMASS") {
+      *AC_cfg >> pmWt >> pmX >> pmY >> pmZ;
+      MassBalance->AddPointMass(pmWt, pmX, pmY, pmZ);
+      if (debug_lvl > 0) cout << "    Point Mass Object: " << pmWt << " lbs. at "
+                         << "X, Y, Z (in.): " << pmX << "  " << pmY << "  " << pmZ
+                         << endl;
     }
   }
-}
-
-
-void FGAircraft::FMGear(void)
-{
-  if (GearUp) {
-    // crash routine
-  } else {
-    for (int i=0;i<lGear.size();i++) {
-      //      lGear[i].
+  
+  // calculate some derived parameters
+  if (cbar != 0.0) {
+    lbarh = HTailArm/cbar;
+    lbarv = VTailArm/cbar;
+    if (WingArea != 0.0) {
+      vbarh = HTailArm*HTailArea / (cbar*WingArea);
+      vbarv = VTailArm*VTailArea / (cbar*WingArea);
     }
-  }
+  }     
+  return true;
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::FMMass(void)
+void FGAircraft::bind(void)
 {
-  Forces[0] += -GRAVITY*sin(tht) * Mass;
-  Forces[1] +=  GRAVITY*sin(phi)*cos(tht) * Mass;
-  Forces[2] +=  GRAVITY*cos(phi)*cos(tht) * Mass;
+  typedef double (FGAircraft::*PMF)(int) const;
+  PropertyManager->Tie("metrics/Sw-sqft", this,
+                       &FGAircraft::GetWingArea);
+  PropertyManager->Tie("metrics/bw-ft", this,
+                       &FGAircraft::GetWingSpan);
+  PropertyManager->Tie("metrics/cbarw-ft", this,
+                       &FGAircraft::Getcbar);
+  PropertyManager->Tie("metrics/iw-deg", this,
+                       &FGAircraft::GetWingIncidence);
+  PropertyManager->Tie("metrics/Sh-sqft", this,
+                       &FGAircraft::GetHTailArea);
+  PropertyManager->Tie("metrics/lh-ft", this,
+                       &FGAircraft::GetHTailArm);
+  PropertyManager->Tie("metrics/Sv-sqft", this,
+                       &FGAircraft::GetVTailArea);
+  PropertyManager->Tie("metrics/lv-ft", this,
+                       &FGAircraft::GetVTailArm);
+  PropertyManager->Tie("metrics/lh-norm", this,
+                       &FGAircraft::Getlbarh);
+  PropertyManager->Tie("metrics/lv-norm", this,
+                       &FGAircraft::Getlbarv);
+  PropertyManager->Tie("metrics/vbarh-norm", this,
+                       &FGAircraft::Getvbarh);
+  PropertyManager->Tie("metrics/vbarv-norm", this,
+                       &FGAircraft::Getvbarv);
+  PropertyManager->Tie("moments/l-total-lbsft", this,1,
+                       (PMF)&FGAircraft::GetMoments);
+  PropertyManager->Tie("moments/m-total-lbsft", this,2,
+                       (PMF)&FGAircraft::GetMoments);
+  PropertyManager->Tie("moments/n-total-lbsft", this,3,
+                       (PMF)&FGAircraft::GetMoments);
+  PropertyManager->Tie("forces/fbx-total-lbs", this,1,
+                       (PMF)&FGAircraft::GetForces);
+  PropertyManager->Tie("forces/fby-total-lbs", this,2,
+                       (PMF)&FGAircraft::GetForces);
+  PropertyManager->Tie("forces/fbz-total-lbs", this,3,
+                       (PMF)&FGAircraft::GetForces);
+  PropertyManager->Tie("metrics/aero-rp-x-ft", this,1,
+                       (PMF)&FGAircraft::GetXYZrp);
+  PropertyManager->Tie("metrics/aero-rp-y-ft", this,2,
+                       (PMF)&FGAircraft::GetXYZrp);
+  PropertyManager->Tie("metrics/aero-rp-z-ft", this,3,
+                       (PMF)&FGAircraft::GetXYZrp);
+  PropertyManager->Tie("metrics/eyepoint-x-ft", this,1,
+                       (PMF)&FGAircraft::GetXYZep);
+  PropertyManager->Tie("metrics/eyepoint-y-ft", this,2,
+                       (PMF)&FGAircraft::GetXYZep);
+  PropertyManager->Tie("metrics/eyepoint-z-ft", this,3,
+                       (PMF)&FGAircraft::GetXYZep);
 }
 
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGAircraft::FMProp(void)
+void FGAircraft::unbind(void)
 {
-  for (int i=0;i<numEngines;i++) {
-    Forces[0] += Engine[i]->CalcThrust();
-  }
+  PropertyManager->Untie("metrics/Sw-sqft");
+  PropertyManager->Untie("metrics/bw-ft");
+  PropertyManager->Untie("metrics/cbarw-ft");
+  PropertyManager->Untie("metrics/iw-deg");
+  PropertyManager->Untie("metrics/Sh-sqft");
+  PropertyManager->Untie("metrics/lh-ft");
+  PropertyManager->Untie("metrics/Sv-sqft");
+  PropertyManager->Untie("metrics/lv-ft");
+  PropertyManager->Untie("metrics/lh-norm");
+  PropertyManager->Untie("metrics/lv-norm");
+  PropertyManager->Untie("metrics/vbarh-norm");
+  PropertyManager->Untie("metrics/vbarv-norm");
+  PropertyManager->Untie("moments/l-total-lbsft");
+  PropertyManager->Untie("moments/m-total-lbsft");
+  PropertyManager->Untie("moments/n-total-lbsft");
+  PropertyManager->Untie("forces/fbx-total-lbs");
+  PropertyManager->Untie("forces/fby-total-lbs");
+  PropertyManager->Untie("forces/fbz-total-lbs");
+  PropertyManager->Untie("metrics/aero-rp-x-ft");
+  PropertyManager->Untie("metrics/aero-rp-y-ft");
+  PropertyManager->Untie("metrics/aero-rp-z-ft");
+  PropertyManager->Untie("metrics/eyepoint-x-ft");
+  PropertyManager->Untie("metrics/eyepoint-y-ft");
+  PropertyManager->Untie("metrics/eyepoint-z-ft");
 }
 
-void FGAircraft::GetState(void)
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+//    The bitmasked value choices are as follows:
+//    unset: In this case (the default) JSBSim would only print
+//       out the normally expected messages, essentially echoing
+//       the config files as they are read. If the environment
+//       variable is not set, debug_lvl is set to 1 internally
+//    0: This requests JSBSim not to output any messages
+//       whatsoever.
+//    1: This value explicity requests the normal JSBSim
+//       startup messages
+//    2: This value asks for a message to be printed out when
+//       a class is instantiated
+//    4: When this value is set, a message is displayed when a
+//       FGModel object executes its Run() method
+//    8: When this value is set, various runtime state variables
+//       are printed out periodically
+//    16: When set various parameters are sanity checked and
+//       a message is printed out when they go out of bounds
+
+void FGAircraft::Debug(int from)
 {
-  dt = State->Getdt();
-
-  alpha = Translation->Getalpha();
-  beta = Translation->Getbeta();
-  phi = Rotation->Getphi();
-  tht = Rotation->Gettht();
-  psi = Rotation->Getpsi();
-}
-
+  if (debug_lvl <= 0) return;
 
-void FGAircraft::PutState(void)
-{
+  if (debug_lvl & 1) { // Standard console startup message output
+    if (from == 0) { // Constructor
+    }
+  }
+  if (debug_lvl & 2 ) { // Instantiation/Destruction notification
+    if (from == 0) cout << "Instantiated: FGAircraft" << endl;
+    if (from == 1) cout << "Destroyed:    FGAircraft" << endl;
+  }
+  if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
+  }
+  if (debug_lvl & 8 ) { // Runtime state variables
+  }
+  if (debug_lvl & 16) { // Sanity checking
+  }
+  if (debug_lvl & 64) {
+    if (from == 0) { // Constructor
+      cout << IdSrc << endl;
+      cout << IdHdr << endl;
+    }
+  }
 }