Skip to content
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

Applied modified version of libocpp patch #31

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ bool Callbacks::all_callbacks_valid() const {
this->get_log_request_callback != nullptr and this->unlock_connector_callback != nullptr and
this->remote_start_transaction_callback != nullptr and this->is_reservation_for_token_callback != nullptr and
this->update_firmware_request_callback != nullptr and this->security_event_callback != nullptr and
(!this->signal_set_charging_profiles_callback.has_value() or this->signal_set_charging_profiles_callback.value() != nullptr) and
(!this->signal_set_charging_profiles_callback.has_value() or
this->signal_set_charging_profiles_callback.value() != nullptr) and
(!this->variable_changed_callback.has_value() or this->variable_changed_callback.value() != nullptr) and
(!this->validate_network_profile_callback.has_value() or
this->validate_network_profile_callback.value() != nullptr) and
Expand Down Expand Up @@ -1195,7 +1196,9 @@ void ChargePoint::remove_network_connection_profiles_below_actual_security_profi
}

void ChargePoint::handle_message(const EnhancedMessage<v201::MessageType>& message) {
EVLOG_info << "Handle_message called: " << message.message;
const auto& json_message = message.message;
EVLOG_info << "json_message called: " << json_message;
switch (message.messageType) {
case MessageType::BootNotificationResponse:
this->handle_boot_notification_response(json_message);
Expand Down Expand Up @@ -1278,6 +1281,9 @@ void ChargePoint::handle_message(const EnhancedMessage<v201::MessageType>& messa
case MessageType::CustomerInformation:
this->handle_customer_information_req(json_message);
break;
case MessageType::SetChargingProfile:
this->handle_set_charging_profile_req(json_message);
break;
default:
if (message.messageTypeId == MessageTypeId::CALL) {
const auto call_error = CallError(message.uniqueId, "NotImplemented", "", json({}));
Expand Down Expand Up @@ -3075,6 +3081,7 @@ void ChargePoint::handle_heartbeat_response(CallResult<HeartbeatResponse> call)
// Functional Block K: Smart Charging
void ChargePoint::handle_set_charging_profile_req(Call<SetChargingProfileRequest> call) {
SetChargingProfileResponse response;
EVLOG_info << "Received SetChargingProfile: " << call.msg << "\nwith messageId: " << call.uniqueId;
auto validity = this->smart_charging_handler->validate_profile(call.msg.chargingProfile, call.msg.evseId);

if (validity != ProfileValidationResultEnum::Valid) {
Expand All @@ -3085,6 +3092,7 @@ void ChargePoint::handle_set_charging_profile_req(Call<SetChargingProfileRequest
this->callbacks.signal_set_charging_profiles_callback.value()();
}
}
EVLOG_info << "Received profile validity: " << validity << "setting response to " << response;
ocpp::CallResult<SetChargingProfileResponse> call_result(response, call.uniqueId);
this->send<SetChargingProfileResponse>(call_result);
}
Expand Down Expand Up @@ -3506,8 +3514,7 @@ std::map<int32_t, CompositeSchedule> ChargePoint::get_all_composite_charging_sch
const auto duration = std::chrono::seconds(duration_s);
const auto end_time = ocpp::DateTime(start_time.to_time_point() + duration);

const auto valid_profiles =
this->smart_charging_handler->get_valid_profiles(start_time, end_time, evse_id);
const auto valid_profiles = this->smart_charging_handler->get_valid_profiles(start_time, end_time, evse_id);
const auto composite_schedule = this->smart_charging_handler->calculate_composite_schedule(
valid_profiles, start_time, end_time, evse_id, ChargingRateUnitEnum::W);
composite_schedules[evse_id] = composite_schedule;
Expand Down
4 changes: 3 additions & 1 deletion lib/ocpp/v201/device_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,9 @@ void DeviceModel::check_integrity(const std::map<int32_t, int32_t>& evse_connect
// check if number of EVSE in the device model matches the configured number
if (nr_evse_components != evse_connector_structure.size()) {
throw DeviceModelStorageError("Number of EVSE configured in device model is incompatible with number of "
"configured EVSEs of the ChargePoint: " + std::to_string(nr_evse_components) + ": " + std::to_string(evse_connector_structure.size()));
"configured EVSEs of the ChargePoint: " +
std::to_string(nr_evse_components) + ": " +
std::to_string(evse_connector_structure.size()));
}

for (const auto [evse_id, nr_of_connectors] : evse_connector_structure) {
Expand Down
14 changes: 4 additions & 10 deletions lib/ocpp/v201/smart_charging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,21 +491,15 @@ bool overlap(const ocpp::DateTime& start_time, const ocpp::DateTime& end_time, c
return delta.count() > 0;
}

std::vector<ChargingProfile> SmartChargingHandler::get_valid_profiles(
const ocpp::DateTime& start_time,
const ocpp::DateTime& end_time,
const int evse_id
) {
std::vector<ChargingProfile> SmartChargingHandler::get_valid_profiles(const ocpp::DateTime& start_time,
const ocpp::DateTime& end_time,
const int evse_id) {
std::vector<ChargingProfile> valid_profiles;

auto all_profiles = station_wide_charging_profiles;
for (auto evse_profile_pair : charging_profiles) {
if (evse_profile_pair.first == evse_id) {
all_profiles.insert(
all_profiles.end(),
evse_profile_pair.second.begin(),
evse_profile_pair.second.end()
);
all_profiles.insert(all_profiles.end(), evse_profile_pair.second.begin(), evse_profile_pair.second.end());
}
}

Expand Down
Loading