MercuryDPM  0.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Time2Finish Class Reference

estimates the time in seconds when tmax should be reached More...

#include <MercuryTime.h>

Public Member Functions

void set (Mdouble t, Mdouble tmax)
 
Mdouble getTime2Finish (Mdouble t)
 
std::string getFinishTime (Mdouble t)
 

Private Attributes

clock_t start
 
Mdouble t_
 
Mdouble tmax_
 

Detailed Description

estimates the time in seconds when tmax should be reached

Definition at line 49 of file MercuryTime.h.

Member Function Documentation

std::string Time2Finish::getFinishTime ( Mdouble  t)
inline

Definition at line 63 of file MercuryTime.h.

References getTime2Finish().

63  {
64  Mdouble time2Finish = getTime2Finish(t);
65  time_t finish = time(NULL) + time2Finish;
66  std::stringstream ss;
67  //write estimated end time
68  ss << ctime(&finish);
69  //decrement put pointer by one to avoid line break
70  ss.seekp((long)ss.tellp()-1);
71  //write time to finish
72  ss << " (" << time2Finish/3600 << "h)";
73  return ss.str();
74  }
Mdouble getTime2Finish(Mdouble t)
Definition: MercuryTime.h:54
double Mdouble
Definition: ExtendedMath.h:33
Mdouble Time2Finish::getTime2Finish ( Mdouble  t)
inline

Definition at line 54 of file MercuryTime.h.

References start, t_, and tmax_.

Referenced by getFinishTime().

54  {
55  clock_t finish = clock();
56  Mdouble elapsedTime = (Mdouble(finish)-Mdouble(start))/CLOCKS_PER_SEC;
57  Mdouble time2Finish = elapsedTime*(tmax_-t_)/(t-t_);
58  start = finish;
59  t_ = t;
60  return time2Finish;
61  }
Mdouble t_
Definition: MercuryTime.h:78
double Mdouble
Definition: ExtendedMath.h:33
Mdouble tmax_
Definition: MercuryTime.h:78
clock_t start
Definition: MercuryTime.h:77
void Time2Finish::set ( Mdouble  t,
Mdouble  tmax 
)
inline

Definition at line 52 of file MercuryTime.h.

References start, t_, and tmax_.

52 {start = clock(); t_=t; tmax_=tmax;}
Mdouble t_
Definition: MercuryTime.h:78
Mdouble tmax_
Definition: MercuryTime.h:78
clock_t start
Definition: MercuryTime.h:77

Member Data Documentation

clock_t Time2Finish::start
private

Definition at line 77 of file MercuryTime.h.

Referenced by getTime2Finish(), and set().

Mdouble Time2Finish::t_
private

Definition at line 78 of file MercuryTime.h.

Referenced by getTime2Finish(), and set().

Mdouble Time2Finish::tmax_
private

Definition at line 78 of file MercuryTime.h.

Referenced by getTime2Finish(), and set().


The documentation for this class was generated from the following file: