-
Notifications
You must be signed in to change notification settings - Fork 53
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
Validate a TxDefaultProfile. #524
Validate a TxDefaultProfile. #524
Conversation
@shankari Please review these changes. |
9313586
to
6327074
Compare
@shankari In case you missed my previous comment, can you please review this PR? |
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 that some additional documentation would be helpful
- there is a static code analysis error in here
67e95ae
to
537fab6
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.
It is not intended that an Evse instance is initialized with ID 0. Ids of Evses must start from 1 upwards as required by 7.1 EVSE Numbering in OCPP2.0.1 Part 1 - Architecture & Topology. This requires a redesign of the validate_tx_default_profile
function signature, where I think the Evse
argument could simply be replaced with int32_t evse_id
.
The Evse class does there not require a member function is_station_wide
.
Additionally, a more general note: Im not sure if the member std::vector<EvseProfile> charging_profiles
of the SmartChargingHandler
is complex enough to represent more complex combinations of profiles. The OCPP1.6 implementation makes use of two different std::map per EVSE (in 1.6 Evse and Connector is equivilant):
https://github.com/EVerest/libocpp/blob/main/include/ocpp/v16/connector.hpp#L20
537fab6
to
8b67c08
Compare
fa19bc3
to
8b04483
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.
lgtm, except for some minor function doc updates and the argument for validate_tx_default_profile
.
Please do not squash and force push after a review, so that the changes made afterwards can be reviewed easier. We will squash the commits when we merge into main
include/ocpp/v201/smart_charging.hpp
Outdated
/// \brief validates the given \p profile according to the specification | ||
/// | ||
ProfileValidationResultEnum validate_tx_default_profile(const ChargingProfile& profile, | ||
std::optional<Evse*> evse_opt) 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.
Couldnt we use a const int32_t evse_id
as an argumen instead of std::optional<Evse*> evse_opt
. Would be more simple and easier to read imo.
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.
Please also update the function docs according to the added param
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've been treating the existence of an Evse as a specific instance and the lack of one as indicating ID = 0. I did this work to follow the pattern we have established elsewhere.
But I can use an ID and check if it is 0 instead.
/// \brief Adds a given \p profile to our stored list of profiles | ||
void add_profile(const ChargingProfile& profile); | ||
/// | ||
void add_profile(int32_t evse_id, ChargingProfile& profile); |
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.
Please update the function docs according to the added param
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.
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 needs a rebase since
#534 has been merged
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.
Sorry I am a bit late to the party here but I do have some suggestions/questions.
include/ocpp/v201/smart_charging.hpp
Outdated
@@ -38,7 +44,8 @@ class SmartChargingHandler { | |||
|
|||
std::shared_ptr<ocpp::v201::DatabaseHandler> database_handler; | |||
// cppcheck-suppress unusedStructMember | |||
std::vector<ChargingProfile> charging_profiles; | |||
std::vector<EvseProfile> charging_profiles; |
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.
Would an std::map
with the evse_id and a vector of charging profiles make sense here? That way we don't need the specific type for EvseProfile
and we can search a bit quicker too.
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 have changed it into a map.
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.
Should the second type not be a vector since you can now only store one profile per EVSE? Or are you storing them by ChargingProfile id 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.
Ah, yes, you're correct.
These changes apply to K01FR52 and K01FR53. Signed-off-by: Christoph <[email protected]> Signed-off-by: Gianfranco Berardi <[email protected]>
Signed-off-by: Gianfranco Berardi <[email protected]>
Signed-off-by: Gianfranco Berardi <[email protected]>
3dac9b0
to
962c43a
Compare
Put PR back into draft due to still waiting for @shankari to re-review. |
Signed-off-by: Gianfranco Berardi <[email protected]>
Signed-off-by: Gianfranco Berardi <[email protected]>
Signed-off-by: Gianfranco Berardi <[email protected]>
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.
@gberardi-pillar the changes look fine to me. However, I would suggest that, in the future, you have more detailed commit messages than "Review fix". A short description of what part of the review is being addressed by the commit would be helpful, along with a summary of the changes. You could even add a link to the commit to make it easier for future maintainers to easily find the review without having to search through all the comments in the PR
@Pietfried @marcemmers Is this PR ready to be merged? |
Yes, go for it 👍 |
Ah, but I don't have permission to merge the PR. B-) |
* Validate a TxDefaultProfile. These changes apply to K01FR52 and K01FR53. Signed-off-by: Christoph <[email protected]> Signed-off-by: Gianfranco Berardi <[email protected]> * Review fixes. Signed-off-by: Gianfranco Berardi <[email protected]> * Review fix. Signed-off-by: Gianfranco Berardi <[email protected]> * Add test case. Signed-off-by: Gianfranco Berardi <[email protected]> * Review fix. Signed-off-by: Gianfranco Berardi <[email protected]> * Review fix. Signed-off-by: Gianfranco Berardi <[email protected]> --------- Signed-off-by: Christoph <[email protected]> Signed-off-by: Gianfranco Berardi <[email protected]>
Contributes to #361 |
These changes apply to K01.FR.52 and K01.FR.53.
Given a TxDefaultProfile on an EVSE or on the charging station as a whole, we can validate whether a new TxDefaultProfile is allowed.