From 5b808fbdc6e236b16bd420ad891b31bc49838c4c Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 26 Feb 1999 22:09:10 +0000 Subject: [PATCH] Added initial support for native SGI compilers. Integrated Jon's next version of JSBsim. --- FDM/JSBsim.cxx | 56 +++++-- FDM/Makefile.am | 2 + FDM/flight.cxx | 12 +- JSBsim/FGAircraft.cpp | 97 ++++++----- JSBsim/FGAircraft.h | 352 +++++++++++++++++++++++++++++++++++---- JSBsim/FGAtmosphere.cpp | 2 +- JSBsim/FGAuxiliary.cpp | 2 +- JSBsim/FGCoefficient.cpp | 17 +- JSBsim/FGCoefficient.h | 37 ++-- JSBsim/FGEngine.cpp | 37 ++-- JSBsim/FGEngine.h | 36 ++-- JSBsim/FGFCS.cpp | 2 +- JSBsim/FGFDMExec.cpp | 18 +- JSBsim/FGMain.cpp | 10 +- JSBsim/FGModel.h | 26 ++- JSBsim/FGOutput.cpp | 57 ++++--- JSBsim/FGPosition.cpp | 13 +- JSBsim/FGRotation.cpp | 2 +- JSBsim/FGRotation.h | 12 +- JSBsim/FGState.cpp | 31 ++-- JSBsim/FGState.h | 26 ++- JSBsim/FGTank.cpp | 22 ++- JSBsim/FGTank.h | 24 ++- JSBsim/FGTranslation.cpp | 2 +- JSBsim/FGTranslation.h | 12 +- JSBsim/FGUtility.cpp | 12 +- JSBsim/Makefile.am | 5 + 27 files changed, 698 insertions(+), 226 deletions(-) diff --git a/FDM/JSBsim.cxx b/FDM/JSBsim.cxx index d1b5d001f..4872c6b9d 100644 --- a/FDM/JSBsim.cxx +++ b/FDM/JSBsim.cxx @@ -22,6 +22,17 @@ // (Log is kept at end of this file) +#include + +#include STL_STRING + +#include +#include +#include +#include +#include
+#include + #include #include #include @@ -32,12 +43,6 @@ #include "JSBsim.hxx" -#include -#include -#include -#include -#include - // The default aircraft FGFDMExec FDMExec; @@ -50,10 +55,13 @@ int fgJSBsimInit(double dt) { FG_LOG( FG_FLIGHT, FG_INFO, " created FDMExec" ); - FDMExec.GetAircraft()->LoadAircraft("X15"); + string aircraft_path = current_options.get_fg_root() + "/Aircraft"; + string engine_path = current_options.get_fg_root() + "/Engine"; + + FDMExec.GetAircraft()->LoadAircraft(aircraft_path, engine_path, "X15"); FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft" ); - FDMExec.GetState()->Reset("reset00"); + FDMExec.GetState()->Reset(aircraft_path, "Reset00"); FG_LOG( FG_FLIGHT, FG_INFO, " loaded initial conditions" ); FDMExec.GetState()->Setdt(dt); @@ -98,7 +106,10 @@ int fgJSBsimUpdate(FGInterface& f, int multiloop) { /* FDMExec.GetState()->Setsim_time(State->Getsim_time() + State->Getdt() * multiloop); */ - FDMExec.Run(); + + for ( int i = 0; i < multiloop; i++ ) { + FDMExec.Run(); + } // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048); // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048); @@ -162,19 +173,24 @@ int fgJSBsim_2_FGInterface (FGInterface& f) { // ***FIXME*** f.set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot ); // Positions - double lat = FDMExec.GetState()->Getlatitude(); + double lat_geoc = FDMExec.GetState()->Getlatitude(); double lon = FDMExec.GetState()->Getlongitude(); double alt = FDMExec.GetState()->Geth(); - double lat_geoc, sl_radius; - fgGeodToGeoc( lat, alt * FEET_TO_METER, &sl_radius, &lat_geoc ); + double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc; + fgGeocToGeod( lat_geoc, EQUATORIAL_RADIUS_M + alt * FEET_TO_METER, + &lat_geod, &tmp_alt, &sl_radius1 ); + fgGeodToGeoc( lat_geod, alt * FEET_TO_METER, &sl_radius2, &tmp_lat_geoc ); - FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << lon << " lat = " << lat + FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << lon << " lat_geod = " << lat_geod << " lat_geoc = " << lat_geoc - << " alt = " << alt - << " sl_radius = " << sl_radius * METER_TO_FEET); + << " alt = " << alt << " tmp_alt = " << tmp_alt * METER_TO_FEET + << " sl_radius1 = " << sl_radius1 * METER_TO_FEET + << " sl_radius2 = " << sl_radius2 * METER_TO_FEET + << " Equator = " << EQUATORIAL_RADIUS_FT ); - f.set_Geocentric_Position( lat_geoc, lon, sl_radius * METER_TO_FEET + alt ); - f.set_Geodetic_Position( lat, lon, alt ); + f.set_Geocentric_Position( lat_geoc, lon, + sl_radius2 * METER_TO_FEET + alt ); + f.set_Geodetic_Position( lat_geod, lon, alt ); f.set_Euler_Angles( FDMExec.GetRotation()->Getphi(), FDMExec.GetRotation()->Gettht(), FDMExec.GetRotation()->Getpsi() ); @@ -217,7 +233,7 @@ int fgJSBsim_2_FGInterface (FGInterface& f) { // f.set_Static_temperature( Static_temperature ); // f.set_Total_temperature( Total_temperature ); - /* **FIXME*** */ f.set_Sea_level_radius( sl_radius * METER_TO_FEET ); + /* **FIXME*** */ f.set_Sea_level_radius( sl_radius2 * METER_TO_FEET ); /* **FIXME*** */ f.set_Earth_position_angle( 0.0 ); /* ***FIXME*** */ f.set_Runway_altitude( 0.0 ); @@ -238,6 +254,10 @@ int fgJSBsim_2_FGInterface (FGInterface& f) { // $Log$ +// Revision 1.3 1999/02/26 22:09:10 curt +// Added initial support for native SGI compilers. +// Integrated Jon's next version of JSBsim. +// // Revision 1.2 1999/02/11 21:09:40 curt // Interface with Jon's submitted JSBsim changes. // diff --git a/FDM/Makefile.am b/FDM/Makefile.am index e44cd5bd8..c876188ba 100644 --- a/FDM/Makefile.am +++ b/FDM/Makefile.am @@ -7,3 +7,5 @@ libFlight_a_SOURCES = flight.cxx flight.hxx \ LaRCsim.cxx LaRCsim.hxx INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator + +DEFS += -DFGFS diff --git a/FDM/flight.cxx b/FDM/flight.cxx index 75ab5f208..734d250fc 100644 --- a/FDM/flight.cxx +++ b/FDM/flight.cxx @@ -24,10 +24,6 @@ #include -#include "flight.hxx" -#include "JSBsim.hxx" -#include "LaRCsim.hxx" - #include #include #include @@ -35,6 +31,10 @@ #include #include
+Longitudinal
   CL0 - Reference lift at zero alpha
   CD0 - Reference drag at zero alpha
   CDM - Drag due to Mach
