Skip to content

Commit

Permalink
Updated FR45 to use supplyPhases
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Giavotto <[email protected]>
  • Loading branch information
Giavotto committed Aug 1, 2024
1 parent f86689b commit 8e49903
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion lib/ocpp/v201/smart_charging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ ProfileValidationResultEnum SmartChargingHandler::validate_tx_profile(const Char
ProfileValidationResultEnum
SmartChargingHandler::validate_profile_schedules(ChargingProfile& profile,
std::optional<EvseInterface*> evse_opt) const {
auto charging_station_supply_phases =
this->device_model->get_value<int32_t>(ControllerComponentVariables::ChargingStationSupplyPhases);

for (auto& schedule : profile.chargingSchedule) {
// K01.FR.26; We currently need to do string conversions for this manually because our DeviceModel class does
// not let us get a vector of ChargingScheduleChargingRateUnits.
Expand Down Expand Up @@ -355,7 +358,7 @@ SmartChargingHandler::validate_profile_schedules(ChargingProfile& profile,
if (phase_type == CurrentPhaseType::AC) {
// K01.FR.45; Once again rejecting invalid values
if (charging_schedule_period.numberPhases.has_value() &&
charging_schedule_period.numberPhases > DEFAULT_AND_MAX_NUMBER_PHASES) {
charging_schedule_period.numberPhases > charging_station_supply_phases) {
return ProfileValidationResultEnum::ChargingSchedulePeriodUnsupportedNumberPhases;
}

Expand Down
8 changes: 6 additions & 2 deletions tests/lib/ocpp/v201/test_smart_charging_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,11 @@ TEST_F(ChargepointTestFixtureV201, K01FR44_IfPhaseToUseProvidedForDCChargingStat
EXPECT_THAT(sut, testing::Eq(ProfileValidationResultEnum::ChargingSchedulePeriodExtraneousPhaseValues));
}

TEST_F(ChargepointTestFixtureV201, K01FR45_IfNumberPhasesGreaterThanMaxNumberPhasesForACEVSE_ThenProfileIsInvalid) {
TEST_F(ChargepointTestFixtureV201,
K01FR45_IfNumberPhasesGreaterThanChargingStationSupplyPhasesForACEVSE_ThenProfileIsInvalid) {
device_model->set_value(ControllerComponentVariables::ChargingStationSupplyPhases.component,
ControllerComponentVariables::ChargingStationSupplyPhases.variable.value(),
AttributeEnum::Actual, std::to_string(0), "test", true);
auto mock_evse = testing::NiceMock<EvseMock>();
ON_CALL(mock_evse, get_current_phase_type).WillByDefault(testing::Return(CurrentPhaseType::AC));

Expand All @@ -701,7 +705,7 @@ TEST_F(ChargepointTestFixtureV201, K01FR45_IfNumberPhasesGreaterThanMaxNumberPha
}

TEST_F(ChargepointTestFixtureV201,
K01FR45_IfNumberPhasesGreaterThanMaxNumberPhasesForACChargingStation_ThenProfileIsInvalid) {
K01FR45_IfNumberPhasesGreaterThanChargingStationSupplyPhasesForACChargingStation_ThenProfileIsInvalid) {
device_model->set_value(ControllerComponentVariables::ChargingStationSupplyPhases.component,
ControllerComponentVariables::ChargingStationSupplyPhases.variable.value(),
AttributeEnum::Actual, std::to_string(1), "test", true);
Expand Down

0 comments on commit 8e49903

Please sign in to comment.