Skip to content

Commit

Permalink
add options-watcher to dds devices
Browse files Browse the repository at this point in the history
  • Loading branch information
maloel committed Feb 8, 2024
1 parent f7779eb commit ca52704
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/dds/rs-dds-sensor-proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "rs-dds-sensor-proxy.h"
#include "rs-dds-option.h"

#include <src/device.h>
#include <src/software-device.h>

#include <realdds/dds-device.h>
#include <realdds/dds-time.h>
Expand Down Expand Up @@ -35,6 +35,12 @@ dds_sensor_proxy::dds_sensor_proxy( std::string const & sensor_name,
, _name( sensor_name )
, _md_enabled( dev->supports_metadata() )
{
rsutils::json const & settings = owner->get_context()->get_settings();
if( auto interval_j = settings.nested( std::string( "options-update-interval", 23 ) ) )
{
auto interval = interval_j.get< uint32_t >(); // NOTE: can throw!
_options_watcher.set_update_interval( std::chrono::milliseconds( interval ) );
}
}


Expand Down Expand Up @@ -156,6 +162,12 @@ void dds_sensor_proxy::register_basic_converters()
}


rsutils::subscription dds_sensor_proxy::register_options_changed_callback( options_watcher::callback && cb )
{
return _options_watcher.subscribe( std::move( cb ) );
}


std::shared_ptr< realdds::dds_video_stream_profile >
dds_sensor_proxy::find_profile( sid_index sidx, realdds::dds_video_stream_profile const & profile ) const
{
Expand Down Expand Up @@ -536,6 +548,7 @@ void dds_sensor_proxy::add_option( std::shared_ptr< realdds::dds_option > option
[=]( const std::string & name, float value ) { _dev->set_option_value( option, value ); },
[=]( const std::string & name ) -> float { return _dev->query_option_value( option ); } );
register_option( option_id, opt );
_options_watcher.register_option( option_id, opt );
}


Expand Down
8 changes: 6 additions & 2 deletions src/dds/rs-dds-sensor-proxy.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2023 Intel Corporation. All Rights Reserved.

#pragma once


#include "sid_index.h"
#include <src/frame.h>
#include <src/software-sensor.h>
#include <src/proc/formats-converter.h>
#include <src/core/options-watcher.h>

#include <realdds/dds-metadata-syncer.h>

Expand Down Expand Up @@ -42,6 +41,7 @@ class dds_sensor_proxy : public software_sensor
std::shared_ptr< realdds::dds_device > const _dev;
std::string const _name;
bool const _md_enabled;
options_watcher _options_watcher;

typedef realdds::dds_metadata_syncer syncer_type;
static void frame_releaser( syncer_type::frame_type * f ) { static_cast< frame * >( f )->release(); }
Expand Down Expand Up @@ -80,6 +80,10 @@ class dds_sensor_proxy : public software_sensor

const std::map< sid_index, std::shared_ptr< realdds::dds_stream > > & streams() const { return _streams; }

// sensor_interface
public:
rsutils::subscription register_options_changed_callback( options_watcher::callback && ) override;

protected:
void register_basic_converters();
stream_profiles init_stream_profiles() override;
Expand Down

0 comments on commit ca52704

Please sign in to comment.