Skip to content

Commit cf3887a

Browse files
author
Coury Richards
committed
updated: added optional evse_id to handler and passed
Signed-off-by: Coury Richards <146002925+couryrr-afs@users.noreply.github.com>
1 parent 42d3740 commit cf3887a

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

include/ocpp/v201/smart_charging.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ class SmartChargingHandlerInterface {
127127
std::optional<int32_t> evse_id) const = 0;
128128

129129
virtual std::pair<ClearedChargingLimitRequest, std::vector<TransactionEventRequest>>
130-
handle_external_limit_cleared(double percentage_delta, ChargingLimitSourceEnum source) const = 0;
130+
handle_external_limit_cleared(std::optional<int32_t> evse_id, double percentage_delta,
131+
ChargingLimitSourceEnum source) const = 0;
131132
};
132133

133134
/// \brief This class handles and maintains incoming ChargingProfiles and contains the logic
@@ -201,7 +202,7 @@ class SmartChargingHandler : public SmartChargingHandlerInterface {
201202
std::optional<ChargingRateUnitEnum> charging_rate_unit) override;
202203

203204
///
204-
/// \brief Determines whether or not we should notify the CSMS of a change to our limits
205+
/// \brief Determines whether or not we should notify the CSMS of a cleared external limit
205206
/// based on \p percentage_delta and builds the notification.
206207
///
207208
std::optional<NotifyChargingLimitRequest>
@@ -210,7 +211,8 @@ class SmartChargingHandler : public SmartChargingHandlerInterface {
210211
std::optional<int32_t> evse_id) const override;
211212

212213
virtual std::pair<ClearedChargingLimitRequest, std::vector<TransactionEventRequest>>
213-
handle_external_limit_cleared(double percentage_delta, ChargingLimitSourceEnum source) const override;
214+
handle_external_limit_cleared(std::optional<int32_t> evse_id, double percentage_delta,
215+
ChargingLimitSourceEnum source) const override;
214216

215217
protected:
216218
///

lib/ocpp/v201/charge_point.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,7 @@ void ChargePoint::on_external_limits_changed(const std::variant<ConstantCharging
11141114

11151115
void ChargePoint::on_external_limit_cleared(std::optional<int32_t> evse_id, double percentage_delta,
11161116
ChargingLimitSourceEnum source) {
1117-
auto request = this->smart_charging_handler->handle_external_limit_cleared(percentage_delta, source);
1117+
auto request = this->smart_charging_handler->handle_external_limit_cleared(evse_id, percentage_delta, source);
11181118

11191119
auto [cleared_charging_limit_request, transaction_event_requests] = request;
11201120

lib/ocpp/v201/smart_charging.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,8 @@ SmartChargingHandler::handle_external_limits_changed(const std::variant<Constant
807807
}
808808

809809
std::pair<ClearedChargingLimitRequest, std::vector<TransactionEventRequest>>
810-
SmartChargingHandler::handle_external_limit_cleared(double percentage_delta, ChargingLimitSourceEnum source) const {
810+
SmartChargingHandler::handle_external_limit_cleared(std::optional<int32_t> evse_id, double percentage_delta,
811+
ChargingLimitSourceEnum source) const {
811812
// K13.FR.02
812813
ClearedChargingLimitRequest cleared_charging_limit_request = {};
813814
cleared_charging_limit_request.chargingLimitSource = source;

tests/lib/ocpp/v201/mocks/smart_charging_handler_mock.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class SmartChargingHandlerMock : public SmartChargingHandlerInterface {
3434
std::optional<int32_t> evse_id),
3535
(const, override));
3636
MOCK_METHOD((std::pair<ClearedChargingLimitRequest, std::vector<TransactionEventRequest>>),
37-
handle_external_limit_cleared, (double percentage_delta, ChargingLimitSourceEnum source),
37+
handle_external_limit_cleared,
38+
(std::optional<int32_t> evse_id, double percentage_delta, ChargingLimitSourceEnum source),
3839
(const, override));
3940
};
4041
} // namespace ocpp::v201

tests/lib/ocpp/v201/test_charge_point.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,10 +980,12 @@ TEST_F(ChargepointTestFixtureV201, K13_OnExternalLimitsCleared_CallsHandler) {
980980
.limit = 100.0,
981981
.charging_rate_unit = ChargingRateUnitEnum::A,
982982
};
983+
984+
std::optional<int32_t> evse_id;
983985
double deltaChanged = 0.2;
984986
auto source = ChargingLimitSourceEnum::Other;
985987

986-
EXPECT_CALL(*smart_charging_handler, handle_external_limit_cleared(deltaChanged, source));
988+
EXPECT_CALL(*smart_charging_handler, handle_external_limit_cleared(evse_id, deltaChanged, source));
987989

988990
charge_point->on_external_limit_cleared(std::nullopt, deltaChanged, source);
989991
}

tests/lib/ocpp/v201/test_smart_charging_handler.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,7 +1840,7 @@ TEST_F(SmartChargingHandlerTestFixtureV201,
18401840
double deltaChanged = 0.2;
18411841
auto source = ChargingLimitSourceEnum::Other;
18421842

1843-
auto resp = handler.handle_external_limit_cleared(deltaChanged, source);
1843+
auto resp = handler.handle_external_limit_cleared(std::nullopt, deltaChanged, source);
18441844

18451845
auto [cleared_charging_limit_request, transaction_event_requests] = resp;
18461846

@@ -1861,7 +1861,7 @@ TEST_F(SmartChargingHandlerTestFixtureV201,
18611861
double deltaChanged = 0.2;
18621862
auto source = ChargingLimitSourceEnum::Other;
18631863

1864-
auto resp = handler.handle_external_limit_cleared(deltaChanged, source);
1864+
auto resp = handler.handle_external_limit_cleared(std::nullopt, deltaChanged, source);
18651865

18661866
auto [cleared_charging_limit_request, transaction_event_requests] = resp;
18671867

@@ -1883,7 +1883,7 @@ TEST_F(
18831883
double deltaChanged = 0.2;
18841884
auto source = ChargingLimitSourceEnum::Other;
18851885

1886-
auto resp = handler.handle_external_limit_cleared(deltaChanged, source);
1886+
auto resp = handler.handle_external_limit_cleared(std::nullopt, deltaChanged, source);
18871887

18881888
auto [cleared_charging_limit_request, transaction_event_requests] = resp;
18891889

0 commit comments

Comments
 (0)