-
Notifications
You must be signed in to change notification settings - Fork 9
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
BufferManager: add mutex, configuration from file, empty constructor workflow et al #65
Conversation
- The ChannelInfo has been changed from a struct of two elements to a std::pair, in order to be easily handled with the json file conf. - All the flags, options of the BufferManager have been put in the BufferConfig - The empty constructor is allowed now, for this we added all the functions needed for configuring a default BufferManager(It fixes #60) - The mutex has been added in saveToFile(partially address #9 - Now the periodicSave, saves only the variables that go above the data_treshold specified
if (ok && _bufferConfig.save_periodically) { | ||
ok = ok && enablePeriodicSave(_bufferConfig.save_period); | ||
} | ||
// TODO ROLL BACK IN CASE OF FAILURE |
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.
If you do not plan to address these, please open issues for any open points. TODO in the code get forgotten quite easily, better to open issues to track then.
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.
Issue #72 opened
bool configureFromFile(const std::string& config_filename) { | ||
// read a JSON file | ||
std::ifstream input_stream(config_filename); | ||
nlohmann::json jason_file; | ||
input_stream >> jason_file; | ||
return configure(jason_file.get<yarp::telemetry::BufferConfig>()); | ||
} |
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't we have this as a free function instead, something like bool configureFromJSONFile(BufferManager& manager, const std::string& config_filename)
?
This would avoid needles coupling of the specific configuration method with the BufferManager class.
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 has been addressed in b5b431e.
Instead of BufferManager
I put as I/O BufferConfig
, in order to avoid circular dependencies
Before merging this maybe we should address #66 that seems straightforward and in this way, we avoid having so many additions |
5ae9a26
to
eaa72fd
Compare
CMakeLists.txt
Outdated
@@ -62,6 +62,23 @@ find_package(matioCpp REQUIRED) | |||
find_package(Boost REQUIRED) | |||
find_package(Threads REQUIRED) | |||
|
|||
option(YARP_TELEMETRY_USES_SYSTEM_nlohmann_json OFF) | |||
if(YARP_TELEMETRY_USES_SYSTEM_nlohmann_json) | |||
find_package(nlohmann_json 3.9.0 REQUIRED) |
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.
Do you really require 3.9? Ubuntu 20.04 ships with 3.7 in apt (https://repology.org/project/nlohmann-json/versions), I would try to at least enable it, if then it does not work we can fix it to the minimum working version.
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 need 3.9.0 for this macro. But we can write the functions by hand.
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.
If we actually need 3.9 then it is ok for me!
Looking https://github.com/robotology-playground/yarp-telemetry/pull/65/checks?check_run_id=1853547617 seems that someone is putting |
Here is why nlohmann/json#2513, we need 3.9.2(that is unreleased) |
FetchContent can also use a specific commit, and then we can switch to 3.9.2 once is released. |
…truct We have to move these in different header It fixes #39
eaa72fd
to
857945e
Compare
I put |
In this way we can have multiple parsers implementation and keep the parser library as private dependency
The
ChannelInfo
has been changed from a struct of two elements to astd::pair
, in order to be easily handled with the JSON file conf.All the flags, options of the BufferManager have been put in the BufferConfig
The empty constructor is allowed now, for this we added all the functions
needed for configuring a default BufferManager(It fixes Support use of the default argument-less constructor for BufferManager class #60)
The mutex has been added in
saveToFile
(partially address Understand how to ensure mutual exclusion of the buffer #9)Now the periodicSave, saves only the variables that go above the
data_treshold specified
Fixes the bug of not saving when the threshold > n_samples(fixes Enforce relative condition between threshold (the max number of samples before) and number of samples #61 )
It has been added the configuration from JSON file using this library with relative example (it fixes Investigation file-based configuration of the buffer manager #39)
It add the possibility to save
BufferConfig
to json file(it fixes Add support to save the configuration #68)It add
nlhomann_json v3.9.0
as dependency viaFetchContent
( it fixes json parser: use fetch content #66)Here is an example of JSON file for configuring the
BufferManager
:For now we used the json library just importing the
json.hpp
file, this has to be in the future to an "extern" folder or better with the cmake FetchContent mechanism.Please review code.
cc @traversaro @S-Dafarra @GiulioRomualdi