1
0
Fork 0

Check return value of FDM::init().

Updated other return values to be bool instead of int.
This commit is contained in:
curt 2000-10-16 14:54:41 +00:00
parent b41fd312c2
commit 47c3f41828
14 changed files with 58 additions and 66 deletions

View file

@ -63,7 +63,7 @@ HISTORY
// Initialize the BalloonSim flight model, dt is the time increment for
// each subsequent iteration through the EOM
int FGBalloonSim::init( double dt ) {
bool FGBalloonSim::init( double dt ) {
sgVec3 temp;
FG_LOG( FG_FLIGHT, FG_INFO, "Starting initializing BalloonSim" );
@ -96,12 +96,12 @@ int FGBalloonSim::init( double dt ) {
FG_LOG( FG_FLIGHT, FG_INFO, "Finished initializing BalloonSim" );
return 1;
return true;
}
// Run an iteration of the EOM (equations of motion)
int FGBalloonSim::update( int multiloop ) {
bool FGBalloonSim::update( int multiloop ) {
double save_alt = 0.0;
// lets try to avoid really screwing up the BalloonSim model
@ -151,18 +151,18 @@ int FGBalloonSim::update( int multiloop ) {
set_Altitude( save_alt );
}
return 1;
return true;
}
// Convert from the FGInterface struct to the BalloonSim
int FGBalloonSim::copy_to_BalloonSim() {
return 1;
bool FGBalloonSim::copy_to_BalloonSim() {
return true;
}
// Convert from the BalloonSim to the FGInterface struct
int FGBalloonSim::copy_from_BalloonSim() {
bool FGBalloonSim::copy_from_BalloonSim() {
sgVec3 temp;
@ -213,7 +213,7 @@ int FGBalloonSim::copy_from_BalloonSim() {
set_sin_cos_longitude( lon );
set_sin_cos_latitude( lat_geod );
return 0;
return true;
}

View file

@ -74,16 +74,16 @@ class FGBalloonSim: public FGInterface {
public:
// copy FDM state to BalloonSim structures
int copy_to_BalloonSim();
bool copy_to_BalloonSim();
// copy FDM state from BalloonSim structures
int copy_from_BalloonSim();
bool copy_from_BalloonSim();
// reset flight params to a specific position
int init( double dt );
bool init( double dt );
// update position based on inputs, positions, velocities, etc.
int update( int multiloop );
bool update( int multiloop );
};

View file

@ -26,24 +26,24 @@
// Initialize the External flight model, dt is the time increment
// for each subsequent iteration through the EOM
int FGExternal::init( double dt ) {
bool FGExternal::init( double dt ) {
// cout << "FGExternal::init()" << endl;
// set valid time for this record
stamp_time();
return 1;
return true;
}
// Run an iteration of the EOM. This is essentially a NOP here
// because these values are getting filled in elsewhere based on
// external input.
int FGExternal::update( int multiloop ) {
bool FGExternal::update( int multiloop ) {
// cout << "FGExternal::update()" << endl;
// double time_step = (1.0 / current_options.get_model_hz()) * multiloop;
return 1;
return true;
}

View file

@ -32,10 +32,10 @@ class FGExternal: public FGInterface {
public:
// reset flight params to a specific position
int init( double dt );
bool init( double dt );
// update position based on inputs, positions, velocities, etc.
int update( int multiloop );
bool update( int multiloop );
};

View file

@ -60,7 +60,7 @@
// Initialize the JSBsim flight model, dt is the time increment for
// each subsequent iteration through the EOM
int FGJSBsim::init( double dt ) {
bool FGJSBsim::init( double dt ) {
bool result;
@ -83,9 +83,9 @@ int FGJSBsim::init( double dt ) {
if (result) {
FG_LOG( FG_FLIGHT, FG_INFO, " loaded aircraft " << current_options.get_aircraft() );
} else {
FG_LOG( FG_FLIGHT, FG_INFO, " aircraft" << current_options.get_aircraft()
<< " does not exist");
return 0;
FG_LOG( FG_FLIGHT, FG_INFO, " aircraft " << current_options.get_aircraft()
<< " does not exist" );
return false;
}
FDMExec.GetAtmosphere()->SetExTemperature(get_Static_temperature());
@ -129,9 +129,6 @@ int FGJSBsim::init( double dt ) {
fgic->SetLatitudeRadIC(get_Lat_geocentric());
fgic->SetLongitudeRadIC(get_Longitude());
//FG_LOG( FG_FLIGHT, FG_INFO, " gamma: " << current_options.get_Gamma());
FG_LOG( FG_FLIGHT, FG_INFO, " phi: " << get_Phi());
//FG_LOG( FG_FLIGHT, FG_INFO, " theta: " << get_Theta() );
@ -184,14 +181,14 @@ int FGJSBsim::init( double dt ) {
copy_from_JSBsim();
return 1;
return true;
}
/******************************************************************************/
// Run an iteration of the EOM (equations of motion)
int FGJSBsim::update( int multiloop ) {
bool FGJSBsim::update( int multiloop ) {
double save_alt = 0.0;
double time_step = (1.0 / current_options.get_model_hz()) * multiloop;
double start_elev = get_Altitude();
@ -237,14 +234,14 @@ int FGJSBsim::update( int multiloop ) {
double end_elev = get_Altitude();
return 1;
return true;
}
/******************************************************************************/
// Convert from the FGInterface struct to the JSBsim generic_ struct
int FGJSBsim::copy_to_JSBsim() {
bool FGJSBsim::copy_to_JSBsim() {
// copy control positions into the JSBsim structure
FDMExec.GetFCS()->SetDaCmd( controls.get_aileron());
@ -273,14 +270,14 @@ int FGJSBsim::copy_to_JSBsim() {
get_V_east_airmass(),
get_V_down_airmass());
return 1;
return true;
}
/******************************************************************************/
// Convert from the JSBsim generic_ struct to the FGInterface struct
int FGJSBsim::copy_from_JSBsim() {
bool FGJSBsim::copy_from_JSBsim() {
set_Inertias( FDMExec.GetAircraft()->GetMass(),
FDMExec.GetAircraft()->GetIxx(),
@ -391,5 +388,5 @@ int FGJSBsim::copy_from_JSBsim() {
set_Climb_Rate(FDMExec.GetPosition()->Gethdot());
return 1;
return true;
}

View file

@ -41,16 +41,16 @@ class FGJSBsim: public FGInterface {
public:
// copy FDM state to LaRCsim structures
int copy_to_JSBsim();
bool copy_to_JSBsim();
// copy FDM state from LaRCsim structures
int copy_from_JSBsim();
bool copy_from_JSBsim();
// reset flight params to a specific position
int init( double dt );
bool init( double dt );
// update position based on inputs, positions, velocities, etc.
int update( int multiloop );
bool update( int multiloop );
};

View file

@ -38,7 +38,7 @@ INCLUDES
#include "FGNozzle.h"
static const char *IdSrc = "$Header$";
static const char *IdHdr = ID_NOZZLE;
static const char *IdHdr = "";
/*******************************************************************************
************************************ CODE **************************************

View file

@ -24,19 +24,14 @@ libJSBSim_a_SOURCES = \
FGDefs.h \
FGFCS.cpp FGFCS.h \
FGFDMExec.cpp FGFDMExec.h \
FGForce.cpp FGForce.h \
FGInitialCondition.cpp FGInitialCondition.h \
FGLGear.cpp FGLGear.h \
FGMatrix.cpp FGMatrix.h \
FGModel.cpp FGModel.h \
FGNozzle.cpp FGNozzle.h \
FGOutput.cpp FGOutput.h \
FGPosition.cpp FGPosition.h \
FGPropeller.cpp FGPropeller.h \
FGRotation.cpp FGRotation.h \
FGRotor.cpp FGRotor.h \
FGState.cpp FGState.h \
FGThruster.cpp FGThruster.h \
FGTranslation.cpp FGTranslation.h \
FGTrim.cpp FGTrim.h \
FGTrimAxis.cpp FGTrimAxis.h \

View file

@ -37,7 +37,7 @@
// Initialize the LaRCsim flight model, dt is the time increment for
// each subsequent iteration through the EOM
int FGLaRCsim::init( double dt ) {
bool FGLaRCsim::init( double dt ) {
if ( current_options.get_aircraft() == "c172" ) {
// Initialize our little engine that hopefully might
@ -79,12 +79,12 @@ int FGLaRCsim::init( double dt ) {
// set valid time for this record
stamp_time();
return 1;
return true;
}
// Run an iteration of the EOM (equations of motion)
int FGLaRCsim::update( int multiloop ) {
bool FGLaRCsim::update( int multiloop ) {
// cout << "FGLaRCsim::update()" << endl;
if ( current_options.get_aircraft() == "c172" ) {
@ -191,12 +191,12 @@ int FGLaRCsim::update( int multiloop ) {
set_Climb_Rate( (end_elev - start_elev) / time_step );
}
return 1;
return true;
}
// Convert from the FGInterface struct to the LaRCsim generic_ struct
int FGLaRCsim::copy_to_LaRCsim () {
bool FGLaRCsim::copy_to_LaRCsim () {
Mass = get_Mass();
I_xx = get_I_xx();
I_yy = get_I_yy();
@ -367,12 +367,12 @@ int FGLaRCsim::copy_to_LaRCsim () {
// Y_pilot_rwy = get_Y_pilot_rwy();
// H_pilot_rwy = get_H_pilot_rwy();
return 1;
return true;
}
// Convert from the LaRCsim generic_ struct to the FGInterface struct
int FGLaRCsim::copy_from_LaRCsim() {
bool FGLaRCsim::copy_from_LaRCsim() {
// Mass properties and geometry values
set_Inertias( Mass, I_xx, I_yy, I_zz, I_xz );
@ -515,5 +515,5 @@ int FGLaRCsim::copy_from_LaRCsim() {
// printf("sin_lon %f cos_lon %f\n",
// get_sin_longitude(), get_cos_longitude());
return 1;
return true;
}

View file

@ -38,16 +38,16 @@ class FGLaRCsim: public FGInterface {
public:
// copy FDM state to LaRCsim structures
int copy_to_LaRCsim();
bool copy_to_LaRCsim();
// copy FDM state from LaRCsim structures
int copy_from_LaRCsim();
bool copy_from_LaRCsim();
// reset flight params to a specific position
int init( double dt );
bool init( double dt );
// update position based on inputs, positions, velocities, etc.
int update( int multiloop );
bool update( int multiloop );
};

View file

@ -33,16 +33,16 @@
// Initialize the Magic Carpet flight model, dt is the time increment
// for each subsequent iteration through the EOM
int FGMagicCarpet::init( double dt ) {
bool FGMagicCarpet::init( double dt ) {
// set valid time for this record
stamp_time();
return 1;
return true;
}
// Run an iteration of the EOM (equations of motion)
int FGMagicCarpet::update( int multiloop ) {
bool FGMagicCarpet::update( int multiloop ) {
// cout << "FGLaRCsim::update()" << endl;
double time_step = (1.0 / current_options.get_model_hz()) * multiloop;
@ -93,5 +93,5 @@ int FGMagicCarpet::update( int multiloop ) {
set_Sea_level_radius( sl_radius * METER_TO_FEET);
set_Altitude( get_Altitude() + climb );
return 1;
return true;
}

View file

@ -32,10 +32,10 @@ class FGMagicCarpet: public FGInterface {
public:
// reset flight params to a specific position
int init( double dt );
bool init( double dt );
// update position based on inputs, positions, velocities, etc.
int update( int multiloop );
bool update( int multiloop );
};

View file

@ -79,15 +79,15 @@ FGInterface::~FGInterface() {
}
int FGInterface::init( double dt ) {
bool FGInterface::init( double dt ) {
cout << "dummy init() ... SHOULDN'T BE CALLED!" << endl;
return 0;
return false;
}
int FGInterface::update( int multi_loop ) {
bool FGInterface::update( int multi_loop ) {
cout << "dummy update() ... SHOULDN'T BE CALLED!" << endl;
return 0;
return false;
}

View file

@ -243,8 +243,8 @@ public:
FGInterface(void);
virtual ~FGInterface();
virtual int init( double dt );
virtual int update( int multi_loop );
virtual bool init( double dt );
virtual bool update( int multi_loop );
// Define the various supported flight models (many not yet implemented)
enum {