Skip to content
Snippets Groups Projects
Commit 0cde075b authored by Joan Vallvé Navarro's avatar Joan Vallvé Navarro
Browse files

removed old commented code

parent 42766f58
No related branches found
No related tags found
1 merge request!209Time stamp
Pipeline #1873 failed
...@@ -5,15 +5,6 @@ namespace wolf { ...@@ -5,15 +5,6 @@ namespace wolf {
std::ostream& operator<<(std::ostream& os, const TimeStamp& _ts) std::ostream& operator<<(std::ostream& os, const TimeStamp& _ts)
{ {
// std::ios_base::fmtflags fmtfl;
//
// //get/set ostream flags and precision digits
// fmtfl = os.flags(std::ios::left);
// os.setf(std::ios::fixed, std::ios::floatfield);
// std::streamsize nn;
// nn = os.precision(TimeStamp::TIME_STAMP_DIGITS_);
os << _ts.getSeconds() << "." << std::setfill('0') << std::setw(9) << std::right <<_ts.getNanoSeconds(); // write obj to stream os << _ts.getSeconds() << "." << std::setfill('0') << std::setw(9) << std::right <<_ts.getNanoSeconds(); // write obj to stream
return os; return os;
} }
...@@ -34,14 +25,12 @@ TimeStamp::TimeStamp(const TimeStamp& _ts) : ...@@ -34,14 +25,12 @@ TimeStamp::TimeStamp(const TimeStamp& _ts) :
} }
TimeStamp::TimeStamp(const Scalar& _ts) : TimeStamp::TimeStamp(const Scalar& _ts) :
//time_stamp_(_ts)
time_stamp_nano_(_ts > 0 ? (unsigned long int)(_ts*1e9) : 0) time_stamp_nano_(_ts > 0 ? (unsigned long int)(_ts*1e9) : 0)
{ {
// //
} }
TimeStamp::TimeStamp(const unsigned long int& _sec, const unsigned long int& _nsec) : TimeStamp::TimeStamp(const unsigned long int& _sec, const unsigned long int& _nsec) :
//time_stamp_((Scalar)_sec + (Scalar)_nsec/(Scalar)1e9)
time_stamp_nano_(_sec*NANOSECS+_nsec) time_stamp_nano_(_sec*NANOSECS+_nsec)
{ {
// //
...@@ -76,27 +65,11 @@ TimeStamp TimeStamp::operator -(const Scalar& dt) const ...@@ -76,27 +65,11 @@ TimeStamp TimeStamp::operator -(const Scalar& dt) const
inline void TimeStamp::operator -=(const Scalar& dt) inline void TimeStamp::operator -=(const Scalar& dt)
{ {
unsigned long int dt_nano = (unsigned long int)(dt*NANOSECS); unsigned long int dt_nano = (unsigned long int)(dt*NANOSECS);
//time_stamp_ -= dt;
time_stamp_nano_ = (dt_nano > time_stamp_nano_ ? 0 : time_stamp_nano_ - dt_nano); time_stamp_nano_ = (dt_nano > time_stamp_nano_ ? 0 : time_stamp_nano_ - dt_nano);
} }
void TimeStamp::print(std::ostream & ost) const void TimeStamp::print(std::ostream & ost) const
{ {
//std::streamsize nn;
//std::ios_base::fmtflags fmtfl;
//
////get/set ostream flags and precision digits
//fmtfl = ost.flags(std::ios::left);
//ost.setf(std::ios::fixed, std::ios::floatfield);
//nn = ost.precision(TIME_STAMP_DIGITS_);
//
////send to ostream
//ost << this->time_stamp_;
//
////restore flags and precision
//ost.flags(fmtfl);
//ost.precision(nn);
ost << *this; ost << *this;
} }
......
...@@ -23,8 +23,6 @@ class TimeStamp ...@@ -23,8 +23,6 @@ class TimeStamp
{ {
protected: protected:
unsigned long int time_stamp_nano_; ///< Time stamp. Expressed in nanoseconds from 1th jan 1970. unsigned long int time_stamp_nano_; ///< Time stamp. Expressed in nanoseconds from 1th jan 1970.
//Scalar time_stamp_; ///< Time stamp. Expressed in seconds from 1th jan 1970.
//static const unsigned int TIME_STAMP_DIGITS_ = 10; ///< Number of digits to print time stamp values
public: public:
/** \brief Constructor /** \brief Constructor
...@@ -178,101 +176,81 @@ class TimeStamp ...@@ -178,101 +176,81 @@ class TimeStamp
inline void TimeStamp::set(const Scalar& ts) inline void TimeStamp::set(const Scalar& ts)
{ {
//time_stamp_ = ts;
time_stamp_nano_ = (ts > 0 ? (unsigned long int)(ts*NANOSECS) : 0); time_stamp_nano_ = (ts > 0 ? (unsigned long int)(ts*NANOSECS) : 0);
} }
inline void TimeStamp::set(const unsigned long int& sec, const unsigned long int& nanosec) inline void TimeStamp::set(const unsigned long int& sec, const unsigned long int& nanosec)
{ {
//time_stamp_ = (Scalar)(sec) + (Scalar)(nanosec) / (Scalar)(1e9);
time_stamp_nano_ = sec*NANOSECS+nanosec; time_stamp_nano_ = sec*NANOSECS+nanosec;
} }
inline void TimeStamp::set(const timeval& ts) inline void TimeStamp::set(const timeval& ts)
{ {
//time_stamp_ = (Scalar)(ts.tv_sec) + (Scalar)(ts.tv_usec) / 1e6;
time_stamp_nano_ = (unsigned long int)(ts.tv_sec*NANOSECS) + (unsigned long int)(ts.tv_usec*1000); time_stamp_nano_ = (unsigned long int)(ts.tv_sec*NANOSECS) + (unsigned long int)(ts.tv_usec*1000);
} }
inline Scalar TimeStamp::get() const inline Scalar TimeStamp::get() const
{ {
//return time_stamp_;
return ((Scalar)( time_stamp_nano_))*1e-9; return ((Scalar)( time_stamp_nano_))*1e-9;
} }
inline unsigned long int TimeStamp::getSeconds() const inline unsigned long int TimeStamp::getSeconds() const
{ {
//unsigned long int ts;
//ts = (unsigned long int)(((floor(time_stamp_))));
//return ts;
return time_stamp_nano_ / NANOSECS; return time_stamp_nano_ / NANOSECS;
} }
inline unsigned long int TimeStamp::getNanoSeconds() const inline unsigned long int TimeStamp::getNanoSeconds() const
{ {
//Scalar ts;
//ts = (Scalar)((floor(time_stamp_)));
//return (unsigned long int)(((time_stamp_ - ts) * 1e9));
return time_stamp_nano_ % NANOSECS; return time_stamp_nano_ % NANOSECS;
} }
inline void TimeStamp::operator =(const TimeStamp& ts) inline void TimeStamp::operator =(const TimeStamp& ts)
{ {
//time_stamp_ = ts.get();
time_stamp_nano_ = ts.time_stamp_nano_; time_stamp_nano_ = ts.time_stamp_nano_;
} }
inline void TimeStamp::operator =(const Scalar& ts) inline void TimeStamp::operator =(const Scalar& ts)
{ {
//time_stamp_ = ts;
time_stamp_nano_ = (unsigned long int)(ts*NANOSECS); time_stamp_nano_ = (unsigned long int)(ts*NANOSECS);
} }
inline bool TimeStamp::operator ==(const TimeStamp& ts) const inline bool TimeStamp::operator ==(const TimeStamp& ts) const
{ {
//return (time_stamp_ == ts.get());
return (time_stamp_nano_ == ts.time_stamp_nano_); return (time_stamp_nano_ == ts.time_stamp_nano_);
} }
inline bool TimeStamp::operator !=(const TimeStamp& ts) const inline bool TimeStamp::operator !=(const TimeStamp& ts) const
{ {
//return (time_stamp_ != ts.get());
return (time_stamp_nano_ != ts.time_stamp_nano_); return (time_stamp_nano_ != ts.time_stamp_nano_);
} }
inline bool TimeStamp::operator <(const TimeStamp& ts) const inline bool TimeStamp::operator <(const TimeStamp& ts) const
{ {
//return (time_stamp_ < ts.get());
return (time_stamp_nano_ < ts.time_stamp_nano_); return (time_stamp_nano_ < ts.time_stamp_nano_);
} }
inline bool TimeStamp::operator >(const TimeStamp& ts) const inline bool TimeStamp::operator >(const TimeStamp& ts) const
{ {
//return (time_stamp_ > ts.get());
return (time_stamp_nano_ > ts.time_stamp_nano_); return (time_stamp_nano_ > ts.time_stamp_nano_);
} }
inline bool TimeStamp::operator <=(const TimeStamp& ts) const inline bool TimeStamp::operator <=(const TimeStamp& ts) const
{ {
//return (time_stamp_ <= ts.get());
return (time_stamp_nano_ <= ts.time_stamp_nano_); return (time_stamp_nano_ <= ts.time_stamp_nano_);
} }
inline bool TimeStamp::operator >=(const TimeStamp& ts) const inline bool TimeStamp::operator >=(const TimeStamp& ts) const
{ {
//return (time_stamp_ >= ts.get());
return (time_stamp_nano_ >= ts.time_stamp_nano_); return (time_stamp_nano_ >= ts.time_stamp_nano_);
} }
inline void TimeStamp::operator +=(const Scalar& dt) inline void TimeStamp::operator +=(const Scalar& dt)
{ {
//time_stamp_ += dt;
time_stamp_nano_ += (unsigned long int)(dt*NANOSECS); time_stamp_nano_ += (unsigned long int)(dt*NANOSECS);
} }
inline Scalar TimeStamp::operator -(const TimeStamp& ts) const inline Scalar TimeStamp::operator -(const TimeStamp& ts) const
{ {
//return (time_stamp_ - ts.get());
return Scalar((long int)(time_stamp_nano_ - ts.time_stamp_nano_))*1e-9; // long int cast fix overflow in case of negative substraction result return Scalar((long int)(time_stamp_nano_ - ts.time_stamp_nano_))*1e-9; // long int cast fix overflow in case of negative substraction result
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment