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

Feature/data transfer functional block #871

Merged
merged 4 commits into from
Nov 20, 2024

Conversation

Pietfried
Copy link
Contributor

@Pietfried Pietfried commented Nov 18, 2024

Describe your changes

  • Added message handler interface to be implemented by specific functional blocks
  • Moved DataTransfer functionality to DataTransfer functional block using the targeted design. Added test cases for the new functional block

Issue ticket number and link

Checklist before requesting a review

…ypes and made it a free function. Removed unused imports and usage of boost/uuid headers

Signed-off-by: Piet Gömpel <[email protected]>
…ng the targeted design. Added test cases for the new functional block

Signed-off-by: Piet Gömpel <[email protected]>
@Pietfried Pietfried force-pushed the feature/data-transfer-functional-block branch from 7d62682 to 9578416 Compare November 19, 2024 08:25
@Pietfried Pietfried marked this pull request as ready for review November 19, 2024 08:40
virtual std::optional<DataTransferResponse> data_transfer_req(const DataTransferRequest& request) = 0;

/// \brief Handles the given DataTransfer.req \p call by the CSMS by responding with a CallResult
virtual void handle_data_transfer_req(Call<DataTransferRequest> call) = 0;
Copy link
Contributor

@marcemmers marcemmers Nov 19, 2024

Choose a reason for hiding this comment

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

For this functional block not really necessary but for the others it would be nicer if this would just be one call I think. Something like handle_message() that internally splits again based on the message type just like the charge_point handle_message.

That enables us to decouple a bit more in not having to change the charge_point as much for new messages or changing message handlers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably then pass along the const EnhancedMessage<v201::MessageType>& message

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 right, I should have added a comment for this since you marked that already in the other PR. I will add it here and definitely agree for other functional blocks, but in the end that is handled/defined by every functional block individually, since the handle_message function is not defined in any general interface but in the interface of every functional block.

Copy link
Contributor

@marcemmers marcemmers Nov 19, 2024

Choose a reason for hiding this comment

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

Ah ok no worries. Yes it does not matter that much for this one but thought it would be nice for uniformity ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

I wanted to say the same, it would be nice to have a handle_message in every functional block.

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 changed this to a handle_message function and found it reasonable to add an interface for it. Using that interface would be more of a convention than something that we can enforce when implementing other functional blocks but it provides at least some soft guidance.

This change goes beyond the scope of the PR, but since we are in the the message dispatching / handling is tightly related to the first functional block implementing it, i would be in favor of merging this as part of this PR.

ocpp::Call<DataTransferRequest> call(request);
auto data_transfer_future = this->message_dispatcher.dispatch_call_async(call);

if (not this->is_websocket_connected()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really like that we have to pass this check along here. Especially since we also have enhanced_message.offline as a value that we return. Would be nice if we can remove the is connected callback and just use the other behavior instead.

If we really do need to have information if we are connected, maybe its better to abstract it into the message dispatcher instead since all blocks will have that anyway.

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 agree, I was just trying to move the functionality to the functional block and provide everything that is required. I think we can indeed just make use of enhanced_message.offline here.

@marcemmers
Copy link
Contributor

Overall looks really good, I think we are heading in the right direction with this! Also good to see at least 100% line coverage on the new functional block files 👍

Copy link
Contributor

@maaikez maaikez left a comment

Choose a reason for hiding this comment

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

Looks good. I would like to have a 'handle_message' function (or something) that handles all messages of this functional block so we can get rid of all those functions in chargepoint. I think that's cleaner.

* DataTransferInterface inherits from this MessageHandlerInterface

Signed-off-by: Piet Gömpel <[email protected]>
@Pietfried
Copy link
Contributor Author

I added the changes discussed above, so it is again ready for review

req.data = data;

return this->data_transfer_req(req);
return this->data_transfer->data_transfer_req(vendorId, messageId, data);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this function still necessary then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes since it doesnt handle a DataTransfer.req from the CSMS but sends a DataTransfer.req to the CSMS

}

return response;
return this->data_transfer->data_transfer_req(request);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for this one, is it still necessary?

@Pietfried Pietfried merged commit 18ca071 into main Nov 20, 2024
7 of 8 checks passed
@Pietfried Pietfried deleted the feature/data-transfer-functional-block branch November 20, 2024 13:11
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.

3 participants