}
-// Portability wrap to get current time.
-void timestamp(fg_timestamp *timestamp) {
-#if defined( WIN32 )
- unsigned int t;
- t = timeGetTime();
- timestamp->seconds = 0;
- timestamp->millis = t;
-#elif defined( HAVE_GETTIMEOFDAY )
- struct timeval current;
- struct timezone tz;
- // fg_timestamp currtime;
- gettimeofday(¤t, &tz);
- timestamp->seconds = current.tv_sec;
- timestamp->millis = current.tv_usec / 1000;
-#elif defined( HAVE_GETLOCALTIME )
- SYSTEMTIME current;
- GetLocalTime(¤t);
- timestamp->seconds = current.wSecond;
- timestamp->millis = current.wMilliseconds;
-#elif defined( HAVE_FTIME )
- struct timeb current;
- ftime(¤t);
- timestamp->seconds = current.time;
- timestamp->millis = current.millitm;
-#else
-# error Port me
-#endif
-}
-
-
-// Return duration in millis from first to last
-long timediff(fg_timestamp *first, fg_timestamp *last) {
-#if defined( WIN32 )
- return (last->millis - first->millis);
-#else
- return ( 1000 * (last->seconds - first->seconds) +
- (last->millis - first->millis) );
-#endif
-}
-
-
-// Return new timestamp given a time stamp and an interval to add in
-void timesum(fg_timestamp *res, fg_timestamp *start, long millis) {
-#ifdef WIN32
- res->seconds = 0;
- res->millis = ( start->millis + millis );
-#else
- res->seconds = start->seconds +
- ( start->millis + millis ) / 1000;
- res->millis = ( start->millis + millis ) % 1000;
-#endif
-}
-
-
// given a date in months, mn, days, dy, years, yr, return the
// modified Julian date (number of days elapsed since 1900 jan 0.5),
// mjd. Adapted from Xephem.
start_gmt = get_start_gmt(gmt->tm_year);
FG_LOG( FG_EVENT, FG_DEBUG,
- " COURSE: GMT = %d/%d/%2d %d:%02d:%02d\n"
+ " COURSE: GMT = "
<< gmt->tm_mon << "/" << gmt->tm_mday << "/" << gmt->tm_year
<< " "
<< gmt->tm_hour << ":" << gmt->tm_min << ":" << gmt->tm_sec );
// Update time variables such as gmt, julian date, and sidereal time
-void fgTimeUpdate(fgFLIGHT *f, fgTIME *t) {
+void fgTimeUpdate(FGState *f, fgTIME *t) {
double gst_precise, gst_course;
- FG_LOG( FG_EVENT, FG_BULK, "Updating time" );
+ FG_LOG( FG_EVENT, FG_DEBUG, "Updating time" );
// get current Unix calendar time (in seconds)
t->warp += t->warp_delta;
t->cur_time = time(NULL) + t->warp;
- FG_LOG( FG_EVENT, FG_BULK,
+ FG_LOG( FG_EVENT, FG_DEBUG,
" Current Unix calendar time = " << t->cur_time
<< " warp = " << t->warp << " delta = " << t->warp_delta );
// get GMT break down for current time
t->gmt = gmtime(&t->cur_time);
- FG_LOG( FG_EVENT, FG_BULK,
+ FG_LOG( FG_EVENT, FG_DEBUG,
" Current GMT = " << t->gmt->tm_mon+1 << "/"
<< t->gmt->tm_mday << "/" << t->gmt->tm_year << " "
<< t->gmt->tm_hour << ":" << t->gmt->tm_min << ":"
// convert "back" to Julian date + partial day (as a fraction of one)
t->jd = t->mjd + MJD0;
- FG_LOG( FG_EVENT, FG_BULK, " Current Julian Date = " << t->jd );
+ FG_LOG( FG_EVENT, FG_DEBUG, " Current Julian Date = " << t->jd );
// printf(" Current Longitude = %.3f\n", FG_Longitude * RAD_TO_DEG);
gst_course = sidereal_course(t, 0.00);
t->gst_diff = gst_precise - gst_course;
- t->lst = sidereal_course(t, -(FG_Longitude * RAD_TO_DEG)) + t->gst_diff;
+ t->lst =
+ sidereal_course(t, -(f->get_Longitude() * RAD_TO_DEG)) + t->gst_diff;
} else {
// course + difference should drift off very slowly
t->gst = sidereal_course(t, 0.00) + t->gst_diff;
- t->lst = sidereal_course(t, -(FG_Longitude * RAD_TO_DEG)) + t->gst_diff;
+ t->lst = sidereal_course(t, -(f->get_Longitude() * RAD_TO_DEG)) +
+ t->gst_diff;
}
FG_LOG( FG_EVENT, FG_DEBUG,
" Current lon=0.00 Sidereal Time = " << t->gst );
FG_LOG( FG_EVENT, FG_DEBUG,
" Current LOCAL Sidereal Time = " << t->lst << " ("
- << sidereal_precise(t->mjd, -(FG_Longitude * RAD_TO_DEG))
+ << sidereal_precise(t->mjd, -(f->get_Longitude() * RAD_TO_DEG))
<< ") (diff = " << t->gst_diff << ")" );
}
// $Log$
+// Revision 1.26 1998/12/05 15:54:28 curt
+// Renamed class fgFLIGHT to class FGState as per request by JSB.
+//
+// Revision 1.25 1998/12/05 14:21:30 curt
+// Moved struct fg_timestamp to class fgTIMESTAMP and moved it's definition
+// to it's own file, timestamp.hxx.
+//
+// Revision 1.24 1998/12/04 01:32:49 curt
+// Converted "struct fg_timestamp" to "class fgTIMESTAMP" and added some
+// convenience inline operators.
+//
+// Revision 1.23 1998/12/03 01:18:40 curt
+// Converted fgFLIGHT to a class.
+//
+// Revision 1.22 1998/11/16 14:00:28 curt
+// FG_LOG() message tweaks.
+//
// Revision 1.21 1998/11/06 21:18:26 curt
// Converted to new logstream debugging facility. This allows release
// builds with no messages at all (and no performance impact) by using