Moved Time/timestamp.hxx into simgear/timing/timestamp.hxx
This commit is contained in:
parent
bde6c86fce
commit
57a4c79eb5
9 changed files with 20 additions and 201 deletions
|
@ -40,12 +40,12 @@
|
||||||
#include <plib/ssg.h>
|
#include <plib/ssg.h>
|
||||||
|
|
||||||
#include <simgear/misc/props.hxx>
|
#include <simgear/misc/props.hxx>
|
||||||
|
#include <simgear/timing/timestamp.hxx>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <plib/fnt.h>
|
#include <plib/fnt.h>
|
||||||
|
|
||||||
#include <Time/timestamp.hxx>
|
|
||||||
|
|
||||||
FG_USING_STD(vector);
|
FG_USING_STD(vector);
|
||||||
FG_USING_STD(map);
|
FG_USING_STD(map);
|
||||||
|
@ -540,8 +540,8 @@ private:
|
||||||
float _pointSize;
|
float _pointSize;
|
||||||
|
|
||||||
mutable string _value;
|
mutable string _value;
|
||||||
mutable FGTimeStamp _then;
|
mutable SGTimeStamp _then;
|
||||||
mutable FGTimeStamp _now;
|
mutable SGTimeStamp _now;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,11 @@
|
||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/math/sg_geodesy.hxx>
|
#include <simgear/math/sg_geodesy.hxx>
|
||||||
|
#include <simgear/timing/timestamp.hxx>
|
||||||
|
|
||||||
#include <Scenery/scenery.hxx>
|
#include <Scenery/scenery.hxx>
|
||||||
#include <FDM/LaRCsim/ls_interface.h>
|
#include <FDM/LaRCsim/ls_interface.h>
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
#include <Time/timestamp.hxx>
|
|
||||||
|
|
||||||
#include "External.hxx"
|
#include "External.hxx"
|
||||||
#include "flight.hxx"
|
#include "flight.hxx"
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <Time/timestamp.hxx>
|
#include <simgear/timing/timestamp.hxx>
|
||||||
|
|
||||||
FG_USING_STD(list);
|
FG_USING_STD(list);
|
||||||
FG_USING_STD(vector);
|
FG_USING_STD(vector);
|
||||||
|
@ -252,8 +252,8 @@ private:
|
||||||
// Engine list
|
// Engine list
|
||||||
engine_list engines;
|
engine_list engines;
|
||||||
|
|
||||||
FGTimeStamp valid_stamp; // time this record is valid
|
SGTimeStamp valid_stamp; // time this record is valid
|
||||||
FGTimeStamp next_stamp; // time this record is valid
|
SGTimeStamp next_stamp; // time this record is valid
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _busdump(void);
|
void _busdump(void);
|
||||||
|
@ -974,7 +974,7 @@ public:
|
||||||
|
|
||||||
inline double get_Climb_Rate() const { return climb_rate; }
|
inline double get_Climb_Rate() const { return climb_rate; }
|
||||||
|
|
||||||
inline FGTimeStamp get_time_stamp() const { return valid_stamp; }
|
inline SGTimeStamp get_time_stamp() const { return valid_stamp; }
|
||||||
inline void stamp_time() { valid_stamp = next_stamp; next_stamp.stamp(); }
|
inline void stamp_time() { valid_stamp = next_stamp; next_stamp.stamp(); }
|
||||||
|
|
||||||
// Extrapolate FDM based on time_offset (in usec)
|
// Extrapolate FDM based on time_offset (in usec)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <simgear/io/sg_serial.hxx>
|
#include <simgear/io/sg_serial.hxx>
|
||||||
#include <simgear/io/sg_socket.hxx>
|
#include <simgear/io/sg_socket.hxx>
|
||||||
#include <simgear/math/sg_types.hxx>
|
#include <simgear/math/sg_types.hxx>
|
||||||
|
#include <simgear/timing/timestamp.hxx>
|
||||||
|
|
||||||
#include <Network/protocol.hxx>
|
#include <Network/protocol.hxx>
|
||||||
#include <Network/native.hxx>
|
#include <Network/native.hxx>
|
||||||
|
@ -42,8 +43,6 @@
|
||||||
#include <Network/rul.hxx>
|
#include <Network/rul.hxx>
|
||||||
#include <Network/joyclient.hxx>
|
#include <Network/joyclient.hxx>
|
||||||
|
|
||||||
#include <Time/timestamp.hxx>
|
|
||||||
|
|
||||||
#include "globals.hxx"
|
#include "globals.hxx"
|
||||||
|
|
||||||
FG_USING_STD(string);
|
FG_USING_STD(string);
|
||||||
|
@ -228,8 +227,8 @@ void fgIOProcess() {
|
||||||
|
|
||||||
static int inited = 0;
|
static int inited = 0;
|
||||||
int interval;
|
int interval;
|
||||||
static FGTimeStamp last;
|
static SGTimeStamp last;
|
||||||
FGTimeStamp current;
|
SGTimeStamp current;
|
||||||
|
|
||||||
if ( ! inited ) {
|
if ( ! inited ) {
|
||||||
inited = 1;
|
inited = 1;
|
||||||
|
|
|
@ -6,7 +6,6 @@ libTime_a_SOURCES = \
|
||||||
light.cxx light.hxx \
|
light.cxx light.hxx \
|
||||||
moonpos.cxx moonpos.hxx \
|
moonpos.cxx moonpos.hxx \
|
||||||
sunpos.cxx sunpos.hxx \
|
sunpos.cxx sunpos.hxx \
|
||||||
timestamp.hxx \
|
|
||||||
tmp.cxx tmp.hxx
|
tmp.cxx tmp.hxx
|
||||||
# fg_time.cxx fg_time.hxx \
|
# fg_time.cxx fg_time.hxx \
|
||||||
# geocoord.cxx geocoord.h \
|
# geocoord.cxx geocoord.h \
|
||||||
|
|
|
@ -253,7 +253,7 @@ fgEVENT_MGR::PrintStats()
|
||||||
// the queue
|
// the queue
|
||||||
void fgEVENT_MGR::Process( void ) {
|
void fgEVENT_MGR::Process( void ) {
|
||||||
fgEVENT *e_ptr;
|
fgEVENT *e_ptr;
|
||||||
FGTimeStamp cur_time;
|
SGTimeStamp cur_time;
|
||||||
unsigned int i, size;
|
unsigned int i, size;
|
||||||
|
|
||||||
FG_LOG( FG_EVENT, FG_DEBUG, "Processing events" );
|
FG_LOG( FG_EVENT, FG_DEBUG, "Processing events" );
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
|
#include <simgear/timing/timestamp.hxx>
|
||||||
|
|
||||||
#include <Include/fg_callback.hxx>
|
#include <Include/fg_callback.hxx>
|
||||||
|
|
||||||
|
@ -38,7 +39,6 @@
|
||||||
#include <list> // STL list
|
#include <list> // STL list
|
||||||
#include STL_STRING
|
#include STL_STRING
|
||||||
|
|
||||||
#include "timestamp.hxx"
|
|
||||||
|
|
||||||
FG_USING_STD(deque);
|
FG_USING_STD(deque);
|
||||||
FG_USING_STD(list);
|
FG_USING_STD(list);
|
||||||
|
@ -87,9 +87,9 @@ private:
|
||||||
|
|
||||||
long interval; // interval in ms between each iteration of this event
|
long interval; // interval in ms between each iteration of this event
|
||||||
|
|
||||||
FGTimeStamp last_run;
|
SGTimeStamp last_run;
|
||||||
FGTimeStamp current;
|
SGTimeStamp current;
|
||||||
FGTimeStamp next_run;
|
SGTimeStamp next_run;
|
||||||
|
|
||||||
long cum_time; // cumulative processor time of this event
|
long cum_time; // cumulative processor time of this event
|
||||||
long min_time; // time of quickest execution
|
long min_time; // time of quickest execution
|
||||||
|
|
|
@ -36,8 +36,9 @@
|
||||||
# include <sys/time.h> // for get/setitimer, gettimeofday, struct timeval
|
# include <sys/time.h> // for get/setitimer, gettimeofday, struct timeval
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <simgear/timing/timestamp.hxx>
|
||||||
|
|
||||||
#include "fg_timer.hxx"
|
#include "fg_timer.hxx"
|
||||||
#include "timestamp.hxx"
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long int fgSimTime;
|
unsigned long int fgSimTime;
|
||||||
|
@ -99,8 +100,8 @@ void fgTimerInit(float dt, void (*f)( int )) {
|
||||||
int fgGetTimeInterval( void ) {
|
int fgGetTimeInterval( void ) {
|
||||||
int interval;
|
int interval;
|
||||||
static int inited = 0;
|
static int inited = 0;
|
||||||
static FGTimeStamp last;
|
static SGTimeStamp last;
|
||||||
FGTimeStamp current;
|
SGTimeStamp current;
|
||||||
|
|
||||||
|
|
||||||
if ( ! inited ) {
|
if ( ! inited ) {
|
||||||
|
|
|
@ -1,180 +0,0 @@
|
||||||
// timestamp.hxx -- class for managing a timestamp (seconds & milliseconds.)
|
|
||||||
//
|
|
||||||
// Written by Curtis Olson, started December 1998.
|
|
||||||
//
|
|
||||||
// Copyright (C) 1998 Curtis L. Olson - curt@flightgear.org
|
|
||||||
//
|
|
||||||
// This program is free software; you can redistribute it and/or
|
|
||||||
// modify it under the terms of the GNU General Public License as
|
|
||||||
// published by the Free Software Foundation; either version 2 of the
|
|
||||||
// License, or (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful, but
|
|
||||||
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
// General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program; if not, write to the Free Software
|
|
||||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
//
|
|
||||||
// $Id$
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _TIMESTAMP_HXX
|
|
||||||
#define _TIMESTAMP_HXX
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __cplusplus
|
|
||||||
# error This library requires C++
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_WINDOWS_H
|
|
||||||
# include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
|
||||||
|
|
||||||
#ifdef FG_HAVE_STD_INCLUDES
|
|
||||||
# include <ctime>
|
|
||||||
#else
|
|
||||||
# include <time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TIMEB_H
|
|
||||||
# include <sys/timeb.h> // for ftime() and struct timeb
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_UNISTD_H
|
|
||||||
# include <unistd.h> // for gettimeofday()
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_SYS_TIME_H
|
|
||||||
# include <sys/time.h> // for get/setitimer, gettimeofday, struct timeval
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// -dw- want to use metrowerks time.h
|
|
||||||
#ifdef macintosh
|
|
||||||
# include <time.h>
|
|
||||||
# include <timer.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
# include <windows.h>
|
|
||||||
# if defined( __CYGWIN__ ) || defined( __CYGWIN32__ )
|
|
||||||
# define NEAR /* */
|
|
||||||
# define FAR /* */
|
|
||||||
# endif
|
|
||||||
# include <mmsystem.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// MSVC++ 6.0 kuldge - Need forward declaration of friends.
|
|
||||||
class FGTimeStamp;
|
|
||||||
FGTimeStamp operator + (const FGTimeStamp& t, const long& m);
|
|
||||||
long operator - (const FGTimeStamp& a, const FGTimeStamp& b);
|
|
||||||
|
|
||||||
class FGTimeStamp {
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
long seconds;
|
|
||||||
long usec;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
FGTimeStamp();
|
|
||||||
FGTimeStamp( const long s, const long m );
|
|
||||||
~FGTimeStamp();
|
|
||||||
|
|
||||||
// Set time to current time
|
|
||||||
void stamp();
|
|
||||||
|
|
||||||
FGTimeStamp& operator = ( const FGTimeStamp& t );
|
|
||||||
|
|
||||||
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_usec() const { return usec; }
|
|
||||||
};
|
|
||||||
|
|
||||||
inline FGTimeStamp::FGTimeStamp() {
|
|
||||||
}
|
|
||||||
|
|
||||||
inline FGTimeStamp::FGTimeStamp( const long s, const long u ) {
|
|
||||||
seconds = s;
|
|
||||||
usec = u;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline FGTimeStamp::~FGTimeStamp() {
|
|
||||||
}
|
|
||||||
|
|
||||||
inline FGTimeStamp& FGTimeStamp::operator = (const FGTimeStamp& t)
|
|
||||||
{
|
|
||||||
seconds = t.seconds;
|
|
||||||
usec = t.usec;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void FGTimeStamp::stamp() {
|
|
||||||
#if defined( WIN32 )
|
|
||||||
unsigned int t;
|
|
||||||
t = timeGetTime();
|
|
||||||
seconds = 0;
|
|
||||||
usec = t * 1000;
|
|
||||||
#elif defined( HAVE_GETTIMEOFDAY )
|
|
||||||
struct timeval current;
|
|
||||||
struct timezone tz;
|
|
||||||
// fg_timestamp currtime;
|
|
||||||
gettimeofday(¤t, &tz);
|
|
||||||
seconds = current.tv_sec;
|
|
||||||
usec = current.tv_usec;
|
|
||||||
#elif defined( HAVE_GETLOCALTIME )
|
|
||||||
SYSTEMTIME current;
|
|
||||||
GetLocalTime(¤t);
|
|
||||||
seconds = current.wSecond;
|
|
||||||
usec = current.wMilliseconds * 1000;
|
|
||||||
#elif defined( HAVE_FTIME )
|
|
||||||
struct timeb current;
|
|
||||||
ftime(¤t);
|
|
||||||
seconds = current.time;
|
|
||||||
usec = current.millitm * 1000;
|
|
||||||
// -dw- uses time manager
|
|
||||||
#elif defined( macintosh )
|
|
||||||
UnsignedWide ms;
|
|
||||||
Microseconds(&ms);
|
|
||||||
|
|
||||||
seconds = ms.lo / 1000000;
|
|
||||||
usec = ms.lo - ( seconds * 1000000 );
|
|
||||||
#else
|
|
||||||
# error Port me
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// increment the time stamp by the number of microseconds (usec)
|
|
||||||
inline FGTimeStamp operator + (const FGTimeStamp& t, const long& m) {
|
|
||||||
#ifdef WIN32
|
|
||||||
return FGTimeStamp( 0, t.usec + m );
|
|
||||||
#else
|
|
||||||
return FGTimeStamp( t.seconds + ( t.usec + m ) / 1000000,
|
|
||||||
( t.usec + m ) % 1000000 );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// difference between time stamps in microseconds (usec)
|
|
||||||
inline long operator - (const FGTimeStamp& a, const FGTimeStamp& b)
|
|
||||||
{
|
|
||||||
#if defined( WIN32 )
|
|
||||||
return a.usec - b.usec;
|
|
||||||
#else
|
|
||||||
return 1000000 * (a.seconds - b.seconds) + (a.usec - b.usec);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _TIMESTAMP_HXX
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue