]> git.mxchange.org Git - flightgear.git/commitdiff
Updates from the Jon and Tony show.
authorcurt <curt>
Mon, 20 Dec 1999 20:24:49 +0000 (20:24 +0000)
committercurt <curt>
Mon, 20 Dec 1999 20:24:49 +0000 (20:24 +0000)
src/FDM/JSBSim/FGAircraft.cpp
src/FDM/JSBSim/FGAircraft.h
src/FDM/JSBSim/FGDefs.h
src/FDM/JSBSim/FGEngine.cpp
src/FDM/JSBSim/FGEngine.h
src/FDM/JSBSim/FGOutput.cpp
src/FDM/JSBSim/FGOutput.h
src/FDM/JSBSim/FGState.cpp
src/FDM/JSBSim/FGState.h
src/FDM/JSBSim/JSBSim.cpp
src/FDM/JSBSim/Makefile.am

index 18be53e265f55a3db3912e13455c74061488c4f2..43e9a4b265a84b20cfeb3d99085b714b96db2b29 100644 (file)
@@ -37,6 +37,9 @@ HISTORY
 04/03/99   JSB   Changed Aero() method to correct body axis force calculation
                  from wind vector. Fix provided by Tony Peden.
 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
 
 ********************************************************************************
 COMMENTS, REFERENCES,  and NOTES
@@ -157,16 +160,17 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
   int axis;
   string axis_descript;
 
-       axis = -1;
+  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();
+    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) {
@@ -174,125 +178,132 @@ bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path, string f
     if (holding_string.compare("//",0,2) != 0) {
 #endif
       if (holding_string == "AIRCRAFT") {
-       cout << "Reading in Aircraft parameters ..." << endl;
+        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_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") {
+        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;
+          cout << "Reading in Fuel Tank #" << numSelectedFuelTanks << " parameters ..." << endl;
           break;
         case FGTank::ttOXIDIZER:
           numSelectedOxiTanks++;
-                                       cout << "Reading in Oxidizer Tank #" << numSelectedOxiTanks << " parameters ..." << endl;
+          cout << "Reading in Oxidizer Tank #" << numSelectedOxiTanks << " parameters ..." << endl;
           break;
         }
         numTanks++;
 
-                       } else if (holding_string == "AC_ENGINE") {
+      } 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;
+        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 == "{") {
 
-                       } else if (holding_string == "{") {
+      } else if (holding_string == "LIFT") {
 
-                       } else if (holding_string == "LIFT") {
+        axis_descript = "   Lift Coefficients ...";
+        axis = LiftCoeff;
 
-                               axis_descript = "   Lift Coefficients ...";
-                               axis = LiftCoeff;
-                               
-                       } else if (holding_string == "DRAG") {
+      } else if (holding_string == "DRAG") {
 
-                               axis_descript = "   Drag Coefficients ...";
-                               axis = DragCoeff;
+        axis_descript = "   Drag Coefficients ...";
+        axis = DragCoeff;
 
-                       } else if (holding_string == "SIDE") {
+      } else if (holding_string == "SIDE") {
 
-                               axis_descript = "   Side Coefficients ...";
-                               axis = SideCoeff;
+        axis_descript = "   Side Coefficients ...";
+        axis = SideCoeff;
 
-                       } else if (holding_string == "ROLL") {
+      } else if (holding_string == "ROLL") {
 
-                               axis_descript = "   Roll Coefficients ...";
-                               axis = RollCoeff;
+        axis_descript = "   Roll Coefficients ...";
+        axis = RollCoeff;
 
-                       } else if (holding_string == "PITCH") {
+      } else if (holding_string == "PITCH") {
 
-                               axis_descript = "   Pitch Coefficients ...";
-                               axis = PitchCoeff;
+        axis_descript = "   Pitch Coefficients ...";
+        axis = PitchCoeff;
 
-                       } else if (holding_string == "YAW") {
+      } else if (holding_string == "YAW") {
 
-                               axis_descript = "   Yaw Coefficients ...";
-                               axis = YawCoeff;
+        axis_descript = "   Yaw Coefficients ...";
+        axis = YawCoeff;
 
-                       }
+      }
+
+      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;
 
