Skip to content

Commit

Permalink
Fixes on clang format
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Suess <[email protected]>
  • Loading branch information
Matthias-NIDEC committed Oct 24, 2023
1 parent 023c054 commit fcb9e38
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 57 deletions.
9 changes: 5 additions & 4 deletions lib/ocpp/common/websocket/websocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ void Websocket::register_connected_callback(const std::function<void(const int s
void Websocket::register_closed_callback(
const std::function<void(const websocketpp::close::status::value reason, const bool doFull)>& callback) {
this->closed_callback = callback;
this->websocket->register_closed_callback([this](const websocketpp::close::status::value reason, const bool doFull) {
this->logging->sys("Disconnected");
this->closed_callback(reason, doFull);
});
this->websocket->register_closed_callback(
[this](const websocketpp::close::status::value reason, const bool doFull) {
this->logging->sys("Disconnected");
this->closed_callback(reason, doFull);
});
}

void Websocket::register_message_callback(const std::function<void(const std::string& message)>& callback) {
Expand Down
37 changes: 19 additions & 18 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,26 +153,27 @@ void ChargePointImpl::init_websocket() {
this->message_queue->resume(); //
this->connected_callback(); //
});
this->websocket->register_closed_callback([this](const websocketpp::close::status::value reason, const bool doFull) {
if (this->connection_state_changed_callback != nullptr) {
this->connection_state_changed_callback(false);
}
if (doFull) {
this->message_queue->pause(); //
if (this->ocsp_request_timer != nullptr) {
this->ocsp_request_timer->stop();
}
if (this->switch_security_profile_callback != nullptr) {
this->switch_security_profile_callback();
this->websocket->register_closed_callback(
[this](const websocketpp::close::status::value reason, const bool doFull) {
if (this->connection_state_changed_callback != nullptr) {
this->connection_state_changed_callback(false);
}
if (this->client_certificate_timer != nullptr) {
this->client_certificate_timer->stop();
}
if (this->v2g_certificate_timer != nullptr) {
this->v2g_certificate_timer->stop();
if (doFull) {
this->message_queue->pause(); //
if (this->ocsp_request_timer != nullptr) {
this->ocsp_request_timer->stop();
}
if (this->switch_security_profile_callback != nullptr) {
this->switch_security_profile_callback();
}
if (this->client_certificate_timer != nullptr) {
this->client_certificate_timer->stop();
}
if (this->v2g_certificate_timer != nullptr) {
this->v2g_certificate_timer->stop();
}
}
}
});
});

this->websocket->register_message_callback([this](const std::string& message) { this->message_callback(message); });
}
Expand Down
70 changes: 35 additions & 35 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,44 +576,44 @@ void ChargePoint::init_websocket() {
this->time_disconnected = std::chrono::time_point<std::chrono::steady_clock>();
});

this->websocket->register_closed_callback(
[this, connection_options, configuration_slot](const websocketpp::close::status::value reason, const bool doFull) {
EVLOG_warning << "Failed to connect to NetworkConfigurationPriority: "
<< this->network_configuration_priority + 1
<< " which is configurationSlot: " << configuration_slot;
this->websocket_connection_status = WebsocketConnectionStatusEnum::Disconnected;
this->message_queue->pause();

// check if offline threshold has been defined
if (this->device_model->get_value<int>(ControllerComponentVariables::OfflineThreshold) != 0) {
// get the status of all the connectors
for (auto const& [evse_id, evse] : this->evses) {
int number_of_connectors = evse->get_number_of_connectors();
EvseConnectorPair conn_states_struct_key;
EVLOG_debug << "evseId: " << evse_id << " numConn: " << number_of_connectors;
for (int connector_id = 1; connector_id <= number_of_connectors; connector_id++) {
conn_states_struct_key.evse_id = evse_id;
conn_states_struct_key.connector_id = connector_id;
conn_state_per_evse[conn_states_struct_key] = evse->get_state(connector_id);
EVLOG_debug << "conn_id: " << conn_states_struct_key.connector_id
<< " State: " << conn_state_per_evse[conn_states_struct_key];
}
this->websocket->register_closed_callback([this, connection_options, configuration_slot](
const websocketpp::close::status::value reason, const bool doFull) {
EVLOG_warning << "Failed to connect to NetworkConfigurationPriority: "
<< this->network_configuration_priority + 1
<< " which is configurationSlot: " << configuration_slot;
this->websocket_connection_status = WebsocketConnectionStatusEnum::Disconnected;
this->message_queue->pause();

// check if offline threshold has been defined
if (this->device_model->get_value<int>(ControllerComponentVariables::OfflineThreshold) != 0) {
// get the status of all the connectors
for (auto const& [evse_id, evse] : this->evses) {
int number_of_connectors = evse->get_number_of_connectors();
EvseConnectorPair conn_states_struct_key;
EVLOG_debug << "evseId: " << evse_id << " numConn: " << number_of_connectors;
for (int connector_id = 1; connector_id <= number_of_connectors; connector_id++) {
conn_states_struct_key.evse_id = evse_id;
conn_states_struct_key.connector_id = connector_id;
conn_state_per_evse[conn_states_struct_key] = evse->get_state(connector_id);
EVLOG_debug << "conn_id: " << conn_states_struct_key.connector_id
<< " State: " << conn_state_per_evse[conn_states_struct_key];
}
// Get the current time point using steady_clock
this->time_disconnected = std::chrono::steady_clock::now();
}
// Get the current time point using steady_clock
this->time_disconnected = std::chrono::steady_clock::now();
}

if (!this->disable_automatic_websocket_reconnects) {
this->websocket_timer.timeout(
[this, reason]() {
if (reason != websocketpp::close::status::service_restart) {
this->next_network_configuration_priority();
}
this->start_websocket();
},
WEBSOCKET_INIT_DELAY);
}
});
if (!this->disable_automatic_websocket_reconnects) {
this->websocket_timer.timeout(
[this, reason]() {
if (reason != websocketpp::close::status::service_restart) {
this->next_network_configuration_priority();
}
this->start_websocket();
},
WEBSOCKET_INIT_DELAY);
}
});

this->websocket->register_message_callback([this](const std::string& message) { this->message_callback(message); });
}
Expand Down

0 comments on commit fcb9e38

Please sign in to comment.