// The time at which these values are correct (for extrapolating
// later frames between position updates)
- fgTIMESTAMP t;
+ FGTimeStamp t;
// Positions
// $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.
//
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
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;
// $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.
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;
// $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.
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;
// 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;
// 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 );
// $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".
//
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 );
// 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" );
// $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.
//
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
// $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.
//
#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;
// $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.
#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(¤t, &tz);
seconds = current.tv_sec;
- millis = current.tv_usec / 1000;
+ usec = current.tv_usec;
#elif defined( HAVE_GETLOCALTIME )
SYSTEMTIME current;
GetLocalTime(¤t);
seconds = current.wSecond;
- millis = current.wMilliseconds;
+ usec = current.wMilliseconds * 1000;
#elif defined( HAVE_FTIME )
struct timeb current;
ftime(¤t);
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
}
// $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.
//