Skip to content

Commit

Permalink
Fixed bug discovered by unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: pietfried <pietgoempel@gmail.com>
Signed-off-by: Piet Gömpel <pietgoempel@gmail.com>
  • Loading branch information
Pietfried committed Oct 5, 2024
1 parent bbc8c0b commit 65ab880
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/ocpp/v16/smart_charging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ SmartChargingHandler::get_valid_profiles(const ocpp::DateTime& start_time, const
std::lock_guard<std::mutex> lk(charge_point_max_profiles_map_mutex);

if (std::find(std::begin(purposes_to_ignore), std::end(purposes_to_ignore),
ChargingProfilePurposeType::ChargePointMaxProfile) != std::end(purposes_to_ignore)) {
ChargingProfilePurposeType::ChargePointMaxProfile) == std::end(purposes_to_ignore)) {
for (const auto& [stack_level, profile] : stack_level_charge_point_max_profiles_map) {
valid_profiles.push_back(profile);
}
Expand All @@ -407,7 +407,8 @@ SmartChargingHandler::get_valid_profiles(const ocpp::DateTime& start_time, const
std::lock_guard<std::mutex> lk_txd(tx_default_profiles_map_mutex);
std::lock_guard<std::mutex> lk_tx(tx_profiles_map_mutex);

if (not purposes_to_ignore.count(ChargingProfilePurposeType::TxProfile)) {
if (std::find(std::begin(purposes_to_ignore), std::end(purposes_to_ignore),
ChargingProfilePurposeType::TxProfile) == std::end(purposes_to_ignore)) {
for (const auto& [stack_level, profile] : itt->second->stack_level_tx_profiles_map) {
// only include profiles that match the transactionId (when there is one)
bool b_add{false};
Expand All @@ -427,7 +428,8 @@ SmartChargingHandler::get_valid_profiles(const ocpp::DateTime& start_time, const
}
}
}
if (not purposes_to_ignore.count(ChargingProfilePurposeType::TxDefaultProfile)) {
if (std::find(std::begin(purposes_to_ignore), std::end(purposes_to_ignore),
ChargingProfilePurposeType::TxDefaultProfile) == std::end(purposes_to_ignore)) {
for (const auto& [stack_level, profile] : itt->second->stack_level_tx_default_profiles_map) {
valid_profiles.push_back(profile);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/ocpp/v201/smart_charging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ SmartChargingHandler::get_valid_profiles_for_evse(int32_t evse_id,
auto evse_profiles = this->database_handler->get_charging_profiles_for_evse(evse_id);
for (auto profile : evse_profiles) {
if (this->validate_profile(profile, evse_id) == ProfileValidationResultEnum::Valid and
not purposes_to_ignore.count(profile.chargingProfilePurpose)) {
std::find(std::begin(purposes_to_ignore), std::end(purposes_to_ignore), profile.chargingProfilePurpose) ==
std::end(purposes_to_ignore)) {
valid_profiles.push_back(profile);
}
}
Expand Down

0 comments on commit 65ab880

Please sign in to comment.