]> git.mxchange.org Git - flightgear.git/commitdiff
Modified FGSubsystem::update() to take an int parameter for delta time
authordavid <david>
Sat, 22 Dec 2001 17:33:27 +0000 (17:33 +0000)
committerdavid <david>
Sat, 22 Dec 2001 17:33:27 +0000 (17:33 +0000)
(i.e. multiloop).  Most subsystems currently ignore the parameter, but
eventually, it will allow all subsystems to update by time rather than
by framerate.

37 files changed:
src/Cockpit/panel.cxx
src/Cockpit/panel.hxx
src/Cockpit/radiostack.cxx
src/Cockpit/radiostack.hxx
src/Controls/controls.cxx
src/Controls/controls.hxx
src/FDM/ADA.cxx
src/FDM/ADA.hxx
src/FDM/Balloon.cxx
src/FDM/Balloon.h
src/FDM/External.cxx
src/FDM/External.hxx
src/FDM/ExternalNet.cxx
src/FDM/ExternalNet.hxx
src/FDM/JSBSim.cxx
src/FDM/JSBSim.hxx
src/FDM/JSBSim/FGAircraft.cpp
src/FDM/LaRCsim.cxx
src/FDM/LaRCsim.hxx
src/FDM/MagicCarpet.cxx
src/FDM/MagicCarpet.hxx
src/FDM/NullFDM.cxx
src/FDM/NullFDM.hxx
src/FDM/YASim/YASim.cxx
src/FDM/YASim/YASim.hxx
src/FDM/flight.cxx
src/FDM/flight.hxx
src/Input/input.cxx
src/Input/input.hxx
src/Main/fgfs.hxx
src/Main/main.cxx
src/Scenery/scenery.cxx
src/Scenery/scenery.hxx
src/Sound/fg_fx.cxx
src/Sound/fg_fx.hxx
src/Sound/soundmgr.cxx
src/Sound/soundmgr.hxx

index d20af07af99fd6913890a2ac943f7d2c50f1b642..a752227891987aeec5bd67707285cd6d472caecc 100644 (file)
@@ -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() ) {
index 0d29ba503d456a56ef827e3fd29d098e1b80c924..d58ccf3339bf5a7a849b32f3afdab7c15e1ad859 100644 (file)
@@ -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!!!
index 14b940c03f7d1a6ec31b80e814094ba44283432e..8d12aef137aacbbc3c7633aae65a44fb688486ba 100644 (file)
@@ -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;
index f96e1f4326e6da716564af00c2d5bdd796e267bd..c003a73f8bed3fd92fac34a5ba0fccb9e3a46f5d 100644 (file)
@@ -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 ();
index 0b4f7ff9419a8d47e21cf156bd9b9f48fd2569ba..286af8010c8f8e14b9aac87d86c1f7b17f901864 100644 (file)
@@ -176,7 +176,7 @@ FGControls::unbind ()
 
 
 void
-FGControls::update ()
+FGControls::update (int dt)
 {
 }
 
index de965ec2c7b040b441e6169daaa15a6e472bf003..0cc5146c7ba81f641f0ce8e5152e64704675b7ef 100644 (file)
@@ -92,7 +92,7 @@ public:
     void init ();
     void bind ();
     void unbind ();
-    void update ();
+    void update (int dt);
 
     // Reset function
     void reset_all(void);
index 1dd27bae8d337a35f5bcbe092d8f5d9d8b0c5f86..0fc0aeee813ac1db4e9614565a494dfb7184b4a3 100644 (file)
@@ -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)
index fdc66cc1a6fbefe7c99c860c4694b3479c6399cc..bef66d88b4d3d1c66f26c116d385b46c2e027d56 100644 (file)
@@ -79,7 +79,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    bool update( int multiloop );
+    void update(int dt);
 
 };
 
index 6790df396ce5fc2042f118fecacc350a024dab60..dd5bc016d8f8580432532adc857e9bcbb6daa138 100644 (file)
@@ -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;
 }
 
 
index 5661bebbcb8341a5c121aea8f58d98ea71fc0323..b180a3a535f05bfb48b8e290f6e2dd37a6aa7e34 100644 (file)
@@ -75,7 +75,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    bool update( int multiloop );
+    void update( int multiloop );
 };
 
 
index b0406dc38bd47bd645a9a5520bc1ea2502a3d819..0c712c1c73c86427996a42952b06009ec12f41f1 100644 (file)
@@ -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;
 }
index 8d2adef3813940f1ec413aed7e17398efdb64328..5ebad88e3b8eaa67b9b945a0243512dfd8614a62 100644 (file)
@@ -38,7 +38,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    bool update( int multiloop );
+    void update( int multiloop );
 };
 
 
index 4d480d4873d22cd4b73465d7f5b739e9aa1f5b03..5953d0d40db9e70b0cd96a33b84ddb69f15a4318 100644 (file)
@@ -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;
 }
index d60b7c6fc85d78937f473e872761ee5df98ac393..b913d873f0f43e14ce8aa8b3924a72a47013fece 100644 (file)
@@ -53,7 +53,7 @@ public:
     void init();
 
     // update the fdm
-    bool update( int multiloop );
+    void update( int multiloop );
 
 };
 
index b869f3e74d79131f10de9f687199181c3c3efa1a..8fe89232d3aabf28f79938993780bd4a2f44c051 100644 (file)
@@ -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;
 }
 
 /******************************************************************************/
index 6d9f66f345bdacf7e44fec89d0f969478e6311f2..8e58aa9d806af20de13403934528dcc3d2bb001b 100644 (file)
@@ -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);
index ac3f48459c89b73ca05a5d746e53d3178a54e9a9..5f0573b4f278f17fdd2ff721585519105c487755 100644 (file)
@@ -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
+  }
 }
 
index cf3682814c9fbe146ff4a756737171c7a8d56f3a..e6c8695bfd23d546e3a351b90694e5a4f57d8ca9 100644 (file)
@@ -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;
 }
 
 
index 3d598dd529640c4d2d89f9473fd6932abe71df85..078579621296f18fdf4b95870165c4bd14bbba57 100644 (file)
@@ -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
index 624ae51e20311ee740f4f9e15cd3f6e509f92b13..58bf6ec31990f815a3483f116e0ef4cd537abc51 100644 (file)
@@ -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;
 }
index e6f6efe80710e64c58d7381901b24a9a8bf32f3c..12d3c656e8bc394f48db9f46f99b2d085428c0b9 100644 (file)
@@ -38,7 +38,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    bool update( int multiloop );
+    void update( int multiloop );
 
 };
 
index 54b4102286b0f7f3c50d91f1052564777554113f..7008245785703491e07e3accc95f69f79e456232 100644 (file)
@@ -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;
 }
index 94dd3282690f4087344c294d2aa8227b58c20dd4..c970d4dbf1fa51a113b057bb9e8f5b8500081da1 100644 (file)
@@ -39,7 +39,7 @@ public:
     void init();
 
     // update position based on inputs, positions, velocities, etc.
-    bool update( int multiloop );
+    void update( int multiloop );
 };
 
 
index 44925db311a2bf96f7515edfb1919c4ddb61fee5..1e8b2b009866411e3c0cdbdae9f2084a74134940 100644 (file)
@@ -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<iterations; i++) {
@@ -193,8 +193,6 @@ bool YASim::update(int iterations)
             _updateCount = 0;
         }
     }
-
-    return true; // what does this mean?
 }
 
 void YASim::copyToYASim(bool copyState)
index 30a4409c6f79a14375883c71cb824beda63a7f16..7238a49a69768d10c0be063d96f3c9f43b4c8d9a 100644 (file)
@@ -13,7 +13,7 @@ public:
     virtual void init();
 
     // Run an iteration
-    virtual bool update(int iterations);
+    virtual void update(int iterations);
 
  private:
     void report();
index 9a857c6822d277b092192a86a537c382723ec47b..ed670fa8b81e4a80b7c620367c9be06e2456466e 100644 (file)
@@ -495,15 +495,9 @@ FGInterface::free_gear_units ()
  * Update the state of the FDM (i.e. run the equations of motion).
  */
 void
