Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00021
00022
00023
00024
00025
00026
00028
00029 #include <math.h>
00030
00031 #include "p_driver.h"
00032 using namespace Stg;
00033
00034
00035 StTime::StTime( StgDriver* driver )
00036 {
00037 assert(driver);
00038 this->driver = driver;
00039 return;
00040 }
00041
00042
00043 StTime::~StTime()
00044 {
00045 return;
00046 }
00047
00048
00049 int StTime::GetTime(struct timeval* time)
00050 {
00051 PRINT_DEBUG( "get time" );
00052
00053 assert( this->driver );
00054
00055 World* world = driver->world;
00056
00057 usec_t usec = world->SimTimeNow();
00058 time->tv_sec = (int)floor(usec/million);
00059 time->tv_usec = (int)rint(fmod(usec,million) * million);
00060
00061 PRINT_DEBUG2( "time now %ld sec %ld usec", time->tv_sec, time->tv_usec );
00062
00063 return 0;
00064 }
00065
00066 int StTime::GetTimeDouble(double* time)
00067 {
00068 PRINT_DEBUG( "get time (double)" );
00069
00070 assert( this->driver );
00071
00072 World* world = driver->world;
00073
00074 *time = world->SimTimeNow() / million;
00075
00076 PRINT_DEBUG1( "time now %f sec ", *time);
00077
00078 return 0;
00079 }