Repository navigation
make hwmon_response product line dependent - #13444
Conversation
| friend class d400_depth_sensor; | ||
|
|
||
| std::shared_ptr<hw_monitor> _hw_monitor; | ||
| std::shared_ptr<ds::d400_hwmon_response_handler> hw_monitor_response = std::make_shared<ds::d400_hwmon_response_handler>(); |
There was a problem hiding this comment.
Why here and not in the constructor?
|
@OhadMeir please review |
|
|
||
| std::string hwmon_error_string( command const &, hwmon_response e ); | ||
| typedef int32_t hwmon_response; | ||
| class base_hwmon_response_handler { // base class for different product number to implement responses |
There was a problem hiding this comment.
We don't have product numbers, you probably meant product ID, which also does not sound correct here. Rephrase to products or product lines
| typedef int32_t hwmon_response; | ||
| class base_hwmon_response_handler { // base class for different product number to implement responses | ||
| public: | ||
| inline virtual std::string hwmon_error2str(int e) const = 0; |
There was a problem hiding this comment.
Virtual can be inlined. Remove inline keyword
| class base_hwmon_response_handler { // base class for different product number to implement responses | ||
| public: | ||
| inline virtual std::string hwmon_error2str(int e) const = 0; | ||
| virtual hwmon_response hwmon_Success() const = 0; |
There was a problem hiding this comment.
Meaning is ambiguous, can be understood as is_successful or success_value.
According to the rest of the code it's the later, please rename.
Note - naming convention, should not capitalize after underscore.
|
|
||
| std::string hwmon_error_string( command const &, hwmon_response e ); | ||
| typedef int32_t hwmon_response; | ||
| class base_hwmon_response_handler { // base class for different product number to implement responses |
There was a problem hiding this comment.
On most places we name interfaces as XXX_interface. Consider renaming hwmon_response_handler_interface or hwmon_response_interface (are we a "handler"?).
Also can wrap typedef int32_t hwmon_response in the class namespace as hwmon_response_interface::type
| explicit hw_monitor(std::shared_ptr<locked_transfer> locked_transfer) | ||
| : _locked_transfer(std::move(locked_transfer)) | ||
| explicit hw_monitor(std::shared_ptr<locked_transfer> locked_transfer, std::shared_ptr<base_hwmon_response_handler> hwmon_response_handler) | ||
| : _locked_transfer(std::move(locked_transfer)), hwmon_response_handler(hwmon_response_handler) |
There was a problem hiding this comment.
Use _ as a prefix to member variables name
| public: | ||
| enum d400_hwmon_response_names : int32_t | ||
| { | ||
| hwm_Success = 0, |
There was a problem hiding this comment.
As we discussed, can shorten the literal names because it's in a class namespace.
d400_hwmon_response::success
|
|
||
| std::shared_ptr<base_hwmon_response_handler> hwmon_response_handler; | ||
|
|
||
| std::string hwmon_error_string(command const&, int e) const; |
There was a problem hiding this comment.
Should be hwmon_response not int
| hwmon_response response; | ||
| auto res = _hwm.send( cmd, &response ); // avoid the throw | ||
| switch( response ) | ||
| if (response != _hwm.hwmon_response_handler->hwmon_Success()) // If no subpreset is streaming, the firmware returns "NO_DATA_TO_RETURN" error |
There was a problem hiding this comment.
This is not exactly equivalent to the former logic. Why was this changed?
There was a problem hiding this comment.
I think it's becasue now we get the success value from a virtual function. I'm getting an error when trying to use _hwm.hwmon_response_handler->hwmon_Success() as a 'case' value ('this' can not be used in a constant expression)
There was a problem hiding this comment.
Yes, but now you don't have any reference to hwmon_response::hwm_NoDataToReturn, is it not needed?
You can replace switch with some else if clauses, but here you have changed the logic. Just make sure its intended and works as expected.
There was a problem hiding this comment.
oh I see, thanks, I will add no_data_to_return_opcode as a member to this class, like we did on alternating_emitter_option
| { | ||
| public: | ||
| alternating_emitter_option(hw_monitor& hwm, bool is_fw_version_using_id); | ||
| alternating_emitter_option(hw_monitor& hwm, bool is_fw_version_using_id, int no_data_to_return_opcode); |
There was a problem hiding this comment.
Use hwmon_response type, not int
| class d400_hwmon_response_handler : public base_hwmon_response_handler | ||
| { | ||
| public: | ||
| enum d400_hwmon_response_names : int32_t |
There was a problem hiding this comment.
Here too, use the defined hwmon_response type
| { | ||
| public: | ||
| enum d400_hwmon_response_names : int32_t | ||
| { |
There was a problem hiding this comment.
Rename d400_hwmon_response_names to opcodes. It will be under the class namespace.
| @@ -94,6 +94,7 @@ namespace librealsense | |||
| friend class d400_depth_sensor; | |||
|
|
|||
| std::shared_ptr<hw_monitor> _hw_monitor; | |||
There was a problem hiding this comment.
Member hw_monitor_response is not needed, create the shared object as you directly pass it into _hw_monitor.
Also, should be prefixed with _
| class d500_hwmon_response_handler : public base_hwmon_response_handler | ||
| { | ||
| public: | ||
| enum d500_hwmon_response_names : int32_t |
Tracked on: [LRS-1105]