ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
diagnostics.hpp
1// SPDX-License-Identifier: Apache-2.0
2// Copyright Pionix GmbH and Contributors to EVerest
3
4#pragma once
5
6#include <ocpp/v2/message_handler.hpp>
7
8#include <ocpp/v2/monitoring_updater.hpp>
9
10namespace ocpp::v2 {
11class AuthorizationInterface;
12struct FunctionalBlockContext;
13
14struct GetLogRequest;
15struct GetLogResponse;
16struct CustomerInformationRequest;
17struct SetMonitoringBaseRequest;
18struct SetMonitoringLevelRequest;
19struct GetMonitoringReportRequest;
20struct ClearVariableMonitoringRequest;
21
22typedef std::function<GetLogResponse(const GetLogRequest& request)> GetLogRequestCallback;
23typedef std::function<std::string(const std::optional<CertificateHashDataType> customer_certificate,
24 const std::optional<IdToken> id_token,
25 const std::optional<CiString<64>> customer_identifier)>
26 GetCustomerInformationCallback;
27typedef std::function<void(const std::optional<CertificateHashDataType> customer_certificate,
28 const std::optional<IdToken> id_token,
29 const std::optional<CiString<64>> customer_identifier)>
30 ClearCustomerInformationCallback;
31
33public:
34 virtual ~DiagnosticsInterface() = default;
35
36 /* OCPP message requests */
37 virtual void notify_event_req(const std::vector<EventData>& events) = 0;
38
39 /* Monitoring */
40 virtual void stop_monitoring() = 0;
41 virtual void start_monitoring() = 0;
42 virtual void process_triggered_monitors() = 0;
43};
44
46public:
47 Diagnostics(const FunctionalBlockContext& context, AuthorizationInterface& authorization,
48 GetLogRequestCallback get_log_request_callback,
49 std::optional<GetCustomerInformationCallback> get_customer_information_callback,
50 std::optional<ClearCustomerInformationCallback> clear_customer_information_callback);
51 void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;
52 void notify_event_req(const std::vector<EventData>& events) override;
53 void stop_monitoring() override;
54 void start_monitoring() override;
55 void process_triggered_monitors() override;
56
57private: // Members
58 const FunctionalBlockContext& context;
59 AuthorizationInterface& authorization;
61 MonitoringUpdater monitoring_updater;
62 GetLogRequestCallback get_log_request_callback;
65 std::optional<GetCustomerInformationCallback> get_customer_information_callback;
66
68 std::optional<ClearCustomerInformationCallback> clear_customer_information_callback;
69
70private: // Functions
71 /* OCPP message requests */
72 void notify_customer_information_req(const std::string& data, const int32_t request_id);
73 void notify_monitoring_report_req(const int request_id, const std::vector<MonitoringData>& montoring_data);
74
75 /* OCPP message handlers */
76 void handle_get_log_req(Call<GetLogRequest> call);
77 void handle_customer_information_req(Call<CustomerInformationRequest> call);
78
79 void handle_set_monitoring_base_req(Call<SetMonitoringBaseRequest> call);
80 void handle_set_monitoring_level_req(Call<SetMonitoringLevelRequest> call);
81 void handle_set_variable_monitoring_req(const EnhancedMessage<v2::MessageType>& message);
82 void handle_get_monitoring_report_req(Call<GetMonitoringReportRequest> call);
83 void handle_clear_variable_monitoring_req(Call<ClearVariableMonitoringRequest> call);
84
85 /* Helper functions */
86
94 std::string get_customer_information(const std::optional<CertificateHashDataType> customer_certificate,
95 const std::optional<IdToken> id_token,
96 const std::optional<CiString<64>> customer_identifier);
97
104 void clear_customer_information(const std::optional<CertificateHashDataType> customer_certificate,
105 const std::optional<IdToken> id_token,
106 const std::optional<CiString<64>> customer_identifier);
107};
108} // namespace ocpp::v2
Contains a CaseInsensitive string implementation that only allows printable ASCII characters.
Definition: cistring.hpp:16
Definition: authorization.hpp:18
Definition: diagnostics.hpp:32
Definition: diagnostics.hpp:45
void handle_message(const ocpp::EnhancedMessage< MessageType > &message) override
Handles the given message from the CSMS. This includes dispatching a CALLRESULT as a response to the ...
Definition: diagnostics.cpp:44
Interface for handling OCPP2.0.1 CALL messages from the CSMS. Classes implementing a functional block...
Definition: message_handler.hpp:13
Definition: monitoring_updater.hpp:99
Contains a OCPP Call message.
Definition: call_types.hpp:60
Contains a OCPP message in json form with additional information.
Definition: message_queue.hpp:54
Context / requirements for the functional blocks.
Definition: functional_block_context.hpp:23