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.
Misplaced, should be on top
| 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.
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.
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/*"
| } | ||
|
|
||
| _calib_model.update(window, error_message); | ||
| _dds_model.render_dds_config_window(window , error_message); |
There was a problem hiding this comment.
Will this work id we build with DDS off?
There was a problem hiding this comment.
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.
| } | ||
| } | ||
| } | ||
| ImGuiSelectableFlags is_streaming_flag = (is_streaming) ? ImGuiSelectableFlags_Disabled : 0; |
There was a problem hiding this comment.
What is the difference between 0 and ImGuiSelectableFlags_Disabled?
There was a problem hiding this comment.
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.
So why not replace 0 with ImGuiSelectableFlags_None?
| #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.
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.
Not initialized but other is?
There was a problem hiding this comment.
initialized _window_open to false as well
There was a problem hiding this comment.
initialized in the constructor initialization list
| 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.
Why calling it twice?
Maybe call it once and use it on both cases?
| if (rsutils::type::ip_address(new_ip_str).is_valid()) { | ||
| ip = rsutils::type::ip_address(new_ip_str); | ||
| } | ||
| else { |
| 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.
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
|
|
||
| bool rs2::dds_model::supports_DDS() | ||
| { | ||
| return _dds_suported; |
16d7803 to
6cb2c25
Compare
| 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.
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.
get might throw if value is of wrong type.
You can use get_ex to get value and success indication.
|
|
||
| // 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.
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.
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.
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.
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.
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.
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.
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.
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.
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() ); |
| 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.
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.
"Load default values", "to" is redundant
|
Need to add scroll bars to the settings when minimized. In another PR. |
OhadMeir
left a comment
There was a problem hiding this comment.
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]