ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
notify_report_requests_splitter.hpp
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest
3
4#ifndef OCPP_NOTIFY_REPORT_REQUESTS_SPLITTER_HPP
5#define OCPP_NOTIFY_REPORT_REQUESTS_SPLITTER_HPP
6
7#include "ocpp/common/call_types.hpp"
8#include "ocpp/v2/messages/NotifyReport.hpp"
9#include "ocpp/v2/types.hpp"
10
11namespace ocpp {
12namespace v2 {
13
16
17private:
18 // cppcheck-suppress unusedStructMember
19 static const std::string MESSAGE_TYPE; // NotifyReport
20 const NotifyReportRequest& original_request;
21 // cppcheck-suppress unusedStructMember
22 size_t max_size;
23 const std::function<MessageId()> message_id_generator_callback;
24 json request_json_template; // json that is used as template for request json
25 // cppcheck-suppress unusedStructMember
26 const size_t json_skeleton_size; // size of the json skeleton for a call json object which includes everything
27 // except the requests' reportData and the messageId
28
29public:
30 NotifyReportRequestsSplitter(const NotifyReportRequest& originalRequest, size_t max_size,
31 std::function<MessageId()>&& message_id_generator_callback);
33
36 std::vector<json> create_call_payloads();
37
38private:
39 size_t create_request_template_json_and_return_skeleton_size();
40
41 // Create next call payload (with as many reportData items as possible)
42 json create_next_payload(const int& seq_no, std::vector<ocpp::v2::ReportData>::const_iterator& report_data_iterator,
43 const std::vector<ocpp::v2::ReportData>::const_iterator& report_data_end,
44 const std::string& message_id);
45
46 // Create next request payload (with as many reportData items as possible) to be contained in next call payload
47 static json create_next_report_data_json(std::vector<ocpp::v2::ReportData>::const_iterator& report_data_iterator,
48 const std::vector<ocpp::v2::ReportData>::const_iterator& report_data_end,
49 const size_t& remaining_size);
50};
51
52} // namespace v2
53} // namespace ocpp
54
55#endif // OCPP_NOTIFY_REPORT_REQUESTS_SPLITTER_HPP
Contains a MessageId implementation based on a case insensitive string with a maximum length of 36 pr...
Definition: call_types.hpp:34
Utility class that is used to split NotifyReportRequest into several ones in case ReportData is too b...
Definition: notify_report_requests_splitter.hpp:15
std::vector< json > create_call_payloads()
Splits the provided NotifyReportRequest into (potentially) several Call payloads.
Definition: notify_report_requests_splitter.cpp:13
Contains a OCPP NotifyReport message.
Definition: NotifyReport.hpp:19