From aabdd355f014ddefeee05c4f495ead1b47c1d18d Mon Sep 17 00:00:00 2001 From: david Date: Sat, 22 Dec 2001 17:33:27 +0000 Subject: [PATCH] Modified FGSubsystem::update() to take an int parameter for delta time (i.e. multiloop). Most subsystems currently ignore the parameter, but eventually, it will allow all subsystems to update by time rather than by framerate. --- src/Cockpit/panel.cxx | 2 +- src/Cockpit/panel.hxx | 2 +- src/Cockpit/radiostack.cxx | 4 ++-- src/Cockpit/radiostack.hxx | 2 +- src/Controls/controls.cxx | 2 +- src/Controls/controls.hxx | 2 +- src/FDM/ADA.cxx | 4 +--- src/FDM/ADA.hxx | 2 +- src/FDM/Balloon.cxx | 4 +--- src/FDM/Balloon.h | 2 +- src/FDM/External.cxx | 5 +---- src/FDM/External.hxx | 2 +- src/FDM/ExternalNet.cxx | 4 +--- src/FDM/ExternalNet.hxx | 2 +- src/FDM/JSBSim.cxx | 4 ++-- src/FDM/JSBSim.hxx | 2 +- src/FDM/JSBSim/FGAircraft.cpp | 42 ++++++++++++++++++++++++++++++----- src/FDM/LaRCsim.cxx | 4 +--- src/FDM/LaRCsim.hxx | 2 +- src/FDM/MagicCarpet.cxx | 4 +--- src/FDM/MagicCarpet.hxx | 2 +- src/FDM/NullFDM.cxx | 4 +--- src/FDM/NullFDM.hxx | 2 +- src/FDM/YASim/YASim.cxx | 6 ++--- src/FDM/YASim/YASim.hxx | 2 +- src/FDM/flight.cxx | 8 +------ src/FDM/flight.hxx | 3 +-- src/Input/input.cxx | 2 +- src/Input/input.hxx | 2 +- src/Main/fgfs.hxx | 2 +- src/Main/main.cxx | 12 +++++----- src/Scenery/scenery.cxx | 2 +- src/Scenery/scenery.hxx | 2 +- src/Sound/fg_fx.cxx | 2 +- src/Sound/fg_fx.hxx | 2 +- src/Sound/soundmgr.cxx | 2 +- src/Sound/soundmgr.hxx | 2 +- 37 files changed, 81 insertions(+), 73 deletions(-) diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index d20af07af..a75222789 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -253,7 +253,7 @@ FGPanel::unbind () * Update the panel. */ void -FGPanel::update () +FGPanel::update (int dt) { // Do nothing if the panel isn't visible. if ( !fgPanelVisible() ) { diff --git a/src/Cockpit/panel.hxx b/src/Cockpit/panel.hxx index 0d29ba503..d58ccf333 100644 --- a/src/Cockpit/panel.hxx +++ b/src/Cockpit/panel.hxx @@ -141,7 +141,7 @@ public: virtual void init (); virtual void bind (); virtual void unbind (); - virtual void update (); + virtual void update (int dt); virtual void update (GLfloat winx, GLfloat winw, GLfloat winy, GLfloat winh); // transfer pointer ownership!!! diff --git a/src/Cockpit/radiostack.cxx b/src/Cockpit/radiostack.cxx index 14b940c03..8d12aef13 100644 --- a/src/Cockpit/radiostack.cxx +++ b/src/Cockpit/radiostack.cxx @@ -140,7 +140,7 @@ FGRadioStack::init () blink.stamp(); search(); - update(); + update(1); // FIXME: use dt // Search radio database once per second global_events.Register( "fgRadioSearch()", fgRadioSearch, @@ -400,7 +400,7 @@ double FGRadioStack::adjustILSRange( double stationElev, double aircraftElev, // Update the various nav values based on position and valid tuned in navs void -FGRadioStack::update() +FGRadioStack::update(int dt) { //DCL string transmission; diff --git a/src/Cockpit/radiostack.hxx b/src/Cockpit/radiostack.hxx index f96e1f432..c003a73f8 100644 --- a/src/Cockpit/radiostack.hxx +++ b/src/Cockpit/radiostack.hxx @@ -215,7 +215,7 @@ public: void init (); void bind (); void unbind (); - void update (); + void update (int dt); // Update nav/adf radios based on current postition void search (); diff --git a/src/Controls/controls.cxx b/src/Controls/controls.cxx index 0b4f7ff94..286af8010 100644 --- a/src/Controls/controls.cxx +++ b/src/Controls/controls.cxx @@ -176,7 +176,7 @@ FGControls::unbind () void -FGControls::update () +FGControls::update (int dt) { } diff --git a/src/Controls/controls.hxx b/src/Controls/controls.hxx index de965ec2c..0cc5146c7 100644 --- a/src/Controls/controls.hxx +++ b/src/Controls/controls.hxx @@ -92,7 +92,7 @@ public: void init (); void bind (); void unbind (); - void update (); + void update (int dt); // Reset function void reset_all(void); diff --git a/src/FDM/ADA.cxx b/src/FDM/ADA.cxx index 1dd27bae8..0fc0aeee8 100644 --- a/src/FDM/ADA.cxx +++ b/src/FDM/ADA.cxx @@ -198,7 +198,7 @@ void FGADA::init() { // Run an iteration of the EOM. This is essentially a NOP here // because these values are getting filled in elsewhere based on // external input. -bool FGADA::update( int multiloop ) { +void FGADA::update( int multiloop ) { // cout << "FGADA::update()" << endl; char Buffer[numberofbytes]; @@ -223,8 +223,6 @@ bool FGADA::update( int multiloop ) { memcpy (&OutBuffer, &visuals_to_sixdof, sizeof (OutBuffer)); int result = fdmsock->write(OutBuffer, nbytes); } - - return true; } // Convert from the FGInterface struct to the FGADA struct (output) diff --git a/src/FDM/ADA.hxx b/src/FDM/ADA.hxx index fdc66cc1a..bef66d88b 100644 --- a/src/FDM/ADA.hxx +++ b/src/FDM/ADA.hxx @@ -79,7 +79,7 @@ public: void init(); // update position based on inputs, positions, velocities, etc. - bool update( int multiloop ); + void update(int dt); }; diff --git a/src/FDM/Balloon.cxx b/src/FDM/Balloon.cxx index 6790df396..dd5bc016d 100644 --- a/src/FDM/Balloon.cxx +++ b/src/FDM/Balloon.cxx @@ -113,7 +113,7 @@ void FGBalloonSim::init() { // Run an iteration of the EOM (equations of motion) -bool FGBalloonSim::update( int multiloop ) { +void FGBalloonSim::update( int multiloop ) { double save_alt = 0.0; // lets try to avoid really screwing up the BalloonSim model @@ -162,8 +162,6 @@ bool FGBalloonSim::update( int multiloop ) { if ( save_alt < -9000.0 ) { set_Altitude( save_alt ); } - - return true; } diff --git a/src/FDM/Balloon.h b/src/FDM/Balloon.h index 5661bebbc..b180a3a53 100644 --- a/src/FDM/Balloon.h +++ b/src/FDM/Balloon.h @@ -75,7 +75,7 @@ public: void init(); // update position based on inputs, positions, velocities, etc. - bool update( int multiloop ); + void update( int multiloop ); }; diff --git a/src/FDM/External.cxx b/src/FDM/External.cxx index b0406dc38..0c712c1c7 100644 --- a/src/FDM/External.cxx +++ b/src/FDM/External.cxx @@ -43,12 +43,9 @@ void FGExternal::init() { // Run an iteration of the EOM. This is essentially a NOP here // because these values are getting filled in elsewhere based on // external input. -bool FGExternal::update( int multiloop ) { +void FGExternal::update( int multiloop ) { // cout << "FGExternal::update()" << endl; // double time_step = (1.0 / fgGetInt("/sim/model-hz")) // * multiloop; - - - return true; } diff --git a/src/FDM/External.hxx b/src/FDM/External.hxx index 8d2adef38..5ebad88e3 100644 --- a/src/FDM/External.hxx +++ b/src/FDM/External.hxx @@ -38,7 +38,7 @@ public: void init(); // update position based on inputs, positions, velocities, etc. - bool update( int multiloop ); + void update( int multiloop ); }; diff --git a/src/FDM/ExternalNet.cxx b/src/FDM/ExternalNet.cxx index 4d480d487..5953d0d40 100644 --- a/src/FDM/ExternalNet.cxx +++ b/src/FDM/ExternalNet.cxx @@ -65,8 +65,6 @@ void FGExternalNet::init() { // Run an iteration of the EOM. This is a NOP here because the flight // model values are getting filled in elsewhere (most likely from some // external source.) -bool FGExternalNet::update( int multiloop ) { +void FGExternalNet::update( int multiloop ) { // cout << "FGExternalNet::update()" << endl; - - return true; } diff --git a/src/FDM/ExternalNet.hxx b/src/FDM/ExternalNet.hxx index d60b7c6fc..b913d873f 100644 --- a/src/FDM/ExternalNet.hxx +++ b/src/FDM/ExternalNet.hxx @@ -53,7 +53,7 @@ public: void init(); // update the fdm - bool update( int multiloop ); + void update( int multiloop ); }; diff --git a/src/FDM/JSBSim.cxx b/src/FDM/JSBSim.cxx index b869f3e74..8fe89232d 100644 --- a/src/FDM/JSBSim.cxx +++ b/src/FDM/JSBSim.cxx @@ -230,7 +230,8 @@ void FGJSBsim::init() { // Run an iteration of the EOM (equations of motion) -bool FGJSBsim::update( int multiloop ) { +void +FGJSBsim::update( int multiloop ) { int i; @@ -306,7 +307,6 @@ bool FGJSBsim::update( int multiloop ) { // translate JSBsim back to FG structure so that the // autopilot (and the rest of the sim can use the updated values copy_from_JSBsim(); - return true; } /******************************************************************************/ diff --git a/src/FDM/JSBSim.hxx b/src/FDM/JSBSim.hxx index 6d9f66f34..8e58aa9d8 100644 --- a/src/FDM/JSBSim.hxx +++ b/src/FDM/JSBSim.hxx @@ -215,7 +215,7 @@ public: /** Update the position based on inputs, positions, velocities, etc. @param multiloop number of times to loop through the FDM @return true if successful */ - bool update( int multiloop ); + void update( int multiloop ); bool ToggleDataLogging(bool state); bool ToggleDataLogging(void); void do_trim(void); diff --git a/src/FDM/JSBSim/FGAircraft.cpp b/src/FDM/JSBSim/FGAircraft.cpp index ac3f48459..5f0573b4f 100644 --- a/src/FDM/JSBSim/FGAircraft.cpp +++ b/src/FDM/JSBSim/FGAircraft.cpp @@ -107,16 +107,14 @@ FGAircraft::FGAircraft(FGFDMExec* fdmex) : FGModel(fdmex) WingIncidence=0; impending_stall = 0; - if (debug_lvl & 2) cout << "Instantiated: " << Name << endl; + Debug(0); } - //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - FGAircraft::~FGAircraft() { - if (debug_lvl & 2) cout << "Destroyed: FGAircraft" << endl; + Debug(1); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -376,9 +374,43 @@ bool FGAircraft::ReadOutput(FGConfigFile* AC_cfg) } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +// The bitmasked value choices are as follows: +// unset: In this case (the default) JSBSim would only print +// out the normally expected messages, essentially echoing +// the config files as they are read. If the environment +// variable is not set, debug_lvl is set to 1 internally +// 0: This requests JSBSim not to output any messages +// whatsoever. +// 1: This value explicity requests the normal JSBSim +// startup messages +// 2: This value asks for a message to be printed out when +// a class is instantiated +// 4: When this value is set, a message is displayed when a +// FGModel object executes its Run() method +// 8: When this value is set, various runtime state variables +// are printed out periodically +// 16: When set various parameters are sanity checked and +// a message is printed out when they go out of bounds void FGAircraft::Debug(int from) { - //TODO: Add your source code here + if (debug_lvl <= 0) return; + + if (debug_lvl & 1) { // Standard console startup message output + if (from == 0) { // Constructor + } + } + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + if (from == 0) cout << "Instantiated: FGAircraft" << endl; + if (from == 1) cout << "Destroyed: FGAircraft" << endl; + } + if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects + } + if (debug_lvl & 8 ) { // Runtime state variables + } + if (debug_lvl & 16) { // Sanity checking + } + if (debug_lvl & 32) { // Turbulence + } } diff --git a/src/FDM/LaRCsim.cxx b/src/FDM/LaRCsim.cxx index cf3682814..e6c8695bf 100644 --- a/src/FDM/LaRCsim.cxx +++ b/src/FDM/LaRCsim.cxx @@ -97,7 +97,7 @@ void FGLaRCsim::init() { // Run an iteration of the EOM (equations of motion) -bool FGLaRCsim::update( int multiloop ) { +void FGLaRCsim::update( int multiloop ) { if ( aero->getStringValue() == "c172" ) { // set control inputs @@ -215,8 +215,6 @@ bool FGLaRCsim::update( int multiloop ) { if ( save_alt < -9000.0 ) { set_Altitude( save_alt ); } - - return true; } diff --git a/src/FDM/LaRCsim.hxx b/src/FDM/LaRCsim.hxx index 3d598dd52..078579621 100644 --- a/src/FDM/LaRCsim.hxx +++ b/src/FDM/LaRCsim.hxx @@ -58,7 +58,7 @@ public: void init(); // update position based on inputs, positions, velocities, etc. - bool update( int multiloop ); + void update( int multiloop ); // Positions void set_Latitude(double lat); //geocentric diff --git a/src/FDM/MagicCarpet.cxx b/src/FDM/MagicCarpet.cxx index 624ae51e2..58bf6ec31 100644 --- a/src/FDM/MagicCarpet.cxx +++ b/src/FDM/MagicCarpet.cxx @@ -49,7 +49,7 @@ void FGMagicCarpet::init() { // Run an iteration of the EOM (equations of motion) -bool FGMagicCarpet::update( int multiloop ) { +void FGMagicCarpet::update( int multiloop ) { // cout << "FGLaRCsim::update()" << endl; double time_step = get_delta_t() * multiloop; @@ -102,6 +102,4 @@ bool FGMagicCarpet::update( int multiloop ) { // cout << "(setto) sea level radius (ft) = " << get_Sea_level_radius() << endl; _set_Sea_level_radius( sl_radius * SG_METER_TO_FEET); _set_Altitude( get_Altitude() + climb ); - - return true; } diff --git a/src/FDM/MagicCarpet.hxx b/src/FDM/MagicCarpet.hxx index e6f6efe80..12d3c656e 100644 --- a/src/FDM/MagicCarpet.hxx +++ b/src/FDM/MagicCarpet.hxx @@ -38,7 +38,7 @@ public: void init(); // update position based on inputs, positions, velocities, etc. - bool update( int multiloop ); + void update( int multiloop ); }; diff --git a/src/FDM/NullFDM.cxx b/src/FDM/NullFDM.cxx index 54b410228..700824578 100644 --- a/src/FDM/NullFDM.cxx +++ b/src/FDM/NullFDM.cxx @@ -43,8 +43,6 @@ void FGNullFDM::init() { // Run an iteration of the EOM. This is a NOP here because the flight // model values are getting filled in elsewhere (most likely from some // external source.) -bool FGNullFDM::update( int multiloop ) { +void FGNullFDM::update( int multiloop ) { // cout << "FGNullFDM::update()" << endl; - - return true; } diff --git a/src/FDM/NullFDM.hxx b/src/FDM/NullFDM.hxx index 94dd32826..c970d4dbf 100644 --- a/src/FDM/NullFDM.hxx +++ b/src/FDM/NullFDM.hxx @@ -39,7 +39,7 @@ public: void init(); // update position based on inputs, positions, velocities, etc. - bool update( int multiloop ); + void update( int multiloop ); }; diff --git a/src/FDM/YASim/YASim.cxx b/src/FDM/YASim/YASim.cxx index 44925db31..1e8b2b009 100644 --- a/src/FDM/YASim/YASim.cxx +++ b/src/FDM/YASim/YASim.cxx @@ -172,11 +172,11 @@ void YASim::init() set_inited(true); } -bool YASim::update(int iterations) +void YASim::update(int iterations) { // If we're crashed, then we don't care if(_fdm->getAirplane()->getModel()->isCrashed()) - return true; + return; int i; for(i=0; i */ - virtual void update () = 0; + virtual void update (int dt) = 0; }; diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 3bf277d52..9970247e1 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -861,10 +861,10 @@ void fgRenderFrame( void ) { // glDisable( GL_TEXTURE_2D ); // update the input subsystem - current_input.update(); + current_input.update(1); // FIXME: use real dt // update the controls subsystem - globals->get_controls()->update(); + globals->get_controls()->update(1); // FIXME: use real dt hud_and_panel->apply(); fgCockpitUpdate(); @@ -875,7 +875,7 @@ void fgRenderFrame( void ) { // update the panel subsystem if ( current_panel != NULL ) { - current_panel->update(); + current_panel->update(1); // FIXME: use real dt } // We can do translucent menus, so why not. :-) @@ -1024,7 +1024,7 @@ void fgUpdateTimeDepCalcs() { cur_fdm_state->get_Latitude() ); // Update radio stack model - current_radiostack->update(); + current_radiostack->update(1); // FIXME: use dt } @@ -1229,8 +1229,8 @@ static void fgMainLoop( void ) { // Run audio scheduler #ifdef ENABLE_AUDIO_SUPPORT if ( fgGetBool("/sim/sound") && globals->get_soundmgr()->is_working() ) { - globals->get_fx()->update(); - globals->get_soundmgr()->update(); + globals->get_fx()->update(1); // FIXME: use dt + globals->get_soundmgr()->update(1); // FIXME: use dt } #endif diff --git a/src/Scenery/scenery.cxx b/src/Scenery/scenery.cxx index 1341d21d4..0f78f66ac 100644 --- a/src/Scenery/scenery.cxx +++ b/src/Scenery/scenery.cxx @@ -61,7 +61,7 @@ FGScenery::~FGScenery() { void FGScenery::init() { } -void FGScenery::update() { +void FGScenery::update(int dt) { } void FGScenery::bind() { diff --git a/src/Scenery/scenery.hxx b/src/Scenery/scenery.hxx index f67883756..4e4531dfe 100644 --- a/src/Scenery/scenery.hxx +++ b/src/Scenery/scenery.hxx @@ -67,7 +67,7 @@ public: void init (); void bind (); void unbind (); - void update (); + void update (int dt); inline double get_cur_elev() const { return cur_elev; } inline void set_cur_elev( double e ) { cur_elev = e; } diff --git a/src/Sound/fg_fx.cxx b/src/Sound/fg_fx.cxx index 25163f91c..9a3f85ecf 100644 --- a/src/Sound/fg_fx.cxx +++ b/src/Sound/fg_fx.cxx @@ -215,7 +215,7 @@ FGFX::unbind () } void -FGFX::update () +FGFX::update (int dt) { FGSoundMgr * mgr = globals->get_soundmgr(); int i; diff --git a/src/Sound/fg_fx.hxx b/src/Sound/fg_fx.hxx index 15b7de961..2c403bd0f 100644 --- a/src/Sound/fg_fx.hxx +++ b/src/Sound/fg_fx.hxx @@ -58,7 +58,7 @@ public: virtual void init (); virtual void bind (); virtual void unbind (); - virtual void update (); + virtual void update (int dt); private: diff --git a/src/Sound/soundmgr.cxx b/src/Sound/soundmgr.cxx index 0103efd4c..a1caaf6ff 100644 --- a/src/Sound/soundmgr.cxx +++ b/src/Sound/soundmgr.cxx @@ -121,7 +121,7 @@ void FGSoundMgr::unbind () // run the audio scheduler -void FGSoundMgr::update() { +void FGSoundMgr::update(int dt) { SGTimeStamp current; current.stamp(); diff --git a/src/Sound/soundmgr.hxx b/src/Sound/soundmgr.hxx index 78b09f639..8abc4bbd6 100644 --- a/src/Sound/soundmgr.hxx +++ b/src/Sound/soundmgr.hxx @@ -121,7 +121,7 @@ public: /** * Run the audio scheduler. */ - void update(); + void update(int dt); // is audio working? -- 2.39.5