24 CLinearCoefficients::CLinearCoefficients(
unsigned int buffer_size) :
26 _buffer_size(buffer_size),
86 sum_x += crnt_sample.
_x;
87 sum_y += crnt_sample.
_y;
88 sum_xy += (crnt_sample.
_x * crnt_sample.
_y);
89 sum_x2 += (crnt_sample.
_x * crnt_sample.
_x);
91 b = (sum_y*sum_x2 - sum_x * sum_xy) / (n*sum_x2 - sum_x * sum_x);
92 a = (n*sum_xy - sum_x * sum_y) / (n*sum_x2 - sum_x * sum_x);
134 base_x = max_device_time;
135 else if ((x -
_last_values.front()._x) > max_device_time / 2)
136 base_x = -max_device_time;
139 LOG_DEBUG(__FUNCTION__ <<
"(" << base_x <<
")");
159 _poll_intervals_ms(sampling_interval_ms),
163 _min_command_delay(1000),
164 _active_object([this](
dispatcher::cancellable_timer cancellable_timer)
184 LOG_ERROR(
"time_diff_keeper users_count <= 0.");
190 LOG_DEBUG(
"time_diff_keeper::stop: stop object.");
211 double command_delay = (system_time_finish-system_time_start)/2;
224 CSample crnt_sample(sample_hw_time, system_time);
231 LOG_DEBUG(
"Temporary skip during time_diff_keeper polling: " << ex.
what());
235 LOG_DEBUG(
"Temporary skip during time_diff_keeper polling: " << ex.
what());
237 catch (
const std::exception& ex)
239 LOG_ERROR(
"Error during time_diff_keeper polling: " << ex.what());
243 LOG_ERROR(
"Unknown error during time_diff_keeper polling!");
252 if (!cancellable_timer.
try_sleep(time_to_sleep))
254 LOG_DEBUG(
"Notification: time_diff_keeper polling loop is being shut-down");
273 std::shared_ptr<time_diff_keeper> timediff,
274 std::shared_ptr<global_time_option> enable_option) :
275 _device_timestamp_reader(
std::
move(device_timestamp_reader)),
276 _time_diff_keeper(timediff),
277 _option_is_enabled(enable_option),
290 frame_time = sp->get_system_hw_time(frame_time,
_ts_is_ready);
292 LOG_DEBUG(
"Notification: global_timestamp_reader - time_diff_keeper is being shut-down");
void get_a_b(double x, double &a, double &b) const
std::recursive_mutex _enable_mtx
static const textual_icon lock
double _min_command_delay
time_diff_keeper(global_time_interface *dev, const unsigned int sampling_interval_ms)
static const double TIMESTAMP_USEC_TO_MSEC
GLboolean GLboolean GLboolean b
rs2_timestamp_domain get_frame_timestamp_domain(const std::shared_ptr< frame_interface > &frame) const override
void update_last_sample_time(double x)
double get_system_hw_time(double crnt_hw_time, bool &is_ready)
void add_value(CSample val)
std::recursive_mutex _read_mtx
void add_const_y_coefs(double dy)
std::shared_ptr< global_time_option > _option_is_enabled
global_time_interface * _device
std::deque< CSample > _last_values
GLboolean GLboolean GLboolean GLboolean a
unsigned int _poll_intervals_ms
std::shared_ptr< time_diff_keeper > _tf_keeper
std::unique_ptr< frame_timestamp_reader > _device_timestamp_reader
CLinearCoefficients _coefs
unsigned long long get_frame_counter(const std::shared_ptr< frame_interface > &frame) const override
virtual double get_device_time_ms()=0
bool update_samples_base(double x)
std::weak_ptr< time_diff_keeper > _time_diff_keeper
auto operator+=(std::string &lhs, StringRef const &sr) -> std::string &
global_timestamp_reader(std::unique_ptr< frame_timestamp_reader > device_timestamp_reader, std::shared_ptr< time_diff_keeper > timediff, std::shared_ptr< global_time_option >)
active_object _active_object
const char * what() const noexceptoverride
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
double calc_value(double x) const
double _last_request_time
unsigned int _buffer_size
void enable_time_diff_keeper(bool is_enable)
bool try_sleep(std::chrono::milliseconds::rep ms)
void polling(dispatcher::cancellable_timer cancellable_timer)
rs2_time_t get_frame_timestamp(const std::shared_ptr< frame_interface > &frame) override
rs2_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.