ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
meter_values.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/common/aligned_timer.hpp>
9#include <ocpp/v2/average_meter_values.hpp>
10
11namespace ocpp::v2 {
12struct FunctionalBlockContext;
13
15public:
16 virtual ~MeterValuesInterface() override = default;
17 virtual void update_aligned_data_interval() = 0;
21 virtual void on_meter_value(const int32_t evse_id, const MeterValue& meter_value) = 0;
22 virtual MeterValue get_latest_meter_value_filtered(const MeterValue& meter_value, ReadingContextEnum context,
23 const RequiredComponentVariable& component_variable) = 0;
24 // Functional Block J: MeterValues
25 virtual void meter_values_req(const int32_t evse_id, const std::vector<MeterValue>& meter_values,
26 const bool initiated_by_trigger_message = false) = 0;
27};
28
30public:
31 virtual ~MeterValues() override = default;
32 explicit MeterValues(const FunctionalBlockContext& functional_block_context);
33 void handle_message(const ocpp::EnhancedMessage<MessageType>& message) override;
34 void update_aligned_data_interval() override;
35 void on_meter_value(const int32_t evse_id, const MeterValue& meter_value) override;
36 MeterValue get_latest_meter_value_filtered(const MeterValue& meter_value, ReadingContextEnum context,
37 const RequiredComponentVariable& component_variable) override;
38
39 void meter_values_req(const int32_t evse_id, const std::vector<MeterValue>& meter_values,
40 const bool initiated_by_trigger_message = false) override;
41
42private: // Members
43 const FunctionalBlockContext& context;
44
45 ClockAlignedTimer aligned_meter_values_timer;
46 AverageMeterValues aligned_data_evse0; // represents evseId = 0 meter value
47
48private: // Functions
49 // Internal helper functions
50 void update_dm_evse_power(const int32_t evse_id, const MeterValue& meter_value);
51};
52} // namespace ocpp::v2
Definition: aligned_timer.hpp:12
Definition: average_meter_values.hpp:16
Interface for handling OCPP2.0.1 CALL messages from the CSMS. Classes implementing a functional block...
Definition: message_handler.hpp:13
Definition: meter_values.hpp:14
virtual void on_meter_value(const int32_t evse_id, const MeterValue &meter_value)=0
Event handler that should be called when a new meter value is present.
Definition: meter_values.hpp:29
void on_meter_value(const int32_t evse_id, const MeterValue &meter_value) override
Event handler that should be called when a new meter value is present.
Definition: meter_values.cpp:90
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: meter_values.cpp:18
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
Definition: ocpp_types.hpp:436
Definition: ocpp_types.hpp:969