-                       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);
+      aircraftfile.getline(scratch, 127);
     }
   }
-       cout << "End of Configuration File Parsing." << endl;
+  cout << "End of Configuration File Parsing." << endl;
 
   return true;
 }
@@ -307,8 +318,7 @@ bool FGAircraft::Run(void)
 
     MassChange();
 
-    FProp(); FAero(); FGear(); FMass();
-    MProp(); MAero(); MGear(); MMass();
+    FMProp(); FMAero(); FMGear(); FMMass();
 
     PutState();
   } else {                               // skip Run() execution this time
@@ -344,13 +354,13 @@ void FGAircraft::MassChange()
         case FGTank::ttFUEL:
           if (Tank[t]->GetSelected()) {
             Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
-                                   numSelectedFuelTanks)*(dt*rate) + Fshortage);
+                                         numSelectedFuelTanks)*(dt*rate) + Fshortage);
           }
           break;
         case FGTank::ttOXIDIZER:
           if (Tank[t]->GetSelected()) {
             Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
-                                    numSelectedOxiTanks)*(dt*rate) + Oshortage);
+                                         numSelectedOxiTanks)*(dt*rate) + Oshortage);
           }
           break;
         }
@@ -362,7 +372,7 @@ void FGAircraft::MassChange()
 
         if (Tank[t]->GetSelected()) {
           Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
-                                   numSelectedFuelTanks)*(dt*rate) + Fshortage);
+                                       numSelectedFuelTanks)*(dt*rate) + Fshortage);
         }
         break;
       }
@@ -379,7 +389,7 @@ void FGAircraft::MassChange()
 
   // Calculate new CG here.
 
-  Xt = Yt = Zt = 0;
+  Xt = Yt = Zt = Tw = 0;
   Xw = Yw = Zw = 0;
   for (t=0; t<numTanks; t++) {
     Xt += Tank[t]->GetX()*Tank[t]->GetContents();
@@ -411,57 +421,44 @@ void FGAircraft::MassChange()
 }
 
 
-void FGAircraft::FAero(void)
+void FGAircraft::FMAero(void)
 {
   float F[3];
-
+  float Fxaero,Fyaero,Fzaero;
+  float dxcg,dycg,dzcg;
+  int axis_ctr,ctr;
   F[0] = F[1] = F[2] = 0.0;
 
-  for (int axis_ctr = 0; axis_ctr < 3; axis_ctr++)
-    for (int ctr=0; ctr < coeff_ctr[axis_ctr]; ctr++)
+  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);
+                 + F[SideCoeff]*cos(beta);
   Forces[2] += - F[DragCoeff]*sin(alpha)*cos(beta)
                - F[SideCoeff]*sin(alpha)*sin(beta)
                - F[LiftCoeff]*cos(alpha);
-}
-
-
-void FGAircraft::FGear(void)
-{
-  if (GearUp) {
-    // crash routine
-  } else {
-    
-  }
-}
-
 
-void FGAircraft::FMass(void)
-{
-  Forces[0] += -GRAVITY*sin(tht) * Mass;
-  Forces[1] +=  GRAVITY*sin(phi)*cos(tht) * Mass;
-  Forces[2] +=  GRAVITY*cos(phi)*cos(tht) * Mass;
-}
-
-
-void FGAircraft::FProp(void)
-{
-  for (int i=0;i<numEngines;i++) {
-    Forces[0] += Engine[i]->CalcThrust();
-  }
-}
+  dxcg = (Xcg - Xrp)/12; //cg and rp values are in inches
+  dycg = (Ycg - Yrp)/12;
+  dzcg = (Zcg - Zrp)/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
 
-void FGAircraft::MAero(void)
-{
-       int axis_ctr, ctr;
-       
   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();
@@ -470,24 +467,33 @@ void FGAircraft::MAero(void)
 }
 
 
