Skip to content
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

Merged

Conversation

gberardi-pillar
Copy link
Contributor

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.

@gberardi-pillar
Copy link
Contributor Author

@shankari Please review these changes.

@gberardi-pillar gberardi-pillar force-pushed the gberardi/v201-validate-txdefaultprofile branch from 9313586 to 6327074 Compare March 11, 2024 19:44
@gberardi-pillar
Copy link
Contributor Author

@shankari In case you missed my previous comment, can you please review this PR?

Copy link

@shankari shankari left a 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

include/ocpp/v201/smart_charging.hpp Outdated Show resolved Hide resolved
include/ocpp/v201/evse.hpp Outdated Show resolved Hide resolved
@gberardi-pillar gberardi-pillar force-pushed the gberardi/v201-validate-txdefaultprofile branch 3 times, most recently from 67e95ae to 537fab6 Compare March 18, 2024 16:31
Copy link
Contributor

@Pietfried Pietfried left a 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

@gberardi-pillar gberardi-pillar force-pushed the gberardi/v201-validate-txdefaultprofile branch from 537fab6 to 8b67c08 Compare March 22, 2024 20:13
@gberardi-pillar gberardi-pillar force-pushed the gberardi/v201-validate-txdefaultprofile branch 2 times, most recently from fa19bc3 to 8b04483 Compare March 26, 2024 14:32
Copy link
Contributor

@Pietfried Pietfried left a 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

/// \brief validates the given \p profile according to the specification
///
ProfileValidationResultEnum validate_tx_default_profile(const ChargingProfile& profile,
std::optional<Evse*> evse_opt) const;
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor Author

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);
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor

@Pietfried Pietfried left a 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

Copy link
Contributor

@marcemmers marcemmers left a 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.

@@ -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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

lib/ocpp/v201/smart_charging.cpp Show resolved Hide resolved
lib/ocpp/v201/smart_charging.cpp Outdated Show resolved Hide resolved
These changes apply to K01FR52 and K01FR53.

Signed-off-by: Christoph <367712+folkengine@users.noreply.github.com>
Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>
Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>
Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>
@gberardi-pillar gberardi-pillar force-pushed the gberardi/v201-validate-txdefaultprofile branch from 3dac9b0 to 962c43a Compare March 28, 2024 12:04
@gberardi-pillar gberardi-pillar marked this pull request as draft March 28, 2024 14:57
@gberardi-pillar
Copy link
Contributor Author

Put PR back into draft due to still waiting for @shankari to re-review.

Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>
Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>
Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>
Copy link

@shankari shankari left a 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

@gberardi-pillar gberardi-pillar marked this pull request as ready for review April 9, 2024 12:59
@gberardi-pillar
Copy link
Contributor Author

@Pietfried @marcemmers Is this PR ready to be merged?

@marcemmers
Copy link
Contributor

@Pietfried @marcemmers Is this PR ready to be merged?

Yes, go for it 👍
Might be good to do a rebase before merging. Don't expect any issues there.

@gberardi-pillar
Copy link
Contributor Author

@Pietfried @marcemmers Is this PR ready to be merged?

Yes, go for it 👍 Might be good to do a rebase before merging. Don't expect any issues there.

Ah, but I don't have permission to merge the PR. B-)

@marcemmers marcemmers merged commit d47fd2d into EVerest:main Apr 10, 2024
3 of 4 checks passed
folkengine pushed a commit to US-JOET/libocpp that referenced this pull request Apr 15, 2024
* Validate a TxDefaultProfile.

These changes apply to K01FR52 and K01FR53.

Signed-off-by: Christoph <367712+folkengine@users.noreply.github.com>
Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>

* Review fixes.

Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>

* Review fix.

Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>

* Add test case.

Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>

* Review fix.

Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>

* Review fix.

Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>

---------

Signed-off-by: Christoph <367712+folkengine@users.noreply.github.com>
Signed-off-by: Gianfranco Berardi <54074967+gberardi-pillar@users.noreply.github.com>
@drmrd
Copy link
Collaborator

drmrd commented May 2, 2024

Contributes to #361

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants