]> git.mxchange.org Git - flightgear.git/commitdiff
Adapt to SGTimeStamp changes.
authorfrohlich <frohlich>
Thu, 12 Mar 2009 18:34:57 +0000 (18:34 +0000)
committerTim Moore <timoore@redhat.com>
Wed, 18 Mar 2009 07:00:08 +0000 (08:00 +0100)
Modified Files:
configure.ac src/Cockpit/panel.cxx src/FDM/Makefile.am
src/FDM/flight.hxx src/FDM/ExternalNet/ExternalNet.hxx
src/Instrumentation/marker_beacon.cxx src/Main/Makefile.am
src/Main/fg_init.cxx src/Main/main.cxx
src/MultiPlayer/multiplaymgr.cxx src/Time/fg_timer.cxx
utils/GPSsmooth/MIDG_main.cxx utils/GPSsmooth/UGear_main.cxx
utils/GPSsmooth/gps_main.cxx

configure.ac
src/Cockpit/panel.cxx
src/FDM/ExternalNet/ExternalNet.hxx
src/Instrumentation/marker_beacon.cxx
src/Main/main.cxx
src/MultiPlayer/multiplaymgr.cxx
src/Time/fg_timer.cxx
utils/GPSsmooth/MIDG_main.cxx
utils/GPSsmooth/UGear_main.cxx
utils/GPSsmooth/gps_main.cxx

index 5dfde3649c48719c138be3ff2b85a733eaa4fcdd..7ea6728bf5be291f5dc66ce4023dcbe83e78e5c7 100644 (file)
@@ -199,6 +199,7 @@ dnl check for some default libraries
 AC_SEARCH_LIBS(sqrt, [am ffm fm fastm m])
 AC_SEARCH_LIBS(ceil, m)
 AC_SEARCH_LIBS(dlclose, dl)
+AC_SEARCH_LIBS(clock_gettime, rt)
 
 base_LIBS="$LIBS"
 
index a7b860afa43aa4ac8433a640f0e4640f9021a5c8..3754d7911ff695a47f0001c0f52431c528fc0e8a 100644 (file)
@@ -1112,7 +1112,7 @@ FGTextLayer::draw (osg::State& state)
     text_renderer.start3f(0, 0, 0);
 
     _now.stamp();
