Added initial support for native SGI compilers.
Integrated Jon's next version of JSBsim.
This commit is contained in:
parent
00ccbd1f25
commit
5b808fbdc6
27 changed files with 698 additions and 226 deletions
|
@ -22,6 +22,17 @@
|
|||
// (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/FGAircraft.h>
|
||||
#include <FDM/JSBsim/FGFCS.h>
|
||||
|
@ -32,12 +43,6 @@
|
|||
|
||||
#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
|
||||
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.
|
||||
//
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -24,10 +24,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "flight.hxx"
|
||||
#include "JSBsim.hxx"
|
||||
#include "LaRCsim.hxx"
|
||||
|
||||
#include <Debug/logstream.hxx>
|
||||
#include <FDM/External/external.hxx>
|
||||
#include <FDM/LaRCsim/ls_interface.h>
|
||||
|
@ -35,6 +31,10 @@
|
|||
#include <Math/fg_geodesy.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
|
||||
// multiples of "dt". This leads to "jitter" with respect to the real
|
||||
|
@ -195,6 +195,10 @@ void fgFDMSetGroundElevation(int model, double ground_meters) {
|
|||
|
||||
|
||||
// $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
|
||||
// Modifications to incorporate Jon S. Berndts flight model code.
|
||||
//
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/** *****************************************************************************
|
||||
/*******************************************************************************
|
||||
|
||||
Module: FGAircraft.cpp
|
||||
Author: Jon S. Berndt
|
||||
|
@ -131,11 +131,20 @@ stability derivatives for the aircraft.
|
|||
********************************************************************************
|
||||
INCLUDES
|
||||
*******************************************************************************/
|
||||
#include <stdlib.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.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 "FGTranslation.h"
|
||||
|
@ -156,17 +165,16 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex)
|
|||
{
|
||||
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;
|
||||
|
||||
strcpy(Axis[LiftCoeff],"CLIFT");
|
||||
strcpy(Axis[DragCoeff],"CDRAG");
|
||||
strcpy(Axis[SideCoeff],"CSIDE");
|
||||
strcpy(Axis[RollCoeff],"CROLL");
|
||||
strcpy(Axis[PitchCoeff],"CPITCH");
|
||||
strcpy(Axis[YawCoeff],"CYAW");
|
||||
Axis[LiftCoeff] = "CLIFT";
|
||||
Axis[DragCoeff] = "CDRAG";
|
||||
Axis[SideCoeff] = "CSIDE";
|
||||
Axis[RollCoeff] = "CROLL";
|
||||
Axis[PitchCoeff] = "CPITCH";
|
||||
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];
|
||||
char fullpath[256];
|
||||
char filename[256];
|
||||
char aircraftDef[256];
|
||||
char tag[256];
|
||||
string path;
|
||||
string fullpath;
|
||||
string filename;
|
||||
string aircraftDef;
|
||||
string tag;
|
||||
DIR* dir;
|
||||
DIR* coeffdir;
|
||||
struct dirent* dirEntry;
|
||||
|
@ -190,8 +199,8 @@ bool FGAircraft::LoadAircraft(char* fname)
|
|||
struct stat st2;
|
||||
ifstream coeffInFile;
|
||||
|
||||
sprintf(aircraftDef, "/h/curt/projects/FlightGear/Simulator/FDM/JSBsim/aircraft/%s/%s.dat", fname, fname);
|
||||
ifstream aircraftfile(aircraftDef);
|
||||
aircraftDef = aircraft_path + "/" + fname + "/" + fname + ".dat";
|
||||
ifstream aircraftfile(aircraftDef.c_str());
|
||||
|
||||
if (aircraftfile) {
|
||||
aircraftfile >> AircraftName; // String with no embedded spaces
|
||||
|
@ -209,29 +218,30 @@ bool FGAircraft::LoadAircraft(char* fname)
|
|||
numTanks = numEngines = 0;
|
||||
numSelectedOxiTanks = numSelectedFuelTanks = 0;
|
||||
|
||||
while (strstr(tag,"EOF") == 0) {
|
||||
if (strstr(tag,"CGLOC")) {
|
||||
while ( !(tag == "EOF") ) {
|
||||
if (tag == "CGLOC") {
|
||||
aircraftfile >> Xcg; // inches
|
||||
aircraftfile >> Ycg; // inches
|
||||
aircraftfile >> Zcg; // inches
|
||||
} else if (strstr(tag,"EYEPOINTLOC")) {
|
||||
} else if (tag == "EYEPOINTLOC") {
|
||||
aircraftfile >> Xep; // inches
|
||||
aircraftfile >> Yep; // inches
|
||||
aircraftfile >> Zep; // inches
|
||||
} else if (strstr(tag,"TANK")) {
|
||||
} else if (tag == "TANK") {
|
||||
Tank[numTanks] = new FGTank(aircraftfile);
|
||||
switch(Tank[numTanks]->GetType()) {
|
||||
case 0:
|
||||
numSelectedOxiTanks++;
|
||||
break;
|
||||
case 1:
|
||||
case FGTank::ttFUEL:
|
||||
numSelectedFuelTanks++;
|
||||
break;
|
||||
case FGTank::ttOXIDIZER:
|
||||
numSelectedOxiTanks++;
|
||||
break;
|
||||
}
|
||||
numTanks++;
|
||||
} else if (strstr(tag,"ENGINE")) {
|
||||
} else if (tag == "ENGINE") {
|
||||
aircraftfile >> tag;
|
||||
Engine[numEngines] = new FGEngine(FDMExec, tag, numEngines);
|
||||
Engine[numEngines] = new FGEngine(FDMExec, engine_path, tag,
|
||||
numEngines);
|
||||
numEngines++;
|
||||
}
|
||||
aircraftfile >> tag;
|
||||
|
@ -257,20 +267,20 @@ bool FGAircraft::LoadAircraft(char* fname)
|
|||
// track of the number of coefficients registered for each of the
|
||||
// previously mentioned axis.
|
||||
|
||||
sprintf(path,"/h/curt/projects/FlightGear/Simulator/FDM/JSBsim/aircraft/%s/",AircraftName);
|
||||
if (dir = opendir(path)) {
|
||||
path = aircraft_path + "/" + AircraftName + "/";
|
||||
if (dir = opendir(path.c_str())) {
|
||||
|
||||
while (dirEntry = readdir(dir)) {
|
||||
sprintf(fullpath,"%s%s",path,dirEntry->d_name);
|
||||
stat(fullpath,&st);
|
||||
fullpath = path + dirEntry->d_name;
|
||||
stat(fullpath.c_str(),&st);
|
||||
if ((st.st_mode & S_IFMT) == S_IFDIR) {
|
||||
for (int axis_ctr=0; axis_ctr < 6; axis_ctr++) {
|
||||
if (strstr(dirEntry->d_name,Axis[axis_ctr])) {
|
||||
if (coeffdir = opendir(fullpath)) {
|
||||
if (dirEntry->d_name == Axis[axis_ctr]) {
|
||||
if (coeffdir = opendir(fullpath.c_str())) {
|
||||
while (coeffdirEntry = readdir(coeffdir)) {
|
||||
if (coeffdirEntry->d_name[0] != '.') {
|
||||
sprintf(filename,"%s%s/%s",path,Axis[axis_ctr],coeffdirEntry->d_name);
|
||||
stat(filename,&st2);
|
||||
filename = path + Axis[axis_ctr] + "/" + coeffdirEntry->d_name;
|
||||
stat(filename.c_str(),&st2);
|
||||
if (st2.st_size > 6) {
|
||||
Coeff[axis_ctr][coeff_ctr[axis_ctr]] = new FGCoefficient(FDMExec, filename);
|
||||
coeff_ctr[axis_ctr]++;
|
||||
|
@ -331,15 +341,16 @@ void FGAircraft::MassChange()
|
|||
Fshortage = Oshortage = 0.0;
|
||||
for (int t=0; t<numTanks; t++) {
|
||||
switch(Engine[e]->GetType()) {
|
||||
case 0: // Rocket
|
||||
case FGEngine::etRocket:
|
||||
|
||||
switch(Tank[t]->GetType()) {
|
||||
case 0: // Fuel
|
||||
case FGTank::ttFUEL:
|
||||
if (Tank[t]->GetSelected()) {
|
||||
Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
|
||||
numSelectedFuelTanks)*(dt*rate) + Fshortage);
|
||||
}
|
||||
break;
|
||||
case 1: // Oxidizer
|
||||
case FGTank::ttOXIDIZER:
|
||||
if (Tank[t]->GetSelected()) {
|
||||
Oshortage = Tank[t]->Reduce((Engine[e]->CalcOxidizerNeed()/
|
||||
numSelectedOxiTanks)*(dt*rate) + Oshortage);
|
||||
|
@ -347,7 +358,11 @@ void FGAircraft::MassChange()
|
|||
break;
|
||||
}
|
||||
break;
|
||||
default: // piston, turbojet, turbofan, etc.
|
||||
|
||||
case FGEngine::etPiston:
|
||||
case FGEngine::etTurboJet:
|
||||
case FGEngine::etTurboProp:
|
||||
|
||||
if (Tank[t]->GetSelected()) {
|
||||
Fshortage = Tank[t]->Reduce((Engine[e]->CalcFuelNeed()/
|
||||
numSelectedFuelTanks)*(dt*rate) + Fshortage);
|
||||
|
|
|
@ -36,22 +36,11 @@ SENTRY
|
|||
|
||||
/*******************************************************************************
|
||||
COMMENTS, REFERENCES, and NOTES
|
||||
********************************************************************************
|
||||
[1] Cooke, Zyda, Pratt, and McGhee, "NPSNET: Flight Simulation Dynamic Modeling
|
||||
Using Quaternions", Presence, Vol. 1, No. 4, pp. 404-420 Naval Postgraduate
|
||||
School, January 1994
|
||||
[2] D. M. Henderson, "Euler Angles, Quaternions, and Transformation Matrices",
|
||||
JSC 12960, July 1977
|
||||
[3] Richard E. McFarland, "A Standard Kinematic Model for Flight Simulation at
|
||||
NASA-Ames", NASA CR-2497, January 1975
|
||||
[4] Barnes W. McCormick, "Aerodynamics, Aeronautics, and Flight Mechanics",
|
||||
Wiley & Sons, 1979 ISBN 0-471-03032-5
|
||||
[5] Bernard Etkin, "Dynamics of Flight, Stability and Control", Wiley & Sons,
|
||||
1982 ISBN 0-471-08936-2
|
||||
|
||||
The aerodynamic coefficients used in this model are:
|
||||
|
||||
Longitudinal
|
||||
*******************************************************************************/
|
||||
/**
|
||||
The aerodynamic coefficients used in this model typically are:
|
||||
<PRE>
|
||||
<b>Longitudinal</b>
|
||||
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
|
||||
<b>Lateral</b>
|
||||
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
|
||||
<b>Control</b>
|
||||
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
|
||||
</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
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fstream.h>
|
||||
#ifdef FGFS
|
||||
# include <Include/compiler.h>
|
||||
# ifdef FG_HAVE_STD_INCLUDES
|
||||
# include <fstream>
|
||||
# else
|
||||
# include <fstream.h>
|
||||
# endif
|
||||
#else
|
||||
# include <fstream>
|
||||
#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/{<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;}
|
||||
|
||||
// ***************************************************************************
|
||||
/** @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:
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ INCLUDES
|
|||
|
||||
FGAtmosphere::FGAtmosphere(FGFDMExec* fdmex) : FGModel(fdmex)
|
||||
{
|
||||
strcpy(Name,"FGAtmosphere");
|
||||
Name = "FGAtmosphere";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ INCLUDES
|
|||
|
||||
FGAuxiliary::FGAuxiliary(FGFDMExec* fdmex) : FGModel(fdmex)
|
||||
{
|
||||
strcpy(Name, "FGAuxiliary");
|
||||
Name = "FGAuxiliary";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -107,10 +107,7 @@ HISTORY
|
|||
INCLUDES
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#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;
|
||||
|
|
|
@ -37,7 +37,22 @@ SENTRY
|
|||
/*******************************************************************************
|
||||
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
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ See header file.
|
|||
|
||||
HISTORY
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
01/21/99 JSB Created
|
||||
|
||||
********************************************************************************
|
||||
|
@ -38,9 +37,6 @@ INCLUDES
|
|||
*******************************************************************************/
|
||||
|
||||
#include <fstream.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#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:
|
||||
|
|
|
@ -44,6 +44,17 @@ SENTRY
|
|||
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
|
||||
*******************************************************************************/
|
||||
|
@ -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
|
||||
#endif
|
||||
|
|
|
@ -55,7 +55,7 @@ INCLUDES
|
|||
|
||||
FGFCS::FGFCS(FGFDMExec* fdmex) : FGModel(fdmex)
|
||||
{
|
||||
strcpy(Name, "FGFCS");
|
||||
Name = "FGFCS";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -38,14 +38,22 @@ HISTORY
|
|||
INCLUDES
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream.h>
|
||||
#include <time.h>
|
||||
#ifdef FGFS
|
||||
# include <Include/compiler.h>
|
||||
# ifdef FG_HAVE_STD_INCLUDES
|
||||
# include <iostream>
|
||||
# include <ctime>
|
||||
# else
|
||||
# include <iostream.h>
|
||||
# include <time.h>
|
||||
# endif
|
||||
#else
|
||||
# include <iostream>
|
||||
# include <ctime>
|
||||
#endif
|
||||
|
||||
#include "FGFDMExec.h"
|
||||
#include "FGState.h"
|
||||
|
||||
#include "FGAtmosphere.h"
|
||||
#include "FGFCS.h"
|
||||
#include "FGAircraft.h"
|
||||
|
|
|
@ -9,11 +9,13 @@
|
|||
#include "FGAuxiliary.h"
|
||||
#include "FGOutput.h"
|
||||
|
||||
#include <iostream.h>
|
||||
#include <time.h>
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -39,9 +39,27 @@ INCLUDES
|
|||
*******************************************************************************/
|
||||
|
||||
#include "FGDefs.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <iostream.h>
|
||||
|
||||
#ifdef FGFS
|
||||
# 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
|
||||
|
@ -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;};
|
||||
|
|
|
@ -39,11 +39,18 @@ HISTORY
|
|||
INCLUDES
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream.h>
|
||||
#ifdef FGFS
|
||||
# include <Include/compiler.h>
|
||||
# ifdef FG_HAVE_STD_INCLUDES
|
||||
# include <iostream>
|
||||
# else
|
||||
# include <iostream.h>
|
||||
# endif
|
||||
#else
|
||||
# include <iostream>
|
||||
#endif
|
||||
#ifdef HAVE_CURSES
|
||||
#include <ncurses.h>
|
||||
# include <ncurses.h>
|
||||
#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();
|
||||
|
||||
|
|
|
@ -53,7 +53,16 @@ COMMENTS, REFERENCES, and NOTES
|
|||
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 "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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,17 @@ SENTRY
|
|||
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"
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -36,9 +36,16 @@ HISTORY
|
|||
INCLUDES
|
||||
*******************************************************************************/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <string>
|
||||
#ifdef FGFS
|
||||
# include <Include/compiler.h>
|
||||
# ifdef FG_HAVE_STD_INCLUDES
|
||||
# include <cmath>
|
||||
# else
|
||||
# include <math.h>
|
||||
# endif
|
||||
#else
|
||||
# include <cmath>
|
||||
#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;
|
||||
|
|
|
@ -44,9 +44,23 @@ SENTRY
|
|||
INCLUDES
|
||||
*******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fstream.h>
|
||||
#include <string>
|
||||
#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
|
||||
|
||||
#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;}
|
||||
|
|
|
@ -35,10 +35,18 @@ HISTORY
|
|||
********************************************************************************
|
||||
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 <fstream.h>
|
||||
#include <string.h>
|
||||
|
||||
/*******************************************************************************
|
||||
************************************ 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; // "
|
||||
|
|
|
@ -43,8 +43,22 @@ SENTRY
|
|||
/*******************************************************************************
|
||||
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
|
||||
|
@ -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
|
||||
#endif
|
||||
|
|
|
@ -73,7 +73,7 @@ INCLUDES
|
|||
|
||||
FGTranslation::FGTranslation(FGFDMExec* fdmex) : FGModel(fdmex)
|
||||
{
|
||||
strcpy(Name, "FGTranslation");
|
||||
Name = "FGTranslation";
|
||||
Udot = Vdot = Wdot = 0.0;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,17 @@ SENTRY
|
|||
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"
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -42,10 +42,20 @@ DEFINES
|
|||
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 "FGState.h"
|
||||
#include "FGFDMExec.h"
|
||||
#include <math.h>
|
||||
|
||||
/*******************************************************************************
|
||||
************************************ CODE **************************************
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue