17 #include <type_traits> 46 void set(float)
override 66 float query()
const override {
return *_val; }
72 void update(std::shared_ptr<extension_snapshot> ext)
override 74 if (
auto opt = As<option>(ext))
76 auto new_val = opt->query();
78 _desc = opt->get_description();
90 : _opt_range(opt_range)
97 virtual void enable_recording(std::function<
void(
const option&)> recording_action)
override;
100 std::function<void(const option&)> _recording_function = [](
const option&) {};
117 :_description(description) {}
121 return _description.c_str();
132 template <
class... Args>
148 LOG_WARNING(
"An exception was thrown while notifying inside cascase_option::set");
166 static_cast<float>(max),
167 static_cast<float>(step),
168 static_cast<float>(def), }),
169 _min(
min), _max(max), _step(step), _def(def), _value(
value), _desc(desc)
172 _on_set = [](
float x) {};
176 const std::map<float, std::string>& description_per_value)
178 static_cast<float>(max),
179 static_cast<float>(step),
180 static_cast<float>(def), }),
181 _min(
min), _max(max), _step(step), _def(def), _value(
value), _desc(desc), _item_desc(description_per_value)
184 _on_set = [](
float x) {};
191 if ((_max < val) || (_min >
val))
199 return static_cast<float>(*_value);
210 auto it = _item_desc.find(val);
211 if (
it != _item_desc.end())
213 return it->second.c_str();
220 _item_desc[
val] = desc;
237 void set(
float value)
override;
238 float query()
const override {
return _value; }
241 const char*
get_description()
const override {
return "A simple custom option for a processing block or software device"; }
263 const char*
get_description()
const override {
return "A simple read-only custom option for a software device"; }
264 void set(float)
override 277 bool is_true() {
return (_value > _opt_range.min); }
279 const char*
get_description()
const override {
return "A simple custom option for a processing block"; }
281 using ptr = std::shared_ptr< bool_option >;
287 void set(
float value)
override;
289 float query()
const override;
304 : _ep(ep), _id(id), _description_per_value(description_per_value)
308 const char* get_description()
const override;
312 if (_description_per_value.find(val) != _description_per_value.end())
313 return _description_per_value.at(val).c_str();
318 _record = record_action;
324 std::function<void(const option&)> _record = [](
const option&) {};
338 if (!dev.
set_xu(_xu, _id, reinterpret_cast<uint8_t*>(&t),
sizeof(
T)))
340 _recording_function(*
this);
346 return static_cast<float>(_ep.invoke_powered(
350 if (!dev.
get_xu(_xu, _id, reinterpret_cast<uint8_t*>(&t),
sizeof(
T)))
353 return static_cast<float>(
t);
359 auto uvc_range = _ep.invoke_powered(
367 auto min = *(
reinterpret_cast<int32_t*
>(uvc_range.min.data()));
368 auto max = *(
reinterpret_cast<int32_t*
>(uvc_range.max.data()));
369 auto step = *(
reinterpret_cast<int32_t*
>(uvc_range.step.data()));
370 auto def = *(
reinterpret_cast<int32_t*
>(uvc_range.def.data()));
372 static_cast<float>(max),
373 static_cast<float>(step),
374 static_cast<float>(def) };
380 : _ep(ep), _xu(xu), _id(id), _desciption(
std::
move(description))
384 : _ep(ep), _xu(xu), _id(id), _desciption(
std::
move(description)), _description_per_value(description_per_value)
389 return _desciption.c_str();
393 _recording_function = record_action;
397 if (_description_per_value.find(val) != _description_per_value.end())
398 return _description_per_value.at(val).c_str();
406 std::function<void(const option&)> _recording_function = [](
const option&) {};
419 :
uvc_xu_option<
T>( ep, xu, id, description, description_per_value)
424 std::lock_guard<std::mutex> lk(_mtx);
430 std::lock_guard<std::mutex> lk(_mtx);
439 template<
class T,
class R,
class W,
class U>
445 _struct_interface->
set(_field,
value);
446 _recording_function(*
this);
450 return _struct_interface->get(_field);
471 _recording_function = record_action;
477 std::function<void(const option&)> _recording_function = [](
const option&) {};
480 template<
class T,
class R,
class W,
class U>
485 return std::make_shared<struct_field_option<T, R, W, U>>
492 std::vector<uint8_t> send_receive(
const std::vector<uint8_t>&
data,
int,
bool require_response)
override;
496 : _uvc(uvc), _xu(
std::
move(xu)), _ctrl(ctrl)
511 : _polling_error_handler(handler), _value(1)
516 void set(
float value)
override;
518 float query()
const override;
522 bool is_enabled()
const override;
525 const char* get_description()
const override;
527 const char* get_value_description(
float value)
const override;
530 _recording_function = record_action;
535 std::function<void(const option&)> _recording_function = [](
const option&) {};
544 : _proxy(proxy_option)
549 return _proxy->get_value_description(val);
553 return _proxy->get_description();
555 virtual void set(
float value)
override 557 return _proxy->set(value);
561 return _proxy->query();
566 return _proxy->get_range();
571 return _proxy->is_enabled();
576 return _proxy->is_read_only();
581 _recording_function = record_action;
585 std::function<void(const option&)> _recording_function = [](
const option&) {};
594 std::shared_ptr<option> affected_option,
595 std::vector<float> move_to_manual_values = { 1.f },
596 float manual_value = 0.f)
597 :
proxy_option(auto_disabling), _affected_control(affected_option)
598 , _move_to_manual_values(move_to_manual_values), _manual_value(manual_value)
603 auto strong = _affected_control.lock();
607 auto move_to_manual =
false;
610 if (
std::find(_move_to_manual_values.begin(),
611 _move_to_manual_values.end(),
val) != _move_to_manual_values.end())
613 move_to_manual =
true;
618 LOG_DEBUG(
"Move option to manual mode in order to set a value");
619 strong->set(_manual_value);
622 _recording_function(*
this);
637 std::vector<std::pair<std::shared_ptr<option>,
std::string>> gated_options)
640 for (
auto& gated : gated_options)
642 _gated_options.push_back(gated);
649 bool gated_set =
false;
650 for (
auto& gated : _gated_options)
652 auto strong = gated.first.lock();
666 _recording_function(*
this);
679 std::shared_ptr<option> min_option)
685 auto strong = _min_option.lock();
689 auto min_value = strong->
query();
691 if (min_value > value)
693 auto min = strong->get_range().min;
697 _recording_function(*
this);
710 std::shared_ptr<option> max_option)
716 auto strong = _max_option.lock();
720 auto max_value = strong->
query();
722 if (max_value < value)
724 auto max = strong->get_range().max;
728 _recording_function(*
this);
738 void set(
float value)
override;
740 float query()
const override;
746 return "Enable/Disable Automatic Motion Data Correction";
option_range get_range() const override
bool is_enabled() const override
const option_range _opt_range
option_range get_range() const override
auto_disabling_control(std::shared_ptr< option > auto_disabling, std::shared_ptr< option > affected_option, std::vector< float > move_to_manual_values={1.f}, float manual_value=0.f)
bool is_enabled() const override
std::weak_ptr< option > _max_option
gated_option(std::shared_ptr< option > leading_to_read_only, std::vector< std::pair< std::shared_ptr< option >, std::string >> gated_options)
const char * get_value_description(float val) const override
class provided a control that changes min distance value when changing max distance value ...
void enable_recording(std::function< void(const option &)> record_action) override
const char * get_string(rs2_rs400_visual_preset value)
const char * get_description() const override
readonly_float_option(const option_range &range)
void set(float value) override
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
const char * get_value_description(float val) const override
option_range get_range() const override
std::vector< std::pair< std::weak_ptr< option >, std::string > > _gated_options
virtual void set(float value)=0
float_option_with_description(option_range range, std::string description)
std::vector< float > _move_to_manual_values
float query() const override
float_option(option_range range)
const char * get_description() const override
uvc_pu_option(uvc_sensor &ep, rs2_option id)
bool is_enabled() const override
cascade_option(Args &&...args)
const char * get_description() const override
float query() const override
protected_xu_option(uvc_sensor &ep, platform::extension_unit xu, uint8_t id, std::string description)
const char * get_description() const override
GLsizei const GLchar *const * string
uvc_xu_option(uvc_sensor &ep, platform::extension_unit xu, uint8_t id, std::string description)
platform::extension_unit _xu
option_range get_range() const override
auto_disabling_control class provided a control that disable auto-control when changing the auto disa...
void enable_recording(std::function< void(const option &)> record_action) override
#define LRS_EXTENSION_API
bool is_read_only() const override
const char * get_value_description(float val) const override
void enable_recording(std::function< void(const option &)> record_action) override
const char * get_description() const override
const char * get_value_description(float val) const override
void add_observer(std::function< void(float)> callback)
bool is_valid(const plane_3d &p)
bool_option(bool default_on=true)
std::shared_ptr< option > _proxy
void set(float value) override
virtual void set_with_no_signal(float value)
struct_field_option(std::shared_ptr< struct_interface< T, R, W >> struct_interface, U T::*field, const option_range &range)
std::weak_ptr< option > _affected_control
std::shared_ptr< struct_field_option< T, R, W, U > > make_field_option(std::shared_ptr< struct_interface< T, R, W >> struct_interface, U T::*field, const option_range &range)
min_distance_option(std::shared_ptr< option > min_option, std::shared_ptr< option > max_option)
bool is_read_only() const override
void set_description(float val, const std::string &desc)
const char * get_description() const override
proxy_option(std::shared_ptr< option > proxy_option)
const char * get_description() const override
const std::map< float, std::string > _description_per_value
std::atomic< bool > _is_active
std::shared_ptr< bool_option > ptr
void enable_recording(std::function< void(const option &)> record_action) override
polling_errors_disable(std::shared_ptr< polling_error_handler > handler)
uvc_pu_option(uvc_sensor &ep, rs2_option id, const std::map< float, std::string > &description_per_value)
const char * get_value_description(float val) const override
void enable_recording(std::function< void(const option &)> record_action) override
float query() const override
T && forward(typename::boost::move_detail::remove_reference< T >::type &t) BOOST_NOEXCEPT
std::weak_ptr< option > _min_option
std::map< float, std::string > _item_desc
uvc_xu_option(uvc_sensor &ep, platform::extension_unit xu, uint8_t id, std::string description, const std::map< float, std::string > &description_per_value)
gated_option class will permit the user to perform only read (query) of the read_only option when its...
float query() const override
const_value_option(std::string desc, float val)
float query() const override
max_distance_option(std::shared_ptr< option > max_option, std::shared_ptr< option > min_option)
ptr_option(T min, T max, T step, T def, T *value, const std::string &desc)
platform::extension_unit _xu
bool is_read_only() const override
const_value_option(std::string desc, lazy< float > val)
float query() const override
command_transfer_over_xu(uvc_sensor &uvc, platform::extension_unit xu, uint8_t ctrl)
std::shared_ptr< struct_interface< T, R, W > > _struct_interface
bool is_enabled() const override
typename::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
std::weak_ptr< polling_error_handler > _polling_error_handler
const char * get_description() const override
const std::map< float, std::string > _description_per_value
const char * get_description() const override
ptr_option(T min, T max, T step, T def, T *value, const std::string &desc, const std::map< float, std::string > &description_per_value)
void update(std::shared_ptr< extension_snapshot > ext) override
bool is_enabled() const override
const char * get_description() const override
bool is_enabled() const override
class provided a control that changes max distance value when changing min distance value ...
void on_set(std::function< void(float)> on_set)
void enable_recording(std::function< void(const option &)> record_action) override
bool is_enabled() const override
option_description(std::string description)
float query() const override
protected_xu_option(uvc_sensor &ep, platform::extension_unit xu, uint8_t id, std::string description, const std::map< float, std::string > &description_per_value)
std::function< void(float)> _on_set
option_base(const option_range &opt_range)
const char * get_description() const override
bool is_enabled() const override
std::vector< std::function< void(float)> > _callbacks
std::string to_string(T value)
void enable_recording(std::function< void(const option &)> record_action) override