-void FGAircraft::MGear(void)
+void FGAircraft::FMGear(void)
 {
   if (GearUp) {
+    // crash routine
   } else {
+    for (int i=0;i<lGear.size();i++) {
+      //      lGear[i].
+    }
   }
 }
 
 
-void FGAircraft::MMass(void)
+void FGAircraft::FMMass(void)
 {
+  Forces[0] += -GRAVITY*sin(tht) * Mass;
+  Forces[1] +=  GRAVITY*sin(phi)*cos(tht) * Mass;
+  Forces[2] +=  GRAVITY*cos(phi)*cos(tht) * Mass;
 }
 
 
-void FGAircraft::MProp(void)
+void FGAircraft::FMProp(void)
 {
+  for (int i=0;i<numEngines;i++) {
+    Forces[0] += Engine[i]->CalcThrust();
+  }
 }
 
-
 void FGAircraft::GetState(void)
 {
   dt = State->Getdt();
index 6e1b3df2ab261dc70a9305b886f748b2b3d59dbe..93180d633c8a0fc206d8ebf8238ffa50bb621614 100644 (file)
@@ -100,17 +100,21 @@ INCLUDES
 #  include <Include/compiler.h>
 #  ifdef FG_HAVE_STD_INCLUDES
 #    include <fstream>
+#    include <vector>
 #  else
 #    include <fstream.h>
+#    include <vector.h>
 #  endif
 #else
 #  include <fstream>
+#  include <vector>
 #endif
 
 #include "FGModel.h"
 #include "FGCoefficient.h"
 #include "FGEngine.h"
 #include "FGTank.h"
+#include "FGLGear.h"
 
 /*******************************************************************************
 DEFINITIONS
@@ -125,7 +129,7 @@ CLASS DECLARATION
 class FGAircraft : public FGModel
 {
 public:
-  FGAircraft(FGFDMExec*);  
+  FGAircraft(FGFDMExec*);
   ~FGAircraft(void);
 
   bool Run(void);
@@ -155,20 +159,17 @@ public:
 private:
   void GetState(void);
   void PutState(void);
-  void FAero(void);
-  void FGear(void);
-  void FMass(void);
-  void FProp(void);
-  void MAero(void);
-  void MGear(void);
-  void MMass(void);
-  void MProp(void);
+  void FMAero(void);
+  void FMGear(void);
+  void FMMass(void);
+  void FMProp(void);
   void MassChange(void);
   float Moments[3];
   float Forces[3];
   string AircraftName;
   float baseIxx, baseIyy, baseIzz, baseIxz, EmptyMass, Mass;
   float Ixx, Iyy, Izz, Ixz;
+  float Xrp, Yrp, Zrp;
   float baseXcg, baseYcg, baseZcg;
   float Xcg, Ycg, Zcg;
   float Xep, Yep, Zep;
@@ -200,6 +201,7 @@ private:
               numCoeffs};
 
   string Axis[6];
+  vector <FGLGear*> lGear;
 
 protected:
 
index 53b9677640b08394b49bdf3feee692258dc01188..28072e4f3a8cf833c26ed2dec81f798c67fade05 100644 (file)
@@ -53,6 +53,8 @@ SENTRY
 #define KTSTOFPS        1.68781
 #define FPSTOKTS        0.592484
 
+#define HPTOFTLBSSEC 550
+
 
 
 /******************************************************************************/
index 42cd972ed42d842f61c83f5364c0df265acc7685..c0d5368dd5db60d7dfbfa0049ac2e4696c925aca 100644 (file)
@@ -60,6 +60,7 @@ INCLUDES
 #include "FGPosition.h"
 #include "FGAuxiliary.h"
 #include "FGOutput.h"
+#include "FGDefs.h"
 
 /*******************************************************************************
 ************************************ CODE **************************************
@@ -96,16 +97,37 @@ FGEngine::FGEngine(FGFDMExec* fdex, string enginePath, string engineName, int nu
     else if (tag == "TURBOJET")  Type = etTurboJet;
     else                         Type = etUnknown;
 
-    enginefile >> X;
-    enginefile >> Y;
-    enginefile >> Z;
-    enginefile >> SLThrustMax;
-    enginefile >> VacThrustMax;
-    enginefile >> MaxThrottle;
-    enginefile >> MinThrottle;
-    enginefile >> SLFuelFlowMax;
-    if (Type == 1)
+    switch(Type)
+    {
+    case etUnknown:
+      cerr << "Unknown engine type: " << tag << endl;
+      break;
+    case etPiston:
+      enginefile >> X;
+      enginefile >> Y;
+      enginefile >> Z;
+      enginefile >> BrakeHorsePower;
+      enginefile >> MaxThrottle;
+      enginefile >> MinThrottle;
+      enginefile >> SLFuelFlowMax;
+      enginefile >> SpeedSlope;
+      enginefile >> SpeedIntercept;
+      enginefile >> AltitudeSlope;
+
+      break;
+    case etRocket:
+      enginefile >> X;
+      enginefile >> Y;
+      enginefile >> Z;
+      enginefile >> SLThrustMax;
+      enginefile >> VacThrustMax;
+      enginefile >> MaxThrottle;
+      enginefile >> MinThrottle;
+      enginefile >> SLFuelFlowMax;
       enginefile >> SLOxiFlowMax;
+      break;
+    }
+
     enginefile.close();
   } else {
     cerr << "Unable to open engine definition file " << engineName << endl;
@@ -135,7 +157,7 @@ float FGEngine::CalcRocketThrust(void)
   } else {
     PctPower = Throttle / MaxThrottle;
     Thrust = PctPower*((1.0 - Atmosphere->Getrho() / 0.002378)*(VacThrustMax - SLThrustMax) +
-                              SLThrustMax); // desired thrust
+                       SLThrustMax); // desired thrust
     Flameout = false;
   }
 
@@ -147,6 +169,18 @@ float FGEngine::CalcRocketThrust(void)
 
 float FGEngine::CalcPistonThrust(void)
 {
+  float v,h,pa;
+
+  Throttle = FCS->GetThrottle(EngineNumber);
+  v=State->GetVt();
+  h=State->Geth();
+  if(v < 10)
+    v=10;
+  if(h < 0)
+    h=0;
+  pa=(SpeedSlope*v + SpeedIntercept)*(1 +AltitudeSlope*h)*BrakeHorsePower;
+  Thrust= Throttle*(pa*HPTOFTLBSSEC)/v;
+
   return Thrust;
 }
 
index 5c5818fb45d112b0b97d35f1dfb02ff2df36033b..a515983cf7f0fb697577506ad5ac1720404163a5 100644 (file)
@@ -47,7 +47,7 @@ INCLUDES
 #ifdef FGFS
 #  include <Include/compiler.h>
 #  include STL_STRING
-   FG_USING_STD(string);
+FG_USING_STD(string);
 #else
 #  include <string>
 #endif
@@ -106,6 +106,11 @@ private:
   float MaxThrottle;
   float MinThrottle;
 
+  float BrakeHorsePower;
+  float SpeedSlope;
+  float SpeedIntercept;
+  float AltitudeSlope;
+
   float Thrust;
   float Throttle;
   float FuelNeed, OxidizerNeed;
index 3d501834a09e19bbbce3b5020b0c1cd9f00cb397..25481c1f7aa21f59392576113067dc729f05b0f1 100644 (file)
@@ -57,19 +57,25 @@ INCLUDES
 FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
 {
   Name = "FGOutput";
-  FirstPass = true;
+  sFirstPass = dFirstPass = true;
+
+#ifdef FG_WITH_JSBSIM_SOCKET
+  socket = new FGfdmSocket("localhost",1138);
+#endif
 }
 
 
 FGOutput::~FGOutput(void)
 {
+  if (socket) delete socket;
 }
 
 
 bool FGOutput::Run(void)
 {
   if (!FGModel::Run()) {
-    DelimitedOutput("JSBSimData.csv");
+    SocketOutput();
+//    DelimitedOutput("JSBSimData.csv");
   } else {
   }
   return false;
@@ -78,7 +84,7 @@ bool FGOutput::Run(void)
 
 void FGOutput::DelimitedOutput(void)
 {
-  if (FirstPass) {
+  if (dFirstPass) {
     cout << "Time,";
     cout << "Altitude,";
     cout << "Phi,";
@@ -112,7 +118,7 @@ void FGOutput::DelimitedOutput(void)
     cout << "M,";
     cout << "N";
     cout << endl;
-    FirstPass = false;
+    dFirstPass = false;
   }
 
   cout << State->Getsim_time() << ",";
@@ -154,7 +160,7 @@ void FGOutput::DelimitedOutput(void)
 
 void FGOutput::DelimitedOutput(string fname)
 {
-  if (FirstPass) {
+  if (sFirstPass) {
     datafile.open(fname.c_str());
     datafile << "Time,";
     datafile << "Altitude,";
@@ -189,7 +195,7 @@ void FGOutput::DelimitedOutput(string fname)
     datafile << "M,";
     datafile << "N";
     datafile << endl;
-    FirstPass = false;
+    sFirstPass = false;
   }
 
   datafile << State->Getsim_time() << ",";
@@ -228,3 +234,97 @@ void FGOutput::DelimitedOutput(string fname)
   datafile.flush();
 }
 
+void FGOutput::SocketOutput(void)
+{
+  string asciiData;
+
+  if (socket <= 0) return;
+
+  socket->Clear();
+  if (sFirstPass) {
+    socket->Append("<LABELS>");
+    socket->Append("Time");
+    socket->Append("Altitude");
+    socket->Append("Phi");
+    socket->Append("Tht");
+    socket->Append("Psi");
+    socket->Append("Rho");
+    socket->Append("Vtotal");
+    socket->Append("U");
+    socket->Append("V");
+    socket->Append("W");
+    socket->Append("Vn");
+    socket->Append("Ve");
+    socket->Append("Vd");
+    socket->Append("Udot");
+    socket->Append("Vdot");
+    socket->Append("Wdot");
+    socket->Append("P");
+    socket->Append("Q");
+    socket->Append("R");
+    socket->Append("PDot");
+    socket->Append("QDot");
+    socket->Append("RDot");
+    socket->Append("Fx");
+    socket->Append("Fy");
+    socket->Append("Fz");
+    socket->Append("Latitude");
+    socket->Append("Longitude");
+    socket->Append("QBar");
+    socket->Append("Alpha");
+    socket->Append("L");
+    socket->Append("M");
+    socket->Append("N");
+    sFirstPass = false;
+    socket->Send();
+  }
+
+  socket->Clear();
+  socket->Append(State->Getsim_time());
+  socket->Append(State->Geth());
+  socket->Append(Rotation->Getphi());
+  socket->Append(Rotation->Gettht());
+  socket->Append(Rotation->Getpsi());
+  socket->Append(Atmosphere->GetDensity());
+  socket->Append(State->GetVt());
+  socket->Append(Translation->GetU());
+  socket->Append(Translation->GetV());
+  socket->Append(Translation->GetW());
+  socket->Append(Position->GetVn());
+  socket->Append(Position->GetVe());
+  socket->Append(Position->GetVd());
+  socket->Append(Translation->GetUdot());
+  socket->Append(Translation->GetVdot());
+  socket->Append(Translation->GetWdot());
+  socket->Append(Rotation->GetP());
+  socket->Append(Rotation->GetQ());
+  socket->Append(Rotation->GetR());
+  socket->Append(Rotation->GetPdot());
+  socket->Append(Rotation->GetQdot());
+  socket->Append(Rotation->GetRdot());
+  socket->Append(Aircraft->GetFx());
+  socket->Append(Aircraft->GetFy());
+  socket->Append(Aircraft->GetFz());
+  socket->Append(State->Getlatitude());
+  socket->Append(State->Getlongitude());
+  socket->Append(State->Getqbar());
+  socket->Append(Translation->Getalpha());
+  socket->Append(Aircraft->GetL());
+  socket->Append(Aircraft->GetM());
+  socket->Append(Aircraft->GetN());
+  socket->Send();
+}
+
+
+void FGOutput::SocketStatusOutput(string out_str)
+{
+  string asciiData;
+
+  if (socket <= 0) return;
+
+  socket->Clear();
+  asciiData = string("<STATUS>") + out_str;
+  socket->Append(asciiData.c_str());
+  socket->Send();
+}
+
index fc94daa1833c1f3cbc834151dc033e0565647f6b..c9cfe5df808c4c260e8b68ec1bea5ef9c1ce1b21 100644 (file)
@@ -54,7 +54,7 @@ INCLUDES
 #  include <fstream>
 #endif
 
-//using namespace std;
+#include "FGfdmSocket.h"
 
 /*******************************************************************************
 CLASS DECLARATION
@@ -70,12 +70,15 @@ public:
 
   void DelimitedOutput(void);
   void DelimitedOutput(string);
+  void SocketOutput(void);
+  void SocketStatusOutput(string);
 
 protected:
 
 private:
-  bool FirstPass;
+  bool sFirstPass, dFirstPass;
   ofstream datafile;
+  FGfdmSocket* socket;
 };
 
 /******************************************************************************/
index 2e347e066cdaf681caf010d00a99e0709a167b86..a087f08db2a922dc5149641bbd913f6fa6b36a87 100644 (file)
@@ -110,7 +110,7 @@ bool FGState::Reset(string path, string fname)
     resetfile.close();
 
     Initialize(U, V, W, phi*DEGTORAD, tht*DEGTORAD, psi*DEGTORAD,
-                                   latitude*DEGTORAD, longitude*DEGTORAD, h);
+               latitude*DEGTORAD, longitude*DEGTORAD, h);
 
     return true;
   } else {
@@ -179,7 +179,7 @@ void FGState::Initialize(float U, float V, float W,
 
 void FGState::Initialize(FGInitialCondition *FGIC)
 {
-       
+
   float tht,psi,phi;
   float U,V,W;
 
@@ -193,8 +193,7 @@ void FGState::Initialize(FGInitialCondition *FGIC)
   phi = FGIC->GetPhiRadIC();
   psi = FGIC->GetPsiRadIC();
 
-  Initialize(U, V, W, phi*DEGTORAD, tht*DEGTORAD, psi*DEGTORAD,
-                                   latitude*DEGTORAD, longitude*DEGTORAD, h);
+  Initialize(U, V, W, phi, tht, psi,latitude, longitude, h);
 }
 
 
index 09860284cc70c640a97b89a97b6bb577b6433d14..7e488c4fff2f996941508de4b761f8f647969654 100644 (file)
@@ -95,6 +95,7 @@ public:
   inline float Getadot(void) {return adot;}
   inline float Getbdot(void) {return bdot;}
 
+  inline float GetLocalAltitudeOverRunway(void) {return LocalAltitudeOverRunway;}
   inline float Geth(void) {return h;}
   inline float Geta(void) {return a;}
   inline float GetMach(void) {return Mach;}
@@ -115,6 +116,7 @@ public:
 
   inline void Setqbar(float tt) {qbar = tt;}
 
+  inline void SetLocalAltitudeOverRunway(float tt) {LocalAltitudeOverRunway = tt;}
   inline void Seth(float tt) {h = tt;}
   inline void Seta(float tt) {a = tt;}
   inline void SetMach(float tt) {Mach = tt;}
@@ -124,6 +126,7 @@ public:
 
   inline float IncrTime(void) {sim_time+=dt;return sim_time;}
 
+
 private:
 
   float Vt;                         // Total velocity
@@ -136,6 +139,7 @@ private:
   float Mach;                       // Mach number
 
   FGFDMExec* FDMExec;
+  float LocalAltitudeOverRunway;
 
 protected:
 
index b8922d5e06c1c54eafb065c33fcb32d0de22237d..72fe75dc37bcdd713c9ed399455e893c4f52799b 100644 (file)
@@ -40,28 +40,30 @@ INCLUDES
 *******************************************************************************/
 
 #if __BCPLUSPLUS__     >= 0x0540   // If compiling under Borland C++Builder
-  //---------------------------------------------------------------------------
-  #pragma hdrstop
-  #include <condefs.h>
-  USEUNIT("FGAircraft.cpp");
-  USEUNIT("FGAtmosphere.cpp");
-  USEUNIT("FGAuxiliary.cpp");
-  USEUNIT("FGCoefficient.cpp");
-  USEUNIT("FGEngine.cpp");
-  USEUNIT("FGFCS.cpp");
-  USEUNIT("FGFDMExec.cpp");
-  USEUNIT("FGInitialCondition.cpp");
-  USEUNIT("FGModel.cpp");
-  USEUNIT("FGOutput.cpp");
-  USEUNIT("FGPosition.cpp");
-  USEUNIT("FGRotation.cpp");
-  USEUNIT("FGState.cpp");
-  USEUNIT("FGTank.cpp");
-  USEUNIT("FGTranslation.cpp");
-  USEUNIT("FGUtility.cpp");
-  USERES("JSBSim.res");
-  //---------------------------------------------------------------------------
-  #pragma argsused
+//---------------------------------------------------------------------------
+#pragma hdrstop
+#include <condefs.h>
+USEUNIT("FGAircraft.cpp");
+USEUNIT("FGAtmosphere.cpp");
+USEUNIT("FGAuxiliary.cpp");
+USEUNIT("FGCoefficient.cpp");
+USEUNIT("FGEngine.cpp");
+USEUNIT("FGFCS.cpp");
+USEUNIT("FGFDMExec.cpp");
+USEUNIT("FGInitialCondition.cpp");
+USEUNIT("FGModel.cpp");
+USEUNIT("FGOutput.cpp");
+USEUNIT("FGPosition.cpp");
+USEUNIT("FGRotation.cpp");
+USEUNIT("FGState.cpp");
+USEUNIT("FGTank.cpp");
+USEUNIT("FGTranslation.cpp");
+USEUNIT("FGUtility.cpp");
+USERES("JSBSim.res");
+USEUNIT("FGLGear.cpp");
+USEUNIT("FGfdmSocket.cpp");
+//---------------------------------------------------------------------------
+#pragma argsused
 #endif
 
 #include "FGFDMExec.h"
@@ -114,7 +116,9 @@ int main(int argc, char** argv)
         FDMExec->GetState()->Getsim_time() < 6.0)
     {
                        FDMExec->GetFCS()->SetDe(0.05);
-               }
+               } else {
+                       FDMExec->GetFCS()->SetDe(0.00);
+    }
 
     FDMExec->Run();
   }
