libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::TimestampMS Class Reference

表示毫秒级时间戳的类。Class representing a timestamp in milliseconds. More...

#include <libxr_time.hpp>

Data Structures

class  TimeDiffMS
 表示毫秒级时间差的类。Class representing a time difference in milliseconds. More...
 

Public Member Functions

 TimestampMS (uint32_t millisecond)
 
 operator uint32_t () const
 
TimeDiffMS operator- (TimestampMS &old_millisecond)
 计算两个时间戳之间的时间差。 Computes the time difference between two timestamps.
 

Private Attributes

uint32_t millisecond_
 以毫秒存储的时间戳。Timestamp stored in milliseconds.
 

Detailed Description

表示毫秒级时间戳的类。Class representing a timestamp in milliseconds.

Definition at line 135 of file libxr_time.hpp.

Constructor & Destructor Documentation

◆ TimestampMS() [1/2]

LibXR::TimestampMS::TimestampMS ( )
inline

Definition at line 138 of file libxr_time.hpp.

138: millisecond_(0) {}
uint32_t millisecond_
以毫秒存储的时间戳。Timestamp stored in milliseconds.

◆ TimestampMS() [2/2]

LibXR::TimestampMS::TimestampMS ( uint32_t  millisecond)
inline

Definition at line 139 of file libxr_time.hpp.

constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

Member Function Documentation

◆ operator uint32_t()

LibXR::TimestampMS::operator uint32_t ( ) const
inline

Definition at line 140 of file libxr_time.hpp.

140{ return millisecond_; }

◆ operator-()

TimeDiffMS LibXR::TimestampMS::operator- ( TimestampMS old_millisecond)
inline

计算两个时间戳之间的时间差。 Computes the time difference between two timestamps.

Parameters
old_millisecond旧的时间戳。The older timestamp.
Returns
TimeDiffMS 计算得到的时间差。Computed time difference.

Definition at line 196 of file libxr_time.hpp.

197 {
198 uint32_t diff; // NOLINT
199
200 if (millisecond_ >= old_millisecond.millisecond_)
201 {
202 diff = millisecond_ - old_millisecond.millisecond_;
203 }
204 else
205 {
206 diff = millisecond_ + (libxr_timebase_max_valid_ms - old_millisecond.millisecond_);
207 }
208
209 ASSERT(diff <= libxr_timebase_max_valid_ms);
210
211 return TimeDiffMS(diff);
212 }

Field Documentation

◆ millisecond_

uint32_t LibXR::TimestampMS::millisecond_
private

以毫秒存储的时间戳。Timestamp stored in milliseconds.

Definition at line 215 of file libxr_time.hpp.


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