]> git.mxchange.org Git - flightgear.git/commitdiff
Convert fgTIMESTAMP to FGTimeStamp which holds usec instead of ms.
authorcurt <curt>
Sat, 9 Jan 1999 13:37:32 +0000 (13:37 +0000)
committercurt <curt>
Sat, 9 Jan 1999 13:37:32 +0000 (13:37 +0000)
External/external.hxx
FDM/flight.cxx
FDM/flight.hxx
Main/GLUTmain.cxx
Time/event.cxx
Time/event.hxx
Time/fg_timer.cxx
Time/timestamp.hxx

index bf65ad0c9c1ba44a8f8a55aad785d84970064b24..12b59b23d7ef2004d7657b5d6f0527993f4bc063 100644 (file)
@@ -44,7 +44,7 @@ public:
 
     // The time at which these values are correct (for extrapolating
     // later frames between position updates)
-    fgTIMESTAMP t;
+    FGTimeStamp t;
 
     // Positions
 
@@ -97,6 +97,9 @@ void fgExternalUpdate( FGState& f, int multiloop );
 
 
 // $Log$
+// Revision 1.4  1999/01/09 13:37:37  curt
+// Convert fgTIMESTAMP to FGTimeStamp which holds usec instead of ms.
+//
 // Revision 1.3  1998/12/05 15:54:14  curt
 // Renamed class fgFLIGHT to class FGState as per request by JSB.
 //
