Skip to content

Commit

Permalink
Renamed the method load charging profiles to clear invalid charging p…
Browse files Browse the repository at this point in the history
…rofiles, removed logic that adds profiles and replaced it with logic that only removes invalid profiles

Signed-off-by: Peter Giavotto <[email protected]>
  • Loading branch information
Giavotto authored and christopher-davis-afs committed Sep 26, 2024
1 parent 177d1d7 commit a977746
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion include/ocpp/v201/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
std::shared_ptr<SmartChargingHandlerInterface> smart_charging_handler;

void handle_message(const EnhancedMessage<v201::MessageType>& message);
void load_charging_profiles();
void clear_invalid_charging_profiles();

public:
/// \brief Construct a new ChargePoint object
Expand Down
12 changes: 4 additions & 8 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ void ChargePoint::start(BootReasonEnum bootreason) {
// get transaction messages from db (if there are any) so they can be sent again.
this->message_queue->get_persisted_messages_from_db();
this->boot_notification_req(bootreason);
// K01.27 - call load_charging_profiles when system boots
this->load_charging_profiles();
// call clear_invalid_charging_profiles when system boots
this->clear_invalid_charging_profiles();
this->connectivity_manager->start();

const std::string firmware_version =
Expand Down Expand Up @@ -4432,19 +4432,15 @@ void ChargePoint::execute_change_availability_request(ChangeAvailabilityRequest
}
}

// K01.27 - load profiles from database
void ChargePoint::load_charging_profiles() {
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_handler->validate_profile(profile, evse_id) ==
if (this->smart_charging_handler->validate_profile(profile, evse_id) !=
ProfileValidationResultEnum::Valid) {
this->smart_charging_handler->add_profile(profile, evse_id);
} else {
// delete if not valid anymore
this->database_handler->delete_charging_profile(profile.id);
}
} catch (const QueryExecutionException& e) {
Expand Down

0 comments on commit a977746

Please sign in to comment.