1
0
Fork 0

Added initial support for native SGI compilers.

Integrated Jon's next version of JSBsim.
This commit is contained in:
curt 1999-02-26 22:09:10 +00:00
parent 00ccbd1f25
commit 5b808fbdc6
27 changed files with 698 additions and 226 deletions

View file

@ -22,6 +22,17 @@
// (Log is kept at end of this file) // (Log is kept at end of this file)
#include <Include/compiler.h>
#include STL_STRING
#include <Aircraft/aircraft.hxx>
#include <Controls/controls.hxx>
#include <Debug/logstream.hxx>
#include <Include/fg_constants.h>
#include <Main/options.hxx>
#include <Math/fg_geodesy.hxx>
#include <FDM/JSBsim/FGFDMExec.h> #include <FDM/JSBsim/FGFDMExec.h>
#include <FDM/JSBsim/FGAircraft.h> #include <FDM/JSBsim/FGAircraft.h>
#include <FDM/JSBsim/FGFCS.h> #include <FDM/JSBsim/FGFCS.h>
@ -32,12 +43,6 @@
#include "JSBsim.hxx" #include "JSBsim.hxx"
#include <Aircraft/aircraft.hxx>
#include <Controls/controls.hxx>
#include <Debug/logstream.hxx>
#include <Include/fg_constants.h>
#include <Math/fg_geodesy.hxx>
// The default aircraft // The default aircraft
FGFDMExec FDMExec; FGFDMExec FDMExec;
@ -50,10 +55,13 @@ int fgJSBsimInit(double dt) {
FG_LOG( FG_FLIGHT, FG_INFO, " created FDMExec" ); 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" ); 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" ); FG_LOG( FG_FLIGHT, FG_INFO, " loaded initial conditions" );
FDMExec.GetState()->Setdt(dt); FDMExec.GetState()->Setdt(dt);
@ -98,7 +106,10 @@ int fgJSBsimUpdate(FGInterface& f, int multiloop) {
/* FDMExec.GetState()->Setsim_time(State->Getsim_time() /* FDMExec.GetState()->Setsim_time(State->Getsim_time()
+ State->Getdt() * multiloop); */ + 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 FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
// printf("%d Altitude = %.2f\n", i, 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 ); // ***FIXME*** f.set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
// Positions // Positions
double lat = FDMExec.GetState()->Getlatitude(); double lat_geoc = FDMExec.GetState()->Getlatitude();
double lon = FDMExec.GetState()->Getlongitude(); double lon = FDMExec.GetState()->Getlongitude();
double alt = FDMExec.GetState()->Geth(); double alt = FDMExec.GetState()->Geth();
double lat_geoc, sl_radius; double lat_geod, tmp_alt, sl_radius1, sl_radius2, tmp_lat_geoc;
fgGeodToGeoc( lat, alt * FEET_TO_METER, &sl_radius, &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 << " lat_geoc = " << lat_geoc
<< " alt = " << alt << " alt = " << alt << " tmp_alt = " << tmp_alt * METER_TO_FEET
<< " sl_radius = " << sl_radius * 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_Geocentric_Position( lat_geoc, lon,
f.set_Geodetic_Position( lat, lon, alt ); sl_radius2 * METER_TO_FEET + alt );
f.set_Geodetic_Position( lat_geod, lon, alt );
f.set_Euler_Angles( FDMExec.GetRotation()->Getphi(), f.set_Euler_Angles( FDMExec.GetRotation()->Getphi(),
FDMExec.GetRotation()->Gettht(), FDMExec.GetRotation()->Gettht(),
FDMExec.GetRotation()->Getpsi() ); FDMExec.GetRotation()->Getpsi() );
@ -217,7 +233,7 @@ int fgJSBsim_2_FGInterface (FGInterface& f) {
// f.set_Static_temperature( Static_temperature ); // f.set_Static_temperature( Static_temperature );
// f.set_Total_temperature( Total_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_Earth_position_angle( 0.0 );
/* ***FIXME*** */ f.set_Runway_altitude( 0.0 ); /* ***FIXME*** */ f.set_Runway_altitude( 0.0 );
@ -238,6 +254,10 @@ int fgJSBsim_2_FGInterface (FGInterface& f) {
// $Log$ // $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 // Revision 1.2 1999/02/11 21:09:40 curt
// Interface with Jon's submitted JSBsim changes. // Interface with Jon's submitted JSBsim changes.
// //

View file

@ -7,3 +7,5 @@ libFlight_a_SOURCES = flight.cxx flight.hxx \
LaRCsim.cxx LaRCsim.hxx LaRCsim.cxx LaRCsim.hxx
INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator INCLUDES += -I$(top_builddir) -I$(top_builddir)/Lib -I$(top_builddir)/Simulator
DEFS += -DFGFS

View file

@ -24,10 +24,6 @@
#include <stdio.h> #include <stdio.h>
#include "flight.hxx"
#include "JSBsim.hxx"
#include "LaRCsim.hxx"
#include <Debug/logstream.hxx> #include <Debug/logstream.hxx>
#include <FDM/External/external.hxx> #include <FDM/External/external.hxx>
#include <FDM/LaRCsim/ls_interface.h> #include <FDM/LaRCsim/ls_interface.h>
@ -35,6 +31,10 @@
#include <Math/fg_geodesy.hxx> #include <Math/fg_geodesy.hxx>
#include <Time/timestamp.hxx> #include <Time/timestamp.hxx>
#include "flight.hxx"
#include "JSBsim.hxx"
#include "LaRCsim.hxx"
// base_fdm_state is the internal state that is updated in integer // base_fdm_state is the internal state that is updated in integer
// multiples of "dt". This leads to "jitter" with respect to the real // multiples of "dt". This leads to "jitter" with respect to the real
@ -195,6 +195,10 @@ void fgFDMSetGroundElevation(int model, double ground_meters) {
// $Log$ // $Log$
// Revision 1.16 1999/02/26 22:09:12 curt
// Added initial support for native SGI compilers.
// Integrated Jon's next version of JSBsim.
//
// Revision 1.15 1999/02/05 21:29:01 curt // Revision 1.15 1999/02/05 21:29:01 curt
// Modifications to incorporate Jon S. Berndts flight model code. // Modifications to incorporate Jon S. Berndts flight model code.
// //

View file

@ -1,4 +1,4 @@
/** ***************************************************************************** /*******************************************************************************
Module: FGAircraft.cpp Module: FGAircraft.cpp
Author: Jon S. Berndt Author: Jon S. Berndt
@ -131,11 +131,20 @@ stability derivatives for the aircraft.
******************************************************************************** ********************************************************************************
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <stdlib.h>
#include <dirent.h> #include <dirent.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <math.h>
#ifdef FGFS
# include <Include/compiler.h>
# ifdef FG_HAVE_STD_INCLUDES
# include <cmath>
# else
# include <math.h>
# endif
#else
# include <cmath>
#endif
#include "FGAircraft.h" #include "FGAircraft.h"
#include "FGTranslation.h" #include "FGTranslation.h"
@ -156,17 +165,16 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
int i; int i;
strcpy(Name,"FGAircraft"); Name = "FGAircraft";
for (i=0;i<6;i++) Axis[i] = (char*)malloc(7);
for (i=0;i<6;i++) coeff_ctr[i] = 0; for (i=0;i<6;i++) coeff_ctr[i] = 0;
strcpy(Axis[LiftCoeff],"CLIFT"); Axis[LiftCoeff] = "CLIFT";
strcpy(Axis[DragCoeff],"CDRAG"); Axis[DragCoeff] = "CDRAG";
strcpy(Axis[SideCoeff],"CSIDE"); Axis[SideCoeff] = "CSIDE";
strcpy(Axis[RollCoeff],"CROLL"); Axis[RollCoeff] = "CROLL";
strcpy(Axis[PitchCoeff],"CPITCH"); Axis[PitchCoeff] = "CPITCH";
strcpy(Axis[YawCoeff],"CYAW"); Axis[YawCoeff] = "CYAW";
} }
@ -175,13 +183,14 @@ FGAircraft::~FGAircraft(void)
} }
bool FGAircraft::LoadAircraft(char* fname) bool FGAircraft::LoadAircraft(string aircraft_path, string engine_path,
string fname)
{ {
char path[256]; string path;
char fullpath[256]; string fullpath;
char filename[256]; string filename;
char aircraftDef[256]; string aircraftDef;
char tag[256]; string tag;
DIR* dir; DIR* dir;
DIR* coeffdir; DIR* coeffdir;
struct dirent* dirEntry; struct dirent* dirEntry;
@ -190,8 +199,8 @@ bool FGAircraft::LoadAircraft(char* fname)
struct stat st2; struct stat st2;
ifstream coeffInFile; ifstream coeffInFile;
sprintf(aircraftDef, "/h/curt/projects/FlightGear/Simulator/FDM/JSBsim/aircraft/%s/%s.dat", fname, fname); aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".dat";
ifstream aircraftfile(aircraftDef); ifstream aircraftfile(aircraftDef.c_str());
if (aircraftfile) { if (aircraftfile) {
aircraftfile >> AircraftName; // String with no embedded spaces aircraftfile >> AircraftName; // String with no embedded spaces
@ -209,29 +218,30 @@ bool FGAircraft::LoadAircraft(char* fname)
numTanks = numEngines = 0; numTanks = numEngines = 0;
numSelectedOxiTanks = numSelectedFuelTanks = 0; numSelectedOxiTanks = numSelectedFuelTanks = 0;
while (strstr(tag,"EOF") == 0) { while ( !(tag == "EOF") ) {
if (strstr(tag,"CGLOC")) { if (tag == "CGLOC") {
aircraftfile >> Xcg; // inches aircraftfile >> Xcg; // inches
aircraftfile >> Ycg; // inches aircraftfile >> Ycg; // inches
aircraftfile >> Zcg; // inches aircraftfile >> Zcg; // inches
} else if (strstr(tag,"EYEPOINTLOC")) { } else if (tag == "EYEPOINTLOC") {
aircraftfile >> Xep; // inches aircraftfile >> Xep; // inches
aircraftfile >> Yep; // inches aircraftfile >> Yep; // inches
aircraftfile >> Zep; // inches aircraftfile >> Zep; // inches
} else if (strstr(tag,"TANK")) { } else if (tag == "TANK") {
Tank[numTanks] = new FGTank(aircraftfile); Tank[numTanks] = new FGTank(aircraftfile);
switch(Tank[numTanks]->GetType()) { switch(Tank[numTanks]->GetType()) {
case 0: case FGTank::ttFUEL:
numSelectedOxiTanks++;
break;
case 1:
numSelectedFuelTanks++; numSelectedFuelTanks++;
break; break;
case FGTank::ttOXIDIZER:
numSelectedOxiTanks++;
break;
} }
numTanks++; numTanks++;
} else if (strstr(tag,"ENGINE")) { } else if (tag == "ENGINE") {
aircraftfile >> tag; aircraftfile >> tag;
Engine[numEngines] = new FGEngine(FDMExec, tag, numEngines); Engine[numEngines] = new FGEngine(FDMExec, engine_path, tag,
numEngines);
numEngines++; numEngines++;
} }
aircraftfile >> tag; aircraftfile >> tag;
@ -257,20 +267,20 @@ bool FGAircraft::LoadAircraft(char* fname)
// track of the number of coefficients registered for each of the // track of the number of coefficients registered for each of the
// previously mentioned axis. // previously mentioned axis.
sprintf(path,"/h/curt/projects/FlightGear/Simulator/FDM/JSBsim/aircraft/%s/",AircraftName); path = aircraft_path + "/" + AircraftName + "/";
if (dir = opendir(path)) { if (dir = opendir(path.c_str())) {
while (dirEntry = readdir(dir)) { while (dirEntry = readdir(dir)) {
sprintf(fullpath,"%s%s",path,dirEntry->d_name); fullpath = path + dirEntry->d_name;
stat(fullpath,&st); stat(fullpath.c_str(),&st);
if ((st.st_mode & S_IFMT) == S_IFDIR) { if ((st.st_mode & S_IFMT) == S_IFDIR) {
for (int axis_ctr=0; axis_ctr < 6; axis_ctr++) { for (int axis_ctr=0; axis_ctr < 6; axis_ctr++) {
if (strstr(dirEntry->d_name,Axis[axis_ctr])) { if (dirEntry->d_name == Axis[axis_ctr]) {
if (coeffdir = opendir(fullpath)) { if (coeffdir = opendir(fullpath.c_str())) {
while (coeffdirEntry = readdir(coeffdir)) { while (coeffdirEntry = readdir(coeffdir)) {
if (coeffdirEntry->d_name[0] != '.') { if (coeffdirEntry->d_name[0] != '.') {
sprintf(filename,"%s%s/%s",path,Axis[axis_ctr],coeffdirEntry->d_name); filename = path + Axis[axis_ctr] + "/" + coeffdirEntry->d_name;
stat(filename,&st2); stat(filename.c_str(),&st2);
if (st2.st_size > 6) { if (st2.st_size > 6) {
Coeff[axis_ctr][coeff_ctr[axis_ctr]] = new FGCoefficient(FDMExec, filename); Coeff[axis_ctr][coeff_ctr[axis_ctr]] = new FGCoefficient(FDMExec, filename);
coeff_ctr[axis_ctr]++; coeff_ctr[axis_ctr]++;
@ -331,15 +341,16 @@ void FGAircraft::MassChange()
Fshortage = Oshortage = 0.0; Fshortage = Oshortage = 0.0;
for (int t=0; t<numTanks; t++) { for (int t=0; t<numTanks; t++) {
switch(Engine[e]->GetType()) { switch(Engine[e]->GetType()) {
case 0: // Rocket case FGEngine::etRocket:
switch(Tank[t]->GetType()) { switch(Tank[t]->GetType()) {
case 0: // Fuel case FGTank::ttFUEL:
if (Tank[t]->GetSelected()) { if (Tank[t]->GetSelected()) {
Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/ Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
numSelectedFuelTanks)*(dt*rate) + Fshortage); numSelectedFuelTanks)*(dt*rate) + Fshortage);
} }
break; break;
case 1: // Oxidizer case FGTank::ttOXIDIZER:
if (Tank[t]->GetSelected()) { if (Tank[t]->GetSelected()) {
Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/ Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
numSelectedOxiTanks)*(dt*rate) + Oshortage); numSelectedOxiTanks)*(dt*rate) + Oshortage);
@ -347,7 +358,11 @@ void FGAircraft::MassChange()
break; break;
} }
break; break;
default: // piston, turbojet, turbofan, etc.
case FGEngine::etPiston:
case FGEngine::etTurboJet:
case FGEngine::etTurboProp:
if (Tank[t]->GetSelected()) { if (Tank[t]->GetSelected()) {
Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/ Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
numSelectedFuelTanks)*(dt*rate) + Fshortage); numSelectedFuelTanks)*(dt*rate) + Fshortage);

View file

@ -36,22 +36,11 @@ SENTRY
/******************************************************************************* /*******************************************************************************
COMMENTS, REFERENCES, and NOTES 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 The aerodynamic coefficients used in this model typically are:
School, January 1994 <PRE>
[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices", <b>Longitudinal</b>
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 CL0 - Reference lift at zero alpha
CD0 - Reference drag at zero alpha CD0 - Reference drag at zero alpha
CDM - Drag due to Mach CDM - Drag due to Mach
@ -61,13 +50,13 @@ Longitudinal
CLM - Lift due to Mach CLM - Lift due to Mach
CLadt - Lift due to alpha rate CLadt - Lift due to alpha rate
Cmadt - Moment due to alpha rate Cmadt - Pitching Moment due to alpha rate
Cm0 - Reference moment at zero alpha Cm0 - Reference Pitching moment at zero alpha
Cma - Pitching moment slope (w.r.t. alpha) Cma - Pitching moment slope (w.r.t. alpha)
Cmq - Pitch damping (pitch moment due to pitch rate) Cmq - Pitch damping (pitch moment due to pitch rate)
CmM - Moment due to Mach CmM - Pitch Moment due to Mach
Lateral <b>Lateral</b>
Cyb - Side force due to sideslip Cyb - Side force due to sideslip
Cyr - Side force due to yaw rate Cyr - Side force due to yaw rate
@ -78,9 +67,9 @@ Lateral
Cnp - Rudder adverse yaw (yaw moment due to roll rate) Cnp - Rudder adverse yaw (yaw moment due to roll rate)
Cnr - Yaw damping (yaw moment due to yaw rate) Cnr - Yaw damping (yaw moment due to yaw rate)
Control <b>Control</b>
ClDe - Lift due to elevator CLDe - Lift due to elevator
CdDe - Drag due to elevator CDDe - Drag due to elevator
CyDr - Side force due to rudder CyDr - Side force due to rudder
CyDa - Side force due to aileron CyDa - Side force due to aileron
@ -89,13 +78,75 @@ Control
ClDr - Roll moment due to rudder ClDr - Roll moment due to rudder
CnDr - Yaw moment due to rudder CnDr - Yaw moment due to rudder
CnDa - Yaw moment due to aileron CnDa - Yaw moment due to aileron
</PRE>
This class expects to be run in a directory which contains the subdirectory
structure shown below (where example aircraft X-15 is shown):
******************************************************************************** <PRE>
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
...
</PRE>
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 <ll>
<li>[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</li>
<li>[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
JSC 12960, July 1977</li>
<li>[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
NASA-Ames", NASA CR-2497, January 1975</li>
<li>[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
Wiley & Sons, 1979 ISBN 0-471-03032-5</li>
<li>[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
1982 ISBN 0-471-08936-2</li>
</ll>
*/
/*******************************************************************************
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#ifdef FGFS
#include <stdio.h> # include <Include/compiler.h>
#include <fstream.h> # ifdef FG_HAVE_STD_INCLUDES
# include <fstream>
# else
# include <fstream.h>
# endif
#else
# include <fstream>
#endif
#include "FGModel.h" #include "FGModel.h"
#include "FGCoefficient.h" #include "FGCoefficient.h"
@ -110,84 +161,318 @@ DEFINITIONS
CLASS DECLARATION CLASS DECLARATION
*******************************************************************************/ *******************************************************************************/
class FGAircraft : public FGModel class FGAircraft : public FGModel
{ {
public: public:
// ***************************************************************************
/** @memo Constructor
@param FGFDMExec* - a pointer to the "owning" FDM Executive
*/
FGAircraft(FGFDMExec*); FGAircraft(FGFDMExec*);
// ***************************************************************************
/** Destructor */
~FGAircraft(void); ~FGAircraft(void);
// ***************************************************************************
/** This must be called for each dt to execute the model algorithm */
bool Run(void); bool Run(void);
bool LoadAircraft(char*); // ***************************************************************************
/** This function must be called with the name of an aircraft which
inline char* GetAircraftName(void) {return AircraftName;} has an associated .dat file in the appropriate subdirectory. The
appropriate subdirectory is underneath the main fgfs binary directory
called "aircraft/{<i>aircraft</i>}/, where {<i>aircraft</i>} 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;} 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;} 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;} inline float GetWingArea(void) {return WingArea;}
// ***************************************************************************
/** @memo Returns the wing span
@param
@return float wing span in feet
*/
inline float GetWingSpan(void) {return WingSpan;} 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;} 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];} inline FGEngine* GetEngine(int tt) {return Engine[tt];}
// ***************************************************************************
/** @memo
@param
@return
*/
inline FGTank* GetTank(int tt) {return Tank[tt];} inline FGTank* GetTank(int tt) {return Tank[tt];}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetWeight(void) {return Weight;} inline float GetWeight(void) {return Weight;}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetMass(void) {return Mass;} inline float GetMass(void) {return Mass;}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetL(void) {return Moments[0];} inline float GetL(void) {return Moments[0];}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetM(void) {return Moments[1];} inline float GetM(void) {return Moments[1];}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetN(void) {return Moments[2];} inline float GetN(void) {return Moments[2];}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetFx(void) {return Forces[0];} inline float GetFx(void) {return Forces[0];}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetFy(void) {return Forces[1];} inline float GetFy(void) {return Forces[1];}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetFz(void) {return Forces[2];} inline float GetFz(void) {return Forces[2];}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetIxx(void) {return Ixx;} inline float GetIxx(void) {return Ixx;}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetIyy(void) {return Iyy;} inline float GetIyy(void) {return Iyy;}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetIzz(void) {return Izz;} inline float GetIzz(void) {return Izz;}
// ***************************************************************************
/** @memo
@param
@return
*/
inline float GetIxz(void) {return Ixz;} inline float GetIxz(void) {return Ixz;}
private: private:
// ***************************************************************************
/** @memo
@param
@return
*/
void GetState(void); void GetState(void);
// ***************************************************************************
/** @memo
@param
@return
*/
void PutState(void); void PutState(void);
// ***************************************************************************
/** @memo
@param
@return
*/
void FAero(void); void FAero(void);
// ***************************************************************************
/** @memo
@param
@return
*/
void FGear(void); void FGear(void);
// ***************************************************************************
/** @memo
@param
@return
*/
void FMass(void); void FMass(void);
// ***************************************************************************
/** @memo
@param
@return
*/
void FProp(void); void FProp(void);
// ***************************************************************************
/** @memo
@param
@return
*/
void MAero(void); void MAero(void);
// ***************************************************************************
/** @memo
@param
@return
*/
void MGear(void); void MGear(void);
// ***************************************************************************
/** @memo
@param
@return
*/
void MMass(void); void MMass(void);
// ***************************************************************************
/** @memo
@param
@return
*/
void MProp(void); void MProp(void);
// ***************************************************************************
/** @memo
@param
@return
*/
void MassChange(void); void MassChange(void);
// ***************************************************************************
/** @memo
@param
@return
*/
float Moments[3]; float Moments[3];
// ***************************************************************************
/** @memo
@param
@return
*/
float Forces[3]; float Forces[3];
char AircraftName[50]; // ***************************************************************************
/** @memo
@param
@return
*/
string AircraftName;
// ***************************************************************************
///
float Ixx, Iyy, Izz, Ixz, EmptyMass, Mass; float Ixx, Iyy, Izz, Ixz, EmptyMass, Mass;
///
float Xcg, Ycg, Zcg; float Xcg, Ycg, Zcg;
///
float Xep, Yep, Zep; float Xep, Yep, Zep;
///
float rho, qbar, Vt; float rho, qbar, Vt;
///
float alpha, beta; float alpha, beta;
///
float WingArea, WingSpan, cbar; float WingArea, WingSpan, cbar;
///
float phi, tht, psi; float phi, tht, psi;
///
float Weight, EmptyWeight; float Weight, EmptyWeight;
///
float dt; float dt;
///
int numTanks; int numTanks;
///
int numEngines; int numEngines;
///
int numSelectedOxiTanks; int numSelectedOxiTanks;
///
int numSelectedFuelTanks; int numSelectedFuelTanks;
///
FGTank* Tank[MAX_TANKS]; FGTank* Tank[MAX_TANKS];
///
FGEngine *Engine[MAX_ENGINES]; FGEngine *Engine[MAX_ENGINES];
///
FGCoefficient *Coeff[6][10]; FGCoefficient *Coeff[6][10];
///
int coeff_ctr[6]; int coeff_ctr[6];
///
bool GearUp; bool GearUp;
///
enum Param {LiftCoeff, enum Param {LiftCoeff,
DragCoeff, DragCoeff,
SideCoeff, SideCoeff,
@ -196,7 +481,8 @@ private:
YawCoeff, YawCoeff,
numCoeffs}; numCoeffs};
char* Axis[6]; ///
string Axis[6];
protected: protected:

View file

@ -55,7 +55,7 @@ INCLUDES
FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex) FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
strcpy(Name,"FGAtmosphere"); Name = "FGAtmosphere";
} }

View file

@ -55,7 +55,7 @@ INCLUDES
FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex) FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
strcpy(Name, "FGAuxiliary"); Name = "FGAuxiliary";
} }

