ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
charge_point.hpp
1// SPDX-License-Identifier: Apache-2.0
2// Copyright Pionix GmbH and Contributors to EVerest
3
4#pragma once
5
6#include <future>
7#include <memory>
8#include <set>
9
10#include <ocpp/common/message_dispatcher.hpp>
11
12#include <ocpp/common/charging_station_base.hpp>
13
14#include <ocpp/v2/average_meter_values.hpp>
15#include <ocpp/v2/charge_point_callbacks.hpp>
16#include <ocpp/v2/ocpp_enums.hpp>
17#include <ocpp/v2/ocpp_types.hpp>
18#include <ocpp/v2/ocsp_updater.hpp>
19#include <ocpp/v2/types.hpp>
20#include <ocpp/v2/utils.hpp>
21
22#include <ocpp/v2/messages/Authorize.hpp>
23#include <ocpp/v2/messages/DataTransfer.hpp>
24#include <ocpp/v2/messages/Get15118EVCertificate.hpp>
25#include <ocpp/v2/messages/GetCompositeSchedule.hpp>
26
27#include "component_state_manager.hpp"
28
29namespace ocpp {
30namespace v2 {
31
32class AuthorizationInterface;
33class AvailabilityInterface;
34class DataTransferInterface;
35class DiagnosticsInterface;
36class DisplayMessageInterface;
37class FirmwareUpdateInterface;
38class MeterValuesInterface;
39class ProvisioningInterface;
40class RemoteTransactionControlInterface;
41class ReservationInterface;
42class SecurityInterface;
43class SmartChargingInterface;
44class TariffAndCostInterface;
45class TransactionInterface;
46
47class DatabaseHandler;
48class DeviceModel;
49class DeviceModelStorageInterface;
50class EvseManager;
51
52struct FunctionalBlockContext;
53
54class UnexpectedMessageTypeFromCSMS : public std::runtime_error {
55 using std::runtime_error::runtime_error;
56};
57
60public:
61 virtual ~ChargePointInterface() = default;
62
67 virtual void start(BootReasonEnum bootreason = BootReasonEnum::PowerUp, bool start_connecting = true) = 0;
68
70 virtual void stop() = 0;
71
77 virtual void connect_websocket(std::optional<int32_t> network_profile_slot = std::nullopt) = 0;
78
80 virtual void disconnect_websocket() = 0;
81
85
89
98 virtual void on_network_disconnected(OCPPInterfaceEnum ocpp_interface) = 0;
99
104 virtual void on_firmware_update_status_notification(int32_t request_id,
105 const FirmwareStatusEnum& firmware_update_status) = 0;
106
110 virtual void on_session_started(const int32_t evse_id, const int32_t connector_id) = 0;
111
116
129 virtual void
130 on_transaction_started(const int32_t evse_id, const int32_t connector_id, const std::string& session_id,
131 const DateTime& timestamp, const TriggerReasonEnum trigger_reason,
132 const MeterValue& meter_start, const std::optional<IdToken>& id_token,
133 const std::optional<IdToken>& group_id_token, const std::optional<int32_t>& reservation_id,
134 const std::optional<int32_t>& remote_start_id, const ChargingStateEnum charging_state) = 0;
135
144 virtual void on_transaction_finished(const int32_t evse_id, const DateTime& timestamp, const MeterValue& meter_stop,
145 const ReasonEnum reason, const TriggerReasonEnum trigger_reason,
146 const std::optional<IdToken>& id_token,
147 const std::optional<std::string>& signed_meter_value,
148 const ChargingStateEnum charging_state) = 0;
149
153 virtual void on_session_finished(const int32_t evse_id, const int32_t connector_id) = 0;
154
156 virtual void on_authorized(const int32_t evse_id, const int32_t connector_id, const IdToken& id_token) = 0;
157
161 virtual void on_meter_value(const int32_t evse_id, const MeterValue& meter_value) = 0;
162
165 virtual void on_unavailable(const int32_t evse_id, const int32_t connector_id) = 0;
166
169 virtual void on_enabled(const int32_t evse_id, const int32_t connector_id) = 0;
170
174 virtual void on_faulted(const int32_t evse_id, const int32_t connector_id) = 0;
175
179 virtual void on_fault_cleared(const int32_t evse_id, const int32_t connector_id) = 0;
180
184 virtual void on_reserved(const int32_t evse_id, const int32_t connector_id) = 0;
185
189 virtual void on_reservation_cleared(const int32_t evse_id, const int32_t connector_id) = 0;
190
196 virtual bool
197 on_charging_state_changed(const uint32_t evse_id, const ChargingStateEnum charging_state,
198 const TriggerReasonEnum trigger_reason = TriggerReasonEnum::ChargingStateChanged) = 0;
199
203 virtual std::optional<std::string> get_evse_transaction_id(int32_t evse_id) = 0;
204
207 virtual void on_event(const std::vector<EventData>& events) = 0;
208
217 virtual void on_log_status_notification(UploadLogStatusEnum status, int32_t requestId) = 0;
218
219 // \brief Notifies chargepoint that a SecurityEvent has occured. This will send a SecurityEventNotification.req to
220 // the
228 virtual void on_security_event(const CiString<50>& event_type, const std::optional<CiString<255>>& tech_info,
229 const std::optional<bool>& critical = std::nullopt,
230 const std::optional<DateTime>& timestamp = std::nullopt) = 0;
231
235 virtual void on_variable_changed(const SetVariableData& set_variable_data) = 0;
236
240 virtual void on_reservation_status(const int32_t reservation_id, const ReservationUpdateStatusEnum status) = 0;
241
243
245
251 virtual AuthorizeResponse validate_token(const IdToken id_token, const std::optional<CiString<5500>>& certificate,
252 const std::optional<std::vector<OCSPRequestData>>& ocsp_request_data) = 0;
253
259 virtual std::optional<DataTransferResponse> data_transfer_req(const CiString<255>& vendorId,
260 const std::optional<CiString<50>>& messageId,
261 const std::optional<json>& data) = 0;
262
267 virtual std::optional<DataTransferResponse> data_transfer_req(const DataTransferRequest& request) = 0;
268
271 virtual void set_message_queue_resume_delay(std::chrono::seconds delay) = 0;
272
278 virtual std::vector<GetVariableResult>
279 get_variables(const std::vector<GetVariableData>& get_variable_data_vector) = 0;
280
285 virtual std::map<SetVariableData, SetVariableResult>
286 set_variables(const std::vector<SetVariableData>& set_variable_data_vector, const std::string& source) = 0;
287
293
300 virtual std::optional<CompositeSchedule> get_composite_schedule(int32_t evse_id, std::chrono::seconds duration,
301 ChargingRateUnitEnum unit) = 0;
302
309 virtual std::vector<CompositeSchedule> get_all_composite_schedules(const int32_t duration,
310 const ChargingRateUnitEnum& unit) = 0;
311
316 virtual std::optional<NetworkConnectionProfile>
317 get_network_connection_profile(const int32_t configuration_slot) const = 0;
318
323 virtual std::optional<int> get_priority_from_configuration_slot(const int configuration_slot) const = 0;
324
330 virtual const std::vector<int>& get_network_connection_slots() const = 0;
331};
332
335
336private:
337 std::shared_ptr<DeviceModel> device_model;
338 std::unique_ptr<EvseManager> evse_manager;
339 std::unique_ptr<ConnectivityManager> connectivity_manager;
340
341 std::unique_ptr<MessageDispatcherInterface<MessageType>> message_dispatcher;
342
343 // Functional blocks
344 std::unique_ptr<FunctionalBlockContext> functional_block_context;
345 std::unique_ptr<DataTransferInterface> data_transfer;
346 std::unique_ptr<ReservationInterface> reservation;
347 std::unique_ptr<AvailabilityInterface> availability;
348 std::unique_ptr<AuthorizationInterface> authorization;
349 std::unique_ptr<DiagnosticsInterface> diagnostics;
350 std::unique_ptr<SecurityInterface> security;
351 std::unique_ptr<DisplayMessageInterface> display_message;
352 std::unique_ptr<FirmwareUpdateInterface> firmware_update;
353 std::unique_ptr<MeterValuesInterface> meter_values;
354 std::unique_ptr<SmartChargingInterface> smart_charging;
355 std::unique_ptr<TariffAndCostInterface> tariff_and_cost;
356 std::unique_ptr<TransactionInterface> transaction;
357 std::unique_ptr<ProvisioningInterface> provisioning;
358 std::unique_ptr<RemoteTransactionControlInterface> remote_transaction_control;
359
360 // utility
361 std::shared_ptr<MessageQueue<v2::MessageType>> message_queue;
362 std::shared_ptr<DatabaseHandler> database_handler;
363
364 // states
365 std::atomic<RegistrationStatusEnum> registration_status;
366 std::atomic<UploadLogStatusEnum> upload_log_status;
367 std::atomic<int32_t> upload_log_status_id;
368 BootReasonEnum bootreason;
369 bool skip_invalid_csms_certificate_notifications;
370
372 std::shared_ptr<ComponentStateManagerInterface> component_state_manager;
373
374 // store the connector status
375 struct EvseConnectorPair {
376 int32_t evse_id;
377 int32_t connector_id;
378
379 // Define a comparison operator for the struct
380 bool operator<(const EvseConnectorPair& other) const {
381 // Compare based on name, then age
382 if (evse_id != other.evse_id) {
383 return evse_id < other.evse_id;
384 }
385 return connector_id < other.connector_id;
386 }
387 };
388
389 std::chrono::time_point<std::chrono::steady_clock> time_disconnected;
390
391 // callback struct
392 Callbacks callbacks;
393
395 OcspUpdater ocsp_updater;
396
398 std::chrono::seconds message_queue_resume_delay = std::chrono::seconds(0);
399
400 // internal helper functions
401 void initialize(const std::map<int32_t, int32_t>& evse_connector_structure, const std::string& message_log_path);
402 void websocket_connected_callback(const int configuration_slot,
403 const NetworkConnectionProfile& network_connection_profile);
404 void websocket_disconnected_callback(const int configuration_slot,
405 const NetworkConnectionProfile& network_connection_profile);
406 void websocket_connection_failed(ConnectionFailedReason reason);
407 void update_dm_availability_state(const int32_t evse_id, const int32_t connector_id,
408 const ConnectorStatusEnum status);
409
410 void message_callback(const std::string& message);
411
414 bool is_offline();
415
418 void configure_message_logging_format(const std::string& message_log_path);
419
420 /* OCPP message requests */
421
422 /* OCPP message handlers */
423
424 // Generates async sending callbacks
425 template <class RequestType, class ResponseType>
426 std::function<ResponseType(RequestType)> send_callback(MessageType expected_response_message_type) {
427 return [this, expected_response_message_type](auto request) {
428 const auto enhanced_response =
429 this->message_dispatcher->dispatch_call_async(ocpp::Call<RequestType>(request)).get();
430 if (enhanced_response.messageType != expected_response_message_type) {
432 std::string("Got unexpected message type from CSMS, expected: ") +
433 conversions::messagetype_to_string(expected_response_message_type) +
434 ", got: " + conversions::messagetype_to_string(enhanced_response.messageType));
435 }
436 ocpp::CallResult<ResponseType> call_result = enhanced_response.message;
437 return call_result.msg;
438 };
439 }
440
441protected:
442 void handle_message(const EnhancedMessage<v2::MessageType>& message);
443 void clear_invalid_charging_profiles();
444
445public:
448
451
462 ChargePoint(const std::map<int32_t, int32_t>& evse_connector_structure, std::shared_ptr<DeviceModel> device_model,
463 std::shared_ptr<DatabaseHandler> database_handler,
464 std::shared_ptr<MessageQueue<v2::MessageType>> message_queue, const std::string& message_log_path,
465 const std::shared_ptr<EvseSecurity> evse_security, const Callbacks& callbacks);
466
477 ChargePoint(const std::map<int32_t, int32_t>& evse_connector_structure,
478 std::unique_ptr<DeviceModelStorageInterface> device_model_storage_interface,
479 const std::string& ocpp_main_path, const std::string& core_database_path,
480 const std::string& sql_init_path, const std::string& message_log_path,
481 const std::shared_ptr<EvseSecurity> evse_security, const Callbacks& callbacks);
482
497 ChargePoint(const std::map<int32_t, int32_t>& evse_connector_structure,
498 const std::string& device_model_storage_address, const bool initialize_device_model,
499 const std::string& device_model_migration_path, const std::string& device_model_config_path,
500 const std::string& ocpp_main_path, const std::string& core_database_path,
501 const std::string& sql_init_path, const std::string& message_log_path,
502 const std::shared_ptr<EvseSecurity> evse_security, const Callbacks& callbacks);
503
505
507
508 ~ChargePoint();
509
510 void start(BootReasonEnum bootreason = BootReasonEnum::PowerUp, bool start_connecting = true) override;
511
512 void stop() override;
513
514 void connect_websocket(std::optional<int32_t> network_profile_slot = std::nullopt) override;
515 virtual void disconnect_websocket() override;
516
517 void on_network_disconnected(OCPPInterfaceEnum ocpp_interface) override;
518
519 void on_firmware_update_status_notification(int32_t request_id,
520 const FirmwareStatusEnum& firmware_update_status) override;
521
522 void on_session_started(const int32_t evse_id, const int32_t connector_id) override;
523
526
527 void on_transaction_started(const int32_t evse_id, const int32_t connector_id, const std::string& session_id,
528 const DateTime& timestamp, const TriggerReasonEnum trigger_reason,
529 const MeterValue& meter_start, const std::optional<IdToken>& id_token,
530 const std::optional<IdToken>& group_id_token,
531 const std::optional<int32_t>& reservation_id,
532 const std::optional<int32_t>& remote_start_id,
533 const ChargingStateEnum charging_state) override;
534
535 void on_transaction_finished(const int32_t evse_id, const DateTime& timestamp, const MeterValue& meter_stop,
536 const ReasonEnum reason, const TriggerReasonEnum trigger_reason,
537 const std::optional<IdToken>& id_token,
538 const std::optional<std::string>& signed_meter_value,
539 const ChargingStateEnum charging_state) override;
540
541 void on_session_finished(const int32_t evse_id, const int32_t connector_id) override;
542
543 void on_authorized(const int32_t evse_id, const int32_t connector_id, const IdToken& id_token) override;
544
545 void on_meter_value(const int32_t evse_id, const MeterValue& meter_value) override;
546
547 void on_unavailable(const int32_t evse_id, const int32_t connector_id) override;
548
549 void on_enabled(const int32_t evse_id, const int32_t connector_id) override;
550
551 void on_faulted(const int32_t evse_id, const int32_t connector_id) override;
552
553 void on_fault_cleared(const int32_t evse_id, const int32_t connector_id) override;
554
555 void on_reserved(const int32_t evse_id, const int32_t connector_id) override;
556
557 void on_reservation_cleared(const int32_t evse_id, const int32_t connector_id) override;
558
560 const uint32_t evse_id, const ChargingStateEnum charging_state,
561 const TriggerReasonEnum trigger_reason = TriggerReasonEnum::ChargingStateChanged) override;
562
563 std::optional<std::string> get_evse_transaction_id(int32_t evse_id) override;
564
565 AuthorizeResponse validate_token(const IdToken id_token, const std::optional<CiString<5500>>& certificate,
566 const std::optional<std::vector<OCSPRequestData>>& ocsp_request_data) override;
567
568 void on_event(const std::vector<EventData>& events) override;
569
570 void on_log_status_notification(UploadLogStatusEnum status, int32_t requestId) override;
571
572 void on_security_event(const CiString<50>& event_type, const std::optional<CiString<255>>& tech_info,
573 const std::optional<bool>& critical = std::nullopt,
574 const std::optional<DateTime>& timestamp = std::nullopt) override;
575
576 void on_variable_changed(const SetVariableData& set_variable_data) override;
577
578 void on_reservation_status(const int32_t reservation_id, const ReservationUpdateStatusEnum status) override;
579
580 std::optional<DataTransferResponse> data_transfer_req(const CiString<255>& vendorId,
581 const std::optional<CiString<50>>& messageId,
582 const std::optional<json>& data) override;
583
584 std::optional<DataTransferResponse> data_transfer_req(const DataTransferRequest& request) override;
585
586 void set_message_queue_resume_delay(std::chrono::seconds delay) override {
587 this->message_queue_resume_delay = delay;
588 }
589
590 std::vector<GetVariableResult> get_variables(const std::vector<GetVariableData>& get_variable_data_vector) override;
591
592 std::map<SetVariableData, SetVariableResult>
593 set_variables(const std::vector<SetVariableData>& set_variable_data_vector, const std::string& source) override;
595 std::optional<CompositeSchedule> get_composite_schedule(int32_t evse_id, std::chrono::seconds duration,
596 ChargingRateUnitEnum unit) override;
597 std::vector<CompositeSchedule> get_all_composite_schedules(const int32_t duration,
598 const ChargingRateUnitEnum& unit) override;
599
600 std::optional<NetworkConnectionProfile>
601 get_network_connection_profile(const int32_t configuration_slot) const override;
602
603 std::optional<int> get_priority_from_configuration_slot(const int configuration_slot) const override;
604
605 const std::vector<int>& get_network_connection_slots() const override;
606
607 void send_not_implemented_error(const MessageId unique_message_id, const MessageTypeId message_type_id);
608
617 template <typename T>
618 RequestDeviceModelResponse<T> request_value(const Component& component_id, const Variable& variable_id,
619 const AttributeEnum& attribute_enum) {
620 return this->device_model->request_value<T>(component_id, variable_id, attribute_enum);
621 }
622};
623
624} // namespace v2
625} // namespace ocpp
Common base class for OCPP1.6 and OCPP2.0.1 charging stations.
Definition: charging_station_base.hpp:16
Contains a DateTime implementation that can parse and create RFC 3339 compatible strings.
Definition: types.hpp:109
Contains a MessageId implementation based on a case insensitive string with a maximum length of 36 pr...
Definition: call_types.hpp:34
Interface class for OCPP2.0.1 Charging Station.
Definition: charge_point.hpp:59
virtual void connect_websocket(std::optional< int32_t > network_profile_slot=std::nullopt)=0
Initializes the websocket and connects to a CSMS. Provide a network_profile_slot to connect to that s...
virtual std::optional< DataTransferResponse > data_transfer_req(const DataTransferRequest &request)=0
Data transfer mechanism initiated by charger.
virtual void start(BootReasonEnum bootreason=BootReasonEnum::PowerUp, bool start_connecting=true)=0
Starts the ChargePoint, initializes and connects to the Websocket endpoint.
virtual void disconnect_websocket()=0
Disconnects the the websocket connection to the CSMS if it is connected.
virtual void stop()=0
Stops the ChargePoint. Disconnects the websocket connection and stops MessageQueue and all timers.
virtual std::vector< GetVariableResult > get_variables(const std::vector< GetVariableData > &get_variable_data_vector)=0
Gets variables specified within get_variable_data_vector from the device model and returns the result...
virtual std::optional< NetworkConnectionProfile > get_network_connection_profile(const int32_t configuration_slot) const =0
Gets the configured NetworkConnectionProfile based on the given configuration_slot ....
virtual GetCompositeScheduleResponse get_composite_schedule(const GetCompositeScheduleRequest &request)=0
Gets a composite schedule based on the given request.
virtual void set_message_queue_resume_delay(std::chrono::seconds delay)=0
Delay draining the message queue after reconnecting, so the CSMS can perform post-reconnect checks fi...
virtual std::map< SetVariableData, SetVariableResult > set_variables(const std::vector< SetVariableData > &set_variable_data_vector, const std::string &source)=0
Sets variables specified within set_variable_data_vector in the device model and returns the result.
virtual const std::vector< int > & get_network_connection_slots() const =0
Get the network connection slots sorted by priority. Each item in the vector contains the configured ...
virtual std::optional< int > get_priority_from_configuration_slot(const int configuration_slot) const =0
Get the priority of the given configuration slot.
virtual AuthorizeResponse validate_token(const IdToken id_token, const std::optional< CiString< 5500 > > &certificate, const std::optional< std::vector< OCSPRequestData > > &ocsp_request_data)=0
Validates provided id_token certificate and ocsp_request_data using CSMS, AuthCache or AuthList.
virtual std::vector< CompositeSchedule > get_all_composite_schedules(const int32_t duration, const ChargingRateUnitEnum &unit)=0
Gets composite schedules for all evse_ids (including 0) for the given duration and unit ....
virtual std::optional< DataTransferResponse > data_transfer_req(const CiString< 255 > &vendorId, const std::optional< CiString< 50 > > &messageId, const std::optional< json > &data)=0
Data transfer mechanism initiated by charger.
virtual std::optional< CompositeSchedule > get_composite_schedule(int32_t evse_id, std::chrono::seconds duration, ChargingRateUnitEnum unit)=0
Gets a composite schedule based on the given parameters.
Class implements OCPP2.0.1 Charging Station.
Definition: charge_point.hpp:334
void on_log_status_notification(UploadLogStatusEnum status, int32_t requestId) override
Event handler that can be called to notify about the log status.
Definition: charge_point.cpp:356
void on_reservation_cleared(const int32_t evse_id, const int32_t connector_id) override
Event handler that should be called when the reservation of the connector is cleared.
Definition: charge_point.cpp:309
std::optional< int > get_priority_from_configuration_slot(const int configuration_slot) const override
Get the priority of the given configuration slot.
Definition: charge_point.cpp:1067
void on_unavailable(const int32_t evse_id, const int32_t connector_id) override
Event handler that should be called when the connector on the given evse_id and connector_id becomes ...
Definition: charge_point.cpp:287
void stop() override
Stops the ChargePoint. Disconnects the websocket connection and stops MessageQueue and all timers.
Definition: charge_point.cpp:153
void set_message_queue_resume_delay(std::chrono::seconds delay) override
Delay draining the message queue after reconnecting, so the CSMS can perform post-reconnect checks fi...
Definition: charge_point.hpp:586
std::vector< GetVariableResult > get_variables(const std::vector< GetVariableData > &get_variable_data_vector) override
Gets variables specified within get_variable_data_vector from the device model and returns the result...
Definition: charge_point.cpp:1038
void on_session_started(const int32_t evse_id, const int32_t connector_id) override
Event handler that should be called when a session has started.
Definition: charge_point.cpp:180
virtual void disconnect_websocket() override
Disconnects the the websocket connection to the CSMS if it is connected.
Definition: charge_point.cpp:164
void start(BootReasonEnum bootreason=BootReasonEnum::PowerUp, bool start_connecting=true) override
Starts the ChargePoint, initializes and connects to the Websocket endpoint.
Definition: charge_point.cpp:110
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: charge_point.cpp:235
void on_transaction_finished(const int32_t evse_id, const DateTime &timestamp, const MeterValue &meter_stop, const ReasonEnum reason, const TriggerReasonEnum trigger_reason, const std::optional< IdToken > &id_token, const std::optional< std::string > &signed_meter_value, const ChargingStateEnum charging_state) override
Event handler that should be called when a transaction has finished.
Definition: charge_point.cpp:200
void on_enabled(const int32_t evse_id, const int32_t connector_id) override
Event handler that should be called when the connector returns from unavailable on the given evse_id ...
Definition: charge_point.cpp:291
void on_firmware_update_status_notification(int32_t request_id, const FirmwareStatusEnum &firmware_update_status) override
Chargepoint notifies about new firmware update status firmware_update_status. This function should be...
Definition: charge_point.cpp:172
void on_fault_cleared(const int32_t evse_id, const int32_t connector_id) override
Event handler that should be called when the fault on the connector on the given evse_id is cleared.
Definition: charge_point.cpp:299
void on_event(const std::vector< EventData > &events) override
Event handler that can be called to trigger a NotifyEvent.req with the given events.
Definition: charge_point.cpp:352
void on_variable_changed(const SetVariableData &set_variable_data) override
Event handler that will update the variable internally when it has been changed on the fly.
Definition: charge_point.cpp:380
Get15118EVCertificateResponse on_get_15118_ev_certificate_request(const Get15118EVCertificateRequest &request) override
Event handler that should be called when the EV sends a certificate request (for update or installati...
Definition: charge_point.cpp:185
void on_faulted(const int32_t evse_id, const int32_t connector_id) override
Event handler that should be called when the connector on the given evse_id and connector_id is fault...
Definition: charge_point.cpp:295
void on_authorized(const int32_t evse_id, const int32_t connector_id, const IdToken &id_token) override
Event handler that should be called when the given id_token is authorized.
Definition: charge_point.cpp:214
std::optional< std::string > get_evse_transaction_id(int32_t evse_id) override
Gets the transaction id for a certain evse_id if there is an active transaction.
Definition: charge_point.cpp:337
std::optional< NetworkConnectionProfile > get_network_connection_profile(const int32_t configuration_slot) const override
Gets the configured NetworkConnectionProfile based on the given configuration_slot ....
Definition: charge_point.cpp:1063
void on_network_disconnected(OCPPInterfaceEnum ocpp_interface) override
Can be called when a network is disconnected, for example when an ethernet cable is removed.
Definition: charge_point.cpp:168
void on_session_finished(const int32_t evse_id, const int32_t connector_id) override
Event handler that should be called when a session has finished.
Definition: charge_point.cpp:210
std::map< SetVariableData, SetVariableResult > set_variables(const std::vector< SetVariableData > &set_variable_data_vector, const std::string &source) override
Sets variables specified within set_variable_data_vector in the device model and returns the result.
Definition: charge_point.cpp:1043
void connect_websocket(std::optional< int32_t > network_profile_slot=std::nullopt) override
Initializes the websocket and connects to a CSMS. Provide a network_profile_slot to connect to that s...
Definition: charge_point.cpp:177
RequestDeviceModelResponse< T > request_value(const Component &component_id, const Variable &variable_id, const AttributeEnum &attribute_enum)
Requests a value of a VariableAttribute specified by combination of component_id and variable_id from...
Definition: charge_point.hpp:618
GetCompositeScheduleResponse get_composite_schedule(const GetCompositeScheduleRequest &request) override
Gets a composite schedule based on the given request.
Definition: charge_point.cpp:1048
void on_reservation_status(const int32_t reservation_id, const ReservationUpdateStatusEnum status) override
Event handler that will send a ReservationStatusUpdate request.
Definition: charge_point.cpp:384
const std::vector< int > & get_network_connection_slots() const override
Get the network connection slots sorted by priority. Each item in the vector contains the configured ...
Definition: charge_point.cpp:1071
void on_transaction_started(const int32_t evse_id, const int32_t connector_id, const std::string &session_id, const DateTime &timestamp, const TriggerReasonEnum trigger_reason, const MeterValue &meter_start, const std::optional< IdToken > &id_token, const std::optional< IdToken > &group_id_token, const std::optional< int32_t > &reservation_id, const std::optional< int32_t > &remote_start_id, const ChargingStateEnum charging_state) override
Event handler that should be called when a transaction has started.
Definition: charge_point.cpp:190
AuthorizeResponse validate_token(const IdToken id_token, const std::optional< CiString< 5500 > > &certificate, const std::optional< std::vector< OCSPRequestData > > &ocsp_request_data) override
Validates provided id_token certificate and ocsp_request_data using CSMS, AuthCache or AuthList.
Definition: charge_point.cpp:347
void on_reserved(const int32_t evse_id, const int32_t connector_id) override
Event handler that should be called when the connector on the given evse_id and connector_id is reser...
Definition: charge_point.cpp:303
std::optional< DataTransferResponse > data_transfer_req(const CiString< 255 > &vendorId, const std::optional< CiString< 50 > > &messageId, const std::optional< json > &data) override
Data transfer mechanism initiated by charger.
Definition: charge_point.cpp:907
std::vector< CompositeSchedule > get_all_composite_schedules(const int32_t duration, const ChargingRateUnitEnum &unit) override
Gets composite schedules for all evse_ids (including 0) for the given duration and unit ....
Definition: charge_point.cpp:1057
bool on_charging_state_changed(const uint32_t evse_id, const ChargingStateEnum charging_state, const TriggerReasonEnum trigger_reason=TriggerReasonEnum::ChargingStateChanged) override
Event handler that will update the charging state internally when it has been changed.
Definition: charge_point.cpp:315
void on_security_event(const CiString< 50 > &event_type, const std::optional< CiString< 255 > > &tech_info, const std::optional< bool > &critical=std::nullopt, const std::optional< DateTime > &timestamp=std::nullopt) override
Definition: charge_point.cpp:369
Definition: ocsp_updater.hpp:55
Definition: charge_point.hpp:54
ChargePoint(const std::map< int32_t, int32_t > &evse_connector_structure, std::shared_ptr< DeviceModel > device_model, std::shared_ptr< DatabaseHandler > database_handler, std::shared_ptr< MessageQueue< v2::MessageType > > message_queue, const std::string &message_log_path, const std::shared_ptr< EvseSecurity > evse_security, const Callbacks &callbacks)
Construct a new ChargePoint object.
Definition: charge_point.cpp:50
virtual void on_network_disconnected(OCPPInterfaceEnum ocpp_interface)=0
Can be called when a network is disconnected, for example when an ethernet cable is removed.
virtual Get15118EVCertificateResponse on_get_15118_ev_certificate_request(const Get15118EVCertificateRequest &request)=0
Event handler that should be called when the EV sends a certificate request (for update or installati...
virtual void on_security_event(const CiString< 50 > &event_type, const std::optional< CiString< 255 > > &tech_info, const std::optional< bool > &critical=std::nullopt, const std::optional< DateTime > &timestamp=std::nullopt)=0
virtual std::optional< std::string > get_evse_transaction_id(int32_t evse_id)=0
Gets the transaction id for a certain evse_id if there is an active transaction.
virtual void on_session_finished(const int32_t evse_id, const int32_t connector_id)=0
Event handler that should be called when a session has finished.
virtual bool on_charging_state_changed(const uint32_t evse_id, const ChargingStateEnum charging_state, const TriggerReasonEnum trigger_reason=TriggerReasonEnum::ChargingStateChanged)=0
Event handler that will update the charging state internally when it has been changed.
virtual void on_transaction_finished(const int32_t evse_id, const DateTime &timestamp, const MeterValue &meter_stop, const ReasonEnum reason, const TriggerReasonEnum trigger_reason, const std::optional< IdToken > &id_token, const std::optional< std::string > &signed_meter_value, const ChargingStateEnum charging_state)=0
Event handler that should be called when a transaction has finished.
virtual void on_firmware_update_status_notification(int32_t request_id, const FirmwareStatusEnum &firmware_update_status)=0
Chargepoint notifies about new firmware update status firmware_update_status. This function should be...
virtual void on_session_started(const int32_t evse_id, const int32_t connector_id)=0
Event handler that should be called when a session has started.
virtual void on_reserved(const int32_t evse_id, const int32_t connector_id)=0
Event handler that should be called when the connector on the given evse_id and connector_id is reser...
virtual void on_reservation_cleared(const int32_t evse_id, const int32_t connector_id)=0
Event handler that should be called when the reservation of the connector is cleared.
virtual void on_reservation_status(const int32_t reservation_id, const ReservationUpdateStatusEnum status)=0
Event handler that will send a ReservationStatusUpdate request.
virtual void on_log_status_notification(UploadLogStatusEnum status, int32_t requestId)=0
Event handler that can be called to notify about the log status.
virtual void on_faulted(const int32_t evse_id, const int32_t connector_id)=0
Event handler that should be called when the connector on the given evse_id and connector_id is fault...
virtual void on_enabled(const int32_t evse_id, const int32_t connector_id)=0
Event handler that should be called when the connector returns from unavailable on the given evse_id ...
virtual void on_transaction_started(const int32_t evse_id, const int32_t connector_id, const std::string &session_id, const DateTime &timestamp, const TriggerReasonEnum trigger_reason, const MeterValue &meter_start, const std::optional< IdToken > &id_token, const std::optional< IdToken > &group_id_token, const std::optional< int32_t > &reservation_id, const std::optional< int32_t > &remote_start_id, const ChargingStateEnum charging_state)=0
Event handler that should be called when a transaction has started.
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.
virtual void on_variable_changed(const SetVariableData &set_variable_data)=0
Event handler that will update the variable internally when it has been changed on the fly.
virtual void on_event(const std::vector< EventData > &events)=0
Event handler that can be called to trigger a NotifyEvent.req with the given events.
virtual void on_fault_cleared(const int32_t evse_id, const int32_t connector_id)=0
Event handler that should be called when the fault on the connector on the given evse_id is cleared.
virtual void on_unavailable(const int32_t evse_id, const int32_t connector_id)=0
Event handler that should be called when the connector on the given evse_id and connector_id becomes ...
virtual void on_authorized(const int32_t evse_id, const int32_t connector_id, const IdToken &id_token)=0
Event handler that should be called when the given id_token is authorized.
Contains a OCPP CallResult message.
Definition: call_types.hpp:105
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
Contains a OCPP AuthorizeResponse message.
Definition: Authorize.hpp:41
Definition: charge_point_callbacks.hpp:22
Definition: ocpp_types.hpp:303
Contains a OCPP DataTransfer message.
Definition: DataTransfer.hpp:19
Contains a OCPP Get15118EVCertificate message.
Definition: Get15118EVCertificate.hpp:20
Contains a OCPP Get15118EVCertificateResponse message.
Definition: Get15118EVCertificate.hpp:42
Contains a OCPP GetCompositeSchedule message.
Definition: GetCompositeSchedule.hpp:19
Contains a OCPP GetCompositeScheduleResponse message.
Definition: GetCompositeSchedule.hpp:41
Definition: ocpp_types.hpp:36
Definition: ocpp_types.hpp:436
Definition: ocpp_types.hpp:831
Response to requesting a value from the device model.
Definition: device_model.hpp:18
Definition: ocpp_types.hpp:898
Definition: ocpp_types.hpp:319