Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
Signed-off-by: Piet Gömpel <pietgoempel@gmail.com>
  • Loading branch information
Pietfried committed Oct 23, 2024
1 parent 4a9af8a commit 2aea2b8
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 34 deletions.
2 changes: 1 addition & 1 deletion include/ocpp/common/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ enum class QueueType {
None,
};

/// \brief Struct containing default limits for amps, watts and number of phases
/// \brief Struct containing default limits for amps, watts and number of phases
struct CompositeScheduleDefaultLimits {
int32_t amps;

Check notice on line 832 in include/ocpp/common/types.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/ocpp/common/types.hpp#L832

struct member 'CompositeScheduleDefaultLimits::amps' is never used.
int32_t watts;

Check notice on line 833 in include/ocpp/common/types.hpp

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

include/ocpp/common/types.hpp#L833

struct member 'CompositeScheduleDefaultLimits::watts' is never used.
Expand Down
1 change: 0 additions & 1 deletion lib/ocpp/v16/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,6 @@ EnhancedChargingSchedule calculate_composite_schedule(const EnhancedChargingSche
duration_tx_default);
update_itt(duration, tx_itt, tx.chargingSchedulePeriod.end(), period_tx, duration_tx);


if (period.startPeriod != -1) {
if (!period.numberPhases.has_value()) {
period.numberPhases = default_limits.number_phases;
Expand Down
6 changes: 1 addition & 5 deletions lib/ocpp/v16/smart_charging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,7 @@ EnhancedChargingSchedule SmartChargingHandler::calculate_enhanced_composite_sche
this->configuration.getCompositeScheduleDefaultNumberPhases().value_or(DEFAULT_AND_MAX_NUMBER_PHASES);
const auto supply_voltage = this->configuration.getSupplyVoltage().value_or(LOW_VOLTAGE);

CompositeScheduleDefaultLimits default_limits = {
default_amps_limit,
default_watts_limit,
default_number_phases
};
CompositeScheduleDefaultLimits default_limits = {default_amps_limit, default_watts_limit, default_number_phases};

auto composite_charge_point_max = ocpp::v16::calculate_composite_schedule(
charge_point_max, start_time, end_time, charging_rate_unit, default_number_phases, supply_voltage);
Expand Down
5 changes: 3 additions & 2 deletions lib/ocpp/v201/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ ChargingSchedulePeriod minimize_charging_schedule_period_by_limit(
CompositeSchedule calculate_composite_schedule(const CompositeSchedule& charging_station_external_constraints,
const CompositeSchedule& charging_station_max,
const CompositeSchedule& tx_default, const CompositeSchedule& tx,
const CompositeScheduleDefaultLimits& default_limits, int32_t supply_voltage) {
const CompositeScheduleDefaultLimits& default_limits,
int32_t supply_voltage) {

CompositeSchedule combined{
.chargingSchedulePeriod = {},
Expand All @@ -486,7 +487,7 @@ CompositeSchedule calculate_composite_schedule(const CompositeSchedule& charging

const float default_limit = (tx_default.chargingRateUnit == ChargingRateUnitEnum::A)
? static_cast<float>(default_limits.amps)
: static_cast<float>(default_limits.watts) ;
: static_cast<float>(default_limits.watts);

int current_period = 0;

Expand Down
12 changes: 4 additions & 8 deletions lib/ocpp/v201/smart_charging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,11 +610,7 @@ CompositeSchedule SmartChargingHandler::calculate_composite_schedule(
const auto supply_voltage =
this->device_model->get_optional_value<int>(ControllerComponentVariables::SupplyVoltage).value_or(LOW_VOLTAGE);

CompositeScheduleDefaultLimits default_limits = {
default_amps_limit,
default_watts_limit,
default_number_phases
};
CompositeScheduleDefaultLimits default_limits = {default_amps_limit, default_watts_limit, default_number_phases};

auto charging_station_external_constraints =
ocpp::v201::calculate_composite_schedule(charging_station_external_constraints_periods, start_time, end_time,
Expand All @@ -626,9 +622,9 @@ CompositeSchedule SmartChargingHandler::calculate_composite_schedule(
auto composite_tx = ocpp::v201::calculate_composite_schedule(tx_periods, start_time, end_time, charging_rate_unit,
default_number_phases, supply_voltage);

CompositeSchedule composite_schedule = ocpp::v201::calculate_composite_schedule(
charging_station_external_constraints, composite_charge_point_max, composite_tx_default, composite_tx,
default_limits, supply_voltage);
CompositeSchedule composite_schedule =
ocpp::v201::calculate_composite_schedule(charging_station_external_constraints, composite_charge_point_max,
composite_tx_default, composite_tx, default_limits, supply_voltage);

// Set the EVSE ID for the resulting CompositeSchedule
composite_schedule.evseId = evse_id;
Expand Down
21 changes: 11 additions & 10 deletions tests/lib/ocpp/v16/profile_testsA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ using ocpp::v16::period_entry_t;
using std::chrono::minutes;
using std::chrono::seconds;

constexpr CompositeScheduleDefaultLimits DEFAULT_LIMITS = {
48,
33120,
3
};
constexpr CompositeScheduleDefaultLimits DEFAULT_LIMITS = {48, 33120, 3};
constexpr int default_supply_voltage = 230;

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -1915,7 +1911,8 @@ TEST(ProfileTestsA, combinedTxDefault) {
EnhancedChargingSchedule tx_default_schedule{ChargingRateUnit::A, {{0, 10.0, std::nullopt}}, 600, start, 10.0};
EnhancedChargingSchedule schedule{ChargingRateUnit::A, {}, 600, start, 6.0};

const auto res = calculate_composite_schedule(schedule, tx_default_schedule, schedule, DEFAULT_LIMITS, default_supply_voltage);
const auto res =
calculate_composite_schedule(schedule, tx_default_schedule, schedule, DEFAULT_LIMITS, default_supply_voltage);
EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A);
EXPECT_EQ(res.duration.value_or(-1), 600);
EXPECT_EQ(res.startSchedule, start);
Expand All @@ -1933,7 +1930,8 @@ TEST(ProfileTestsA, combinedTxDefaultTx) {
EnhancedChargingSchedule tx_schedule{ChargingRateUnit::A, {{0, 32.0, std::nullopt}}, 600, start, std::nullopt};
EnhancedChargingSchedule schedule{ChargingRateUnit::A, {}, 600, start, 6.0};

const auto res = calculate_composite_schedule(schedule, tx_default_schedule, tx_schedule, DEFAULT_LIMITS, default_supply_voltage);
const auto res = calculate_composite_schedule(schedule, tx_default_schedule, tx_schedule, DEFAULT_LIMITS,
default_supply_voltage);
EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A);
EXPECT_EQ(res.duration.value_or(-1), 600);
EXPECT_EQ(res.startSchedule, start);
Expand All @@ -1952,7 +1950,8 @@ TEST(ProfileTestsA, combinedTxDefaultTxMin) {
EnhancedChargingSchedule cpm_schedule{ChargingRateUnit::A, {{0, 6.0, std::nullopt}}, 600, start, std::nullopt};
EnhancedChargingSchedule schedule{ChargingRateUnit::A, {}, 600, start, 6.0};

const auto res = calculate_composite_schedule(cpm_schedule, tx_default_schedule, tx_schedule, DEFAULT_LIMITS, default_supply_voltage);
const auto res = calculate_composite_schedule(cpm_schedule, tx_default_schedule, tx_schedule, DEFAULT_LIMITS,
default_supply_voltage);
EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A);
EXPECT_EQ(res.duration.value_or(-1), 600);
EXPECT_EQ(res.startSchedule, start);
Expand All @@ -1977,7 +1976,8 @@ TEST(ProfileTestsA, combinedOverlapA) {
EnhancedChargingSchedule cpm_schedule{
ChargingRateUnit::A, {{0, no_limit_specified, std::nullopt}}, 600, start, std::nullopt};

const auto res = calculate_composite_schedule(cpm_schedule, tx_default_schedule, tx_schedule, DEFAULT_LIMITS, default_supply_voltage);
const auto res = calculate_composite_schedule(cpm_schedule, tx_default_schedule, tx_schedule, DEFAULT_LIMITS,
default_supply_voltage);
// std::cout << res << std::endl;

EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A);
Expand Down Expand Up @@ -2016,7 +2016,8 @@ TEST(ProfileTestsA, combinedOverlapB) {
start,
std::nullopt};

const auto res = calculate_composite_schedule(cpm_schedule, tx_default_schedule, tx_schedule, DEFAULT_LIMITS, default_supply_voltage);
const auto res = calculate_composite_schedule(cpm_schedule, tx_default_schedule, tx_schedule, DEFAULT_LIMITS,
default_supply_voltage);
// std::cout << res << std::endl;

EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A);
Expand Down
10 changes: 3 additions & 7 deletions tests/lib/ocpp/v201/test_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@

#include "smart_charging_test_utils.hpp"

constexpr ocpp::CompositeScheduleDefaultLimits DEFAULT_LIMITS = {
48,
33120,
3
};
constexpr ocpp::CompositeScheduleDefaultLimits DEFAULT_LIMITS = {48, 33120, 3};

namespace {
using namespace ocpp::v201;
Expand Down Expand Up @@ -1079,8 +1075,8 @@ TEST(OCPPTypesTest, CalculateChargingScheduleCombined_Default) {

};

const CompositeSchedule actual = calculate_composite_schedule(
DEFAULT_SCHEDULE, DEFAULT_SCHEDULE, DEFAULT_SCHEDULE, DEFAULT_SCHEDULE, DEFAULT_LIMITS, LOW_VOLTAGE);
const CompositeSchedule actual = calculate_composite_schedule(DEFAULT_SCHEDULE, DEFAULT_SCHEDULE, DEFAULT_SCHEDULE,
DEFAULT_SCHEDULE, DEFAULT_LIMITS, LOW_VOLTAGE);

ASSERT_EQ(expected, actual);
}
Expand Down

0 comments on commit 2aea2b8

Please sign in to comment.