index 07f756fd2af041b1c8f8d1c7314962617447ca29..ea70188a9ab96a5fb9243d466d891ccd7762680b 100644 (file)
@@ -94,7 +94,7 @@ int fgFlightModelInit(int model, FGState& f, double dt) {
 static FGState extrapolate_fdm( FGState &base, int jitter ) {
     FGState result;
 
-    double dt = jitter / 1000.0;
+    double dt = jitter / 1000000.0;
     // cout << "dt = " << dt << endl;
 
     // start by making a straight up copy
@@ -118,9 +118,9 @@ static FGState extrapolate_fdm( FGState &base, int jitter ) {
     double alt = base.get_Altitude() + base.get_Radius_dot() * dt;
     double radius = base.get_Radius_to_vehicle() + base.get_Radius_dot() * dt;
 
-    result.set_Longitude( lon );
-    result.set_Latitude( lat );
-    result.set_Altitude( alt );
+    // result.set_Longitude( lon );
+    // result.set_Latitude( lat );
+    // result.set_Altitude( alt );
     // result.set_Geocentric_Position( lon_geoc, lat_geoc, radius );
 
     return result;
@@ -184,6 +184,9 @@ void fgFlightModelSetAltitude(int model, double alt_meters) {
 
 
 // $Log$
+// Revision 1.10  1999/01/09 13:37:32  curt
+// Convert fgTIMESTAMP to FGTimeStamp which holds usec instead of ms.
+//
 // Revision 1.9  1999/01/08 19:27:37  curt
 // Fixed AOA reading on HUD.
 // Continued work on time jitter compensation.
index 9cd463723144bc80d1c95be2167757582c66fce8..331c96ec6f08dfaa7f18d9396787ae3f863787dd 100644 (file)
@@ -544,7 +544,7 @@ public:
        geocentric_position_v[2] = radius;
     }
 
-//     inline void set_Geocentric_Position( double lat, double lon, double rad ) {
+    inline void set_Geocentric_Position( double lat, double lon, double rad ) {
        geocentric_position_v[0] = lat;
        geocentric_position_v[1] = lon;
        geocentric_position_v[2] = rad;
@@ -797,6 +797,9 @@ void fgFlightModelSetAltitude(int model, double alt_meters);
 
 
 // $Log$
+// Revision 1.10  1999/01/09 13:37:33  curt
+// Convert fgTIMESTAMP to FGTimeStamp which holds usec instead of ms.
+//
 // Revision 1.9  1999/01/08 19:27:38  curt
 // Fixed AOA reading on HUD.
 // Continued work on time jitter compensation.
index 1b25327f8534e350ca3532ac90d78ef3b2731a72..f1fba8050f92c08dde5f8b3c7267a8d440e41400 100644 (file)
@@ -450,8 +450,8 @@ static const double alt_adjust_m = alt_adjust_ft * FEET_TO_METER;
 static void fgMainLoop( void ) {
     FGState *f;
     fgTIME *t;
-    static int remainder = 0;
-    int elapsed, multi_loop;
+    static long remainder = 0;
+    long elapsed, multi_loop;
     // int i;
     // double accum;
     static time_t last_time = 0;
@@ -508,15 +508,17 @@ static void fgMainLoop( void ) {
     // update "time"
     fgTimeUpdate(f, t);
 
-    // Get elapsed time for this past frame
+    // Get elapsed time (in usec) for this past frame
     elapsed = fgGetTimeInterval();
-    FG_LOG( FG_ALL, FG_BULK
-           "Time interval is = " << elapsed 
+    FG_LOG( FG_ALL, FG_DEBUG
+           "Elapsed time interval is = " << elapsed 
            << ", previous remainder is = " << remainder );
 
     // Calculate frame rate average
     if ( (t->cur_time != last_time) && (last_time > 0) ) {
        general.set_frame_rate( frames );
+       FG_LOG( FG_ALL, FG_DEBUG, 
+               "--> Frame rate is = " << general.get_frame_rate() );
        frames = 0;
     }
     last_time = t->cur_time;
@@ -541,13 +543,11 @@ static void fgMainLoop( void ) {
     // Run flight model
     if ( ! use_signals ) {
        // Calculate model iterations needed for next frame
-       FG_LOG( FG_ALL, FG_DEBUG, 
-               "--> Frame rate is = " << general.get_frame_rate() );
        elapsed += remainder;
 
-       multi_loop = (int)(((float)elapsed * 0.001) * DEFAULT_MODEL_HZ);
-       remainder = elapsed - ((multi_loop*1000) / DEFAULT_MODEL_HZ);
-       FG_LOG( FG_ALL, FG_BULK
+       multi_loop = (int)(((double)elapsed * 0.000001) * DEFAULT_MODEL_HZ);
+       remainder = elapsed - ((multi_loop*1000000) / DEFAULT_MODEL_HZ);
+       FG_LOG( FG_ALL, FG_DEBUG
                "Model iterations needed = " << multi_loop
                << ", new remainder = " << remainder );
        
@@ -1000,6 +1000,9 @@ int main( int argc, char **argv ) {
 
 
 // $Log$
+// Revision 1.80  1999/01/09 13:37:40  curt
+// Convert fgTIMESTAMP to FGTimeStamp which holds usec instead of ms.
+//
 // Revision 1.79  1999/01/08 03:23:56  curt
 // Beginning work on compensating for sim time vs. real world time "jitter".
 //
index 1126e03dc9d152c93adc10d40c533827950f7170..5f4d204dc76dacf55ef6222a79a7f9a7ed6715ac 100644 (file)
@@ -190,7 +190,8 @@ fgEVENT_MGR::Register( const string& desc,
                       fgEVENT::EventState status, 
                       int interval )
 {
-    fgEVENT* e = new fgEVENT( desc, cb, status, interval );
+    // convert interval specified in milleseconds to usec
+    fgEVENT* e = new fgEVENT( desc, cb, status, interval * 1000 );
 
     FG_LOG( FG_EVENT, FG_INFO, "Registering event: " << desc );
 
@@ -249,7 +250,7 @@ fgEVENT_MGR::PrintStats()
 // the queue
 void fgEVENT_MGR::Process( void ) {
     fgEVENT *e_ptr;
-    fgTIMESTAMP cur_time;
+    FGTimeStamp cur_time;
     unsigned int i, size;
 
     FG_LOG( FG_EVENT, FG_DEBUG, "Processing events" );
@@ -305,6 +306,9 @@ fgEVENT_MGR::~fgEVENT_MGR( void ) {
 
 
 // $Log$
+// Revision 1.15  1999/01/09 13:37:42  curt
+// Convert fgTIMESTAMP to FGTimeStamp which holds usec instead of ms.
+//
 // Revision 1.14  1999/01/07 20:25:32  curt
 // Portability changes and updates from Bernie Bright.
 //
index 57d81e81de0b55dd1159452b97ccb4a46f1e9bd0..2ef1a8844348c18c70c89ff7ae28c168dd28028b 100644 (file)
@@ -88,9 +88,9 @@ private:
 
     long interval;    // interval in ms between each iteration of this event
 
-    fgTIMESTAMP last_run;
-    fgTIMESTAMP current;
-    fgTIMESTAMP next_run;
+    FGTimeStamp last_run;
+    FGTimeStamp current;
+    FGTimeStamp next_run;
 
     long cum_time;    // cumulative processor time of this event
     long min_time;    // time of quickest execution
@@ -166,6 +166,9 @@ extern fgEVENT_MGR global_events;
 
 
 // $Log$
+// Revision 1.16  1999/01/09 13:37:43  curt
+// Convert fgTIMESTAMP to FGTimeStamp which holds usec instead of ms.
+//
 // Revision 1.15  1999/01/07 20:25:33  curt
 // Portability changes and updates from Bernie Bright.
 //
index c77cda5bf56048906e5976e7932d2d862b9f8df8..074d90f5bf45dc5c066ed4ce90e90390441303df 100644 (file)
@@ -96,13 +96,13 @@ void fgTimerInit(float dt, void (*f)( int )) {
 #endif // HAVE_SETITIMER
 
 
-// This function returns the number of milleseconds since the last
+// This function returns the number of microseconds since the last
 // time it was called.
 int fgGetTimeInterval( void ) {
     int interval;
     static int inited = 0;
-    static fgTIMESTAMP last;
-    fgTIMESTAMP current;
+    static FGTimeStamp last;
+    FGTimeStamp current;
 
     if ( ! inited ) {
        inited = 1;
@@ -119,6 +119,9 @@ int fgGetTimeInterval( void ) {
 
 
 // $Log$
+// Revision 1.6  1999/01/09 13:37:45  curt
+// Convert fgTIMESTAMP to FGTimeStamp which holds usec instead of ms.
+//
 // Revision 1.5  1998/12/05 14:21:32  curt
 // Moved struct fg_timestamp to class fgTIMESTAMP and moved it's definition
 // to it's own file, timestamp.hxx.
index 42f8734d41bcf76ef4195f920f1457a0134266fd..b20b19f6c74dd9b83843ba250bea312b52318715 100644 (file)
 #endif
 
 
-class fgTIMESTAMP {
+class FGTimeStamp {
 
 private:
 
     long seconds;
-    long millis;
+    long usec;
 
 public:
 
-    fgTIMESTAMP();
-    fgTIMESTAMP( const long s, const long m );
-    ~fgTIMESTAMP();
+    FGTimeStamp();
+    FGTimeStamp( const long s, const long m );
+    ~FGTimeStamp();
 
     // Set time to current time
     void stamp();
 
-    fgTIMESTAMP& operator = ( const fgTIMESTAMP& t );
+    FGTimeStamp& operator = ( const FGTimeStamp& t );
 
-    friend fgTIMESTAMP operator + (const fgTIMESTAMP& t, const long& m);
-    friend long operator - (const fgTIMESTAMP& a, const fgTIMESTAMP& b);
+    friend FGTimeStamp operator + (const FGTimeStamp& t, const long& m);
+    friend long operator - (const FGTimeStamp& a, const FGTimeStamp& b);
 
     inline long get_seconds() const { return seconds; }
-    inline long get_millis() const { return millis; }
+    // inline long get_usec() const { return usec; }
 };
 
-inline fgTIMESTAMP::fgTIMESTAMP() {
+inline FGTimeStamp::FGTimeStamp() {
 }
 
-inline fgTIMESTAMP::fgTIMESTAMP( const long s, const long m ) {
+inline FGTimeStamp::FGTimeStamp( const long s, const long u ) {
     seconds = s;
-    millis = m;
+    usec = u;
 }
 
-inline fgTIMESTAMP::~fgTIMESTAMP() {
+inline FGTimeStamp::~FGTimeStamp() {
 }
 
-inline fgTIMESTAMP& fgTIMESTAMP::operator = (const fgTIMESTAMP& t)
+inline FGTimeStamp& FGTimeStamp::operator = (const FGTimeStamp& t)
 {
     seconds = t.seconds;
-    millis = t.millis;
+    usec = t.usec;
     return *this;
 }
 
-inline void fgTIMESTAMP::stamp() {
+inline void FGTimeStamp::stamp() {
 #if defined( WIN32 )
     unsigned int t;
     t = timeGetTime();
     seconds = 0;
-    millis =  t;
+    usec =  t * 1000;
 #elif defined( HAVE_GETTIMEOFDAY )
     struct timeval current;
     struct timezone tz;
     // fg_timestamp currtime;
     gettimeofday(&current, &tz);
     seconds = current.tv_sec;
-    millis = current.tv_usec / 1000;
+    usec = current.tv_usec;
 #elif defined( HAVE_GETLOCALTIME )
     SYSTEMTIME current;
     GetLocalTime(&current);
     seconds = current.wSecond;
-    millis = current.wMilliseconds;
+    usec = current.wMilliseconds * 1000;
 #elif defined( HAVE_FTIME )
     struct timeb current;
     ftime(&current);
     seconds = current.time;
-    millis = current.millitm;
+    usec = current.millitm * 1000;
 #else
 # error Port me
 #endif
 }
 
-// difference between time stamps in milliseconds
-inline fgTIMESTAMP operator + (const fgTIMESTAMP& t, const long& m) {
+// difference between time stamps in microseconds (usec)
+inline FGTimeStamp operator + (const FGTimeStamp& t, const long& m) {
 #ifdef WIN32
-    return fgTIMESTAMP( 0, t.millis + m );
+    return FGTimeStamp( 0, t.usec + m );
 #else
-    return fgTIMESTAMP( t.seconds + ( t.millis + m ) / 1000,
-                       ( t.millis + m ) % 1000 );
+    return FGTimeStamp( t.seconds + ( t.usec + m ) / 1000000,
+                       ( t.usec + m ) % 1000000 );
 #endif
 }
 
-// difference between time stamps in milliseconds
-inline long operator - (const fgTIMESTAMP& a, const fgTIMESTAMP& b)
+// difference between time stamps in microseconds (usec)
+inline long operator - (const FGTimeStamp& a, const FGTimeStamp& b)
 {
 #if defined( WIN32 )
-    return a.millis - b.millis;
+    return a.usec - b.usec;
 #else
-    return 1000 * (a.seconds - b.seconds) + (a.millis - b.millis);
+    return 1000000 * (a.seconds - b.seconds) + (a.usec - b.usec);
 #endif
 }
 
@@ -163,6 +163,9 @@ inline long operator - (const fgTIMESTAMP& a, const fgTIMESTAMP& b)
 
 
 // $Log$
+// Revision 1.4  1999/01/09 13:37:46  curt
+// Convert fgTIMESTAMP to FGTimeStamp which holds usec instead of ms.
+//
 // Revision 1.3  1999/01/07 20:25:39  curt
 // Portability changes and updates from Bernie Bright.
 //