Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
  • Loading branch information
hikinggrass committed Aug 17, 2023
1 parent c797168 commit 8853dbf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
3 changes: 2 additions & 1 deletion include/ocpp/v201/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ class ChargePoint : ocpp::ChargingStationBase {
/// \param signed_meter_value
void on_transaction_finished(const int32_t evse_id, const DateTime& timestamp, const MeterValue& meter_stop,
const ReasonEnum reason, const std::optional<std::string>& id_token,
const std::optional<std::string>& signed_meter_value, const ChargingStateEnum charging_state);
const std::optional<std::string>& signed_meter_value,
const ChargingStateEnum charging_state);

/// \brief Event handler that should be called when a session has finished
/// \param evse_id
Expand Down
27 changes: 10 additions & 17 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,10 @@ bool ChargePoint::on_charging_state_changed(const uint32_t evse_id, ChargingStat
this->evses.at(static_cast<int32_t>(evse_id))->get_transaction();
if (transaction != nullptr) {
transaction->chargingState = charging_state;
this->transaction_event_req(
TransactionEventEnum::Updated, DateTime(),
transaction->get_transaction(),
TriggerReasonEnum::ChargingStateChanged,
transaction->get_seq_no(), std::nullopt,
this->evses.at(static_cast<int32_t>(evse_id))->get_evse_info(),
std::nullopt, std::nullopt, std::nullopt, std::nullopt,
std::nullopt);
this->transaction_event_req(TransactionEventEnum::Updated, DateTime(), transaction->get_transaction(),
TriggerReasonEnum::ChargingStateChanged, transaction->get_seq_no(),
std::nullopt, this->evses.at(static_cast<int32_t>(evse_id))->get_evse_info(),
std::nullopt, std::nullopt, std::nullopt, std::nullopt, std::nullopt);
return true;
} else {
EVLOG_warning << "Can not change charging state: no transaction for evse id " << evse_id;
Expand Down Expand Up @@ -852,27 +848,24 @@ void ChargePoint::transaction_event_req(const TransactionEventEnum& event_type,

ocpp::Call<TransactionEventRequest> call(req, this->message_queue->createMessageId());

// Check if id token is in the remote start map, because when a remote
// start request is done, the first transaction event request should
// always contain trigger reason 'RemoteStart'.
// Check if id token is in the remote start map, because when a remote
// start request is done, the first transaction event request should
// always contain trigger reason 'RemoteStart'.
auto it = std::find_if(
remote_start_id_per_evse.begin(), remote_start_id_per_evse.end(),
[&id_token, &evse](const std::pair<int32_t, std::pair<IdToken, int32_t>>& remote_start_per_evse) {
if (id_token.has_value() &&
remote_start_per_evse.second.first.idToken == id_token.value().idToken) {
if (id_token.has_value() && remote_start_per_evse.second.first.idToken == id_token.value().idToken) {

if (remote_start_per_evse.first == 0) {
return true;
}

if (evse.has_value() &&
evse.value().id == remote_start_per_evse.first) {
if (evse.has_value() && evse.value().id == remote_start_per_evse.first) {
return true;
}
}
return false;
}
);
});

if (it != remote_start_id_per_evse.end()) {
// Found remote start. Set remote start id and the trigger reason.
Expand Down

0 comments on commit 8853dbf

Please sign in to comment.