Go to the documentation of this file.
5 #ifndef UAVCAN_TIME_HPP_INCLUDED
6 #define UAVCAN_TIME_HPP_INCLUDED
12 #include <uavcan/Timestamp.hpp>
68 return *
static_cast<D*
>(
this);
73 return *
static_cast<D*
>(
this);
76 template <
typename Scale>
79 template <
typename Scale>
82 *
this = *
this * scale;
83 return *
static_cast<D*
>(
this);
94 template <
typename T,
typename D>
154 return *
static_cast<const T*
>(
this) + (-r);
164 return *
static_cast<T*
>(
this);
169 return *
static_cast<T*
>(
this);
203 *
this = fromUSec(ts.usec);
207 operator Timestamp()
const
217 template <
typename D>
220 template <
typename T,
typename D>
223 template <
typename D>
231 (void)
snprintf(ptr, StringBufSize - 1,
"%llu.%06lu",
232 static_cast<unsigned long long>(getAbs().toUSec() / 1000000L),
233 static_cast<unsigned long>(getAbs().toUSec() % 1000000L));
237 template <
typename T,
typename D>
240 (void)
snprintf(buf, StringBufSize,
"%llu.%06lu",
241 static_cast<unsigned long long>(toUSec() / 1000000UL),
242 static_cast<unsigned long>(toUSec() % 1000000UL));
248 template <
typename D>
251 char buf[StringBufSize];
253 return std::string(buf);
256 template <
typename T,
typename D>
259 char buf[StringBufSize];
261 return std::string(buf);
267 template <
typename Stream,
typename D>
277 template <
typename Stream,
typename T,
typename D>
289 #endif // UAVCAN_TIME_HPP_INCLUDED
bool operator>=(const T &r) const
T operator-(const D &r) const
D operator*(Scale scale) const
static T fromMSec(uint64_t ms)
bool operator>(const T &r) const
Implicitly convertible to/from uavcan.Timestamp.
OStream & operator<<(OStream &s, long long x)
static D fromMSec(int64_t ms)
static const unsigned StringBufSize
UtcTime & operator=(const Timestamp &ts)
struct UAVCAN_EXPORT StaticAssert
bool operator!=(const T &r) const
D & operator*=(Scale scale)
bool operator==(const T &r) const
D & operator+=(const D &r)
D operator-(const D &r) const
static T fromUSec(uint64_t us)
int snprintf(char *out, std::size_t maxlen, const char *format,...)
bool operator<(const D &r) const
const UAVCAN_EXPORT T & max(const T &a, const T &b)
bool operator!=(const D &r) const
static std::string toString(long x)
bool operator<=(const D &r) const
D operator+(const D &r) const
UtcTime(const Timestamp &ts)
void toString(char buf[StringBufSize]) const
Prints time in seconds with microsecond resolution.
static const unsigned StringBufSize
bool operator<(const T &r) const
D operator-(const T &r) const
D & operator-=(const D &r)
bool operator==(const D &r) const
bool operator<=(const T &r) const
bool operator>(const D &r) const
void toString(char buf[StringBufSize]) const
Prints time in seconds with microsecond resolution.
T & operator+=(const D &r)
static D fromUSec(int64_t us)
T operator+(const D &r) const
bool operator>=(const D &r) const
T & operator-=(const D &r)