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

LinuxTimebase 类,用于获取 Linux 系统的时间基准。Provides a timebase for Linux systems. More...

#include <linux_timebase.hpp>

Inheritance diagram for LibXR::LinuxTimebase:
Collaboration diagram for LibXR::LinuxTimebase:

Public Member Functions

TimestampUS _get_microseconds ()
 获取当前时间戳(微秒级)。Returns the current timestamp in microseconds.
 
TimestampMS _get_milliseconds ()
 获取当前时间戳(毫秒级)
 
- Public Member Functions inherited from LibXR::Timebase
 Timebase (uint64_t max_valid_us=UINT64_MAX, uint32_t max_valid_ms=UINT32_MAX)
 默认构造函数,初始化全局时间基指针。 Default constructor, initializing the global timebase pointer.
 

Additional Inherited Members

- Static Public Member Functions inherited from LibXR::Timebase
static TimestampUS GetMicroseconds ()
 获取当前时间的微秒级时间戳。 Gets the current timestamp in microseconds.
 
static TimestampMS GetMilliseconds ()
 获取当前时间的毫秒级时间戳。 Gets the current timestamp in milliseconds.
 
- Static Public Attributes inherited from LibXR::Timebase
static Timebasetimebase = nullptr
 静态指针,用于存储全局时间基对象。 Static pointer storing the global timebase instance.
 

Detailed Description

LinuxTimebase 类,用于获取 Linux 系统的时间基准。Provides a timebase for Linux systems.

Definition at line 14 of file linux_timebase.hpp.

Member Function Documentation

◆ _get_microseconds()

TimestampUS LibXR::LinuxTimebase::_get_microseconds ( )
inlinevirtual

获取当前时间戳(微秒级)。Returns the current timestamp in microseconds.

Returns
TimestampUS

Implements LibXR::Timebase.

Definition at line 22 of file linux_timebase.hpp.

23 {
24 struct timeval tv;
25 gettimeofday(&tv, nullptr);
26 return ((tv.tv_sec - libxr_linux_start_time.tv_sec) * 1000000 +
27 (tv.tv_usec - libxr_linux_start_time.tv_usec)) %
29 }
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

◆ _get_milliseconds()

TimestampMS LibXR::LinuxTimebase::_get_milliseconds ( )
inlinevirtual

获取当前时间戳(毫秒级)

Returns
TimestampMS

Implements LibXR::Timebase.

Definition at line 36 of file linux_timebase.hpp.

37 {
38 struct timeval tv;
39 gettimeofday(&tv, nullptr);
40 return ((tv.tv_sec - libxr_linux_start_time.tv_sec) * 1000 +
41 (tv.tv_usec - libxr_linux_start_time.tv_usec) / 1000) %
43 }

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