@@ -61,13 +50,13 @@ Longitudinal
   CLM - Lift due to Mach
   CLadt - Lift due to alpha rate
 
-  Cmadt - Moment due to alpha rate
-  Cm0 - Reference moment at zero alpha
+  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 - Moment due to Mach
+  CmM - Pitch Moment due to Mach
 
-Lateral
+Lateral
   Cyb - Side force due to sideslip
   Cyr - Side force due to yaw rate
 
@@ -78,9 +67,9 @@ Lateral
   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
+Control
+  CLDe - Lift due to elevator
+  CDDe - Drag due to elevator
   CyDr - Side force due to rudder
   CyDa - Side force due to aileron
 
@@ -89,13 +78,75 @@ Control
   ClDr - Roll moment due to rudder
   CnDr - Yaw moment due to rudder
   CnDa - Yaw moment due to aileron
+
+This class expects to be run in a directory which contains the subdirectory +structure shown below (where example aircraft X-15 is shown): -******************************************************************************** +
+aircraft/
+  X-15/
+    X-15.dat reset00 reset01 reset02 ...
+      CDRAG/
+        a0 a M De
+      CSIDE/
+        b r Dr Da
+      CLIFT/
+        a0 a M adt De
+      CROLL/
+        b p r Da Dr
+      CPITCH/
+        a0 a adt q M De
+      CYAW/
+        b p r Dr Da
+  F-16/
+    F-16.dat reset00 reset01 ...
+      CDRAG/
+        a0 a M De
+      ...
+
+ +The General Idea + +The file structure is arranged so that various modeled aircraft are stored in +their own subdirectory. Each aircraft subdirectory is named after the aircraft. +There should be a file present in the specific aircraft subdirectory (e.g. +aircraft/X-15) with the same name as the directory with a .dat appended. This +file contains mass properties information, name of aircraft, etc. for the +aircraft. In that same directory are reset files numbered starting from 0 (two +digit numbers), e.g. reset03. Within each reset file are values for important +state variables for specific flight conditions (altitude, airspeed, etc.). Also +within this directory are the directories containing lookup tables for the +stability derivatives for the aircraft. +@author Jon S. Berndt +@memo Encompasses all aircraft functionality and objects +@see +
  • [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
  • +
    +*/ + +/******************************************************************************* INCLUDES *******************************************************************************/ - -#include -#include +#ifdef FGFS +# include +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif +#else +# include +#endif #include "FGModel.h" #include "FGCoefficient.h" @@ -110,84 +161,318 @@ DEFINITIONS CLASS DECLARATION *******************************************************************************/ - class FGAircraft : public FGModel { public: + // *************************************************************************** + /** @memo Constructor + @param FGFDMExec* - a pointer to the "owning" FDM Executive + */ FGAircraft(FGFDMExec*); + + // *************************************************************************** + /** Destructor */ ~FGAircraft(void); + // *************************************************************************** + /** This must be called for each dt to execute the model algorithm */ bool Run(void); - bool LoadAircraft(char*); - - inline char* GetAircraftName(void) {return AircraftName;} + // *************************************************************************** + /** This function must be called with the name of an aircraft which + has an associated .dat file in the appropriate subdirectory. The + appropriate subdirectory is underneath the main fgfs binary directory + called "aircraft/{aircraft}/, where {aircraft} is the name of + specific aircraft you want to simulate. + @memo Loads the given aircraft. + @param string Path to the Aircraft files + @param string Path to the Engine files + @param string The name of the aircraft to be loaded, e.g. "X15". + @return True - if successful + */ + bool LoadAircraft(string, string, string); + // *************************************************************************** + /** @memo Gets the aircraft name as defined in the aircraft config file. + @param + @return string Aircraft name. + */ + inline string GetAircraftName(void) {return AircraftName;} + + // *************************************************************************** + /** @memo Sets the GearUp flag + @param boolean true or false + @return + */ inline void SetGearUp(bool tt) {GearUp = tt;} + + // *************************************************************************** + /** @memo Returns the state of the GearUp flag + @param + @return boolean true or false + */ inline bool GetGearUp(void) {return GearUp;} + + // *************************************************************************** + /** @memo Returns the area of the wing + @param + @return float wing area S, in square feet + */ inline float GetWingArea(void) {return WingArea;} + + // *************************************************************************** + /** @memo Returns the wing span + @param + @return float wing span in feet + */ inline float GetWingSpan(void) {return WingSpan;} + + // *************************************************************************** + /** @memo Returns the average wing chord + @param + @return float wing chord in feet + */ inline float Getcbar(void) {return cbar;} + + // *************************************************************************** + /** @memo Returns an engine object + @param int The engine number + @return FGEengine* The pointer to the requested engine object. + */ inline FGEngine* GetEngine(int tt) {return Engine[tt];} + + // *************************************************************************** + /** @memo + @param + @return + */ inline FGTank* GetTank(int tt) {return Tank[tt];} + + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetWeight(void) {return Weight;} + + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetMass(void) {return Mass;} + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetL(void) {return Moments[0];} + + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetM(void) {return Moments[1];} + + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetN(void) {return Moments[2];} + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetFx(void) {return Forces[0];} + + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetFy(void) {return Forces[1];} + + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetFz(void) {return Forces[2];} + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetIxx(void) {return Ixx;} + + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetIyy(void) {return Iyy;} + + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetIzz(void) {return Izz;} + + // *************************************************************************** + /** @memo + @param + @return + */ inline float GetIxz(void) {return Ixz;} private: + // *************************************************************************** + /** @memo + @param + @return + */ void GetState(void); + + // *************************************************************************** + /** @memo + @param + @return + */ void PutState(void); + // *************************************************************************** + /** @memo + @param + @return + */ void FAero(void); + + // *************************************************************************** + /** @memo + @param + @return + */ void FGear(void); + + // *************************************************************************** + /** @memo + @param + @return + */ void FMass(void); + + // *************************************************************************** + /** @memo + @param + @return + */ void FProp(void); + // *************************************************************************** + /** @memo + @param + @return + */ void MAero(void); + + // *************************************************************************** + /** @memo + @param + @return + */ void MGear(void); + + // *************************************************************************** + /** @memo + @param + @return + */ void MMass(void); + + // *************************************************************************** + /** @memo + @param + @return + */ void MProp(void); + // *************************************************************************** + /** @memo + @param + @return + */ void MassChange(void); + // *************************************************************************** + /** @memo + @param + @return + */ float Moments[3]; + + // *************************************************************************** + /** @memo + @param + @return + */ float Forces[3]; - char AircraftName[50]; + // *************************************************************************** + /** @memo + @param + @return + */ + string AircraftName; + + // *************************************************************************** + /// float Ixx, Iyy, Izz, Ixz, EmptyMass, Mass; + /// float Xcg, Ycg, Zcg; + /// float Xep, Yep, Zep; + /// float rho, qbar, Vt; + /// float alpha, beta; + /// float WingArea, WingSpan, cbar; + /// float phi, tht, psi; + /// float Weight, EmptyWeight; + /// float dt; + /// int numTanks; + /// int numEngines; + /// int numSelectedOxiTanks; + /// int numSelectedFuelTanks; + /// FGTank* Tank[MAX_TANKS]; + /// FGEngine *Engine[MAX_ENGINES]; + /// FGCoefficient *Coeff[6][10]; + /// int coeff_ctr[6]; + /// bool GearUp; + /// enum Param {LiftCoeff, DragCoeff, SideCoeff, @@ -196,7 +481,8 @@ private: YawCoeff, numCoeffs}; - char* Axis[6]; + /// + string Axis[6]; protected: diff --git a/JSBsim/FGAtmosphere.cpp b/JSBsim/FGAtmosphere.cpp index 713282e30..a066b3046 100644 --- a/JSBsim/FGAtmosphere.cpp +++ b/JSBsim/FGAtmosphere.cpp @@ -55,7 +55,7 @@ INCLUDES FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex) { - strcpy(Name,"FGAtmosphere"); + Name = "FGAtmosphere"; } diff --git a/JSBsim/FGAuxiliary.cpp b/JSBsim/FGAuxiliary.cpp index d1b272458..232e05f09 100644 --- a/JSBsim/FGAuxiliary.cpp +++ b/JSBsim/FGAuxiliary.cpp @@ -55,7 +55,7 @@ INCLUDES FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex) { - strcpy(Name, "FGAuxiliary"); + Name = "FGAuxiliary"; } diff --git a/JSBsim/FGCoefficient.cpp b/JSBsim/FGCoefficient.cpp index f0115909d..15b457c3c 100644 --- a/JSBsim/FGCoefficient.cpp +++ b/JSBsim/FGCoefficient.cpp @@ -107,10 +107,7 @@ HISTORY INCLUDES *******************************************************************************/ -#include -#include #include "FGCoefficient.h" - #include "FGAtmosphere.h" #include "FGState.h" #include "FGFDMExec.h" @@ -143,7 +140,7 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex) } -FGCoefficient::FGCoefficient(FGFDMExec* fdex, char* fname) +FGCoefficient::FGCoefficient(FGFDMExec* fdex, string fname) { int r, c; float ftrashcan; @@ -159,7 +156,7 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, char* fname) Auxiliary = FDMExec->GetAuxiliary(); Output = FDMExec->GetOutput(); - ifstream coeffDefFile(fname); + ifstream coeffDefFile(fname.c_str()); if (coeffDefFile) { if (!coeffDefFile.fail()) { @@ -167,11 +164,11 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, char* fname) coeffDefFile >> description; coeffDefFile >> method; - if (strcmp(method,"EQUATION") == 0) type = 4; - else if (strcmp(method,"TABLE") == 0) type = 3; - else if (strcmp(method,"VECTOR") == 0) type = 2; - else if (strcmp(method,"VALUE") == 0) type = 1; - else type = 0; + if (method == "EQUATION") type = 4; + else if (method == "TABLE") type = 3; + else if (method == "VECTOR") type = 2; + else if (method == "VALUE") type = 1; + else type = 0; if (type == 2 || type == 3) { coeffDefFile >> rows; diff --git a/JSBsim/FGCoefficient.h b/JSBsim/FGCoefficient.h index 97fcdc180..b5995692d 100644 --- a/JSBsim/FGCoefficient.h +++ b/JSBsim/FGCoefficient.h @@ -37,7 +37,22 @@ SENTRY /******************************************************************************* INCLUDES *******************************************************************************/ -#include +#ifdef FGFS +# include +# include STL_STRING +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif + FG_USING_STD(string); +# ifdef FG_HAVE_NATIVE_SGI_COMPILERS + FG_USING_NAMESPACE(std); +# endif +#else +# include +# include +#endif /******************************************************************************* DEFINES @@ -80,7 +95,7 @@ public: FGCoefficient(FGFDMExec*); FGCoefficient(FGFDMExec*, int, int); FGCoefficient(FGFDMExec*, int); - FGCoefficient(FGFDMExec*, char*); + FGCoefficient(FGFDMExec*, string); ~FGCoefficient(void); bool Allocate(int); @@ -93,19 +108,19 @@ public: protected: private: + string filename; + string description; + string name; + string method; float StaticValue; float *Table2D; float **Table3D; - int rows, columns; - char filename[50]; - char description[50]; - char name[10]; - int type; - char method[15]; - int multipliers; - long int mult_idx[10]; - int mult_count; float LookupR, LookupC; + long int mult_idx[10]; + int rows, columns; + int type; + int multipliers; + int mult_count; float GetCoeffVal(int); diff --git a/JSBsim/FGEngine.cpp b/JSBsim/FGEngine.cpp index dcc2f89f3..c14149d28 100644 --- a/JSBsim/FGEngine.cpp +++ b/JSBsim/FGEngine.cpp @@ -30,7 +30,6 @@ See header file. HISTORY -------------------------------------------------------------------------------- - 01/21/99 JSB Created ******************************************************************************** @@ -38,9 +37,6 @@ INCLUDES *******************************************************************************/ #include -#include -#include -#include #include "FGEngine.h" #include "FGState.h" @@ -59,10 +55,11 @@ INCLUDES *******************************************************************************/ -FGEngine::FGEngine(FGFDMExec* fdex, char *engineName, int num) +FGEngine::FGEngine(FGFDMExec* fdex, string enginePath, string engineName, + int num) { - char fullpath[256]; - char tag[256]; + string fullpath; + string tag; FDMExec = fdex; @@ -76,17 +73,19 @@ FGEngine::FGEngine(FGFDMExec* fdex, char *engineName, int num) Auxiliary = FDMExec->GetAuxiliary(); Output = FDMExec->GetOutput(); - strcpy(Name, engineName); - sprintf(fullpath,"/h/curt/projects/FlightGear/Simulator/FDM/JSBsim/engine/%s.dat", engineName); - ifstream enginefile(fullpath); + Name = engineName; + fullpath = enginePath + "/" + engineName + ".dat"; + ifstream enginefile(fullpath.c_str()); if (enginefile) { enginefile >> tag; - if (strstr(tag,"ROCKET")) Type = 0; - else if (strstr(tag,"PISTON")) Type = 1; - else if (strstr(tag,"TURBOPROP")) Type = 2; - else if (strstr(tag,"TURBOJET")) Type = 3; - else Type = 0; + + if (tag == "ROCKET") Type = etRocket; + else if (tag == "PISTON") Type = etPiston; + else if (tag == "TURBOPROP") Type = etTurboProp; + else if (tag == "TURBOJET") Type = etTurboJet; + else Type = etUnknown; + enginefile >> X; enginefile >> Y; enginefile >> Z; @@ -95,7 +94,7 @@ FGEngine::FGEngine(FGFDMExec* fdex, char *engineName, int num) enginefile >> MaxThrottle; enginefile >> MinThrottle; enginefile >> SLFuelFlowMax; - if (Type == 0) + if (Type == 1) enginefile >> SLOxiFlowMax; enginefile.close(); } else { @@ -130,7 +129,7 @@ float FGEngine::CalcRocketThrust(void) Flameout = false; } - Thrust += 0.8*(Thrust - lastThrust); // actual thrust + Thrust += 0.8*(Thrust - lastThrust); // actual thrust return Thrust; } @@ -145,10 +144,10 @@ float FGEngine::CalcPistonThrust(void) float FGEngine::CalcThrust(void) { switch(Type) { - case 0: // Rocket + case etRocket: return CalcRocketThrust(); // break; - case 1: // Piston + case etPiston: return CalcPistonThrust(); // break; default: diff --git a/JSBsim/FGEngine.h b/JSBsim/FGEngine.h index bafc38ebc..05e6406df 100644 --- a/JSBsim/FGEngine.h +++ b/JSBsim/FGEngine.h @@ -44,6 +44,17 @@ SENTRY INCLUDES *******************************************************************************/ +#ifdef FGFS +# include +# include STL_STRING + FG_USING_STD(string); +# ifdef FG_HAVE_NATIVE_SGI_COMPILERS + FG_USING_NAMESPACE(std); +# endif +#else +# include +#endif + /******************************************************************************* DEFINES *******************************************************************************/ @@ -66,28 +77,29 @@ class FGOutput; class FGEngine { public: - FGEngine(FGFDMExec*, char*, int); + FGEngine(FGFDMExec*, string, string, int); ~FGEngine(void); - float GetThrust(void) {return Thrust;} - bool GetStarved(void) {return Starved;} - bool GetFlameout(void) {return Flameout;} - float GetThrottle(void) {return Throttle;} - char* GetName() {return Name;} + enum EngineType {etUnknown, etRocket, etPiston, etTurboProp, etTurboJet}; + + float GetThrottle(void) {return Throttle;} + float GetThrust(void) {return Thrust;} + bool GetStarved(void) {return Starved;} + bool GetFlameout(void) {return Flameout;} + int GetType(void) {return Type;} + string GetName() {return Name;} void SetStarved(bool tt) {Starved = tt;} void SetStarved(void) {Starved = true;} - int GetType(void) {return Type;} - float CalcThrust(void); float CalcFuelNeed(void); float CalcOxidizerNeed(void); private: - char Name[30]; + string Name; + EngineType Type; float X, Y, Z; - int Type; float SLThrustMax; float VacThrustMax; float SLFuelFlowMax; @@ -113,7 +125,7 @@ private: FGPosition* Position; FGAuxiliary* Auxiliary; FGOutput* Output; - + protected: float CalcRocketThrust(void); float CalcPistonThrust(void); @@ -121,4 +133,4 @@ protected: }; /******************************************************************************/ -#endif \ No newline at end of file +#endif diff --git a/JSBsim/FGFCS.cpp b/JSBsim/FGFCS.cpp index 124af1082..04bfb3880 100644 --- a/JSBsim/FGFCS.cpp +++ b/JSBsim/FGFCS.cpp @@ -55,7 +55,7 @@ INCLUDES FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex) { - strcpy(Name, "FGFCS"); + Name = "FGFCS"; } diff --git a/JSBsim/FGFDMExec.cpp b/JSBsim/FGFDMExec.cpp index 6f2cc1b9d..9f4adfa80 100644 --- a/JSBsim/FGFDMExec.cpp +++ b/JSBsim/FGFDMExec.cpp @@ -38,14 +38,22 @@ HISTORY INCLUDES *******************************************************************************/ -#include -#include -#include -#include +#ifdef FGFS +# include +# ifdef FG_HAVE_STD_INCLUDES +# include +# include +# else +# include +# include +# endif +#else +# include +# include +#endif #include "FGFDMExec.h" #include "FGState.h" - #include "FGAtmosphere.h" #include "FGFCS.h" #include "FGAircraft.h" diff --git a/JSBsim/FGMain.cpp b/JSBsim/FGMain.cpp index 02484a1a1..fc0c4e6d4 100644 --- a/JSBsim/FGMain.cpp +++ b/JSBsim/FGMain.cpp @@ -9,11 +9,13 @@ #include "FGAuxiliary.h" #include "FGOutput.h" -#include -#include +#include +#include void main(int argc, char** argv) { + FGFDMExec* FDMExec; + struct timespec short_wait = {0,100000000}; struct timespec no_wait = {0,100000000}; @@ -26,8 +28,8 @@ void main(int argc, char** argv) FDMExec = new FGFDMExec(); - FDMExec->GetAircraft()->LoadAircraft(argv[1]); - FDMExec->GetState()->Reset(argv[2]); + FDMExec->GetAircraft()->LoadAircraft(string(argv[1])); + FDMExec->GetState()->Reset(string(argv[2])); while (FDMExec->GetState()->Getsim_time() <= 25.0) { diff --git a/JSBsim/FGModel.h b/JSBsim/FGModel.h index 7ea0f0d27..47c07fb44 100644 --- a/JSBsim/FGModel.h +++ b/JSBsim/FGModel.h @@ -39,9 +39,27 @@ INCLUDES *******************************************************************************/ #include "FGDefs.h" -#include -#include -#include + +#ifdef FGFS +# include +# include STL_STRING +# ifdef FG_HAVE_STD_INCLUDES +# include +# include +# else +# include +# include +# endif + FG_USING_STD(string); +# ifdef FG_HAVE_NATIVE_SGI_COMPILERS + FG_USING_NAMESPACE(std); +# endif +#else +# include +# include +# include +#endif + /******************************************************************************* DEFINES @@ -69,7 +87,7 @@ public: ~FGModel(void); FGModel* NextModel; - char Name[30]; + string Name; virtual bool Run(void); virtual bool InitModel(void); void SetRate(int tt) {rate = tt;}; diff --git a/JSBsim/FGOutput.cpp b/JSBsim/FGOutput.cpp index 8bd4f11bc..e5e2f7624 100644 --- a/JSBsim/FGOutput.cpp +++ b/JSBsim/FGOutput.cpp @@ -39,11 +39,18 @@ HISTORY INCLUDES *******************************************************************************/ -#include -#include -#include +#ifdef FGFS +# include +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif +#else +# include +#endif #ifdef HAVE_CURSES - #include +# include #endif #include "FGOutput.h" @@ -63,7 +70,7 @@ INCLUDES FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex) { - strcpy(Name, "FGOutput"); + Name = "FGOutput"; FirstPass = true; #ifdef HAVE_CURSES initscr(); @@ -92,7 +99,7 @@ bool FGOutput::Run(void) void FGOutput::ConsoleOutput(void) { #ifdef HAVE_CURSES - char buffer[20]; + string buffer; clear(); move(1,1); insstr("Quaternions"); @@ -101,10 +108,10 @@ void FGOutput::ConsoleOutput(void) move(2,27); insstr("Q2"); move(2,38); insstr("Q3"); - move(3,1); sprintf(buffer,"%4.4f",Rotation->GetQ0()); insstr(buffer); - move(3,12); sprintf(buffer,"%4.4f",Rotation->GetQ1()); insstr(buffer); - move(3,23); sprintf(buffer,"%4.4f",Rotation->GetQ2()); insstr(buffer); - move(3,34); sprintf(buffer,"%4.4f",Rotation->GetQ3()); insstr(buffer); + move(3,1); buffer = Rotation->GetQ0(); insstr(buffer.c_str()); + move(3,12); buffer = Rotation->GetQ1(); insstr(buffer.c_str()); + move(3,23); buffer = Rotation->GetQ2(); insstr(buffer.c_str()); + move(3,34); buffer = Rotation->GetQ3(); insstr(buffer.c_str()); move(0,0); insstr("Time: "); move(0,6); insstr(gcvt(State->Getsim_time(),6,buffer)); @@ -113,41 +120,41 @@ void FGOutput::ConsoleOutput(void) move(2,55); insstr("Tht"); move(2,64); insstr("Psi"); - move(3,45); sprintf(buffer,"%3.3f",Rotation->Getphi()); insstr(buffer); - move(3,54); sprintf(buffer,"%3.3f",Rotation->Gettht()); insstr(buffer); - move(3,63); sprintf(buffer,"%3.3f",Rotation->Getpsi()); insstr(buffer); + move(3,45); buffer = Rotation->Getphi(); insstr(buffer.c_str()); + move(3,54); buffer = Rotation->Gettht(); insstr(buffer.c_str()); + move(3,63); buffer = Rotation->Getpsi(); insstr(buffer.c_str()); move(5,47); insstr("U"); move(5,56); insstr("V"); move(5,65); insstr("W"); - move(6,45); sprintf(buffer,"%5.2f",Translation->GetU()); insstr(buffer); - move(6,54); sprintf(buffer,"%5.2f",Translation->GetV()); insstr(buffer); - move(6,63); sprintf(buffer,"%5.2f",Translation->GetW()); insstr(buffer); + move(6,45); buffer = Translation->GetU(); insstr(buffer.c_str()); + move(6,54); buffer = Translation->GetV(); insstr(buffer.c_str()); + move(6,63); buffer = Translation->GetW(); insstr(buffer.c_str()); move(8,47); insstr("Fx"); move(8,56); insstr("Fy"); move(8,65); insstr("Fz"); - move(9,45); sprintf(buffer,"%5.2f",Aircraft->GetFx()); insstr(buffer); - move(9,54); sprintf(buffer,"%5.2f",Aircraft->GetFy()); insstr(buffer); - move(9,63); sprintf(buffer,"%5.2f",Aircraft->GetFz()); insstr(buffer); + move(9,45); buffer = Aircraft->GetFx(); insstr(buffer.c_str()); + move(9,54); buffer = Aircraft->GetFy(); insstr(buffer.c_str()); + move(9,63); buffer = Aircraft->GetFz(); insstr(buffer.c_str()); move(11,47); insstr("Fn"); move(11,56); insstr("Fe"); move(11,65); insstr("Fd"); - move(12,45); sprintf(buffer,"%5.2f",Position->GetFn()); insstr(buffer); - move(12,54); sprintf(buffer,"%5.2f",Position->GetFe()); insstr(buffer); - move(12,63); sprintf(buffer,"%5.2f",Position->GetFd()); insstr(buffer); + move(12,45); buffer = Position->GetFn(); insstr(buffer.c_str()); + move(12,54); buffer = Position->GetFe(); insstr(buffer.c_str()); + move(12,63); buffer = Position->GetFd(); insstr(buffer.c_str()); move(14,47); insstr("Latitude"); move(14,57); insstr("Longitude"); move(14,67); insstr("Altitude"); - move(15,47); sprintf(buffer,"%5.2f",State->Getlatitude()); insstr(buffer); - move(15,57); sprintf(buffer,"%5.2f",State->Getlongitude()); insstr(buffer); - move(15,67); sprintf(buffer,"%5.2f",State->Geth()); insstr(buffer); + move(15,47); buffer = State->Getlatitude(); insstr(buffer.c_str()); + move(15,57); buffer = State->Getlongitude(); insstr(buffer.c_str()); + move(15,67); buffer = State->Geth(); insstr(buffer.c_str()); refresh(); diff --git a/JSBsim/FGPosition.cpp b/JSBsim/FGPosition.cpp index 51b49c459..8c7ee85ff 100644 --- a/JSBsim/FGPosition.cpp +++ b/JSBsim/FGPosition.cpp @@ -53,7 +53,16 @@ COMMENTS, REFERENCES, and NOTES INCLUDES *******************************************************************************/ -#include +#ifdef FGFS +# include +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif +#else +# include +#endif #include "FGPosition.h" #include "FGAtmosphere.h" #include "FGState.h" @@ -72,7 +81,7 @@ INCLUDES FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex) { - strcpy(Name, "FGPosition"); + Name = "FGPosition"; AccelN = AccelE = AccelD = 0.0; LongitudeDot = LatitudeDot = RadiusDot = 0.0; } diff --git a/JSBsim/FGRotation.cpp b/JSBsim/FGRotation.cpp index 715c0a76f..494d9da66 100644 --- a/JSBsim/FGRotation.cpp +++ b/JSBsim/FGRotation.cpp @@ -73,7 +73,7 @@ INCLUDES FGRotation::FGRotation(FGFDMExec* fdmex) : FGModel(fdmex) { - strcpy(Name, "FGRotation"); + Name = "FGRotation"; Q0dot = Q1dot = Q2dot = Q3dot = 0.0; Pdot = Qdot = Rdot = 0.0; } diff --git a/JSBsim/FGRotation.h b/JSBsim/FGRotation.h index 66999e7af..e0b40894b 100644 --- a/JSBsim/FGRotation.h +++ b/JSBsim/FGRotation.h @@ -56,7 +56,17 @@ SENTRY INCLUDES *******************************************************************************/ -#include +#ifdef FGFS +# include +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif +#else +# include +#endif + #include "FGModel.h" /******************************************************************************* diff --git a/JSBsim/FGState.cpp b/JSBsim/FGState.cpp index 532c20047..6309b55d6 100644 --- a/JSBsim/FGState.cpp +++ b/JSBsim/FGState.cpp @@ -36,9 +36,16 @@ HISTORY INCLUDES *******************************************************************************/ -#include - -#include +#ifdef FGFS +# include +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif +#else +# include +#endif #include "FGState.h" #include "FGFDMExec.h" @@ -75,7 +82,7 @@ FGState::~FGState(void) } -bool FGState::Reset(const string& path, const string& fname) +bool FGState::Reset(string path, string fname) { string resetDef; float U, V, W; @@ -84,12 +91,10 @@ bool FGState::Reset(const string& path, const string& fname) float Q0, Q1, Q2, Q3; float T[4][4]; - resetDef = path; - resetDef += "/"; - resetDef += FDMExec->GetAircraft()->GetAircraftName(); - resetDef += "/" + fname; + resetDef = path + "/" + FDMExec->GetAircraft()->GetAircraftName() + + "/" + fname; - ifstream resetfile( resetDef.c_str() ); + ifstream resetfile(resetDef.c_str()); if (resetfile) { resetfile >> U; @@ -157,9 +162,9 @@ bool FGState::Reset(const string& path, const string& fname) } -bool FGState::StoreData(char* fname) +bool FGState::StoreData(string fname) { - ofstream datafile(fname); + ofstream datafile(fname.c_str()); if (datafile) { datafile << FDMExec->GetTranslation()->GetU(); @@ -180,9 +185,9 @@ bool FGState::StoreData(char* fname) } -bool FGState::DumpData(char* fname) +bool FGState::DumpData(string fname) { - ofstream datafile(fname); + ofstream datafile(fname.c_str()); if (datafile) { datafile << "U: " << FDMExec->GetTranslation()->GetU() << endl; diff --git a/JSBsim/FGState.h b/JSBsim/FGState.h index d78f427c7..3324281d8 100644 --- a/JSBsim/FGState.h +++ b/JSBsim/FGState.h @@ -44,9 +44,23 @@ SENTRY INCLUDES *******************************************************************************/ -#include -#include -#include +#ifdef FGFS +# include +# include STL_STRING +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif + FG_USING_STD(string); +# ifdef FG_HAVE_NATIVE_SGI_COMPILERS + FG_USING_NAMESPACE(std); +# endif +#else +# include +# include +#endif + #include "FGDefs.h" /******************************************************************************* @@ -64,9 +78,9 @@ public: FGState(FGFDMExec*); ~FGState(void); - bool FGState::Reset(const string& path, const string& fname); - bool StoreData(char*); - bool DumpData(char*); + bool Reset(string, string); + bool StoreData(string); + bool DumpData(string); bool DisplayData(void); inline float GetVt(void) {return Vt;} diff --git a/JSBsim/FGTank.cpp b/JSBsim/FGTank.cpp index 991959b43..ce5d448c6 100644 --- a/JSBsim/FGTank.cpp +++ b/JSBsim/FGTank.cpp @@ -35,10 +35,18 @@ HISTORY ******************************************************************************** INCLUDES *******************************************************************************/ +#ifdef FGFS +# include +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif +#else +# include +#endif #include "FGTank.h" -#include -#include /******************************************************************************* ************************************ CODE ************************************** @@ -47,12 +55,12 @@ INCLUDES FGTank::FGTank(ifstream& acfile) { - char type[20]; + string type; - acfile >> type; // Type = 0: rocket, 1: piston - if (strstr(type,"FUEL")) Type = 0; - else if (strstr(type,"OXIDIZER")) Type = 1; - else Type = -1; + acfile >> type; // Type = 0: fuel, 1: oxidizer + if (type == "FUEL") Type = ttFUEL; + else if (type == "OXIDIZER") Type = ttOXIDIZER; + else Type = ttUNKNOWN; acfile >> X; // inches acfile >> Y; // " acfile >> Z; // " diff --git a/JSBsim/FGTank.h b/JSBsim/FGTank.h index afb3020ea..390f14de0 100644 --- a/JSBsim/FGTank.h +++ b/JSBsim/FGTank.h @@ -43,8 +43,22 @@ SENTRY /******************************************************************************* INCLUDES *******************************************************************************/ - -#include +#ifdef FGFS +# include +# include STL_STRING +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif + FG_USING_STD(string); +# ifdef FG_HAVE_NATIVE_SGI_COMPILERS + FG_USING_NAMESPACE(std); +# endif +#else +# include +# include +#endif /******************************************************************************* DEFINES @@ -65,11 +79,13 @@ public: bool GetSelected(void) {return Selected;} float GetPctFull(void) {return PctFull;} float GetContents(void) {return Contents;} + + enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER}; private: + TankType Type; float X, Y, Z; float Capacity; - int Type; float Radius; float PctFull; float Contents; @@ -79,4 +95,4 @@ protected: }; /******************************************************************************/ -#endif \ No newline at end of file +#endif diff --git a/JSBsim/FGTranslation.cpp b/JSBsim/FGTranslation.cpp index 05adbbf8d..63db8801f 100644 --- a/JSBsim/FGTranslation.cpp +++ b/JSBsim/FGTranslation.cpp @@ -73,7 +73,7 @@ INCLUDES FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex) { - strcpy(Name, "FGTranslation"); + Name = "FGTranslation"; Udot = Vdot = Wdot = 0.0; } diff --git a/JSBsim/FGTranslation.h b/JSBsim/FGTranslation.h index 423f7ab03..bbc3dc297 100644 --- a/JSBsim/FGTranslation.h +++ b/JSBsim/FGTranslation.h @@ -56,7 +56,17 @@ SENTRY INCLUDES *******************************************************************************/ -#include +#ifdef FGFS +# include +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif +#else +# include +#endif + #include "FGModel.h" /******************************************************************************* diff --git a/JSBsim/FGUtility.cpp b/JSBsim/FGUtility.cpp index afc3d6573..f7e7d1de3 100644 --- a/JSBsim/FGUtility.cpp +++ b/JSBsim/FGUtility.cpp @@ -42,10 +42,20 @@ DEFINES INCLUDES *******************************************************************************/ +#ifdef FGFS +# include +# ifdef FG_HAVE_STD_INCLUDES +# include +# else +# include +# endif +#else +# include +#endif + #include "FGUtility.h" #include "FGState.h" #include "FGFDMExec.h" -#include /******************************************************************************* ************************************ CODE ************************************** diff --git a/JSBsim/Makefile.am b/JSBsim/Makefile.am index cc7548477..bc540a476 100644 --- a/JSBsim/Makefile.am +++ b/JSBsim/Makefile.am @@ -4,6 +4,7 @@ libJSBsim_a_SOURCES = FGAircraft.cpp FGAircraft.h \ FGAtmosphere.cpp FGAtmosphere.h \ FGAuxiliary.cpp FGAuxiliary.h \ FGCoefficient.cpp FGCoefficient.h \ + FGDefs.h \ FGFCS.cpp FGFCS.h \ FGFDMExec.cpp FGFDMExec.h \ FGModel.cpp FGModel.h \ @@ -15,3 +16,7 @@ libJSBsim_a_SOURCES = FGAircraft.cpp FGAircraft.h \ FGUtility.cpp FGUtility.h \ FGEngine.cpp FGEngine.h \ FGTank.cpp FGTank.h + +INCLUDES += -I$(top_builddir) + +DEFS += -DFGFS