From f9f9350b9638dc8804182b7648be20ecedf4121a Mon Sep 17 00:00:00 2001 From: frohlich Date: Thu, 12 Mar 2009 18:34:57 +0000 Subject: [PATCH] Adapt to SGTimeStamp changes. 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 | 1 + src/Cockpit/panel.cxx | 2 +- src/FDM/ExternalNet/ExternalNet.hxx | 4 +--- src/Instrumentation/marker_beacon.cxx | 11 +++++------ src/Main/main.cxx | 9 +++++---- src/MultiPlayer/multiplaymgr.cxx | 4 +--- src/Time/fg_timer.cxx | 2 +- utils/GPSsmooth/MIDG_main.cxx | 6 +++--- utils/GPSsmooth/UGear_main.cxx | 6 +++--- utils/GPSsmooth/gps_main.cxx | 4 ++-- 10 files changed, 23 insertions(+), 26 deletions(-) diff --git a/configure.ac b/configure.ac index 5dfde3649..7ea6728bf 100644 --- a/configure.ac +++ b/configure.ac @@ -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" diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index a7b860afa..3754d7911 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -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 diff --git a/src/FDM/ExternalNet/ExternalNet.hxx b/src/FDM/ExternalNet/ExternalNet.hxx index 41e848d9f..92d76a322 100644 --- a/src/FDM/ExternalNet/ExternalNet.hxx +++ b/src/FDM/ExternalNet/ExternalNet.hxx @@ -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; diff --git a/src/Instrumentation/marker_beacon.cxx b/src/Instrumentation/marker_beacon.cxx index 2037211bb..f8109ee9e 100644 --- a/src/Instrumentation/marker_beacon.cxx +++ b/src/Instrumentation/marker_beacon.cxx @@ -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 ) { diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 634bda309..4d48d7aba 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -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 diff --git a/src/MultiPlayer/multiplaymgr.cxx b/src/MultiPlayer/multiplaymgr.cxx index 95c49b992..f413af67e 100644 --- a/src/MultiPlayer/multiplaymgr.cxx +++ b/src/MultiPlayer/multiplaymgr.cxx @@ -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 diff --git a/src/Time/fg_timer.cxx b/src/Time/fg_timer.cxx index 71df3e787..7f6fef851 100644 --- a/src/Time/fg_timer.cxx +++ b/src/Time/fg_timer.cxx @@ -110,7 +110,7 @@ int fgGetTimeInterval( void ) { interval = 0; } else { current.stamp(); - interval = current - last; + interval = (current - last).toUSecs(); last = current; } diff --git a/utils/GPSsmooth/MIDG_main.cxx b/utils/GPSsmooth/MIDG_main.cxx index 696740147..613f1d39d 100644 --- a/utils/GPSsmooth/MIDG_main.cxx +++ b/utils/GPSsmooth/MIDG_main.cxx @@ -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 diff --git a/utils/GPSsmooth/UGear_main.cxx b/utils/GPSsmooth/UGear_main.cxx index 697d17a6c..4352e1c72 100644 --- a/utils/GPSsmooth/UGear_main.cxx +++ b/utils/GPSsmooth/UGear_main.cxx @@ -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("\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 diff --git a/utils/GPSsmooth/gps_main.cxx b/utils/GPSsmooth/gps_main.cxx index 5be5d384f..cb70e3bc0 100644 --- a/utils/GPSsmooth/gps_main.cxx +++ b/utils/GPSsmooth/gps_main.cxx @@ -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(); } -- 2.39.5