ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
evse_manager.hpp
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2020 - 2024 Pionix GmbH and Contributors to EVerest
3
4#pragma once
5
6#include <ocpp/common/custom_iterators.hpp>
7#include <ocpp/v2/evse.hpp>
8
9namespace ocpp {
10namespace v2 {
11
18void set_evse_connectors_unavailable(EvseInterface& evse, bool persist);
19
22public:
24
26 virtual ~EvseManagerInterface() = default;
27
30 virtual EvseInterface& get_evse(int32_t id) = 0;
31
34 virtual const EvseInterface& get_evse(int32_t id) const = 0;
35
40 virtual bool does_connector_exist(const int32_t evse_id, ConnectorEnum connector_type) const = 0;
41
43 virtual bool does_evse_exist(int32_t id) const = 0;
44
49
51 virtual size_t get_number_of_evses() const = 0;
52
58 virtual std::optional<int32_t> get_transaction_evseid(const CiString<36>& transaction_id) const = 0;
59
64 virtual bool any_transaction_active(const std::optional<EVSE>& evse) const = 0;
65
71 virtual bool is_valid_evse(const EVSE& evse) const = 0;
72
74 virtual EvseIterator begin() = 0;
76 virtual EvseIterator end() = 0;
77};
78
80private:
81 std::vector<std::unique_ptr<EvseInterface>> evses;
82
83public:
84 EvseManager(const std::map<int32_t, int32_t>& evse_connector_structure, DeviceModel& device_model,
85 std::shared_ptr<DatabaseHandler> database_handler,
86 std::shared_ptr<ComponentStateManagerInterface> component_state_manager,
87 const std::function<void(const MeterValue& meter_value, EnhancedTransaction& transaction)>&
88 transaction_meter_value_req,
89 const std::function<void(int32_t evse_id)>& pause_charging_callback);
90
91 EvseInterface& get_evse(int32_t id) override;
92 const EvseInterface& get_evse(const int32_t id) const override;
93
94 virtual bool does_connector_exist(const int32_t evse_id, const ConnectorEnum connector_type) const override;
95 bool does_evse_exist(const int32_t id) const override;
96
98
99 size_t get_number_of_evses() const override;
100
101 std::optional<int32_t> get_transaction_evseid(const CiString<36>& transaction_id) const override;
102
103 bool any_transaction_active(const std::optional<EVSE>& evse) const override;
104 bool is_valid_evse(const EVSE& evse) const override;
105
106 EvseIterator begin() override;
107 EvseIterator end() override;
108};
109
110} // namespace v2
111} // namespace ocpp
This class manages access to the device model representation and to the device model interface and pr...
Definition: device_model.hpp:96
Definition: evse.hpp:27
Class used to access the Evse instances.
Definition: evse_manager.hpp:21
virtual EvseInterface & get_evse(int32_t id)=0
Get a reference to the evse with id.
virtual size_t get_number_of_evses() const =0
Get the number of evses.
virtual EvseIterator begin()=0
Gets an iterator pointing to the first evse.
virtual std::optional< int32_t > get_transaction_evseid(const CiString< 36 > &transaction_id) const =0
Get evseid for the given transaction id.
virtual ~EvseManagerInterface()=default
Default destructor.
virtual bool any_transaction_active(const std::optional< EVSE > &evse) const =0
Helper function to determine if there is any active transaction for the given evse.
virtual bool are_all_connectors_effectively_inoperative() const =0
Checks if all connectors are effectively inoperative. If this is the case, calls the all_connectors_u...
virtual bool is_valid_evse(const EVSE &evse) const =0
Check if the given evse is valid.
virtual EvseIterator end()=0
Gets an iterator pointing past the last evse.
virtual bool does_evse_exist(int32_t id) const =0
Check if an evse with id exists.
virtual bool does_connector_exist(const int32_t evse_id, ConnectorEnum connector_type) const =0
Check if the connector exists on the given evse id.
virtual const EvseInterface & get_evse(int32_t id) const =0
Get a const reference to the evse with id.
Definition: evse_manager.hpp:79
size_t get_number_of_evses() const override
Get the number of evses.
Definition: evse_manager.cpp:75
bool any_transaction_active(const std::optional< EVSE > &evse) const override
Helper function to determine if there is any active transaction for the given evse.
Definition: evse_manager.cpp:91
virtual bool does_connector_exist(const int32_t evse_id, const ConnectorEnum connector_type) const override
Check if the connector exists on the given evse id.
Definition: evse_manager.cpp:46
bool does_evse_exist(const int32_t id) const override
Check if an evse with id exists.
Definition: evse_manager.cpp:58
EvseIterator begin() override
Gets an iterator pointing to the first evse.
Definition: evse_manager.cpp:25
bool is_valid_evse(const EVSE &evse) const override
Check if the given evse is valid.
Definition: evse_manager.cpp:103
EvseInterface & get_evse(int32_t id) override
Get a reference to the evse with id.
Definition: evse_manager.cpp:32
EvseIterator end() override
Gets an iterator pointing past the last evse.
Definition: evse_manager.cpp:28
std::optional< int32_t > get_transaction_evseid(const CiString< 36 > &transaction_id) const override
Get evseid for the given transaction id.
Definition: evse_manager.cpp:79
bool are_all_connectors_effectively_inoperative() const override
Checks if all connectors are effectively inoperative. If this is the case, calls the all_connectors_u...
Definition: evse_manager.cpp:62
Helper struct that allows the use of an iterator in an interface, can be implemented using any forwar...
Definition: custom_iterators.hpp:41
Definition: ocpp_types.hpp:155
Struct that enhances the OCPP Transaction by some meta data and functionality.
Definition: transaction.hpp:16
Definition: ocpp_types.hpp:436