View file

@ -107,10 +107,7 @@ HISTORY
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "FGCoefficient.h" #include "FGCoefficient.h"
#include "FGAtmosphere.h" #include "FGAtmosphere.h"
#include "FGState.h" #include "FGState.h"
#include "FGFDMExec.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; int r, c;
float ftrashcan; float ftrashcan;
@ -159,7 +156,7 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, char* fname)
Auxiliary = FDMExec->GetAuxiliary(); Auxiliary = FDMExec->GetAuxiliary();
Output = FDMExec->GetOutput(); Output = FDMExec->GetOutput();
ifstream coeffDefFile(fname); ifstream coeffDefFile(fname.c_str());
if (coeffDefFile) { if (coeffDefFile) {
if (!coeffDefFile.fail()) { if (!coeffDefFile.fail()) {
@ -167,11 +164,11 @@ FGCoefficient::FGCoefficient(FGFDMExec* fdex, char* fname)
coeffDefFile >> description; coeffDefFile >> description;
coeffDefFile >> method; coeffDefFile >> method;
if (strcmp(method,"EQUATION") == 0) type = 4; if (method == "EQUATION") type = 4;
else if (strcmp(method,"TABLE") == 0) type = 3; else if (method == "TABLE") type = 3;
else if (strcmp(method,"VECTOR") == 0) type = 2; else if (method == "VECTOR") type = 2;
else if (strcmp(method,"VALUE") == 0) type = 1; else if (method == "VALUE") type = 1;
else type = 0; else type = 0;
if (type == 2 || type == 3) { if (type == 2 || type == 3) {
coeffDefFile >> rows; coeffDefFile >> rows;

View file

@ -37,7 +37,22 @@ SENTRY
/******************************************************************************* /*******************************************************************************
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <fstream.h> #ifdef FGFS
# include <Include/compiler.h>
# include STL_STRING
# ifdef FG_HAVE_STD_INCLUDES
# include <fstream>
# else
# include <fstream.h>
# endif
FG_USING_STD(string);
# ifdef FG_HAVE_NATIVE_SGI_COMPILERS
FG_USING_NAMESPACE(std);
# endif
#else
# include <string>
# include <fstream>
#endif
/******************************************************************************* /*******************************************************************************
DEFINES DEFINES
@ -80,7 +95,7 @@ public:
FGCoefficient(FGFDMExec*); FGCoefficient(FGFDMExec*);
FGCoefficient(FGFDMExec*, int, int); FGCoefficient(FGFDMExec*, int, int);
FGCoefficient(FGFDMExec*, int); FGCoefficient(FGFDMExec*, int);
FGCoefficient(FGFDMExec*, char*); FGCoefficient(FGFDMExec*, string);
~FGCoefficient(void); ~FGCoefficient(void);
bool Allocate(int); bool Allocate(int);
@ -93,19 +108,19 @@ public:
protected: protected:
private: private:
string filename;
string description;
string name;
string method;
float StaticValue; float StaticValue;
float *Table2D; float *Table2D;
float **Table3D; 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; float LookupR, LookupC;
long int mult_idx[10];
int rows, columns;
int type;
int multipliers;
int mult_count;
float GetCoeffVal(int); float GetCoeffVal(int);

View file

@ -30,7 +30,6 @@ See header file.
HISTORY HISTORY
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
01/21/99 JSB Created 01/21/99 JSB Created
******************************************************************************** ********************************************************************************
@ -38,9 +37,6 @@ INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <fstream.h> #include <fstream.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "FGEngine.h" #include "FGEngine.h"
#include "FGState.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]; string fullpath;
char tag[256]; string tag;
FDMExec = fdex; FDMExec = fdex;
@ -76,17 +73,19 @@ FGEngine::FGEngine(FGFDMExec* fdex, char *engineName, int num)
Auxiliary = FDMExec->GetAuxiliary(); Auxiliary = FDMExec->GetAuxiliary();
Output = FDMExec->GetOutput(); Output = FDMExec->GetOutput();
strcpy(Name, engineName); Name = engineName;
sprintf(fullpath,"/h/curt/projects/FlightGear/Simulator/FDM/JSBsim/engine/%s.dat", engineName); fullpath = enginePath + "/" + engineName + ".dat";
ifstream enginefile(fullpath); ifstream enginefile(fullpath.c_str());
if (enginefile) { if (enginefile) {
enginefile >> tag; enginefile >> tag;
if (strstr(tag,"ROCKET")) Type = 0;
else if (strstr(tag,"PISTON")) Type = 1; if (tag == "ROCKET") Type = etRocket;
else if (strstr(tag,"TURBOPROP")) Type = 2; else if (tag == "PISTON") Type = etPiston;
else if (strstr(tag,"TURBOJET")) Type = 3; else if (tag == "TURBOPROP") Type = etTurboProp;
else Type = 0; else if (tag == "TURBOJET") Type = etTurboJet;
else Type = etUnknown;
enginefile >> X; enginefile >> X;
enginefile >> Y; enginefile >> Y;
enginefile >> Z; enginefile >> Z;
@ -95,7 +94,7 @@ FGEngine::FGEngine(FGFDMExec* fdex, char *engineName, int num)
enginefile >> MaxThrottle; enginefile >> MaxThrottle;
enginefile >> MinThrottle; enginefile >> MinThrottle;
enginefile >> SLFuelFlowMax; enginefile >> SLFuelFlowMax;
if (Type == 0) if (Type == 1)
enginefile >> SLOxiFlowMax; enginefile >> SLOxiFlowMax;
enginefile.close(); enginefile.close();
} else { } else {
@ -130,7 +129,7 @@ float FGEngine::CalcRocketThrust(void)
Flameout = false; Flameout = false;
} }
Thrust += 0.8*(Thrust - lastThrust); // actual thrust Thrust += 0.8*(Thrust - lastThrust); // actual thrust
return Thrust; return Thrust;
} }
@ -145,10 +144,10 @@ float FGEngine::CalcPistonThrust(void)
float FGEngine::CalcThrust(void) float FGEngine::CalcThrust(void)
{ {
switch(Type) { switch(Type) {
case 0: // Rocket case etRocket:
return CalcRocketThrust(); return CalcRocketThrust();
// break; // break;
case 1: // Piston case etPiston:
return CalcPistonThrust(); return CalcPistonThrust();
// break; // break;
default: default:

View file

@ -44,6 +44,17 @@ SENTRY
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#ifdef FGFS
# include <Include/compiler.h>
# include STL_STRING
FG_USING_STD(string);
# ifdef FG_HAVE_NATIVE_SGI_COMPILERS
FG_USING_NAMESPACE(std);
# endif
#else
# include <string>
#endif
/******************************************************************************* /*******************************************************************************
DEFINES DEFINES
*******************************************************************************/ *******************************************************************************/
@ -66,28 +77,29 @@ class FGOutput;
class FGEngine class FGEngine
{ {
public: public:
FGEngine(FGFDMExec*, char*, int); FGEngine(FGFDMExec*, string, string, int);
~FGEngine(void); ~FGEngine(void);
float GetThrust(void) {return Thrust;} enum EngineType {etUnknown, etRocket, etPiston, etTurboProp, etTurboJet};
bool GetStarved(void) {return Starved;}
bool GetFlameout(void) {return Flameout;} float GetThrottle(void) {return Throttle;}
float GetThrottle(void) {return Throttle;} float GetThrust(void) {return Thrust;}
char* GetName() {return Name;} 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(bool tt) {Starved = tt;}
void SetStarved(void) {Starved = true;} void SetStarved(void) {Starved = true;}
int GetType(void) {return Type;}
float CalcThrust(void); float CalcThrust(void);
float CalcFuelNeed(void); float CalcFuelNeed(void);
float CalcOxidizerNeed(void); float CalcOxidizerNeed(void);
private: private:
char Name[30]; string Name;
EngineType Type;
float X, Y, Z; float X, Y, Z;
int Type;
float SLThrustMax; float SLThrustMax;
float VacThrustMax; float VacThrustMax;
float SLFuelFlowMax; float SLFuelFlowMax;
@ -113,7 +125,7 @@ private:
FGPosition* Position; FGPosition* Position;
FGAuxiliary* Auxiliary; FGAuxiliary* Auxiliary;
FGOutput* Output; FGOutput* Output;
protected: protected:
float CalcRocketThrust(void); float CalcRocketThrust(void);
float CalcPistonThrust(void); float CalcPistonThrust(void);
@ -121,4 +133,4 @@ protected:
}; };
/******************************************************************************/ /******************************************************************************/
#endif #endif

View file

@ -55,7 +55,7 @@ INCLUDES
FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex) FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
strcpy(Name, "FGFCS"); Name = "FGFCS";
} }

View file

@ -38,14 +38,22 @@ HISTORY
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <stdio.h> #ifdef FGFS
#include <stdlib.h> # include <Include/compiler.h>
#include <iostream.h> # ifdef FG_HAVE_STD_INCLUDES
#include <time.h> # include <iostream>
# include <ctime>
# else
# include <iostream.h>
# include <time.h>
# endif
#else
# include <iostream>
# include <ctime>
#endif
#include "FGFDMExec.h" #include "FGFDMExec.h"
#include "FGState.h" #include "FGState.h"
#include "FGAtmosphere.h" #include "FGAtmosphere.h"
#include "FGFCS.h" #include "FGFCS.h"
#include "FGAircraft.h" #include "FGAircraft.h"

View file

@ -9,11 +9,13 @@
#include "FGAuxiliary.h" #include "FGAuxiliary.h"
#include "FGOutput.h" #include "FGOutput.h"
#include <iostream.h> #include <iostream>
#include <time.h> #include <ctime>
void main(int argc, char** argv) void main(int argc, char** argv)
{ {
FGFDMExec* FDMExec;
struct timespec short_wait = {0,100000000}; struct timespec short_wait = {0,100000000};
struct timespec no_wait = {0,100000000}; struct timespec no_wait = {0,100000000};
@ -26,8 +28,8 @@ void main(int argc, char** argv)
FDMExec = new FGFDMExec(); FDMExec = new FGFDMExec();
FDMExec->GetAircraft()->LoadAircraft(argv[1]); FDMExec->GetAircraft()->LoadAircraft(string(argv[1]));
FDMExec->GetState()->Reset(argv[2]); FDMExec->GetState()->Reset(string(argv[2]));
while (FDMExec->GetState()->Getsim_time() <= 25.0) while (FDMExec->GetState()->Getsim_time() <= 25.0)
{ {

View file

@ -39,9 +39,27 @@ INCLUDES
*******************************************************************************/ *******************************************************************************/
#include "FGDefs.h" #include "FGDefs.h"
#include <stdio.h>
#include <string.h> #ifdef FGFS
#include <iostream.h> # include <Include/compiler.h>
# include STL_STRING
# ifdef FG_HAVE_STD_INCLUDES
# include <cstring>
# include <iostream>
# else
# include <string.h>
# include <iostream.h>
# endif
FG_USING_STD(string);
# ifdef FG_HAVE_NATIVE_SGI_COMPILERS
FG_USING_NAMESPACE(std);
# endif
#else
# include <string>
# include <cstring>
# include <iostream>
#endif
/******************************************************************************* /*******************************************************************************
DEFINES DEFINES
@ -69,7 +87,7 @@ public:
~FGModel(void); ~FGModel(void);
FGModel* NextModel; FGModel* NextModel;
char Name[30]; string Name;
virtual bool Run(void); virtual bool Run(void);
virtual bool InitModel(void); virtual bool InitModel(void);
void SetRate(int tt) {rate = tt;}; void SetRate(int tt) {rate = tt;};

View file

@ -39,11 +39,18 @@ HISTORY
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <stdio.h> #ifdef FGFS
#include <stdlib.h> # include <Include/compiler.h>
#include <iostream.h> # ifdef FG_HAVE_STD_INCLUDES
# include <iostream>
# else
# include <iostream.h>
# endif
#else
# include <iostream>
#endif
#ifdef HAVE_CURSES #ifdef HAVE_CURSES
#include <ncurses.h> # include <ncurses.h>
#endif #endif
#include "FGOutput.h" #include "FGOutput.h"
@ -63,7 +70,7 @@ INCLUDES
FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex) FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
strcpy(Name, "FGOutput"); Name = "FGOutput";
FirstPass = true; FirstPass = true;
#ifdef HAVE_CURSES #ifdef HAVE_CURSES
initscr(); initscr();
@ -92,7 +99,7 @@ bool FGOutput::Run(void)
void FGOutput::ConsoleOutput(void) void FGOutput::ConsoleOutput(void)
{ {
#ifdef HAVE_CURSES #ifdef HAVE_CURSES
char buffer[20]; string buffer;
clear(); clear();
move(1,1); insstr("Quaternions"); move(1,1); insstr("Quaternions");
@ -101,10 +108,10 @@ void FGOutput::ConsoleOutput(void)
move(2,27); insstr("Q2"); move(2,27); insstr("Q2");
move(2,38); insstr("Q3"); move(2,38); insstr("Q3");
move(3,1); sprintf(buffer,"%4.4f",Rotation->GetQ0()); insstr(buffer); move(3,1); buffer = Rotation->GetQ0(); insstr(buffer.c_str());
move(3,12); sprintf(buffer,"%4.4f",Rotation->GetQ1()); insstr(buffer); move(3,12); buffer = Rotation->GetQ1(); insstr(buffer.c_str());
move(3,23); sprintf(buffer,"%4.4f",Rotation->GetQ2()); insstr(buffer); move(3,23); buffer = Rotation->GetQ2(); insstr(buffer.c_str());
move(3,34); sprintf(buffer,"%4.4f",Rotation->GetQ3()); insstr(buffer); move(3,34); buffer = Rotation->GetQ3(); insstr(buffer.c_str());
move(0,0); insstr("Time: "); move(0,0); insstr("Time: ");
move(0,6); insstr(gcvt(State->Getsim_time(),6,buffer)); 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,55); insstr("Tht");
move(2,64); insstr("Psi"); move(2,64); insstr("Psi");
move(3,45); sprintf(buffer,"%3.3f",Rotation->Getphi()); insstr(buffer); move(3,45); buffer = Rotation->Getphi(); insstr(buffer.c_str());
move(3,54); sprintf(buffer,"%3.3f",Rotation->Gettht()); insstr(buffer); move(3,54); buffer = Rotation->Gettht(); insstr(buffer.c_str());
move(3,63); sprintf(buffer,"%3.3f",Rotation->Getpsi()); insstr(buffer); move(3,63); buffer = Rotation->Getpsi(); insstr(buffer.c_str());
move(5,47); insstr("U"); move(5,47); insstr("U");
move(5,56); insstr("V"); move(5,56); insstr("V");
move(5,65); insstr("W"); move(5,65); insstr("W");
move(6,45); sprintf(buffer,"%5.2f",Translation->GetU()); insstr(buffer); move(6,45); buffer = Translation->GetU(); insstr(buffer.c_str());
move(6,54); sprintf(buffer,"%5.2f",Translation->GetV()); insstr(buffer); move(6,54); buffer = Translation->GetV(); insstr(buffer.c_str());
move(6,63); sprintf(buffer,"%5.2f",Translation->GetW()); insstr(buffer); move(6,63); buffer = Translation->GetW(); insstr(buffer.c_str());
move(8,47); insstr("Fx"); move(8,47); insstr("Fx");
move(8,56); insstr("Fy"); move(8,56); insstr("Fy");
move(8,65); insstr("Fz"); move(8,65); insstr("Fz");
move(9,45); sprintf(buffer,"%5.2f",Aircraft->GetFx()); insstr(buffer); move(9,45); buffer = Aircraft->GetFx(); insstr(buffer.c_str());
move(9,54); sprintf(buffer,"%5.2f",Aircraft->GetFy()); insstr(buffer); move(9,54); buffer = Aircraft->GetFy(); insstr(buffer.c_str());
move(9,63); sprintf(buffer,"%5.2f",Aircraft->GetFz()); insstr(buffer); move(9,63); buffer = Aircraft->GetFz(); insstr(buffer.c_str());
move(11,47); insstr("Fn"); move(11,47); insstr("Fn");
move(11,56); insstr("Fe"); move(11,56); insstr("Fe");
move(11,65); insstr("Fd"); move(11,65); insstr("Fd");
move(12,45); sprintf(buffer,"%5.2f",Position->GetFn()); insstr(buffer); move(12,45); buffer = Position->GetFn(); insstr(buffer.c_str());
move(12,54); sprintf(buffer,"%5.2f",Position->GetFe()); insstr(buffer); move(12,54); buffer = Position->GetFe(); insstr(buffer.c_str());
move(12,63); sprintf(buffer,"%5.2f",Position->GetFd()); insstr(buffer); move(12,63); buffer = Position->GetFd(); insstr(buffer.c_str());
move(14,47); insstr("Latitude"); move(14,47); insstr("Latitude");
move(14,57); insstr("Longitude"); move(14,57); insstr("Longitude");
move(14,67); insstr("Altitude"); move(14,67); insstr("Altitude");
move(15,47); sprintf(buffer,"%5.2f",State->Getlatitude()); insstr(buffer); move(15,47); buffer = State->Getlatitude(); insstr(buffer.c_str());
move(15,57); sprintf(buffer,"%5.2f",State->Getlongitude()); insstr(buffer); move(15,57); buffer = State->Getlongitude(); insstr(buffer.c_str());
move(15,67); sprintf(buffer,"%5.2f",State->Geth()); insstr(buffer); move(15,67); buffer = State->Geth(); insstr(buffer.c_str());
refresh(); refresh();

View file

@ -53,7 +53,16 @@ COMMENTS, REFERENCES, and NOTES
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <math.h> #ifdef FGFS
# include <Include/compiler.h>
# ifdef FG_HAVE_STD_INCLUDES
# include <cmath>
# else
# include <math.h>
# endif
#else
# include <cmath>
#endif
#include "FGPosition.h" #include "FGPosition.h"
#include "FGAtmosphere.h" #include "FGAtmosphere.h"
#include "FGState.h" #include "FGState.h"
@ -72,7 +81,7 @@ INCLUDES
FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex) FGPosition::FGPosition(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
strcpy(Name, "FGPosition"); Name = "FGPosition";
AccelN = AccelE = AccelD = 0.0; AccelN = AccelE = AccelD = 0.0;
LongitudeDot = LatitudeDot = RadiusDot = 0.0; LongitudeDot = LatitudeDot = RadiusDot = 0.0;
} }

View file

@ -73,7 +73,7 @@ INCLUDES
FGRotation::FGRotation(FGFDMExec* fdmex) : FGModel(fdmex) FGRotation::FGRotation(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
strcpy(Name, "FGRotation"); Name = "FGRotation";
Q0dot = Q1dot = Q2dot = Q3dot = 0.0; Q0dot = Q1dot = Q2dot = Q3dot = 0.0;
Pdot = Qdot = Rdot = 0.0; Pdot = Qdot = Rdot = 0.0;
} }

View file

@ -56,7 +56,17 @@ SENTRY
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <math.h> #ifdef FGFS
# include <Include/compiler.h>
# ifdef FG_HAVE_STD_INCLUDES
# include <cmath>
# else
# include <math.h>
# endif
#else
# include <cmath>
#endif
#include "FGModel.h" #include "FGModel.h"
/******************************************************************************* /*******************************************************************************

View file

@ -36,9 +36,16 @@ HISTORY
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <math.h> #ifdef FGFS
# include <Include/compiler.h>
#include <string> # ifdef FG_HAVE_STD_INCLUDES
# include <cmath>
# else
# include <math.h>
# endif
#else
# include <cmath>
#endif
#include "FGState.h" #include "FGState.h"
#include "FGFDMExec.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; string resetDef;
float U, V, W; float U, V, W;
@ -84,12 +91,10 @@ bool FGState::Reset(const string& path, const string& fname)
float Q0, Q1, Q2, Q3; float Q0, Q1, Q2, Q3;
float T[4][4]; float T[4][4];
resetDef = path; resetDef = path + "/" + FDMExec->GetAircraft()->GetAircraftName() +
resetDef += "/"; "/" + fname;
resetDef += FDMExec->GetAircraft()->GetAircraftName();
resetDef += "/" + fname;
ifstream resetfile( resetDef.c_str() ); ifstream resetfile(resetDef.c_str());
if (resetfile) { if (resetfile) {
resetfile >> U; 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) { if (datafile) {
datafile << FDMExec->GetTranslation()->GetU(); 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) { if (datafile) {
datafile << "U: " << FDMExec->GetTranslation()->GetU() << endl; datafile << "U: " << FDMExec->GetTranslation()->GetU() << endl;

View file

@ -44,9 +44,23 @@ SENTRY
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <stdio.h> #ifdef FGFS
#include <fstream.h> # include <Include/compiler.h>
#include <string> # include STL_STRING
# ifdef FG_HAVE_STD_INCLUDES
# include <fstream>
# else
# include <fstream.h>
# endif
FG_USING_STD(string);
# ifdef FG_HAVE_NATIVE_SGI_COMPILERS
FG_USING_NAMESPACE(std);
# endif
#else
# include <string>
# include <fstream>
#endif
#include "FGDefs.h" #include "FGDefs.h"
/******************************************************************************* /*******************************************************************************
@ -64,9 +78,9 @@ public:
FGState(FGFDMExec*); FGState(FGFDMExec*);
~FGState(void); ~FGState(void);
bool FGState::Reset(const string& path, const string& fname); bool Reset(string, string);
bool StoreData(char*); bool StoreData(string);
bool DumpData(char*); bool DumpData(string);
bool DisplayData(void); bool DisplayData(void);
inline float GetVt(void) {return Vt;} inline float GetVt(void) {return Vt;}

View file

@ -35,10 +35,18 @@ HISTORY
******************************************************************************** ********************************************************************************
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#ifdef FGFS
# include <Include/compiler.h>
# ifdef FG_HAVE_STD_INCLUDES
# include <fstream>
# else
# include <fstream.h>
# endif
#else
# include <fstream>
#endif
#include "FGTank.h" #include "FGTank.h"
#include <fstream.h>
#include <string.h>
/******************************************************************************* /*******************************************************************************
************************************ CODE ************************************** ************************************ CODE **************************************
@ -47,12 +55,12 @@ INCLUDES
FGTank::FGTank(ifstream& acfile) FGTank::FGTank(ifstream& acfile)
{ {
char type[20]; string type;
acfile >> type; // Type = 0: rocket, 1: piston acfile >> type; // Type = 0: fuel, 1: oxidizer
if (strstr(type,"FUEL")) Type = 0; if (type == "FUEL") Type = ttFUEL;
else if (strstr(type,"OXIDIZER")) Type = 1; else if (type == "OXIDIZER") Type = ttOXIDIZER;
else Type = -1; else Type = ttUNKNOWN;
acfile >> X; // inches acfile >> X; // inches
acfile >> Y; // " acfile >> Y; // "
acfile >> Z; // " acfile >> Z; // "

View file

@ -43,8 +43,22 @@ SENTRY
/******************************************************************************* /*******************************************************************************
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#ifdef FGFS
#include <fstream.h> # include <Include/compiler.h>
# include STL_STRING
# ifdef FG_HAVE_STD_INCLUDES
# include <fstream>
# else
# include <fstream.h>
# endif
FG_USING_STD(string);
# ifdef FG_HAVE_NATIVE_SGI_COMPILERS
FG_USING_NAMESPACE(std);
# endif
#else
# include <string>
# include <fstream>
#endif
/******************************************************************************* /*******************************************************************************
DEFINES DEFINES
@ -65,11 +79,13 @@ public:
bool GetSelected(void) {return Selected;} bool GetSelected(void) {return Selected;}
float GetPctFull(void) {return PctFull;} float GetPctFull(void) {return PctFull;}
float GetContents(void) {return Contents;} float GetContents(void) {return Contents;}
enum TankType {ttUNKNOWN, ttFUEL, ttOXIDIZER};
private: private:
TankType Type;
float X, Y, Z; float X, Y, Z;
float Capacity; float Capacity;
int Type;
float Radius; float Radius;
float PctFull; float PctFull;
float Contents; float Contents;
@ -79,4 +95,4 @@ protected:
}; };
/******************************************************************************/ /******************************************************************************/
#endif #endif

View file

@ -73,7 +73,7 @@ INCLUDES
FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex) FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex)
{ {
strcpy(Name, "FGTranslation"); Name = "FGTranslation";
Udot = Vdot = Wdot = 0.0; Udot = Vdot = Wdot = 0.0;
} }

View file

@ -56,7 +56,17 @@ SENTRY
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#include <math.h> #ifdef FGFS
# include <Include/compiler.h>
# ifdef FG_HAVE_STD_INCLUDES
# include <cmath>
# else
# include <math.h>
# endif
#else
# include <cmath>
#endif
#include "FGModel.h" #include "FGModel.h"
/******************************************************************************* /*******************************************************************************

View file

@ -42,10 +42,20 @@ DEFINES
INCLUDES INCLUDES
*******************************************************************************/ *******************************************************************************/
#ifdef FGFS
# include <Include/compiler.h>
# ifdef FG_HAVE_STD_INCLUDES
# include <cmath>
# else
# include <math.h>
# endif
#else
# include <cmath>
#endif
#include "FGUtility.h" #include "FGUtility.h"
#include "FGState.h" #include "FGState.h"
#include "FGFDMExec.h" #include "FGFDMExec.h"
#include <math.h>
/******************************************************************************* /*******************************************************************************
************************************ CODE ************************************** ************************************ CODE **************************************

View file

@ -4,6 +4,7 @@ libJSBsim_a_SOURCES = FGAircraft.cpp FGAircraft.h \
FGAtmosphere.cpp FGAtmosphere.h \ FGAtmosphere.cpp FGAtmosphere.h \
FGAuxiliary.cpp FGAuxiliary.h \ FGAuxiliary.cpp FGAuxiliary.h \
FGCoefficient.cpp FGCoefficient.h \ FGCoefficient.cpp FGCoefficient.h \
FGDefs.h \
FGFCS.cpp FGFCS.h \ FGFCS.cpp FGFCS.h \
FGFDMExec.cpp FGFDMExec.h \ FGFDMExec.cpp FGFDMExec.h \
FGModel.cpp FGModel.h \ FGModel.cpp FGModel.h \
@ -15,3 +16,7 @@ libJSBsim_a_SOURCES = FGAircraft.cpp FGAircraft.h \
FGUtility.cpp FGUtility.h \ FGUtility.cpp FGUtility.h \
FGEngine.cpp FGEngine.h \ FGEngine.cpp FGEngine.h \
FGTank.cpp FGTank.h FGTank.cpp FGTank.h
INCLUDES += -I$(top_builddir)
DEFS += -DFGFS