]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/flight.cxx
Fix maximum speed bug.
[flightgear.git] / src / FDM / flight.cxx
index 6d404dd76676717a91580d529bd93636735a6c31..76f93e2a4c46933666ecb3c2568113107d898d91 100644 (file)
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 
-#include "External.hxx"
 #include "flight.hxx"
-#include "JSBSim.hxx"
-#include "LaRCsim.hxx"
-#include "Balloon.h"
 
 
 // base_fdm_state is the internal state that is updated in integer
@@ -61,8 +57,9 @@ FGInterface::FGInterface() {
 
 FGInterface::FGInterface( double dt ) {
     _setup();
-    delta_t = dt;
-    remainder = elapsed = multi_loop = 0;
+//     delta_t = dt;
+//     remainder = elapsed = multi_loop = 0;
+    remainder = 0;
 }
 
 // Destructor
@@ -71,6 +68,21 @@ FGInterface::~FGInterface() {
 }
 
 
+int
+FGInterface::_calc_multiloop (double dt)
+{
+  int hz = fgGetInt("/sim/model-hz");
+  int speedup = fgGetInt("/sim/speed-up");
+
+  dt += remainder;
+  remainder = 0;
+  double ml = dt * hz;
+  int multiloop = int(floor(ml));
+  remainder = (ml - multiloop) / hz;
+  return (multiloop * speedup);
+}
+
+
 /**
  * Set default values for the state of the FDM.
  *
@@ -167,8 +179,8 @@ FGInterface::common_init ()
 
     set_inited( true );
 
-    stamp();
-    set_remainder( 0 );
+//     stamp();
+//     set_remainder( 0 );
 
     // Set initial position
     SG_LOG( SG_FLIGHT, SG_INFO, "...initializing position..." );
@@ -258,14 +270,14 @@ FGInterface::bind ()
   bound = true;
 
                                 // Time management (read-only)
-  fgTie("/fdm/time/delta_t", this,
-        &FGInterface::get_delta_t); // read-only
-  fgTie("/fdm/time/elapsed", this,
-        &FGInterface::get_elapsed); // read-only
-  fgTie("/fdm/time/remainder", this,
-        &FGInterface::get_remainder); // read-only
-  fgTie("/fdm/time/multi_loop", this,
-        &FGInterface::get_multi_loop); // read-only
+//   fgTie("/fdm/time/delta_t", this,
+//         &FGInterface::get_delta_t); // read-only
+//   fgTie("/fdm/time/elapsed", this,
+//         &FGInterface::get_elapsed); // read-only
+//   fgTie("/fdm/time/remainder", this,
+//         &FGInterface::get_remainder); // read-only
+//   fgTie("/fdm/time/multi_loop", this,
+//         &FGInterface::get_multi_loop); // read-only
 
                        // Aircraft position
   fgTie("/position/latitude-deg", this,
@@ -409,9 +421,9 @@ FGInterface::unbind ()
  * Update the state of the FDM (i.e. run the equations of motion).
  */
 void
-FGInterface::update (int dt)
+FGInterface::update (double dt)
 {
-    cout << "dummy update() ... SHOULDN'T BE CALLED!" << endl;
+    SG_LOG(SG_FLIGHT, SG_ALERT, "dummy update() ... SHOULDN'T BE CALLED!");
 }
 
 
@@ -529,7 +541,7 @@ void FGInterface::extrapolate( int time_offset ) {
     // -dw- metrowerks complains about ambiguous access, not critical
     // to keep this ;)
 #ifndef __MWERKS__
-    cout << "extrapolating FDM by dt = " << dt << endl;
+    SG_LOG(SG_FLIGHT, SG_INFO, "extrapolating FDM by dt = " << dt);
 #endif
 
     double lat = geodetic_position_v[0] + geocentric_rates_v[0] * dt;