From 47c3f4182886fa790d074b76b3225f59f5918200 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 16 Oct 2000 14:54:41 +0000 Subject: [PATCH] Check return value of FDM::init(). Updated other return values to be bool instead of int. --- src/FDM/Balloon.cxx | 16 ++++++++-------- src/FDM/Balloon.h | 8 ++++---- src/FDM/External.cxx | 8 ++++---- src/FDM/External.hxx | 4 ++-- src/FDM/JSBSim.cxx | 25 +++++++++++-------------- src/FDM/JSBSim.hxx | 8 ++++---- src/FDM/JSBSim/FGNozzle.cpp | 2 +- src/FDM/JSBSim/Makefile.am | 5 ----- src/FDM/LaRCsim.cxx | 16 ++++++++-------- src/FDM/LaRCsim.hxx | 8 ++++---- src/FDM/MagicCarpet.cxx | 8 ++++---- src/FDM/MagicCarpet.hxx | 4 ++-- src/FDM/flight.cxx | 8 ++++---- src/FDM/flight.hxx | 4 ++-- 14 files changed, 58 insertions(+), 66 deletions(-) diff --git a/src/FDM/Balloon.cxx b/src/FDM/Balloon.cxx index 6a89a73c2..211b7c6ac 100644 --- a/src/FDM/Balloon.cxx +++ b/src/FDM/Balloon.cxx @@ -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; } diff --git a/src/FDM/Balloon.h b/src/FDM/Balloon.h index 8ba627579..e6e0ae095 100644 --- a/src/FDM/Balloon.h +++ b/src/FDM/Balloon.h @@ -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 ); }; diff --git a/src/FDM/External.cxx b/src/FDM/External.cxx index 9284c9a46..f5d3b8f4a 100644 --- a/src/FDM/External.cxx +++ b/src/FDM/External.cxx @@ -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; } diff --git a/src/FDM/External.hxx b/src/FDM/External.hxx index 159615907..a9e8c8ef8 100644 --- a/src/FDM/External.hxx +++ b/src/FDM/External.hxx @@ -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 ); }; diff --git a/src/FDM/JSBSim.cxx b/src/FDM/JSBSim.cxx index 6abc5e2a0..db8ee0c3f 100644 --- a/src/FDM/JSBSim.cxx +++ b/src/FDM/JSBSim.cxx @@ -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; } diff --git a/src/FDM/JSBSim.hxx b/src/FDM/JSBSim.hxx index 093719b7f..3933678c9 100644 --- a/src/FDM/JSBSim.hxx +++ b/src/FDM/JSBSim.hxx @@ -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 ); }; diff --git a/src/FDM/JSBSim/FGNozzle.cpp b/src/FDM/JSBSim/FGNozzle.cpp index d1ec626e2..9c0edbf53 100644 --- a/src/FDM/JSBSim/FGNozzle.cpp +++ b/src/FDM/JSBSim/FGNozzle.cpp @@ -38,7 +38,7 @@ INCLUDES #include "FGNozzle.h" static const char *IdSrc = "$Header$"; -static const char *IdHdr = ID_NOZZLE; +static const char *IdHdr = ""; /******************************************************************************* ************************************ CODE ************************************** diff --git a/src/FDM/JSBSim/Makefile.am b/src/FDM/JSBSim/Makefile.am index 2bf1260c8..53838094b 100644 --- a/src/FDM/JSBSim/Makefile.am +++ b/src/FDM/JSBSim/Makefile.am @@ -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 \ diff --git a/src/FDM/LaRCsim.cxx b/src/FDM/LaRCsim.cxx index 568913cc3..f1e742236 100644 --- a/src/FDM/LaRCsim.cxx +++ b/src/FDM/LaRCsim.cxx @@ -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; } diff --git a/src/FDM/LaRCsim.hxx b/src/FDM/LaRCsim.hxx index 5007409e6..97773f3c9 100644 --- a/src/FDM/LaRCsim.hxx +++ b/src/FDM/LaRCsim.hxx @@ -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 ); }; diff --git a/src/FDM/MagicCarpet.cxx b/src/FDM/MagicCarpet.cxx index 708046b4d..12a018e3d 100644 --- a/src/FDM/MagicCarpet.cxx +++ b/src/FDM/MagicCarpet.cxx @@ -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; } diff --git a/src/FDM/MagicCarpet.hxx b/src/FDM/MagicCarpet.hxx index 5705b8b00..21c4ffecc 100644 --- a/src/FDM/MagicCarpet.hxx +++ b/src/FDM/MagicCarpet.hxx @@ -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 ); }; diff --git a/src/FDM/flight.cxx b/src/FDM/flight.cxx index 93a6c27ea..df2da8b7a 100644 --- a/src/FDM/flight.cxx +++ b/src/FDM/flight.cxx @@ -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; } diff --git a/src/FDM/flight.hxx b/src/FDM/flight.hxx index c9e43e6f0..3a724b562 100644 --- a/src/FDM/flight.hxx +++ b/src/FDM/flight.hxx @@ -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 { -- 2.39.5