@@ -125,7 +129,8 @@ int main(int argc, char** argv)
 }
 
 #ifndef FGFS
-WinMain()
+int WinMain()
 {
+  return 0;
 }
 #endif
index a2e91b9067fd4887a4a523cd45cd73dc5c9ac336..bbf80f4b291aa77b3d461c4423ce4e188f6bffef 100644 (file)
@@ -10,6 +10,7 @@ libJSBsim_a_SOURCES = FGAircraft.cpp FGAircraft.h \
        FGFCS.cpp FGFCS.h \
        FGFDMExec.cpp FGFDMExec.h \
        FGInitialCondition.cpp FGInitialCondition.h \
+       FGLGear.cpp FGLGear.h \
        FGModel.cpp FGModel.h \
        FGOutput.cpp FGOutput.h \
        FGPosition.cpp FGPosition.h \
@@ -18,7 +19,8 @@ libJSBsim_a_SOURCES = FGAircraft.cpp FGAircraft.h \
        FGTranslation.cpp FGTranslation.h \
        FGUtility.cpp FGUtility.h \
        FGEngine.cpp FGEngine.h \
-       FGTank.cpp FGTank.h 
+       FGTank.cpp FGTank.h \
+       FGfdmSocket.cpp FGfdmSocket.h
 
 noinst_PROGRAMS = testJSBsim