]> git.mxchange.org Git - flightgear.git/blobdiff - utils/GPSsmooth/MIDG-II.hxx
Allow setting of NED velocities.
[flightgear.git] / utils / GPSsmooth / MIDG-II.hxx
index 31ef825ab3ccb8812af92ea729f2235239a13e02..21ce5856350b01764a3b836bd71c8a641bf00685 100644 (file)
@@ -8,28 +8,18 @@
 
 #include <simgear/compiler.h>
 
-#include <stdio.h>
-
 #include <iostream>
 #include <string>
 #include <vector>
 
-#ifdef HAVE_STDINT_H
-# include <stdint.h>
-#elif defined( _MSC_VER ) || defined(__MINGW32__) || defined(sun)
-typedef signed short     int16_t;
-typedef signed int       int32_t;
-typedef unsigned short   uint16_t;
-typedef unsigned int     uint32_t;
-#else
-# error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
-#endif
-
+#include <simgear/misc/stdint.hxx>
+#include <simgear/io/iochannel.hxx>
+#include <simgear/serial/serial.hxx>
 
-SG_USING_STD(cout);
-SG_USING_STD(endl);
-SG_USING_STD(string);
-SG_USING_STD(vector);
+using std::cout;
+using std::endl;
+using std::string;
+using std::vector;
 
 
 // encapsulate a midg integer time (fixme, assumes all times in a track
@@ -128,9 +118,8 @@ class MIDGTrack {
 
 private:
 
-    vector <MIDGpos> posdata;
-    vector <MIDGatt> attdata;
-    FILE *fd;
+    vector <MIDGpos> pos_data;
+    vector <MIDGatt> att_data;
 
     // parse message and put current data into vector if message has a
     // newer time stamp than existing data.
@@ -141,23 +130,31 @@ public:
     MIDGTrack();
     ~MIDGTrack();
 
-    int load( const string &file );
+    // read/parse the next message from the specified data stream,
+    // returns id # if a valid message found.
+    int next_message( SGIOChannel *ch, SGIOChannel *log,
+                      MIDGpos *pos, MIDGatt *att );
+    int next_message( SGSerialPort *serial, SGIOChannel *log,
+                      MIDGpos *pos, MIDGatt *att );
+
+    // load the named file into internal buffers
+    bool load( const string &file );
 
-    inline int possize() const { return posdata.size(); }
-    inline int attsize() const { return attdata.size(); }
+    inline int pos_size() const { return pos_data.size(); }
+    inline int att_size() const { return att_data.size(); }
 
     inline MIDGpos get_pospt( const unsigned int i )
     {
-        if ( i < posdata.size() ) {
-            return posdata[i];
+        if ( i < pos_data.size() ) {
+            return pos_data[i];
         } else {
             return MIDGpos();
         }
     }
     inline MIDGatt get_attpt( const unsigned int i )
     {
-        if ( i < attdata.size() ) {
-            return attdata[i];
+        if ( i < att_data.size() ) {
+            return att_data[i];
         } else {
             return MIDGatt();
         }