ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
connector.hpp
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2020 - 2023 Pionix GmbH and Contributors to EVerest
3
4#pragma once
5
6#include <functional>
7#include <mutex>
8
9#include "component_state_manager.hpp"
10#include "database_handler.hpp"
11#include <ocpp/v2/ocpp_enums.hpp>
12#include <optional>
13
14namespace ocpp {
15namespace v2 {
16
18enum class ConnectorEvent {
19 PlugIn,
20 PlugOut,
21 Reserve,
22 ReservationCleared,
23 Error,
24 ErrorCleared,
25 Unavailable,
26 UnavailableCleared
27};
28
29namespace conversions {
32std::string connector_event_to_string(ConnectorEvent e);
33} // namespace conversions
34
36class Connector {
37private:
39 // cppcheck-suppress unusedStructMember
40 int32_t evse_id;
42 int32_t connector_id;
43
45 std::shared_ptr<ComponentStateManagerInterface> component_state_manager;
46
48 std::mutex status_mutex;
49
50public:
55 Connector(const int32_t evse_id, const int32_t connector_id,
56 std::shared_ptr<ComponentStateManagerInterface> component_state_manager);
57
59 OperationalStatusEnum get_effective_operational_status();
61 ConnectorStatusEnum get_effective_connector_status();
62
65 void submit_event(ConnectorEvent event);
66
70 void set_connector_operative_status(OperationalStatusEnum new_status, bool persist);
71
75};
76
77} // namespace v2
78} // namespace ocpp
Represents a Connector, thus electrical outlet on a Charging Station. Single physical Connector.
Definition: connector.hpp:36
OperationalStatusEnum get_effective_operational_status()
Gets the effective Operative/Inoperative status of this connector.
Definition: connector.cpp:97
Connector(const int32_t evse_id, const int32_t connector_id, std::shared_ptr< ComponentStateManagerInterface > component_state_manager)
Construct a new Connector object.
Definition: connector.cpp:42
ConnectorStatusEnum get_effective_connector_status()
Gets the effective Available/Unavailable/Faulted/Reserved/Occupied status of this connector.
Definition: connector.cpp:101
void submit_event(ConnectorEvent event)
Adjust the state of the connector according to the event that was submitted.
Definition: connector.cpp:47
void restore_connector_operative_status()
Restores the operative status of the connector to the persisted status and recomputes its effective s...
Definition: connector.cpp:82
void set_connector_operative_status(OperationalStatusEnum new_status, bool persist)
Switches the operative status of the connector and recomputes its effective status.
Definition: connector.cpp:77