l500-device.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2018 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
6 #include <vector>
7 #include <mutex>
8 #include <string>
9 #include "device.h"
10 #include "context.h"
11 #include "backend.h"
12 #include "hw-monitor.h"
13 #include "image.h"
14 #include "stream.h"
15 #include "l500-private.h"
16 #include "error-handling.h"
19 #include "device-calibration.h"
20 
21 namespace librealsense
22 {
23  class l500_depth_sensor;
24  class l500_color_sensor;
25 
27  : public virtual device
28  , public debug_interface
29  , public global_time_interface
30  , public updatable
31  , public device_calibration
32  {
33  public:
34  l500_device(std::shared_ptr<context> ctx,
36 
37  std::shared_ptr<synthetic_sensor> create_depth_device(std::shared_ptr<context> ctx,
38  const std::vector<platform::uvc_device_info>& all_device_infos);
39 
40  virtual void configure_depth_options();
41 
42  virtual l500_color_sensor * get_color_sensor() = 0;
43 
47  {
49  return dynamic_cast<uvc_sensor&>(*depth_sensor.get_raw_sensor());
50  }
51 
53  {
54  _calibration_change_callbacks.push_back( callback );
55  }
56 
58 
60 
61  std::vector< uint8_t > send_receive_raw_data(const std::vector< uint8_t > & input) override;
62 
63  void hardware_reset() override
64  {
66  }
67 
68  void create_snapshot(std::shared_ptr<debug_interface>& snapshot) const override;
69  void enable_recording(std::function<void(const debug_interface&)> record_action) override;
70  double get_device_time_ms() override;
71 
72  void enter_update_state() const override;
73  std::vector<uint8_t> backup_flash(update_progress_callback_ptr callback) override;
74  void update_flash(const std::vector<uint8_t>& image, update_progress_callback_ptr callback, int update_mode) override;
75  void update_flash_section(std::shared_ptr<hw_monitor> hwm, const std::vector<uint8_t>& image, uint32_t offset, uint32_t size,
76  update_progress_callback_ptr callback, float continue_from, float ratio);
77  void update_section(std::shared_ptr<hw_monitor> hwm, const std::vector<uint8_t>& merged_image, flash_section fs, uint32_t tables_size,
78  update_progress_callback_ptr callback, float continue_from, float ratio);
79  void update_flash_internal(std::shared_ptr<hw_monitor> hwm, const std::vector<uint8_t>& image, std::vector<uint8_t>& flash_backup,
80  update_progress_callback_ptr callback, int update_mode);
81 
83 
84 
85  protected:
88 
89  friend class l500_depth_sensor;
90 
91  std::shared_ptr<hw_monitor> _hw_monitor;
93 
94  std::shared_ptr<polling_error_handler> _polling_error_handler;
95 
98  std::shared_ptr<stream_interface> _depth_stream;
99  std::shared_ptr<stream_interface> _ir_stream;
100  std::shared_ptr<stream_interface> _confidence_stream;
101 
102  std::shared_ptr< ivcam2::ac_trigger > _autocal;
103 
104  void force_hardware_reset() const;
105  bool _is_locked = true;
106 
107  //TODO - add these to device class as pure virtual methods
110 
111  std::vector<rs2_option> _advanced_options;
112 
113  std::vector< calibration_change_callback_ptr > _calibration_change_callbacks;
115 
116  mutable std::mutex _temperature_mutex;
117  std::atomic_bool _keep_reading_temperature{ false }; // If true temperature reading thread is working, otherwise indicate to the thread to stop
118  std::atomic_bool _have_temperatures{ false }; // If true, then the _temperatures are valid and up-to-date.
119  std::thread _temperature_reader;
121  };
122 
124  {
125  public:
126  notification decode(int value) override;
127  };
128 
130  {
131  public:
132 
133  void do_after_delay(std::function<void()> action, int milliseconds = 2000)
134  {
135  wait(milliseconds);
136  action();
137  _last_update = std::chrono::system_clock::now();
138  }
139 
140  private:
141  void wait(int milliseconds)
142  {
144  auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(now - _last_update).count();
145 
146  while (diff < milliseconds)
147  {
148  std::this_thread::sleep_for(std::chrono::milliseconds(5));
150  diff = std::chrono::duration_cast<std::chrono::milliseconds>(now - _last_update).count();
151  }
152  }
153 
154  std::chrono::system_clock::time_point _last_update;
155  };
156 }
std::shared_ptr< hw_monitor > _hw_monitor
Definition: l500-device.h:91
std::vector< uint8_t > backup_flash(update_progress_callback_ptr callback) override
std::shared_ptr< synthetic_sensor > create_depth_device(std::shared_ptr< context > ctx, const std::vector< platform::uvc_device_info > &all_device_infos)
std::chrono::system_clock::time_point _last_update
Definition: l500-device.h:154
ivcam2::extended_temperatures _temperatures
Definition: l500-device.h:120
rs2_calibration_type
Definition: rs_device.h:344
void notify_of_calibration_change(rs2_calibration_status status)
std::shared_ptr< sensor_base > get_raw_sensor() const
Definition: sensor.h:218
std::atomic_bool _have_temperatures
Definition: l500-device.h:118
virtual l500_color_sensor * get_color_sensor()=0
GLfloat value
void enter_update_state() const override
void enable_recording(std::function< void(const debug_interface &)> record_action) override
double get_device_time_ms() override
std::vector< rs2_option > _advanced_options
Definition: l500-device.h:111
platform::usb_spec _usb_mode
Definition: l500-device.h:114
unsigned char uint8_t
Definition: stdint.h:78
std::shared_ptr< stream_interface > _depth_stream
Definition: l500-device.h:98
void update_flash_internal(std::shared_ptr< hw_monitor > hwm, const std::vector< uint8_t > &image, std::vector< uint8_t > &flash_backup, update_progress_callback_ptr callback, int update_mode)
void trigger_device_calibration(rs2_calibration_type) override
GLenum GLenum GLsizei void * image
status
Defines return codes that SDK interfaces use. Negative values indicate errors, a zero value indicates...
std::shared_ptr< ivcam2::ac_trigger > _autocal
Definition: l500-device.h:102
std::shared_ptr< rs2_update_progress_callback > update_progress_callback_ptr
Definition: src/types.h:1077
std::shared_ptr< stream_interface > _confidence_stream
Definition: l500-device.h:100
firmware_version _fw_version
Definition: l500-device.h:97
GLsizeiptr size
void update_section(std::shared_ptr< hw_monitor > hwm, const std::vector< uint8_t > &merged_image, flash_section fs, uint32_t tables_size, update_progress_callback_ptr callback, float continue_from, float ratio)
rs2_calibration_status
Definition: rs_device.h:356
unsigned int uint32_t
Definition: stdint.h:80
GLboolean GLuint group
Definition: glext.h:5688
std::shared_ptr< stream_interface > _ir_stream
Definition: l500-device.h:99
l500_depth_sensor & get_depth_sensor()
command get_flash_logs_command() const
def callback(frame)
Definition: t265_stereo.py:91
virtual void configure_depth_options()
void do_after_delay(std::function< void()> action, int milliseconds=2000)
Definition: l500-device.h:133
lazy< ivcam2::intrinsic_depth > _calib_table
Definition: l500-device.h:96
uvc_sensor & get_raw_depth_sensor()
Definition: l500-device.h:46
action
Definition: enums.py:62
command get_firmware_logs_command() const
sensor_interface & get_sensor(size_t subdevice) override
Definition: device.cpp:187
std::vector< uint8_t > send_receive_raw_data(const std::vector< uint8_t > &input) override
void hardware_reset() override
Definition: l500-device.h:63
std::shared_ptr< polling_error_handler > _polling_error_handler
Definition: l500-device.h:94
GLenum GLenum GLenum input
Definition: glext.h:10805
std::thread _temperature_reader
Definition: l500-device.h:119
GLint GLsizei count
void update_flash(const std::vector< uint8_t > &image, update_progress_callback_ptr callback, int update_mode) override
std::vector< calibration_change_callback_ptr > _calibration_change_callbacks
Definition: l500-device.h:113
void wait(int milliseconds)
Definition: l500-device.h:141
void register_calibration_change_callback(calibration_change_callback_ptr callback) override
Definition: l500-device.h:52
void create_snapshot(std::shared_ptr< debug_interface > &snapshot) const override
void force_hardware_reset() const
l500_device(std::shared_ptr< context > ctx, const platform::backend_device_group &group)
Definition: l500-device.cpp:54
std::atomic_bool _keep_reading_temperature
Definition: l500-device.h:117
void update_flash_section(std::shared_ptr< hw_monitor > hwm, const std::vector< uint8_t > &image, uint32_t offset, uint32_t size, update_progress_callback_ptr callback, float continue_from, float ratio)
ivcam2::extended_temperatures get_temperatures() const
std::shared_ptr< rs2_calibration_change_callback > calibration_change_callback_ptr
Definition: src/types.h:1074
synthetic_sensor & get_synthetic_depth_sensor()
Definition: l500-device.h:44
GLintptr offset


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:21