-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
add dds config tool #13628
add dds config tool #13628
Conversation
4c15cb3
to
6234882
Compare
6234882
to
7e2db73
Compare
@@ -0,0 +1,332 @@ | |||
#include "dds-model.h" | |||
// License: Apache 2.0. See LICENSE file in root directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misplaced, should be on top
tools/dds/dds-config/CMakeLists.txt
Outdated
@@ -9,6 +9,7 @@ file( GLOB_RECURSE RS_DDS_CONFIG_SOURCE_FILES | |||
LIST_DIRECTORIES false | |||
RELATIVE ${PROJECT_SOURCE_DIR} | |||
"${CMAKE_CURRENT_LIST_DIR}/*" | |||
"${PROJECT_SOURCE_DIR}/../../../third-party/rsutils/include/rsutils/type/*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This path seems weird..
relative to the source dir we only need third-party/rsutils/include/rsutils/type/*
no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The source dir for the dds tool is librealsense\tools\dds\dds-config so only using part of the path won't work but I can set the THIRD_PARTY_DIR so it looks more readable:
set(THIRD_PARTY_DIR "${PROJECT_SOURCE_DIR}/../../../third-party")
"${THIRD_PARTY_DIR}/rsutils/include/rsutils/type/*"
common/device-model.cpp
Outdated
@@ -1457,6 +1472,7 @@ namespace rs2 | |||
} | |||
|
|||
_calib_model.update(window, error_message); | |||
_dds_model.render_dds_config_window(window , error_message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work id we build with DDS off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add a check to see if the device supports DDS before using this function.
But in general, yes the functionality works with DDS off because the function already checks whether the window should be open. If the device doesn't support DDS, the window is closed by default.
common/device-model.cpp
Outdated
@@ -1435,6 +1436,20 @@ namespace rs2 | |||
} | |||
} | |||
} | |||
ImGuiSelectableFlags is_streaming_flag = (is_streaming) ? ImGuiSelectableFlags_Disabled : 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the difference between 0 and ImGuiSelectableFlags_Disabled
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0 is equal to ImGuiSelectableFlags_None that will show the "DDS Configuration" option an enabled
and using the ImGuiSelectableFlags_Disabled will show this option as disabled (faded and not allowing clicks on it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why not replace 0 with ImGuiSelectableFlags_None
?
common/dds-model.h
Outdated
#include <set> | ||
#include <rsutils/type/ip-address.h> | ||
#include <rsutils/string/hexdump.h> | ||
#include "../third-party/rsutils/include/rsutils/type/eth-config.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also use <>?
<party/rsutils/include/rsutils/type/eth-config.h>
?
eth_config _current_config; | ||
eth_config _changed_config; | ||
|
||
bool _window_open; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not initialized but other is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialized _window_open to false as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
initialized in the constructor initialization list
common/dds-model.cpp
Outdated
if (ImGui::InputText(label_name.c_str(), buffer, sizeof(buffer))) { | ||
std::string new_ip_str(buffer); | ||
if (rsutils::type::ip_address(new_ip_str).is_valid()) { | ||
ip = rsutils::type::ip_address(new_ip_str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why calling it twice?
Maybe call it once and use it on both cases?
common/dds-model.cpp
Outdated
if (rsutils::type::ip_address(new_ip_str).is_valid()) { | ||
ip = rsutils::type::ip_address(new_ip_str); | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line please for the {
common/dds-model.cpp
Outdated
ImGui::Text("DHCP Timeout (seconds)"); | ||
ImGui::SameLine(); | ||
int tempTimeout = static_cast<int>(_changed_config.dhcp.timeout); | ||
if (ImGui::InputInt("##DHCP Timeout (seconds)", &tempTimeout)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please place { on a new line for all uses here.
I will send you a mail about using clang format
@Noy-Zini can you please build a version for us to play with and check? |
4bead95
to
16d7803
Compare
common/dds-model.cpp
Outdated
|
||
bool rs2::dds_model::supports_DDS() | ||
{ | ||
return _dds_suported; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supported
16d7803
to
6cb2c25
Compare
@@ -105,7 +105,7 @@ bool eth_config::operator==( eth_config const & other ) const noexcept | |||
// Only compare those items that are configurable | |||
return configured.ip == other.configured.ip && configured.netmask == other.configured.netmask | |||
&& configured.gateway == other.configured.gateway && dds.domain_id == other.dds.domain_id | |||
&& dhcp.on == other.dhcp.on && link.priority == other.link.priority && link.timeout == other.link.timeout; | |||
&& dhcp.on == other.dhcp.on && link.priority == other.link.priority && link.timeout == other.link.timeout && dhcp.timeout != other.dhcp.timeout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be ==
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes thank I fixed it 👍
896a47d
to
81fa5a9
Compare
} | ||
current = &( *current )[token]; // getting to the next level in the JSON structure | ||
} | ||
return current->get< T >(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get
might throw if value is of wrong type.
You can use get_ex
to get value and success indication.
@@ -87,6 +87,105 @@ namespace rs2 | |||
|
|||
static config_file& instance(); | |||
|
|||
// Retrieves a value from a nested JSON structure using dot notation | |||
template< typename T > | |||
T get_nested( const std::string & path ) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we return T
or config_value
like get
?
{ | ||
( *current )[keys[i]] = rsutils::json::object(); | ||
} | ||
current = &( *current )[keys[i]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that working with a reference, not a pointer, will be easier and the syntax clearer
std::stringstream val_ss; | ||
val_ss << default_val; | ||
_defaults[path] = val_ss.str(); | ||
save(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we saving to file here? User did not select apply
#include <set> | ||
#include <rsutils/type/ip-address.h> | ||
#include <rsutils/string/hexdump.h> | ||
#include <../third-party/rsutils/include/rsutils/type/eth-config.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can shorten #include <rsutils/type/eth-config.h>
like the other includes
bool const ACTUAL_VALUES = 0; | ||
bool const DEFULT_VALUES = 1; | ||
|
||
enum priority { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Define under the class namespace. Looks like it can be private
#include <rsutils/json.h> | ||
#include <rsutils/json-config.h> | ||
|
||
uint32_t const GET_ETH_CONFIG = 0xBB; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constsants should be under a namespace at minimum. Better yet, move to CPP as these are internal details that don't need to be included by users
#include <realsense_imgui.h> | ||
#include <set> | ||
#include <rsutils/type/ip-address.h> | ||
#include <rsutils/string/hexdump.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all these includes needed here? Move to cpp what's used only by implementation and doesn't need to be declared here
{ | ||
if( check_DDS_support() ) | ||
{ | ||
_defult_config = get_eth_config( _device, DEFULT_VALUES ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You implicitly convert int to bool and later check the bool and convert back to int. Better just pass int as parameter and use it int curr_or_default
.
if( check_DDS_support() ) | ||
{ | ||
_defult_config = get_eth_config( _device, DEFULT_VALUES ); | ||
_current_config = get_eth_config( _device, ACTUAL_VALUES ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need the first parameter, it is always _device
and can be used internally.
} | ||
else | ||
{ | ||
std::snprintf( buffer, sizeof( buffer ), "%s", ip.to_string().c_str() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
break; | ||
case DYNAMIC: | ||
_changed_config.link.priority | ||
= _current_config.link.speed ? link_priority::dynamic_eth_first : link_priority::dynamic_usb_first; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic not clear. Add a comment "If link speed is not 0 than we are connected by Ethernet"
} | ||
ImGui::Checkbox( "No Reset after changes", &_no_reset ); | ||
|
||
if( ImGui::Checkbox( "Load to defult values", &_set_defult ) ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Load default values", "to" is redundant
Need to add scroll bars to the settings when minimized. In another PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR, helpful capability.
As discussed offline, we will merge now, open comments will be handled in a follow-up PR
Tracked on : [RSDEV-2884]