Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emitter On /Off and Emitter Always On enabling together avoided #7911

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/ds5/ds5-active.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,19 @@ namespace librealsense

if (auto hdr_enabled_option = depth_ep.get_option_handler(RS2_OPTION_HDR_ENABLED))
{
std::vector<std::pair<std::shared_ptr<option>, std::string>> emitter_options_and_reasons = { std::make_pair(hdr_enabled_option,
"Emitter status cannot be set while HDR is enabled")};
depth_ep.register_option(RS2_OPTION_EMITTER_ENABLED,
std::make_shared<gated_option>(
emitter_enabled,
hdr_enabled_option,
"Emitter status cannot be set while HDR is enabled"));
emitter_options_and_reasons));

std::vector<std::pair<std::shared_ptr<option>, std::string>> laser_options_and_reasons = { std::make_pair(hdr_enabled_option,
"Laser Power status cannot be set while HDR is enabled") };
depth_ep.register_option(RS2_OPTION_LASER_POWER,
std::make_shared<gated_option>(
laser_power_auto_disabling,
hdr_enabled_option,
"Laser Power status cannot be set while HDR is enabled"));
laser_options_and_reasons));
}
else
{
Expand Down
37 changes: 29 additions & 8 deletions src/ds5/ds5-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -819,11 +819,12 @@ namespace librealsense
exposure_option = hdr_conditional_exposure_option;
gain_option = hdr_conditional_gain_option;

std::vector<std::pair<std::shared_ptr<option>, std::string>> options_and_reasons = { std::make_pair(hdr_enabled_option,
"Auto Exposure cannot be set while HDR is enabled") };
depth_sensor.register_option(RS2_OPTION_ENABLE_AUTO_EXPOSURE,
std::make_shared<gated_option>(
enable_auto_exposure,
hdr_enabled_option,
"Auto Exposure cannot be set while HDR is enabled"));
options_and_reasons));
}
else
{
Expand All @@ -850,13 +851,36 @@ namespace librealsense
if ((_fw_version >= firmware_version("5.11.3.0")) && ((_device_capabilities & mask) == mask))
{
auto alternating_emitter_opt = std::make_shared<alternating_emitter_option>(*_hw_monitor, &raw_depth_sensor, is_fw_version_using_id);
auto emitter_always_on_opt = std::make_shared<emitter_always_on_option>(*_hw_monitor, &depth_sensor);

if ((_fw_version >= firmware_version("5.12.1.0")) && ((_device_capabilities & d400_caps::CAP_GLOBAL_SHUTTER) == d400_caps::CAP_GLOBAL_SHUTTER))
{
std::vector<std::pair<std::shared_ptr<option>, std::string>> options_and_reasons = { std::make_pair(alternating_emitter_opt,
"Emitter always ON cannot be set while Emitter ON/OFF is enabled")};
depth_sensor.register_option(RS2_OPTION_EMITTER_ALWAYS_ON,
std::make_shared<gated_option>(
emitter_always_on_opt,
options_and_reasons));
}

if (_fw_version >= hdr_firmware_version)
{
std::vector<std::pair<std::shared_ptr<option>, std::string>> options_and_reasons = { std::make_pair(hdr_enabled_option, "Emitter ON/OFF cannot be set while HDR is enabled"),
std::make_pair(emitter_always_on_opt, "Emitter ON/OFF cannot be set while Emitter always ON is enabled") };
depth_sensor.register_option(RS2_OPTION_EMITTER_ON_OFF,
std::make_shared<gated_option>(
alternating_emitter_opt,
hdr_enabled_option,
"Emitter ON/OFF cannot be set while HDR is enabled"));
options_and_reasons
));
}
else if ((_fw_version >= firmware_version("5.12.1.0")) && ((_device_capabilities & d400_caps::CAP_GLOBAL_SHUTTER) == d400_caps::CAP_GLOBAL_SHUTTER))
{
std::vector<std::pair<std::shared_ptr<option>, std::string>> options_and_reasons = { std::make_pair(emitter_always_on_opt,
"Emitter ON/OFF cannot be set while Emitter always ON is enabled") };
depth_sensor.register_option(RS2_OPTION_EMITTER_ON_OFF,
std::make_shared<gated_option>(
alternating_emitter_opt,
options_and_reasons));
}
else
{
Expand All @@ -869,10 +893,7 @@ namespace librealsense
depth_sensor.register_option(RS2_OPTION_EMITTER_ON_OFF, std::make_shared<emitter_on_and_off_option>(*_hw_monitor, &raw_depth_sensor));
}

if ((_fw_version >= firmware_version("5.12.1.0")) && ((_device_capabilities & d400_caps::CAP_GLOBAL_SHUTTER) == d400_caps::CAP_GLOBAL_SHUTTER))
{
depth_sensor.register_option(RS2_OPTION_EMITTER_ALWAYS_ON, std::make_shared<emitter_always_on_option>(*_hw_monitor, &depth_sensor));
}


if (_fw_version >= firmware_version("5.12.4.0") && (_device_capabilities & d400_caps::CAP_GLOBAL_SHUTTER) == d400_caps::CAP_GLOBAL_SHUTTER)
{
Expand Down
40 changes: 26 additions & 14 deletions src/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -592,28 +592,40 @@ namespace librealsense
{
public:
explicit gated_option(std::shared_ptr<option> leading_to_read_only,
std::shared_ptr<option> gated_option, std::string reason = "This option cannot be set right now")
: proxy_option(leading_to_read_only), _gated_option(gated_option), _reason(reason)
{}
std::vector<std::pair<std::shared_ptr<option>, std::string>> gated_options)
: proxy_option(leading_to_read_only)
{
for (auto& gated : gated_options)
{
_gated_options.push_back(gated);
}
}

void set(float value) override
{
auto strong = _gated_option.lock();
if (!strong)
return;
auto val = strong->query();

if (val)
LOG_WARNING(_reason.c_str());
else
_proxy->set(value);

bool gated_set = false;
for (auto& gated : _gated_options)
{
auto strong = gated.first.lock();
if (!strong)
return;
auto val = strong->query();
if (val)
{
gated_set = true;
LOG_WARNING(gated.second.c_str());
}
}

if (!gated_set)
_proxy->set(value);

_recording_function(*this);
}

private:
std::weak_ptr<option> _gated_option;
std::string _reason;
std::vector < std::pair<std::weak_ptr<option>, std::string> > _gated_options;
};

/** \brief class provided a control
Expand Down