-    long diff = _now - _then;
+    double diff = (_now - _then).toUSecs();
 
     if (diff > 100000 || diff < 0 ) {
       // ( diff < 0 ) is a sanity check and indicates our time stamp
index 41e848d9f8038b59ed0ff27cd7664f9074c5dc61..92d76a3229a2c3b75946ffd1fd4aaeb942f9e7b9 100644 (file)
@@ -67,9 +67,7 @@ public:
 
     bool isDone() const { return done; }
     bool isDone( long usec ) const { 
-        SGTimeStamp now;
-        now.stamp();
-        if ( (now - start) > usec ) {
+        if ( start + SGTimeStamp::fromUSec(usec) < SGTimeStamp::now() ) {
             return true;
         } else {
             return done;
index 2037211bbf8e69a24d742ec3e99a9b9e4430d430..f8109ee9e9930f290af4d54f65710f7818d4eb97 100644 (file)
@@ -175,15 +175,14 @@ FGMarkerBeacon::update(double dt)
 
         // marker beacon blinking
         bool light_on = ( outer_blink || middle_blink || inner_blink );
-        SGTimeStamp current;
-        current.stamp();
+        SGTimeStamp current = SGTimeStamp::now();
 
-        if ( light_on && (current - blink > 400000) ) {
+        if ( light_on && blink + SGTimeStamp::fromUSec(400000) < current ) {
             light_on = false;
-            blink.stamp();
-        } else if ( !light_on && (current - blink > 100000) ) {
+            blink = current;
+        } else if ( !light_on && blink + SGTimeStamp::fromUSec(100000) < current ) {
             light_on = true;
-            blink.stamp();
+            blink = current;
         }
 
         if ( outer_marker ) {
index 634bda3093cd7b99ca1136760c51d26ff471b0de..4d48d7aba6b75061c89d47d789b780c4bf474347 100644 (file)
@@ -273,7 +273,7 @@ static void fgMainLoop( void ) {
         }
         current_time_stamp.stamp();
         /* Convert to ms */
-        double elapsed_us = current_time_stamp - last_time_stamp;
+        double elapsed_us = (current_time_stamp - last_time_stamp).toUSecs();
         if ( elapsed_us < frame_us ) {
             double requested_us = frame_us - elapsed_us;
             ulMilliSecondSleep ( (int)(requested_us / 1000.0) ) ;
@@ -286,7 +286,9 @@ static void fgMainLoop( void ) {
         // ulMilliSecondSleep() call is omitted this will peg the cpu
         // (which is just fine if FG is the only app you care about.)
         current_time_stamp.stamp();
-        while ( current_time_stamp - last_time_stamp < frame_us ) {
+        SGTimeStamp next_time_stamp = last_time_stamp;
+        next_time_stamp += SGTimeStamp::fromSec(1e-6*frame_us);
+        while ( current_time_stamp < next_time_stamp ) {
             current_time_stamp.stamp();
         }
     } else {
@@ -294,8 +296,7 @@ static void fgMainLoop( void ) {
         current_time_stamp.stamp();
     }
 
-    real_delta_time_sec
-        = double(current_time_stamp - last_time_stamp) / 1000000.0;
+    real_delta_time_sec = (current_time_stamp - last_time_stamp).toSecs();
 
     // Limit the time we need to spend in simulation loops
     // That means, if the /sim/max-simtime-per-frame value is strictly positive
index 95c49b9929cd18acffaf26b51700a66a9ee2891d..f413af67ebddb21da3fa6c40246c743b035430e7 100644 (file)
@@ -712,9 +712,7 @@ FGMultiplayMgr::Update(void)
     return;
 
   /// Just for expiry
-  SGTimeStamp timestamper;
-  timestamper.stamp();
-  long stamp = timestamper.get_seconds();
+  long stamp = SGTimeStamp::now().getSeconds();
 
   //////////////////////////////////////////////////
   //  Read the receive socket and process any data
index 71df3e7877a960b417fd7e1279f2d0f86be9139e..7f6fef8512fba0476857762a6f6d5198bad7e685 100644 (file)
@@ -110,7 +110,7 @@ int fgGetTimeInterval( void ) {
        interval = 0;
     } else {
         current.stamp();
-       interval = current - last;
+       interval = (current - last).toUSecs();
        last = current;
     }
 
index 696740147dd77be696829a866c1e7cf62089e724..613f1d39d8c77d40e0677b0397a410c0d7d29a0d 100644 (file)
@@ -539,13 +539,13 @@ int main( int argc, char **argv ) {
 
             current_time_stamp.stamp();
             /* Convert to ms */
-            double elapsed_us = current_time_stamp - last_time_stamp;
+            double elapsed_us = (current_time_stamp - last_time_stamp).toUSecs();
             if ( elapsed_us < (frame_us - 2000) ) {
                 double requested_us = (frame_us - elapsed_us) - 2000 ;
                 ulMilliSecondSleep ( (int)(requested_us / 1000.0) ) ;
             }
             current_time_stamp.stamp();
-            while ( current_time_stamp - last_time_stamp < frame_us ) {
+            while ( (current_time_stamp - last_time_stamp).toUSecs() < frame_us ) {
                 current_time_stamp.stamp();
             }
 
@@ -554,7 +554,7 @@ int main( int argc, char **argv ) {
         }
 
         cout << "Processed " << pos_count << " entries in "
-             << (current_time_stamp - start_time) / 1000000 << " seconds."
+             << current_time_stamp - start_time << " seconds."
              << endl;
     } else if ( serialdev.length() ) {
         // process incoming data from the serial port
index 697d17a6c6154cedc3c0fa64161c02753ee4f824..4352e1c721e7d787421b3986e387fcc17edc1480 100644 (file)
@@ -956,13 +956,13 @@ int main( int argc, char **argv ) {
 
                 current_time_stamp.stamp();
                 /* Convert to ms */
-                double elapsed_us = current_time_stamp - last_time_stamp;
+                double elapsed_us = (current_time_stamp - last_time_stamp).toUSecs();
                 if ( elapsed_us < (frame_us - 2000) ) {
                     double requested_us = (frame_us - elapsed_us) - 2000 ;
                     ulMilliSecondSleep ( (int)(requested_us / 1000.0) ) ;
                 }
                 current_time_stamp.stamp();
-                while ( current_time_stamp - last_time_stamp < frame_us ) {
+                while ( (current_time_stamp - last_time_stamp).toUSecs() < frame_us ) {
                     current_time_stamp.stamp();
                 }
             }
@@ -985,7 +985,7 @@ int main( int argc, char **argv ) {
         printf("<gpx>\n");
 
         cout << "Processed " << imu_count << " entries in "
-             << (current_time_stamp - start_time) / 1000000 << " seconds."
+             << current_time_stamp - start_time << " seconds."
              << endl;
     } else if ( serialdev.length() ) {
         // process incoming data from the serial port
index 5be5d384f84f032c526b828ee37908cc97451ada..cb70e3bc09b9be3037e4c48b42832c4a9f81c7e1 100644 (file)
@@ -465,13 +465,13 @@ int main( int argc, char **argv ) {
 
         current_time_stamp.stamp();
         /* Convert to ms */
-        double elapsed_us = current_time_stamp - last_time_stamp;
+        double elapsed_us = (current_time_stamp - last_time_stamp).toUSecs();
         if ( elapsed_us < (frame_us - 2000) ) {
             double requested_us = (frame_us - elapsed_us) - 2000 ;
             ulMilliSecondSleep ( (int)(requested_us / 1000.0) ) ;
         }
         current_time_stamp.stamp();
-        while ( current_time_stamp - last_time_stamp < frame_us ) {
+        while ( (current_time_stamp - last_time_stamp).toUSecs() < frame_us ) {
             current_time_stamp.stamp();
         }