]> git.mxchange.org Git - flightgear.git/blobdiff - utils/GPSsmooth/UGear_main.cxx
Merge branch 'next' into durk-atc
[flightgear.git] / utils / GPSsmooth / UGear_main.cxx
index c38f0c4089ab69b52e91e6ca36f24ab100bbf471..43d44b6f2af0ec05ebe94805d61dbc71d587fb3b 100644 (file)
@@ -2,7 +2,13 @@
 #  include <config.h>
 #endif
 
-#ifndef _MSC_VER
+#ifdef HAVE_WINDOWS_H
+#  include <windows.h>
+#else
+#  include <netinet/in.h>       // htonl() ntohl()
+#endif
+
+#ifndef _WIN32
 #  include <strings.h>         // for bzero()
 #else
 #  define bzero(a,b) memset(a,0,b)
 #include <iostream>
 #include <string>
 
-#include <plib/net.h>
 #include <plib/sg.h>
 
 #include <simgear/constants.h>
 #include <simgear/io/lowlevel.hxx> // endian tests
 #include <simgear/io/sg_file.hxx>
+#include <simgear/io/raw_socket.hxx>
 #include <simgear/serial/serial.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/timing/timestamp.hxx>
 #include "UGear_telnet.hxx"
 
 
-SG_USING_STD(cout);
-SG_USING_STD(endl);
-SG_USING_STD(string);
+using std::cout;
+using std::endl;
+using std::string;
 
 
 // Network channels
-static netSocket fdm_sock, ctrls_sock, opengc_sock;
+static simgear::Socket fdm_sock, ctrls_sock, opengc_sock;
 
 // ugear data
 UGTrack track;
@@ -658,7 +664,7 @@ int main( int argc, char **argv ) {
 
     // Setup up outgoing network connections
 
-    netInit( &argc,argv ); // We must call this before any other net stuff
+    simgear::Socket::initSockets(); // We must call this before any other net stuff
 
     if ( ! opengc_sock.open( false ) ) {  // open a UDP socket
         cout << "error opening opengc output socket" << endl;
@@ -956,13 +962,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 +991,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