1 #ifndef _FG_MIDG_II_HXX
2 #define _FG_MIDG_II_HXX
9 #include <simgear/compiler.h>
19 #elif defined( _MSC_VER ) || defined(__MINGW32__) || defined(sun)
20 typedef signed short int16_t;
21 typedef signed int int32_t;
22 typedef unsigned short uint16_t;
23 typedef unsigned int uint32_t;
25 # error "Port me! Platforms that don't have <stdint.h> need to define int8_t, et. al."
35 // encapsulate a midg integer time (fixme, assumes all times in a track
36 // are from the same day, so we don't handle midnight roll over)
44 inline MIDGTime( const int dd, const int hh, const int mm,
47 seconds = dd*86400.0 + hh*3600.0 + mm*60.0 + ss;
48 msec = (uint32_t)(seconds * 1000);
50 inline MIDGTime( const uint32_t midgtime_msec ) {
52 seconds = (double)midgtime_msec / 1000.0;
53 // cout << midgtime << " = " << seconds << endl;
57 inline double get_seconds() const { return seconds; }
58 inline uint32_t get_msec() const { return msec; }
59 inline double diff_seconds( const MIDGTime t ) const {
60 return seconds - t.seconds;
66 // base class for MIDG data types
74 midg_time(MIDGTime(0))
77 inline double get_seconds() const { return midg_time.get_seconds(); }
78 inline uint32_t get_msec() const { return midg_time.get_msec(); }
82 // encapsulate the interesting midg data for a moment in time
83 class MIDGpos : public MIDGpoint {
109 // encapsulate the interesting midg data for a moment in time
110 class MIDGatt : public MIDGpoint {
126 // Manage a saved midg log (track file)
131 vector <MIDGpos> posdata;
132 vector <MIDGatt> attdata;
135 // parse message and put current data into vector if message has a
136 // newer time stamp than existing data.
137 void parse_msg( const int id, char *buf, MIDGpos *pos, MIDGatt *att );
144 int load( const string &file );
146 inline int possize() const { return posdata.size(); }
147 inline int attsize() const { return attdata.size(); }
149 inline MIDGpos get_pospt( const unsigned int i )
151 if ( i < posdata.size() ) {
157 inline MIDGatt get_attpt( const unsigned int i )
159 if ( i < attdata.size() ) {
170 MIDGpos MIDGInterpPos( const MIDGpos A, const MIDGpos B, const double percent );
171 MIDGatt MIDGInterpAtt( const MIDGatt A, const MIDGatt B, const double percent );
174 #endif // _FG_MIDG_II_HXX