-
Notifications
You must be signed in to change notification settings - Fork 133
[OCPP] Add support for OCPP 2.1 Q11 and Q12 #1852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 8 commits
56cd4bc
610a24b
e56afe8
c1ebe22
80d5e27
890e8ac
0864f5f
ae63fda
456679e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,9 +7,11 @@ | |
| #include <ocpp/v2/messages/SetNetworkProfile.hpp> | ||
| #include <ocpp/v2/ocpp_types.hpp> | ||
|
|
||
| #include <chrono> | ||
|
Check warning on line 10 in lib/everest/ocpp/include/ocpp/v2/connectivity_manager.hpp
|
||
| #include <functional> | ||
| #include <future> | ||
| #include <optional> | ||
|
|
||
| namespace ocpp { | ||
| namespace v2 { | ||
|
|
||
|
|
@@ -84,6 +86,11 @@ | |
| /// | ||
| virtual bool is_websocket_connected() = 0; | ||
|
|
||
| /// @brief Get the time the websocket has been disconnected. | ||
| /// @return The time the websocket has been disconnected | ||
| /// | ||
| virtual std::optional<std::chrono::time_point<std::chrono::steady_clock>> get_time_disconnected() const = 0; | ||
|
|
||
| /// \brief Connect to the websocket | ||
| /// \param configuration_slot Optional the network_profile_slot to connect to. std::nullopt will select the slot | ||
| /// internally. | ||
|
|
@@ -168,6 +175,7 @@ | |
| std::optional<std::int32_t> get_priority_from_configuration_slot(const int configuration_slot) const override; | ||
| const std::vector<int>& get_network_connection_slots() const override; | ||
| bool is_websocket_connected() override; | ||
| std::optional<std::chrono::time_point<std::chrono::steady_clock>> get_time_disconnected() const override; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should wrap this in a monitor as it can now be used from multiple threads |
||
| void connect(std::optional<std::int32_t> network_profile_slot = std::nullopt) override; | ||
| void disconnect() override; | ||
| bool send_to_websocket(const std::string& message) override; | ||
|
|
@@ -176,6 +184,8 @@ | |
| void confirm_successful_connection() override; | ||
|
|
||
| private: | ||
| std::optional<std::chrono::time_point<std::chrono::steady_clock>> time_disconnected{}; | ||
|
|
||
| /// \brief Initializes the websocket and tries to connect | ||
| /// | ||
| void try_connect_websocket(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1092,10 +1092,11 @@ void ChargePoint::websocket_connected_callback(const int configuration_slot, | |
| if (this->registration_status == RegistrationStatusEnum::Accepted) { | ||
| this->connectivity_manager->confirm_successful_connection(); | ||
|
|
||
| if (this->time_disconnected.time_since_epoch() != 0s) { | ||
| if (const auto time_disconnected = this->connectivity_manager->get_time_disconnected(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should use the check on the variable here since we always set time disconnected |
||
| time_disconnected.has_value()) { | ||
mlitre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // handle offline threshold | ||
| // Get the current time point using steady_clock | ||
| auto offline_duration = std::chrono::steady_clock::now() - this->time_disconnected; | ||
| const auto offline_duration = std::chrono::steady_clock::now() - time_disconnected.value(); | ||
|
|
||
| // B04.FR.01 | ||
| // If offline period exceeds offline threshold then send the status notification for all connectors | ||
|
|
@@ -1113,7 +1114,6 @@ void ChargePoint::websocket_connected_callback(const int configuration_slot, | |
| 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; | ||
|
|
@@ -1128,12 +1128,6 @@ 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(); | ||
| } | ||
|
Comment on lines
-1132
to
-1135
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a regression on this functionality as we now always set the time disconnected. We should most likely remove the optional from time_disconnected and a check on this variable when we do the reconnection check. See other comment |
||
|
|
||
| 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, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Offline Duration | ||
|
|
||
| This scenario layers profiles with maxOfflineDuration and invalidAfterOfflineDuration on top of profiles without. | ||
|
|
||
| Used by: | ||
|
|
||
| * OfflineDuration_Online | ||
| * OfflineDuration_OfflineNotLongEnough | ||
| * OfflineDuration_OfflineTooLong | ||
| * OfflineDuration_OfflineTooLong_ValidAfterOfflineDuration | ||
| * OfflineDuration_OfflineTooLong_InvalidAfterOfflineDuration | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "id": 1, | ||
| "chargingProfileKind": "Absolute", | ||
| "chargingProfilePurpose": "TxProfile", | ||
| "chargingSchedule": [ | ||
| { | ||
| "id": 0, | ||
| "chargingRateUnit": "W", | ||
| "chargingSchedulePeriod": [ | ||
| { | ||
| "limit": 2000.0, | ||
| "numberPhases": 3, | ||
| "startPeriod": 0 | ||
| } | ||
| ], | ||
| "startSchedule": "2024-01-17T18:00:00.000Z" | ||
| } | ||
| ], | ||
| "stackLevel": 1, | ||
| "transactionId": "f1522902-1170-416f-8e43-9e3bce28fde7" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| { | ||
| "id": 3, | ||
| "chargingProfileKind": "Absolute", | ||
| "chargingProfilePurpose": "TxProfile", | ||
| "chargingSchedule": [ | ||
| { | ||
| "id": 0, | ||
| "chargingRateUnit": "W", | ||
| "chargingSchedulePeriod": [ | ||
| { | ||
| "limit": 2000.0, | ||
| "numberPhases": 3, | ||
| "operationMode": "CentralSetpoint", | ||
| "setpoint": -2000.0, | ||
| "startPeriod": 0 | ||
| } | ||
| ], | ||
| "startSchedule": "2024-01-17T18:00:00.000Z" | ||
| } | ||
| ], | ||
| "invalidAfterOfflineDuration": true, | ||
| "maxOfflineDuration": 600, | ||
| "stackLevel": 2, | ||
| "transactionId": "f1522902-1170-416f-8e43-9e3bce28fde7" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "id": 1, | ||
| "chargingProfileKind": "Absolute", | ||
| "chargingProfilePurpose": "TxProfile", | ||
| "chargingSchedule": [ | ||
| { | ||
| "id": 0, | ||
| "chargingRateUnit": "W", | ||
| "chargingSchedulePeriod": [ | ||
| { | ||
| "limit": 2000.0, | ||
| "numberPhases": 3, | ||
| "startPeriod": 0 | ||
| } | ||
| ], | ||
| "startSchedule": "2024-01-17T18:00:00.000Z" | ||
| } | ||
| ], | ||
| "stackLevel": 1, | ||
| "transactionId": "f1522902-1170-416f-8e43-9e3bce28fde7" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "id": 2, | ||
| "chargingProfileKind": "Absolute", | ||
| "chargingProfilePurpose": "TxProfile", | ||
| "chargingSchedule": [ | ||
| { | ||
| "id": 0, | ||
| "chargingRateUnit": "W", | ||
| "chargingSchedulePeriod": [ | ||
| { | ||
| "limit": 2000.0, | ||
| "numberPhases": 3, | ||
| "operationMode": "CentralSetpoint", | ||
| "setpoint": -2000.0, | ||
| "startPeriod": 0 | ||
| } | ||
| ], | ||
| "startSchedule": "2024-01-17T18:00:00.000Z" | ||
| } | ||
| ], | ||
| "maxOfflineDuration": 600, | ||
| "stackLevel": 2, | ||
| "transactionId": "f1522902-1170-416f-8e43-9e3bce28fde7" | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.