-FGInterface::update ()
+FGInterface::update (int dt)
 {
-  update(1);
-}
-
-
-bool FGInterface::update( int multi_loop ) {
     cout << "dummy update() ... SHOULDN'T BE CALLED!" << endl;
-    return false;
 }
 
 
index 85a5f16ad36bf993d74ff899ea25e5c26f50bd6d..f291af2519cd355ff8f3704af9798bd6240d8130 100644 (file)
@@ -522,8 +522,7 @@ public:
     virtual void init ();
     virtual void bind ();
     virtual void unbind ();
-    virtual void update ();
-    virtual bool update( int multi_loop );
+    virtual void update(int dt);
     virtual bool ToggleDataLogging(bool state) { return false; }
     virtual bool ToggleDataLogging(void) { return false; }
 
index 1ebf78d915e85a8fecce16db76c95e0670872908..64d95d5aab4b19121d7e78f6e401017171245b1d 100644 (file)
@@ -204,7 +204,7 @@ FGInput::unbind ()
 }
 
 void 
-FGInput::update ()
+FGInput::update (int dt)
 {
   _update_keyboard();
   _update_joystick();
index 3ca62c8f26eea81ca3a0fe7f8f0827d12b271820..a2899ab705549092dfd4e398f468b18ee6b16255 100644 (file)
@@ -185,7 +185,7 @@ public:
   virtual void init ();
   virtual void bind ();
   virtual void unbind ();
-  virtual void update ();
+  virtual void update (int dt);
 
 
   /**
index 79dec566d0998d25efd2230296954069503c196a..f7aa373e1b7fea49f443aa67f745d59e53c57c3a 100644 (file)
@@ -150,7 +150,7 @@ public:
    * update its state.  If the subsystem requires delta time information,
    * it should track it itself.</p>
    */
-  virtual void update () = 0;
+  virtual void update (int dt) = 0;
 
 };
 
index 3bf277d52f4c1433ef398e4be1c502e870f73a06..9970247e12fcfd89ec09f8d829a9da9d83a566c6 100644 (file)
@@ -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
 
index 1341d21d42cb3a4481974c4d415cedfa1c8616f7..0f78f66ac149ffb9c9c5cfbfa10ed0350c2fbf74 100644 (file)
@@ -61,7 +61,7 @@ FGScenery::~FGScenery() {
 void FGScenery::init() {
 }
 
-void FGScenery::update() {
+void FGScenery::update(int dt) {
 }
 
 void FGScenery::bind() {
index f67883756e31cff9525cf704cc46b346f8aeadbd..4e4531dfe10ddda7dafafab9d84d879aa4c6a100 100644 (file)
@@ -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; }
index 25163f91ca6edf1fd09485056fef9441a80d3330..9a3f85ecf04e085a9e94ef55166d763ca3141722 100644 (file)
@@ -215,7 +215,7 @@ FGFX::unbind ()
 }
 
 void
-FGFX::update ()
+FGFX::update (int dt)
 {
   FGSoundMgr * mgr = globals->get_soundmgr();
   int i;
index 15b7de961efc8513386388c56b5fbe429dd7756d..2c403bd0fd7a0d2587ad4dfc03ae9ee8831c9dba 100644 (file)
@@ -58,7 +58,7 @@ public:
   virtual void init ();
   virtual void bind ();
   virtual void unbind ();
-  virtual void update ();
+  virtual void update (int dt);
 
 private:
 
index 0103efd4ca7b13a62d2efb7b588e5fa886c92e10..a1caaf6ffb6356b6444b1accf586cd5af34ca384 100644 (file)
@@ -121,7 +121,7 @@ void FGSoundMgr::unbind ()
 
 
 // run the audio scheduler
-void FGSoundMgr::update() {
+void FGSoundMgr::update(int dt) {
     SGTimeStamp current;
     current.stamp();
 
index 78b09f639d1135e8329fe004cafbfa322422103f..8abc4bbd6f0e26eea60afeba45f08c82021ac0ed 100644 (file)
@@ -121,7 +121,7 @@ public:
     /**
      * Run the audio scheduler.
      */
-    void update();
+    void update(int dt);
 
 
     // is audio working?