17#ifndef CYBER_PYTHON_INTERNAL_PY_TIME_H_
18#define CYBER_PYTHON_INTERNAL_PY_TIME_H_
34 explicit PyTime(uint64_t nanoseconds) { time_ =
Time(nanoseconds); }
63 duration_ = std::make_shared<Duration>(nanoseconds);
66 void sleep()
const {
return duration_->Sleep(); }
69 std::shared_ptr<Duration> duration_ =
nullptr;
74 explicit PyRate(uint64_t nanoseconds) {
75 rate_ = std::make_shared<Rate>(nanoseconds);
78 void sleep()
const {
return rate_->Sleep(); }
79 void reset()
const {
return rate_->Reset(); }
80 uint64_t
get_cycle_time()
const {
return rate_->CycleTime().ToNanosecond(); }
82 return rate_->ExpectedCycleTime().ToNanosecond();
86 std::shared_ptr<Rate> rate_ =
nullptr;
PyDuration(int64_t nanoseconds)
uint64_t get_expected_cycle_time() const
uint64_t get_cycle_time() const
PyRate(uint64_t nanoseconds)
static PyTime mono_time()
PyTime(uint64_t nanoseconds)
static void sleep_until(uint64_t nanoseconds)
Cyber has builtin time type Time.
static void SleepUntil(const Time &time)
Sleep Until time.
uint64_t ToNanosecond() const
convert time to nanosecond.
static Time Now()
get the current time.
double ToSecond() const
convert time to second.