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

Can update options automatically, get notification of value change #12483

Merged
merged 20 commits into from
Jan 2, 2024

Conversation

OhadMeir
Copy link
Contributor

@OhadMeir OhadMeir commented Dec 5, 2023

Added option_updater class that handles auto query of registered options.
Added C and CPP API to register a value change notification callback .

Added Python API and unit test

Also fixed bug in cpp unit tests - on restart_first_device_and_return_depth_sensor old device was used after HW reset instead of new device.

src/core/options-updater.h Outdated Show resolved Hide resolved
src/core/options-updater.h Outdated Show resolved Hide resolved
src/sensor.h Show resolved Hide resolved
src/core/CMakeLists.txt Outdated Show resolved Hide resolved
src/core/options-updater.cpp Outdated Show resolved Hide resolved
src/core/options-updater.cpp Outdated Show resolved Hide resolved
src/rs.cpp Outdated Show resolved Hide resolved
src/core/options-watcher.h Outdated Show resolved Hide resolved
src/core/options-watcher.h Outdated Show resolved Hide resolved
src/core/options-watcher.h Outdated Show resolved Hide resolved
src/sensor.h Outdated Show resolved Hide resolved
src/core/options-watcher.h Outdated Show resolved Hide resolved
src/sensor.h Outdated Show resolved Hide resolved
src/core/options-watcher.h Outdated Show resolved Hide resolved
src/CMakeLists.txt Outdated Show resolved Hide resolved
src/sensor.h Outdated Show resolved Hide resolved
src/core/options-watcher.h Outdated Show resolved Hide resolved
@@ -16,6 +16,7 @@ options_watcher::options_watcher( std::chrono::milliseconds update_interval )

options_watcher::~options_watcher()
{
_alive = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to clear _options inside a mutex any more; don't need the try-catch, either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not locking before clear. try-catch needed because clear and join might throw.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you don't need the clear()...

Copy link
Collaborator

@maloel maloel Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if join() might throw, please catch it inside stop()...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to clear explicitly, but locking is not needed.
Also found out clear has a noexcept overload. Catching join errors in stop.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, I don't agree - if you clear, then a lock is necessary.
You don't need to clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -79,7 +79,8 @@ namespace librealsense

rsutils::subscription register_options_changed_callback( options_watcher::callback && cb ) override
{
throw not_implemented_exception( "Registering options value changed callback is not implemented for this sensor" );
LOG_ERROR( "Registering options value changed callback is not implemented for this sensor" );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? I don't think this is good...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we throw then the viewer cannot play recorded files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted change. Viewer handling the exception

@maloel maloel merged commit ee5b8cb into IntelRealSense:development Jan 2, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants