-
Notifications
You must be signed in to change notification settings - Fork 74
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
Adding Ocpp Configuration Module #799
base: main
Are you sure you want to change the base?
Conversation
#include "mapping_reader.hpp" | ||
#include "util.hpp" | ||
#include <iostream> |
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.
put includes into sections
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.
Done but I think this should be done automatically by some tool instead of having to do it manually. Isn't this set up somehow already?
4fa1426
to
475e176
Compare
72147ca
to
2b86368
Compare
|
||
private: | ||
const std::optional<EverestConfigMapping> | ||
find_mapping_by_component_variable_or_log_error(const types::ocpp::ComponentVariable& component_variable) 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.
It should be considered normal to receive event data for variables that are not part of the mapping, so I wouldnt throw a runtime_error
exception here but simply do nothing in case nothing can be found in the mapping. I think its enough to only have this function:
const std::optional<EverestConfigMapping> find_mapping_by_component_variable(const types::ocpp::ComponentVariable& component_variable) 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.
I decided to keep both functions but change the high level function to not log any error.
My reasoning was that the high level function checks if the low level function returned a value and if not returns a nullopt and the other function makes the actual lookup.
This way both functions have just one responsibility and I can still use the raii approach in the caller function of the high level function
namespace module { | ||
|
||
void OCPPConfiguration::init() { | ||
invoke_init(*p_main); |
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 should verify the configuration parameters in the init:
- Check if mapping file exists and is valid and warn if it doesn't
- Check if user config exists and warn if it doesn't
In case the configuration could not be verified this module is not operational, but it should not crash, since it doesn't provide any interface and shold not cause a crash of everest ever.
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 first case is handled implicitly now but I think the second case shouldn't generate a warning and just silently create the file. Do you disagree?
namespace module { | ||
OcppToEverestConfigMapping MappingReader::read_mapping(const std::filesystem::path& file_path) { | ||
const auto hacked_file_path = | ||
std::filesystem::path{"modules"} / "OCPPConfiguration" / file_path; // TODO: this is very hacky |
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 ;) you could pass the mapping file path in the constructor of the 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.
I completely changed this and I think the solution is good, so this comment would be irrelevant then
throw std::runtime_error("EVSE node must have an id"); | ||
} | ||
const auto id_val = node["id"].val(); | ||
auto id = std::stoi(std::string{id_val.str, id_val.len}); |
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 should catch std::invalid_argument
|
||
const auto connector_id_optional_val = node.has_child("id") ? std::optional{node["id"].val()} : std::nullopt; | ||
auto connector_id = connector_id_optional_val.has_value() | ||
? std::optional{std::stoi(std::string{connector_id_optional_val.value().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.
This should catch std::invalid_argument
a27fc7f
to
a7cb4be
Compare
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.
does not touch Rust or Bazel, so lgtm.
85c6c08
to
cae1e6b
Compare
f6022fe
to
83f3de8
Compare
Signed-off-by: MarzellT <[email protected]>
Signed-off-by: MarzellT <[email protected]>
Signed-off-by: MarzellT <[email protected]>
… information to the config Signed-off-by: MarzellT <[email protected]>
Signed-off-by: MarzellT <[email protected]>
Signed-off-by: MarzellT <[email protected]>
Signed-off-by: MarzellT <[email protected]>
Signed-off-by: MarzellT <[email protected]>
* adds first documentation draft * renames config-mapping to example-config-mapping * removes monitor_variables from config * small refactorings Signed-off-by: MarzellT <[email protected]>
…on ocpp config Signed-off-by: MarzellT <[email protected]>
…ll refactoring Signed-off-by: MarzellT <[email protected]>
Signed-off-by: MarzellT <[email protected]>
Signed-off-by: MarzellT <[email protected]>
83f3de8
to
10db827
Compare
Describe your changes
Issue ticket number and link
Checklist before requesting a review