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

Event handler for NotifyEVChargingNeedsRequest #1003

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 12 additions & 12 deletions doc/v2/ocpp_2x_status.md
Original file line number Diff line number Diff line change
Expand Up @@ -1417,24 +1417,24 @@ This document contains the status of which OCPP 2.0.1 and OCPP2.1 numbered funct

| ID | Status | Remark |
|-----------|--------|--------|
| K15.FR.01 | | |
| K15.FR.02 | | |
| K15.FR.03 | | |
| K15.FR.04 | | |
| K15.FR.05 | | |
| K15.FR.06 | | |
| K15.FR.07 | | |
| K15.FR.08 | | |
| K15.FR.09 | | |
| K15.FR.01 | | |
| K15.FR.02 | 🌐 | |
| K15.FR.03 | 🌐 | |
| K15.FR.04 | 🌐 | |
| K15.FR.05 | 🌐 | |
| K15.FR.06 | ⛽️ | |
| K15.FR.07 | 🌐 | |
| K15.FR.08 | 🌐 | |
| K15.FR.09 | ⛽️ | |
| K15.FR.10 | | |
| K15.FR.11 | | |
| K15.FR.12 | | |
| K15.FR.13 | | |
| K15.FR.13 | 🌐 | |
| K15.FR.14 | | |
| K15.FR.15 | | |
| K15.FR.15 | | |
| K15.FR.16 | | |
| K15.FR.17 | | |
| K15.FR.18 | | |
| K15.FR.18 | 🌐 | |
| K15.FR.19 | | |

## SmartCharging - Renegotiation initiated by CSMS
Expand Down
7 changes: 7 additions & 0 deletions include/ocpp/v2/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <ocpp/v2/messages/DataTransfer.hpp>
#include <ocpp/v2/messages/Get15118EVCertificate.hpp>
#include <ocpp/v2/messages/GetCompositeSchedule.hpp>
#include <ocpp/v2/messages/NotifyEVChargingNeeds.hpp>

#include "component_state_manager.hpp"

Expand Down Expand Up @@ -239,6 +240,10 @@ class ChargePointInterface {
/// \param status The status.
virtual void on_reservation_status(const int32_t reservation_id, const ReservationUpdateStatusEnum status) = 0;

/// \brief Event handler that should be called when the charging station receives a ChargeParameterDiscoveryReq from
/// the CSMS \param request specifies the parameters sent from the EV to the charging station
virtual void on_ev_charging_needs(const NotifyEVChargingNeedsRequest& request) = 0;

/// @} // End handlers group

/// @}
Expand Down Expand Up @@ -577,6 +582,8 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa

void on_reservation_status(const int32_t reservation_id, const ReservationUpdateStatusEnum status) override;

void on_ev_charging_needs(const NotifyEVChargingNeedsRequest& request) override;

std::optional<DataTransferResponse> data_transfer_req(const CiString<255>& vendorId,
const std::optional<CiString<50>>& messageId,
const std::optional<json>& data) override;
Expand Down
6 changes: 6 additions & 0 deletions include/ocpp/v2/functional_blocks/smart_charging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct GetCompositeScheduleRequest;
struct ClearChargingProfileResponse;
struct ClearChargingProfileRequest;
struct ReportChargingProfilesRequest;
struct NotifyEVChargingNeedsRequest;

enum class ProfileValidationResultEnum {
Valid,
Expand Down Expand Up @@ -117,6 +118,10 @@ class SmartChargingInterface : public MessageHandlerInterface {
/// \return the composite schedule if the operation was successful, otherwise nullopt
virtual std::optional<CompositeSchedule> get_composite_schedule(int32_t evse_id, std::chrono::seconds duration,
ChargingRateUnitEnum unit) = 0;

/// \brief Initiates a NotifyEvChargingNeeds.req message to the CSMS
/// \param req the request to send
virtual void notify_ev_charging_needs_req(const NotifyEVChargingNeedsRequest& req) = 0;
};

class SmartCharging : public SmartChargingInterface {
Expand All @@ -143,6 +148,7 @@ class SmartCharging : public SmartChargingInterface {
ProfileValidationResultEnum conform_and_validate_profile(
ChargingProfile& profile, int32_t evse_id,
AddChargingProfileSource source_of_request = AddChargingProfileSource::SetChargingProfile) override;
void notify_ev_charging_needs_req(const NotifyEVChargingNeedsRequest& req) override;

protected:
///
Expand Down
4 changes: 4 additions & 0 deletions lib/ocpp/v2/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ void ChargePoint::on_reservation_status(const int32_t reservation_id, const Rese
}
}

void ChargePoint::on_ev_charging_needs(const NotifyEVChargingNeedsRequest& request) {
this->smart_charging->notify_ev_charging_needs_req(request);
}

void ChargePoint::initialize(const std::map<int32_t, int32_t>& evse_connector_structure,
const std::string& message_log_path) {
this->device_model->check_integrity(evse_connector_structure);
Expand Down
11 changes: 11 additions & 0 deletions lib/ocpp/v2/functional_blocks/smart_charging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <ocpp/v2/messages/ClearChargingProfile.hpp>
#include <ocpp/v2/messages/GetChargingProfiles.hpp>
#include <ocpp/v2/messages/GetCompositeSchedule.hpp>
#include <ocpp/v2/messages/NotifyEVChargingNeeds.hpp>
#include <ocpp/v2/messages/ReportChargingProfiles.hpp>
#include <ocpp/v2/messages/SetChargingProfile.hpp>

Expand Down Expand Up @@ -680,6 +681,16 @@ void SmartCharging::report_charging_profile_req(const ReportChargingProfilesRequ
this->context.message_dispatcher.dispatch_call(call);
}

void SmartCharging::notify_ev_charging_needs_req(const NotifyEVChargingNeedsRequest& req) {
// TODO: req.timestamp = std::nullopt; // timestamp will be added with OCPP2.1 messages
// if (ocpp_version != OcppProtocolVersion::v21) {
// req.timestamp = std::nullopt; // field is not present in OCPP2.0.1
// }

ocpp::Call<NotifyEVChargingNeedsRequest> call(req);
this->context.message_dispatcher.dispatch_call(call);
}

void SmartCharging::handle_set_charging_profile_req(Call<SetChargingProfileRequest> call) {
EVLOG_debug << "Received SetChargingProfileRequest: " << call.msg << "\nwith messageId: " << call.uniqueId;
auto msg = call.msg;
Expand Down