-
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
Add simple EvAPI and extend EvManager with simplistic SoC calculation #891
base: main
Are you sure you want to change the base?
Conversation
7ae8d8d
to
bc64cb7
Compare
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
bc64cb7
to
b7a727d
Compare
…nnectors" This allows both the API and EvAPI modules to run simultaneously Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
This allows an EV implementation to report more detailed information such as SoC Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Maybe we can combine the new |
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.
In general, things are looking good. See my two comments.
modules/EvAPI/EvAPI.hpp
Outdated
|
||
private: | ||
std::mutex session_info_mutex; | ||
std::string state = "Unknown"; |
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, state
should be types::board_support_common::event
and not std::string
modules/EvAPI/EvAPI.hpp
Outdated
|
||
private: | ||
std::mutex session_info_mutex; | ||
std::string state = "Unknown"; |
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 an enum could be preferable here. It would make it clearer what the possible values can be
modules/EvAPI/EvAPI.cpp
Outdated
this->state = "Unknown"; | ||
} | ||
|
||
void EvSessionInfo::update_state(const std::string& event) { |
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.
Maybe rename event
here? I think it might be a little bit confusing to call this variable event when it actually represents the state
|
||
std::list<std::unique_ptr<EvSessionInfo>> info; | ||
|
||
const std::string api_base = "everest_api/"; |
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.
Perhaps make this a static inline constexpr std::string_view
modules/EvAPI/EvAPI.cpp
Outdated
EvSessionInfo::operator std::string() { | ||
std::lock_guard<std::mutex> lock(this->session_info_mutex); | ||
|
||
auto now = date::utc_clock::now(); |
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 this be made const
?
modules/EvAPI/EvAPI.cpp
Outdated
std::string var_base = ev_base + "/var/"; | ||
|
||
std::string var_ev_info = var_base + "ev_info"; | ||
ev->subscribe_ev_info([this, &ev, var_ev_info](types::evse_manager::EVInfo ev_info) { | ||
json ev_info_json = ev_info; | ||
this->mqtt.publish(var_ev_info, ev_info_json.dump()); | ||
}); | ||
|
||
std::string var_session_info = var_base + "session_info"; | ||
ev->subscribe_bsp_event([this, var_session_info, &session_info](const auto& bsp_event) { | ||
session_info->update_state(types::board_support_common::event_to_string(bsp_event.event)); | ||
this->mqtt.publish(var_session_info, *session_info); | ||
}); |
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 it could improve readability if those blocks are refactored to static functions like publish_ev_info
and publish_session_info
}; | ||
|
||
void CarSimulation::simulate_soc() { | ||
double ms = |
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 be made const
double ms = | ||
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - timepoint_last_update) | ||
.count(); | ||
double factor = (1.0 / 60.0 / 60.0 / 1000.0) * ms; |
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.
Also const
const module::Conf& config; | ||
std::chrono::time_point<std::chrono::steady_clock> timepoint_last_update; | ||
double charge_current_a{0}; | ||
double charge_voltage_v{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.
Is there a reason this is a class member? As far as I can see this is only used in one function where it's just copying the value of the config so it could live only there
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
This is was only used for AC, where we now get it via the config Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
…e enum Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Describe your changes
Issue ticket number and link
Checklist before requesting a review