-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathcharge_point.cpp
987 lines (875 loc) · 53.8 KB
/
charge_point.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest
#include <ocpp/v201/charge_point.hpp>
#include <ocpp/common/constants.hpp>
#include <ocpp/common/types.hpp>
#include <ocpp/v201/ctrlr_component_variables.hpp>
#include <ocpp/v201/database_handler.hpp>
#include <ocpp/v201/device_model.hpp>
#include <ocpp/v201/device_model_storage_interface.hpp>
#include <ocpp/v201/device_model_storage_sqlite.hpp>
#include <ocpp/v201/evse_manager.hpp>
#include <ocpp/v201/message_dispatcher.hpp>
#include <ocpp/v201/notify_report_requests_splitter.hpp>
#include <ocpp/v201/functional_blocks/authorization.hpp>
#include <ocpp/v201/functional_blocks/availability.hpp>
#include <ocpp/v201/functional_blocks/data_transfer.hpp>
#include <ocpp/v201/functional_blocks/diagnostics.hpp>
#include <ocpp/v201/functional_blocks/display_message.hpp>
#include <ocpp/v201/functional_blocks/firmware_update.hpp>
#include <ocpp/v201/functional_blocks/meter_values.hpp>
#include <ocpp/v201/functional_blocks/provisioning.hpp>
#include <ocpp/v201/functional_blocks/remote_transaction_control.hpp>
#include <ocpp/v201/functional_blocks/reservation.hpp>
#include <ocpp/v201/functional_blocks/security.hpp>
#include <ocpp/v201/functional_blocks/smart_charging.hpp>
#include <ocpp/v201/functional_blocks/tariff_and_cost.hpp>
#include <ocpp/v201/functional_blocks/transaction.hpp>
#include <ocpp/v201/messages/LogStatusNotification.hpp>
#include <ocpp/v201/messages/RequestStopTransaction.hpp>
#include <ocpp/v201/messages/TriggerMessage.hpp>
#include <optional>
#include <stdexcept>
#include <string>
using namespace std::chrono_literals;
using DatabaseException = ocpp::common::DatabaseException;
namespace ocpp {
namespace v201 {
const auto DEFAULT_MESSAGE_QUEUE_SIZE_THRESHOLD = 2E5;
ChargePoint::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<v201::MessageType>> message_queue,
const std::string& message_log_path, const std::shared_ptr<EvseSecurity> evse_security,
const Callbacks& callbacks) :
ocpp::ChargingStationBase(evse_security),
message_queue(message_queue),
device_model(device_model),
database_handler(database_handler),
registration_status(RegistrationStatusEnum::Rejected),
skip_invalid_csms_certificate_notifications(false),
upload_log_status(UploadLogStatusEnum::Idle),
bootreason(BootReasonEnum::PowerUp),
ocsp_updater(this->evse_security, this->send_callback<GetCertificateStatusRequest, GetCertificateStatusResponse>(
MessageType::GetCertificateStatusResponse)),
callbacks(callbacks) {
if (!this->device_model) {
EVLOG_AND_THROW(std::invalid_argument("Device model should not be null"));
}
// Make sure the received callback struct is completely filled early before we actually start running
if (!this->callbacks.all_callbacks_valid(this->device_model)) {
EVLOG_AND_THROW(std::invalid_argument("All non-optional callbacks must be supplied"));
}
if (!this->database_handler) {
EVLOG_AND_THROW(std::invalid_argument("Database handler should not be null"));
}
initialize(evse_connector_structure, message_log_path);
}
ChargePoint::ChargePoint(const std::map<int32_t, int32_t>& evse_connector_structure,
std::unique_ptr<DeviceModelStorageInterface> device_model_storage_interface,
const std::string& ocpp_main_path, const std::string& core_database_path,
const std::string& sql_init_path, const std::string& message_log_path,
const std::shared_ptr<EvseSecurity> evse_security, const Callbacks& callbacks) :
ChargePoint(
evse_connector_structure, std::make_shared<DeviceModel>(std::move(device_model_storage_interface)),
std::make_shared<DatabaseHandler>(
std::make_unique<common::DatabaseConnection>(fs::path(core_database_path) / "cp.db"), sql_init_path),
nullptr /* message_queue initialized in this constructor */, message_log_path, evse_security, callbacks) {
}
ChargePoint::ChargePoint(const std::map<int32_t, int32_t>& evse_connector_structure,
const std::string& device_model_storage_address, const bool initialize_device_model,
const std::string& device_model_migration_path, const std::string& device_model_config_path,
const std::string& ocpp_main_path, const std::string& core_database_path,
const std::string& sql_init_path, const std::string& message_log_path,
const std::shared_ptr<EvseSecurity> evse_security, const Callbacks& callbacks) :
ChargePoint(evse_connector_structure,
std::make_unique<DeviceModelStorageSqlite>(device_model_storage_address, device_model_migration_path,
device_model_config_path, initialize_device_model),
ocpp_main_path, core_database_path, sql_init_path, message_log_path, evse_security, callbacks) {
}
ChargePoint::~ChargePoint() {
}
void ChargePoint::start(BootReasonEnum bootreason, bool start_connecting) {
this->message_queue->start();
this->bootreason = bootreason;
// Trigger all initial status notifications and callbacks related to component state
// Should be done before sending the BootNotification.req so that the correct states can be reported
this->component_state_manager->trigger_all_effective_availability_changed_callbacks();
// get transaction messages from db (if there are any) so they can be sent again.
this->message_queue->get_persisted_messages_from_db();
this->provisioning->boot_notification_req(bootreason);
// call clear_invalid_charging_profiles when system boots
this->clear_invalid_charging_profiles();
if (start_connecting) {
this->connectivity_manager->connect();
}
const std::string firmware_version =
this->device_model->get_value<std::string>(ControllerComponentVariables::FirmwareVersion);
if (this->bootreason == BootReasonEnum::RemoteReset) {
this->security->security_event_notification_req(
CiString<50>(ocpp::security_events::RESET_OR_REBOOT),
std::optional<CiString<255>>("Charging Station rebooted due to requested remote reset!"), true, true);
} else if (this->bootreason == BootReasonEnum::ScheduledReset) {
this->security->security_event_notification_req(
CiString<50>(ocpp::security_events::RESET_OR_REBOOT),
std::optional<CiString<255>>("Charging Station rebooted due to a scheduled reset!"), true, true);
} else if (this->bootreason == BootReasonEnum::PowerUp) {
std::string startup_message = "Charging Station powered up! Firmware version: " + firmware_version;
this->security->security_event_notification_req(CiString<50>(ocpp::security_events::STARTUP_OF_THE_DEVICE),
std::optional<CiString<255>>(startup_message), true, true);
} else if (this->bootreason == BootReasonEnum::FirmwareUpdate) {
std::string startup_message =
"Charging station reboot after firmware update. Firmware version: " + firmware_version;
this->security->security_event_notification_req(CiString<50>(ocpp::security_events::FIRMWARE_UPDATED),
std::optional<CiString<255>>(startup_message), true, true);
} else {
std::string startup_message = "Charging station reset or reboot. Firmware version: " + firmware_version;
this->security->security_event_notification_req(CiString<50>(ocpp::security_events::RESET_OR_REBOOT),
std::optional<CiString<255>>(startup_message), true, true);
}
}
void ChargePoint::stop() {
this->ocsp_updater.stop();
this->availability->stop_heartbeat_timer();
this->provisioning->stop_bootnotification_timer();
this->connectivity_manager->disconnect();
this->security->stop_certificate_expiration_check_timers();
this->diagnostics->stop_monitoring();
this->message_queue->stop();
this->security->stop_certificate_signed_timer();
}
void ChargePoint::disconnect_websocket() {
this->connectivity_manager->disconnect();
}
void ChargePoint::on_network_disconnected(OCPPInterfaceEnum ocpp_interface) {
this->connectivity_manager->on_network_disconnected(ocpp_interface);
}
void ChargePoint::on_firmware_update_status_notification(int32_t request_id,
const FirmwareStatusEnum& firmware_update_status) {
this->firmware_update->on_firmware_update_status_notification(request_id, firmware_update_status);
}
void ChargePoint::connect_websocket(std::optional<int32_t> network_profile_slot) {
this->connectivity_manager->connect(network_profile_slot);
}
void ChargePoint::on_session_started(const int32_t evse_id, const int32_t connector_id) {
this->evse_manager->get_evse(evse_id).submit_event(connector_id, ConnectorEvent::PlugIn);
}
Get15118EVCertificateResponse
ChargePoint::on_get_15118_ev_certificate_request(const Get15118EVCertificateRequest& request) {
return this->security->on_get_15118_ev_certificate_request(request);
}
void ChargePoint::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) {
this->transaction->on_transaction_started(evse_id, connector_id, session_id, timestamp, trigger_reason, meter_start,
id_token, group_id_token, reservation_id, remote_start_id,
charging_state);
}
void ChargePoint::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) {
this->transaction->on_transaction_finished(evse_id, timestamp, meter_stop, reason, trigger_reason, id_token,
signed_meter_value, charging_state);
}
void ChargePoint::on_session_finished(const int32_t evse_id, const int32_t connector_id) {
this->evse_manager->get_evse(evse_id).submit_event(connector_id, ConnectorEvent::PlugOut);
}
void ChargePoint::on_authorized(const int32_t evse_id, const int32_t connector_id, const IdToken& id_token) {
auto& evse = this->evse_manager->get_evse(evse_id);
if (!evse.has_active_transaction()) {
// nothing to report in case transaction is not yet open
return;
}
std::unique_ptr<EnhancedTransaction>& transaction = evse.get_transaction();
if (transaction->id_token_sent) {
// if transactions id_token_sent is set, it is assumed it has already been reported
return;
}
// set id_token of enhanced_transaction and send TransactionEvent(Updated) with id_token
transaction->set_id_token_sent();
this->transaction->transaction_event_req(TransactionEventEnum::Updated, ocpp::DateTime(),
transaction->get_transaction(), TriggerReasonEnum::Authorized,
transaction->get_seq_no(), std::nullopt, std::nullopt, id_token,
std::nullopt, std::nullopt, this->is_offline(), std::nullopt);
}
void ChargePoint::on_meter_value(const int32_t evse_id, const MeterValue& meter_value) {
this->meter_values->on_meter_value(evse_id, meter_value);
}
void ChargePoint::configure_message_logging_format(const std::string& message_log_path) {
auto log_formats = this->device_model->get_value<std::string>(ControllerComponentVariables::LogMessagesFormat);
bool log_to_console = log_formats.find("console") != log_formats.npos;
bool detailed_log_to_console = log_formats.find("console_detailed") != log_formats.npos;
bool log_to_file = log_formats.find("log") != log_formats.npos;
bool log_to_html = log_formats.find("html") != log_formats.npos;
bool log_security = log_formats.find("security") != log_formats.npos;
bool session_logging = log_formats.find("session_logging") != log_formats.npos;
bool message_callback = log_formats.find("callback") != log_formats.npos;
std::function<void(const std::string& message, MessageDirection direction)> logging_callback = nullptr;
bool log_rotation =
this->device_model->get_optional_value<bool>(ControllerComponentVariables::LogRotation).value_or(false);
bool log_rotation_date_suffix =
this->device_model->get_optional_value<bool>(ControllerComponentVariables::LogRotationDateSuffix)
.value_or(false);
uint64_t log_rotation_maximum_file_size =
this->device_model->get_optional_value<uint64_t>(ControllerComponentVariables::LogRotationMaximumFileSize)
.value_or(0);
uint64_t log_rotation_maximum_file_count =
this->device_model->get_optional_value<uint64_t>(ControllerComponentVariables::LogRotationMaximumFileCount)
.value_or(0);
if (message_callback) {
logging_callback = this->callbacks.ocpp_messages_callback.value_or(nullptr);
}
if (log_rotation) {
this->logging = std::make_shared<ocpp::MessageLogging>(
!log_formats.empty(), message_log_path, "libocpp_201", log_to_console, detailed_log_to_console, log_to_file,
log_to_html, log_security, session_logging, logging_callback,
ocpp::LogRotationConfig(log_rotation_date_suffix, log_rotation_maximum_file_size,
log_rotation_maximum_file_count),
[this](ocpp::LogRotationStatus status) {
if (status == ocpp::LogRotationStatus::RotatedWithDeletion) {
const auto& security_event = ocpp::security_events::SECURITYLOGWASCLEARED;
std::string tech_info = "Security log was rotated and an old log was deleted in the process";
this->security->security_event_notification_req(CiString<50>(security_event),
CiString<255>(tech_info), true,
utils::is_critical(security_event));
}
});
} else {
this->logging = std::make_shared<ocpp::MessageLogging>(
!log_formats.empty(), message_log_path, DateTime().to_rfc3339(), log_to_console, detailed_log_to_console,
log_to_file, log_to_html, log_security, session_logging, logging_callback);
}
}
void ChargePoint::on_unavailable(const int32_t evse_id, const int32_t connector_id) {
this->evse_manager->get_evse(evse_id).submit_event(connector_id, ConnectorEvent::Unavailable);
}
void ChargePoint::on_enabled(const int32_t evse_id, const int32_t connector_id) {
this->evse_manager->get_evse(evse_id).submit_event(connector_id, ConnectorEvent::UnavailableCleared);
}
void ChargePoint::on_faulted(const int32_t evse_id, const int32_t connector_id) {
this->evse_manager->get_evse(evse_id).submit_event(connector_id, ConnectorEvent::Error);
}
void ChargePoint::on_fault_cleared(const int32_t evse_id, const int32_t connector_id) {
this->evse_manager->get_evse(evse_id).submit_event(connector_id, ConnectorEvent::ErrorCleared);
}
void ChargePoint::on_reserved(const int32_t evse_id, const int32_t connector_id) {
if (this->reservation != nullptr) {
this->reservation->on_reserved(evse_id, connector_id);
}
}
void ChargePoint::on_reservation_cleared(const int32_t evse_id, const int32_t connector_id) {
if (this->reservation != nullptr) {
this->reservation->on_reservation_cleared(evse_id, connector_id);
}
}
bool ChargePoint::on_charging_state_changed(const uint32_t evse_id, const ChargingStateEnum charging_state,
const TriggerReasonEnum trigger_reason) {
auto& evse = this->evse_manager->get_evse(evse_id);
std::unique_ptr<EnhancedTransaction>& transaction = evse.get_transaction();
if (transaction == nullptr) {
EVLOG_warning << "Can not change charging state: no transaction for evse id " << evse_id;
return false;
}
if (transaction->chargingState == charging_state) {
EVLOG_debug << "Trying to send charging state changed without actual change, dropping message";
} else {
transaction->chargingState = charging_state;
this->transaction->transaction_event_req(TransactionEventEnum::Updated, DateTime(),
transaction->get_transaction(), trigger_reason,
transaction->get_seq_no(), std::nullopt, std::nullopt, std::nullopt,
std::nullopt, std::nullopt, this->is_offline(), std::nullopt);
}
return true;
}
std::optional<std::string> ChargePoint::get_evse_transaction_id(int32_t evse_id) {
const auto& tx = this->evse_manager->get_evse(evse_id).get_transaction();
if (tx != nullptr) {
return tx->transactionId.get();
}
return std::nullopt;
}
AuthorizeResponse ChargePoint::validate_token(const IdToken id_token, const std::optional<CiString<5500>>& certificate,
const std::optional<std::vector<OCSPRequestData>>& ocsp_request_data) {
return this->authorization->validate_token(id_token, certificate, ocsp_request_data);
}
void ChargePoint::on_event(const std::vector<EventData>& events) {
this->diagnostics->notify_event_req(events);
}
void ChargePoint::on_log_status_notification(UploadLogStatusEnum status, int32_t requestId) {
LogStatusNotificationRequest request;
request.status = status;
request.requestId = requestId;
// Store for use by the triggerMessage
this->upload_log_status = status;
this->upload_log_status_id = requestId;
ocpp::Call<LogStatusNotificationRequest> call(request);
this->message_dispatcher->dispatch_call(call);
}
void ChargePoint::on_security_event(const CiString<50>& event_type, const std::optional<CiString<255>>& tech_info,
const std::optional<bool>& critical, const std::optional<DateTime>& timestamp) {
auto critical_security_event = true;
if (critical.has_value()) {
critical_security_event = critical.value();
} else {
critical_security_event = utils::is_critical(event_type);
}
this->security->security_event_notification_req(event_type, tech_info, false, critical_security_event, timestamp);
}
void ChargePoint::on_variable_changed(const SetVariableData& set_variable_data) {
this->provisioning->on_variable_changed(set_variable_data);
}
void ChargePoint::on_reservation_status(const int32_t reservation_id, const ReservationUpdateStatusEnum status) {
if (reservation != nullptr) {
this->reservation->on_reservation_status(reservation_id, status);
}
}
void ChargePoint::initialize(const std::map<int32_t, int32_t>& evse_connector_structure,
const std::string& message_log_path) {
this->device_model->check_integrity(evse_connector_structure);
this->database_handler->open_connection();
this->component_state_manager = std::make_shared<ComponentStateManager>(
evse_connector_structure, database_handler,
[this](auto evse_id, auto connector_id, auto status, bool initiated_by_trigger_message) {
this->update_dm_availability_state(evse_id, connector_id, status);
if (this->connectivity_manager == nullptr or !this->connectivity_manager->is_websocket_connected() or
this->registration_status != RegistrationStatusEnum::Accepted) {
return false;
} else {
this->availability->status_notification_req(evse_id, connector_id, status,
initiated_by_trigger_message);
return true;
}
});
if (this->callbacks.cs_effective_operative_status_changed_callback.has_value()) {
this->component_state_manager->set_cs_effective_availability_changed_callback(
this->callbacks.cs_effective_operative_status_changed_callback.value());
}
if (this->callbacks.evse_effective_operative_status_changed_callback.has_value()) {
this->component_state_manager->set_evse_effective_availability_changed_callback(
this->callbacks.evse_effective_operative_status_changed_callback.value());
}
this->component_state_manager->set_connector_effective_availability_changed_callback(
this->callbacks.connector_effective_operative_status_changed_callback);
auto transaction_meter_value_callback = [this](const MeterValue& _meter_value, EnhancedTransaction& transaction) {
if (_meter_value.sampledValue.empty() or !_meter_value.sampledValue.at(0).context.has_value()) {
EVLOG_info << "Not sending MeterValue due to no values";
return;
}
auto type = _meter_value.sampledValue.at(0).context.value();
if (type != ReadingContextEnum::Sample_Clock and type != ReadingContextEnum::Sample_Periodic) {
EVLOG_info << "Not sending MeterValue due to wrong context";
return;
}
const auto filter_vec = utils::get_measurands_vec(this->device_model->get_value<std::string>(
type == ReadingContextEnum::Sample_Clock ? ControllerComponentVariables::AlignedDataMeasurands
: ControllerComponentVariables::SampledDataTxUpdatedMeasurands));
const auto filtered_meter_value = utils::get_meter_value_with_measurands_applied(_meter_value, filter_vec);
if (!filtered_meter_value.sampledValue.empty()) {
const auto trigger = type == ReadingContextEnum::Sample_Clock ? TriggerReasonEnum::MeterValueClock
: TriggerReasonEnum::MeterValuePeriodic;
this->transaction->transaction_event_req(TransactionEventEnum::Updated, DateTime(), transaction, trigger,
transaction.get_seq_no(), std::nullopt, std::nullopt, std::nullopt,
std::vector<MeterValue>(1, filtered_meter_value), std::nullopt,
this->is_offline(), std::nullopt);
}
};
this->evse_manager = std::make_unique<EvseManager>(
evse_connector_structure, *this->device_model, this->database_handler, component_state_manager,
transaction_meter_value_callback, this->callbacks.pause_charging_callback);
this->configure_message_logging_format(message_log_path);
this->connectivity_manager =
std::make_unique<ConnectivityManager>(*this->device_model, this->evse_security, this->logging,
std::bind(&ChargePoint::message_callback, this, std::placeholders::_1));
this->connectivity_manager->set_websocket_connected_callback(
[this](int configuration_slot, const NetworkConnectionProfile& network_connection_profile, auto) {
this->websocket_connected_callback(configuration_slot, network_connection_profile);
});
this->connectivity_manager->set_websocket_disconnected_callback(
[this](int configuration_slot, const NetworkConnectionProfile& network_connection_profile, auto) {
this->websocket_disconnected_callback(configuration_slot, network_connection_profile);
});
this->connectivity_manager->set_websocket_connection_failed_callback(
std::bind(&ChargePoint::websocket_connection_failed, this, std::placeholders::_1));
if (this->message_queue == nullptr) {
std::set<v201::MessageType> message_types_discard_for_queueing;
try {
const auto message_types_discard_for_queueing_csl = ocpp::split_string(
this->device_model
->get_optional_value<std::string>(ControllerComponentVariables::MessageTypesDiscardForQueueing)
.value_or(""),
',');
std::transform(message_types_discard_for_queueing_csl.begin(), message_types_discard_for_queueing_csl.end(),
std::inserter(message_types_discard_for_queueing, message_types_discard_for_queueing.end()),
[](const std::string element) { return conversions::string_to_messagetype(element); });
} catch (const StringToEnumException& e) {
EVLOG_warning << "Could not convert configured MessageType value of MessageTypesDiscardForQueueing. Please "
"check you configuration: "
<< e.what();
} catch (...) {
EVLOG_warning << "Could not apply MessageTypesDiscardForQueueing configuration";
}
this->message_queue = std::make_unique<ocpp::MessageQueue<v201::MessageType>>(
[this](json message) -> bool { return this->connectivity_manager->send_to_websocket(message.dump()); },
MessageQueueConfig<v201::MessageType>{
this->device_model->get_value<int>(ControllerComponentVariables::MessageAttempts),
this->device_model->get_value<int>(ControllerComponentVariables::MessageAttemptInterval),
this->device_model->get_optional_value<int>(ControllerComponentVariables::MessageQueueSizeThreshold)
.value_or(DEFAULT_MESSAGE_QUEUE_SIZE_THRESHOLD),
this->device_model->get_optional_value<bool>(ControllerComponentVariables::QueueAllMessages)
.value_or(false),
message_types_discard_for_queueing,
this->device_model->get_value<int>(ControllerComponentVariables::MessageTimeout)},
this->database_handler);
}
this->message_dispatcher =
std::make_unique<MessageDispatcher>(*this->message_queue, *this->device_model, registration_status);
this->data_transfer = std::make_unique<DataTransfer>(
*this->message_dispatcher, this->callbacks.data_transfer_callback, DEFAULT_WAIT_FOR_FUTURE_TIMEOUT);
this->security = std::make_unique<Security>(*this->message_dispatcher, *this->device_model, *this->logging,
*this->evse_security, *this->connectivity_manager, this->ocsp_updater,
this->callbacks.security_event_callback);
if (device_model->get_optional_value<bool>(ControllerComponentVariables::ReservationCtrlrAvailable)
.value_or(false)) {
this->reservation = std::make_unique<Reservation>(
*this->message_dispatcher, *this->device_model, *this->evse_manager,
this->callbacks.reserve_now_callback.value(), this->callbacks.cancel_reservation_callback.value(),
this->callbacks.is_reservation_for_token_callback);
}
this->authorization = std::make_unique<Authorization>(*this->message_dispatcher, *this->device_model,
*this->connectivity_manager.get(),
*this->database_handler.get(), *this->evse_security.get());
this->authorization->start_auth_cache_cleanup_thread();
this->diagnostics = std::make_unique<Diagnostics>(
*this->message_dispatcher, *this->device_model, *this->connectivity_manager, *this->authorization,
this->callbacks.get_log_request_callback, this->callbacks.get_customer_information_callback,
this->callbacks.clear_customer_information_callback);
this->diagnostics->start_monitoring();
if (device_model->get_optional_value<bool>(ControllerComponentVariables::DisplayMessageCtrlrAvailable)
.value_or(false)) {
this->display_message = std::make_unique<DisplayMessageBlock>(
*this->message_dispatcher, *this->device_model, *this->evse_manager,
this->callbacks.get_display_message_callback.value(), this->callbacks.set_display_message_callback.value(),
this->callbacks.clear_display_message_callback.value());
}
this->meter_values =
std::make_unique<MeterValues>(*this->message_dispatcher, *this->device_model, *this->evse_manager);
this->availability = std::make_unique<Availability>(
*this->message_dispatcher, *this->device_model, *this->evse_manager, *this->component_state_manager,
this->callbacks.time_sync_callback, this->callbacks.all_connectors_unavailable_callback);
if (this->callbacks.configure_network_connection_profile_callback.has_value()) {
this->connectivity_manager->set_configure_network_connection_profile_callback(
this->callbacks.configure_network_connection_profile_callback.value());
}
this->smart_charging = std::make_unique<SmartCharging>(
*this->device_model, *this->evse_manager, *this->connectivity_manager, *this->message_dispatcher,
*this->database_handler, this->callbacks.set_charging_profiles_callback);
this->tariff_and_cost = std::make_unique<TariffAndCost>(
*this->message_dispatcher, *this->device_model, *this->evse_manager, *this->meter_values,
this->callbacks.set_display_message_callback, this->callbacks.set_running_cost_callback, this->io_service);
this->firmware_update = std::make_unique<FirmwareUpdate>(
*this->message_dispatcher, *this->device_model, *this->evse_manager, *this->evse_security, *this->availability,
*this->security, this->callbacks.update_firmware_request_callback,
this->callbacks.all_connectors_unavailable_callback);
this->transaction = std::make_unique<TransactionBlock>(
*this->message_dispatcher, *this->device_model, *this->connectivity_manager, *this->evse_manager,
*this->message_queue, *this->database_handler, *this->authorization, *this->availability, *this->smart_charging,
*this->tariff_and_cost, this->callbacks.stop_transaction_callback, this->callbacks.pause_charging_callback,
this->callbacks.transaction_event_callback, this->callbacks.transaction_event_response_callback,
this->callbacks.reset_callback);
this->provisioning = std::make_unique<Provisioning>(
*this->device_model, *this->message_dispatcher, *this->message_queue, *this->connectivity_manager,
*this->component_state_manager, this->ocsp_updater, *this->evse_manager, *this->evse_security,
*this->availability, *this->meter_values, *this->security, *this->diagnostics, *this->transaction,
this->callbacks.time_sync_callback, this->callbacks.boot_notification_callback,
this->callbacks.validate_network_profile_callback, this->callbacks.is_reset_allowed_callback,
this->callbacks.reset_callback, this->callbacks.stop_transaction_callback,
this->callbacks.variable_changed_callback, this->registration_status);
this->remote_transaction_control = std::make_unique<RemoteTransactionControl>(
*this->message_dispatcher, *this->device_model, *this->connectivity_manager, *this->evse_manager,
*this->component_state_manager, *this->transaction, *this->smart_charging, *this->meter_values,
*this->availability, *this->firmware_update, *this->security, this->reservation.get(), *this->provisioning,
this->callbacks.unlock_connector_callback, this->callbacks.remote_start_transaction_callback,
this->callbacks.stop_transaction_callback, this->registration_status, this->upload_log_status,
this->upload_log_status_id);
Component ocpp_comm_ctrlr = {"OCPPCommCtrlr"};
Variable field_length = {"FieldLength"};
field_length.instance = "Get15118EVCertificateResponse.exiResponse";
this->device_model->set_value(ocpp_comm_ctrlr, field_length, AttributeEnum::Actual,
std::to_string(ISO15118_GET_EV_CERTIFICATE_EXI_RESPONSE_SIZE),
VARIABLE_ATTRIBUTE_VALUE_SOURCE_INTERNAL, true);
}
void ChargePoint::handle_message(const EnhancedMessage<v201::MessageType>& message) {
const auto& json_message = message.message;
try {
switch (message.messageType) {
case MessageType::BootNotificationResponse:
case MessageType::SetVariables:
case MessageType::GetVariables:
case MessageType::GetBaseReport:
case MessageType::GetReport:
case MessageType::Reset:
case MessageType::SetNetworkProfile:
this->provisioning->handle_message(message);
break;
case MessageType::ChangeAvailability:
case MessageType::HeartbeatResponse:
this->availability->handle_message(message);
break;
case MessageType::TransactionEventResponse:
case MessageType::GetTransactionStatus:
this->transaction->handle_message(message);
break;
case MessageType::RequestStartTransaction:
case MessageType::RequestStopTransaction:
case MessageType::UnlockConnector:
case MessageType::TriggerMessage:
this->remote_transaction_control->handle_message(message);
break;
case MessageType::DataTransfer:
this->data_transfer->handle_message(message);
break;
case MessageType::GetLog:
case MessageType::CustomerInformation:
case MessageType::SetMonitoringBase:
case MessageType::SetMonitoringLevel:
case MessageType::SetVariableMonitoring:
case MessageType::GetMonitoringReport:
case MessageType::ClearVariableMonitoring:
this->diagnostics->handle_message(message);
break;
case MessageType::ClearCache:
case MessageType::SendLocalList:
case MessageType::GetLocalListVersion:
this->authorization->handle_message(message);
break;
case MessageType::UpdateFirmware:
this->firmware_update->handle_message(message);
break;
case MessageType::ReserveNow:
case MessageType::CancelReservation:
if (this->reservation != nullptr) {
this->reservation->handle_message(message);
} else {
send_not_implemented_error(message.uniqueId, message.messageTypeId);
}
break;
case MessageType::CertificateSigned:
case MessageType::SignCertificateResponse:
case MessageType::GetInstalledCertificateIds:
case MessageType::InstallCertificate:
case MessageType::DeleteCertificate:
this->security->handle_message(message);
break;
case MessageType::SetChargingProfile:
case MessageType::ClearChargingProfile:
case MessageType::GetChargingProfiles:
case MessageType::GetCompositeSchedule:
this->smart_charging->handle_message(message);
break;
case MessageType::GetDisplayMessages:
case MessageType::SetDisplayMessage:
case MessageType::ClearDisplayMessage:
if (this->display_message != nullptr) {
this->display_message->handle_message(message);
} else {
send_not_implemented_error(message.uniqueId, message.messageTypeId);
}
break;
case MessageType::CostUpdated:
this->tariff_and_cost->handle_message(message);
break;
default:
send_not_implemented_error(message.uniqueId, message.messageTypeId);
break;
}
} catch (const MessageTypeNotImplementedException& e) {
EVLOG_warning << e.what();
send_not_implemented_error(message.uniqueId, message.messageTypeId);
}
}
void ChargePoint::message_callback(const std::string& message) {
EnhancedMessage<v201::MessageType> enhanced_message;
try {
enhanced_message = this->message_queue->receive(message);
} catch (const json::exception& e) {
this->logging->central_system("Unknown", message);
EVLOG_error << "JSON exception during reception of message: " << e.what();
this->message_dispatcher->dispatch_call_error(
CallError(MessageId("-1"), "RpcFrameworkError", e.what(), json({})));
const auto& security_event = ocpp::security_events::INVALIDMESSAGES;
this->security->security_event_notification_req(CiString<50>(security_event, StringTooLarge::Truncate),
CiString<255>(message, StringTooLarge::Truncate), true,
utils::is_critical(security_event));
return;
} catch (const StringConversionException& e) {
this->logging->central_system("Unknown", message);
EVLOG_error << "JSON exception during reception of message: " << e.what();
this->message_dispatcher->dispatch_call_error(
CallError(MessageId("-1"), "RpcFrameworkError", e.what(), json({})));
const auto& security_event = ocpp::security_events::INVALIDMESSAGES;
this->security->security_event_notification_req(CiString<50>(security_event, StringTooLarge::Truncate),
CiString<255>(message, StringTooLarge::Truncate), true,
utils::is_critical(security_event));
return;
} catch (const EnumConversionException& e) {
EVLOG_error << "EnumConversionException during handling of message: " << e.what();
auto call_error = CallError(MessageId("-1"), "FormationViolation", e.what(), json({}));
this->message_dispatcher->dispatch_call_error(call_error);
const auto& security_event = ocpp::security_events::INVALIDMESSAGES;
this->security->security_event_notification_req(CiString<50>(security_event, StringTooLarge::Truncate),
CiString<255>(message, StringTooLarge::Truncate), true,
utils::is_critical(security_event));
return;
}
enhanced_message.message_size = message.size();
auto json_message = enhanced_message.message;
this->logging->central_system(conversions::messagetype_to_string(enhanced_message.messageType), message);
try {
if (this->registration_status == RegistrationStatusEnum::Accepted) {
this->handle_message(enhanced_message);
} else if (this->registration_status == RegistrationStatusEnum::Pending) {
if (enhanced_message.messageType == MessageType::BootNotificationResponse) {
this->provisioning->handle_message(enhanced_message);
} else {
// TODO(piet): Check what kind of messages we should accept in Pending state
if (enhanced_message.messageType == MessageType::GetVariables or
enhanced_message.messageType == MessageType::SetVariables or
enhanced_message.messageType == MessageType::GetBaseReport or
enhanced_message.messageType == MessageType::GetReport or
enhanced_message.messageType == MessageType::NotifyReportResponse or
enhanced_message.messageType == MessageType::TriggerMessage) {
this->handle_message(enhanced_message);
} else if (enhanced_message.messageType == MessageType::RequestStartTransaction) {
// Send rejected: B02.FR.05
RequestStartTransactionResponse response;
response.status = RequestStartStopStatusEnum::Rejected;
const ocpp::CallResult<RequestStartTransactionResponse> call_result(response,
enhanced_message.uniqueId);
this->message_dispatcher->dispatch_call_result(call_result);
} else if (enhanced_message.messageType == MessageType::RequestStopTransaction) {
// Send rejected: B02.FR.05
RequestStopTransactionResponse response;
response.status = RequestStartStopStatusEnum::Rejected;
const ocpp::CallResult<RequestStopTransactionResponse> call_result(response,
enhanced_message.uniqueId);
this->message_dispatcher->dispatch_call_result(call_result);
} else {
std::string const call_error_message =
"Received invalid MessageType: " +
conversions::messagetype_to_string(enhanced_message.messageType) +
" from CSMS while in state Pending";
EVLOG_warning << call_error_message;
// B02.FR.09 send CALLERROR SecurityError
const auto call_error =
CallError(enhanced_message.uniqueId, "SecurityError", call_error_message, json({}));
this->message_dispatcher->dispatch_call_error(call_error);
}
}
} else if (this->registration_status == RegistrationStatusEnum::Rejected) {
if (enhanced_message.messageType == MessageType::BootNotificationResponse) {
this->provisioning->handle_message(enhanced_message);
} else if (enhanced_message.messageType == MessageType::TriggerMessage) {
Call<TriggerMessageRequest> call(json_message);
if (call.msg.requestedMessage == MessageTriggerEnum::BootNotification) {
this->handle_message(enhanced_message);
} else {
const auto error_message =
"Received TriggerMessage with requestedMessage != BootNotification before "
"having received an accepted BootNotificationResponse";
EVLOG_warning << error_message;
const auto call_error = CallError(enhanced_message.uniqueId, "SecurityError", "", json({}));
this->message_dispatcher->dispatch_call_error(call_error);
}
} else {
const auto error_message = "Received other message than BootNotificationResponse before "
"having received an accepted BootNotificationResponse";
EVLOG_warning << error_message;
const auto call_error = CallError(enhanced_message.uniqueId, "SecurityError", "", json({}, true));
this->message_dispatcher->dispatch_call_error(call_error);
}
}
} catch (const EvseOutOfRangeException& e) {
EVLOG_error << "Exception during handling of message: " << e.what();
auto call_error = CallError(enhanced_message.uniqueId, "OccurrenceConstraintViolation", e.what(), json({}));
this->message_dispatcher->dispatch_call_error(call_error);
} catch (const ConnectorOutOfRangeException& e) {
EVLOG_error << "Exception during handling of message: " << e.what();
auto call_error = CallError(enhanced_message.uniqueId, "OccurrenceConstraintViolation", e.what(), json({}));
this->message_dispatcher->dispatch_call_error(call_error);
} catch (const EnumConversionException& e) {
EVLOG_error << "EnumConversionException during handling of message: " << e.what();
auto call_error = CallError(enhanced_message.uniqueId, "FormationViolation", e.what(), json({}));
this->message_dispatcher->dispatch_call_error(call_error);
} catch (const TimePointParseException& e) {
EVLOG_error << "Exception during handling of message: " << e.what();
auto call_error = CallError(enhanced_message.uniqueId, "FormationViolation", e.what(), json({}));
this->message_dispatcher->dispatch_call_error(call_error);
} catch (json::exception& e) {
EVLOG_error << "JSON exception during handling of message: " << e.what();
if (json_message.is_array() and json_message.size() > MESSAGE_ID) {
auto call_error = CallError(enhanced_message.uniqueId, "FormationViolation", e.what(), json({}));
this->message_dispatcher->dispatch_call_error(call_error);
}
}
}
bool ChargePoint::is_offline() {
return !this->connectivity_manager->is_websocket_connected();
}
std::optional<DataTransferResponse> ChargePoint::data_transfer_req(const CiString<255>& vendorId,
const std::optional<CiString<50>>& messageId,
const std::optional<json>& data) {
return this->data_transfer->data_transfer_req(vendorId, messageId, data);
}
std::optional<DataTransferResponse> ChargePoint::data_transfer_req(const DataTransferRequest& request) {
return this->data_transfer->data_transfer_req(request);
}
void ChargePoint::websocket_connected_callback(const int configuration_slot,
const NetworkConnectionProfile& network_connection_profile) {
this->message_queue->resume(this->message_queue_resume_delay);
if (this->registration_status == RegistrationStatusEnum::Accepted) {
this->connectivity_manager->confirm_successful_connection();
if (this->time_disconnected.time_since_epoch() != 0s) {
// handle offline threshold
// Get the current time point using steady_clock
auto offline_duration = std::chrono::steady_clock::now() - this->time_disconnected;
// B04.FR.01
// If offline period exceeds offline threshold then send the status notification for all connectors
if (offline_duration > std::chrono::seconds(this->device_model->get_value<int>(
ControllerComponentVariables::OfflineThreshold))) {
EVLOG_debug << "offline for more than offline threshold ";
this->component_state_manager->send_status_notification_all_connectors();
} else {
// B04.FR.02
// If offline period doesn't exceed offline threshold then send the status notification for all
// connectors that changed state
EVLOG_debug << "offline for less than offline threshold ";
this->component_state_manager->send_status_notification_changed_connectors();
}
this->security->init_certificate_expiration_check_timers(); // re-init as timers are stopped on disconnect
}
}
this->time_disconnected = std::chrono::time_point<std::chrono::steady_clock>();
// We have a connection again so next time it fails we should send the notification again
this->skip_invalid_csms_certificate_notifications = false;
if (this->callbacks.connection_state_changed_callback.has_value()) {
this->callbacks.connection_state_changed_callback.value()(true, configuration_slot, network_connection_profile);
}
}
void ChargePoint::websocket_disconnected_callback(const int configuration_slot,
const NetworkConnectionProfile& network_connection_profile) {
this->message_queue->pause();
// check if offline threshold has been defined
if (this->device_model->get_value<int>(ControllerComponentVariables::OfflineThreshold) != 0) {
// Get the current time point using steady_clock
this->time_disconnected = std::chrono::steady_clock::now();
}
this->security->stop_certificate_expiration_check_timers();
if (this->callbacks.connection_state_changed_callback.has_value()) {
this->callbacks.connection_state_changed_callback.value()(false, configuration_slot,
network_connection_profile);
}
}
void ChargePoint::websocket_connection_failed(ConnectionFailedReason reason) {
switch (reason) {
case ConnectionFailedReason::InvalidCSMSCertificate:
if (!this->skip_invalid_csms_certificate_notifications) {
this->security->security_event_notification_req(CiString<50>(ocpp::security_events::INVALIDCSMSCERTIFICATE),
std::nullopt, true, true);
this->skip_invalid_csms_certificate_notifications = true;
} else {
EVLOG_debug << "Skipping InvalidCsmsCertificate SecurityEvent since it has been sent already";
}
break;
case ConnectionFailedReason::FailedToAuthenticateAtCsms:
const auto& security_event = ocpp::security_events::FAILEDTOAUTHENTICATEATCSMS;
this->security->security_event_notification_req(CiString<50>(security_event), std::nullopt, true,
utils::is_critical(security_event));
break;
}
}
void ChargePoint::update_dm_availability_state(const int32_t evse_id, const int32_t connector_id,
const ConnectorStatusEnum status) {
ComponentVariable charging_station = ControllerComponentVariables::ChargingStationAvailabilityState;
ComponentVariable evse_cv =
EvseComponentVariables::get_component_variable(evse_id, EvseComponentVariables::AvailabilityState);
ComponentVariable connector_cv = ConnectorComponentVariables::get_component_variable(
evse_id, connector_id, ConnectorComponentVariables::AvailabilityState);
if (evse_cv.variable.has_value()) {
this->device_model->set_read_only_value(
evse_cv.component, evse_cv.variable.value(), ocpp::v201::AttributeEnum::Actual,
conversions::connector_status_enum_to_string(status), VARIABLE_ATTRIBUTE_VALUE_SOURCE_INTERNAL);
}
if (connector_cv.variable.has_value()) {
this->device_model->set_read_only_value(
connector_cv.component, connector_cv.variable.value(), ocpp::v201::AttributeEnum::Actual,
conversions::connector_status_enum_to_string(status), VARIABLE_ATTRIBUTE_VALUE_SOURCE_INTERNAL);
}
// if applicable to the entire charging station
if (evse_id == 0 and charging_station.variable.has_value()) {
this->device_model->set_read_only_value(
charging_station.component, charging_station.variable.value(), ocpp::v201::AttributeEnum::Actual,
conversions::connector_status_enum_to_string(status), VARIABLE_ATTRIBUTE_VALUE_SOURCE_INTERNAL);
}
}
void ChargePoint::clear_invalid_charging_profiles() {
try {
auto evses = this->database_handler->get_all_charging_profiles_group_by_evse();
EVLOG_info << "Found " << evses.size() << " evse in the database";
for (const auto& [evse_id, profiles] : evses) {
for (auto profile : profiles) {
try {
if (this->smart_charging->conform_and_validate_profile(profile, evse_id) !=
ProfileValidationResultEnum::Valid) {
this->database_handler->delete_charging_profile(profile.id);
}
} catch (const QueryExecutionException& e) {
EVLOG_warning << "Failed database operation for ChargingProfiles: " << e.what();
}
}
}
} catch (const std::exception& e) {
EVLOG_warning << "Unknown error while loading charging profiles from database: " << e.what();
}
}
std::vector<GetVariableResult>
ChargePoint::get_variables(const std::vector<GetVariableData>& get_variable_data_vector) {
return this->provisioning->get_variables(get_variable_data_vector);
}
std::map<SetVariableData, SetVariableResult>
ChargePoint::set_variables(const std::vector<SetVariableData>& set_variable_data_vector, const std::string& source) {
// set variables and allow setting of ReadOnly variables
return this->provisioning->set_variables(set_variable_data_vector, source);
}
GetCompositeScheduleResponse ChargePoint::get_composite_schedule(const GetCompositeScheduleRequest& request) {
return this->smart_charging->get_composite_schedule(request);
}
std::optional<CompositeSchedule> ChargePoint::get_composite_schedule(int32_t evse_id, std::chrono::seconds duration,
ChargingRateUnitEnum unit) {
return this->smart_charging->get_composite_schedule(evse_id, duration, unit);
}
std::vector<CompositeSchedule> ChargePoint::get_all_composite_schedules(const int32_t duration_s,
const ChargingRateUnitEnum& unit) {
return this->smart_charging->get_all_composite_schedules(duration_s, unit);
}
std::optional<NetworkConnectionProfile>
ChargePoint::get_network_connection_profile(const int32_t configuration_slot) const {
return this->connectivity_manager->get_network_connection_profile(configuration_slot);
}
std::optional<int> ChargePoint::get_priority_from_configuration_slot(const int configuration_slot) const {
return this->connectivity_manager->get_priority_from_configuration_slot(configuration_slot);
}
const std::vector<int>& ChargePoint::get_network_connection_slots() const {
return this->connectivity_manager->get_network_connection_slots();
}
void ChargePoint::send_not_implemented_error(const MessageId unique_message_id, const MessageTypeId message_type_id) {
if (message_type_id == MessageTypeId::CALL) {
const auto call_error = CallError(unique_message_id, "NotImplemented", "", json({}));
this->message_dispatcher->dispatch_call_error(call_error);
}
}
} // namespace v201
} // namespace ocpp