From d250b21122397105807b1b5170222ef730af7355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piet=20G=C3=B6mpel?= Date: Fri, 18 Oct 2024 14:50:03 +0200 Subject: [PATCH] * Added configuration options for composite schedule default limits for OCPP2.0.1 and OCPP1.6: * CompositeScheduleDefaultLimitAmps * CompositeScheduleDefaultLimitWatts * CompositeScheduleDefaultNumberPhases * SupplyVoltage * Added ChargePointConfiguration member to SmartChargingHandler to allow the SmartChargingHandler to get the configuration required for its operation * Addressed required changes in test cases due to adding ChargePointConfiguration to SmartChargingHandler and changed function signatures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piet Gömpel --- config/v16/CMakeLists.txt | 1 + config/v16/profile_schemas/Internal.json | 29 +++ .../standardized/SmartChargingCtrlr.json | 73 +++++++ .../ocpp/v16/charge_point_configuration.hpp | 12 ++ include/ocpp/v16/profile.hpp | 8 +- include/ocpp/v16/smart_charging.hpp | 5 +- .../ocpp/v201/ctrlr_component_variables.hpp | 4 + include/ocpp/v201/profile.hpp | 19 +- lib/ocpp/v16/charge_point_configuration.cpp | 183 +++++++++++++++++- lib/ocpp/v16/charge_point_impl.cpp | 5 +- lib/ocpp/v16/profile.cpp | 28 ++- lib/ocpp/v16/smart_charging.cpp | 34 ++-- lib/ocpp/v201/ctrlr_component_variables.cpp | 20 ++ lib/ocpp/v201/profile.cpp | 48 ++--- lib/ocpp/v201/smart_charging.cpp | 31 ++- tests/CMakeLists.txt | 13 ++ tests/config/v16/resources/config.json | 59 ++++++ tests/config/v16/resources/user_config.json | 1 + tests/lib/ocpp/v16/database_stub.hpp | 5 + tests/lib/ocpp/v16/profile_testsA.cpp | 73 ++++--- tests/lib/ocpp/v16/profile_testsB.cpp | 30 +-- tests/lib/ocpp/v16/profile_testsC.cpp | 46 ++--- .../lib/ocpp/v16/test_composite_schedule.cpp | 7 +- .../ocpp/v16/test_smart_charging_handler.cpp | 26 +-- tests/lib/ocpp/v201/test_profile.cpp | 78 +++++--- 25 files changed, 664 insertions(+), 174 deletions(-) create mode 100644 tests/config/v16/resources/config.json create mode 100644 tests/config/v16/resources/user_config.json diff --git a/config/v16/CMakeLists.txt b/config/v16/CMakeLists.txt index e0dcbd202..7e318e6df 100644 --- a/config/v16/CMakeLists.txt +++ b/config/v16/CMakeLists.txt @@ -12,6 +12,7 @@ collect_migration_files( INSTALL_DESTINATION ${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP/core_migrations ) +set(OCPP1_6_CONFIG_DIR "${CMAKE_CURRENT_SOURCE_DIR}" PARENT_SCOPE) set(MIGRATION_FILE_VERSION_V16 ${TARGET_MIGRATION_FILE_VERSION} PARENT_SCOPE) set(MIGRATION_FILES_SOURCE_DIR_V16 ${MIGRATION_FILES_LOCATION} PARENT_SCOPE) diff --git a/config/v16/profile_schemas/Internal.json b/config/v16/profile_schemas/Internal.json index b8a86df45..b33fabac7 100644 --- a/config/v16/profile_schemas/Internal.json +++ b/config/v16/profile_schemas/Internal.json @@ -203,6 +203,35 @@ "readOnly": true, "default": 31536000 }, + "CompositeScheduleDefaultLimitAmps": { + "description": "Default amps limit applied when composite schedule is calculated and no limit was provided by the CSMS", + "type": "number", + "readOnly": true, + "default": 48, + "minimum": 0 + }, + "CompositeScheduleDefaultLimitWatts": { + "description": "Default watts limit applied when composite schedule is calculated and no limit was provided by the CSMS", + "type": "number", + "readOnly": true, + "default": 33120, + "minimum": 0 + }, + "CompositeScheduleDefaultNumberPhases": { + "description": "Default number of phases applied when composite schedule is calculated and no limit was provided by the CSMS", + "type": "number", + "readOnly": true, + "default": 3, + "minimum": 1, + "maximum": 3 + }, + "SupplyVoltage": { + "description": "Supply voltage of the grid. This value is only used in case a conversion between smart charging amp and watt limits is required", + "type": "number", + "readOnly": false, + "default": 230, + "minimum": 0 + }, "WebsocketPingPayload": { "$comment": "The payload sent in a websocket ping.", "type": "string", diff --git a/config/v201/component_config/standardized/SmartChargingCtrlr.json b/config/v201/component_config/standardized/SmartChargingCtrlr.json index 3ca47b67e..ebd7d5bdc 100644 --- a/config/v201/component_config/standardized/SmartChargingCtrlr.json +++ b/config/v201/component_config/standardized/SmartChargingCtrlr.json @@ -178,6 +178,79 @@ ], "description": "A list of supported quantities for use in a ChargingSchedule. Allowed values: 'A' and 'W\ufffd", "type": "string" + }, + "CompositeScheduleDefaultLimitAmps": { + "variable_name": "CompositeScheduleDefaultLimitAmps", + "characteristics": { + "unit": "A", + "minLimit": 0, + "supportsMonitoring": true, + "dataType": "integer" + }, + "attributes": [ + { + "type": "Actual", + "mutability": "ReadWrite", + "value": 48 + } + ], + "type": "integer", + "description": "Default amps limit applied when composite schedule is calculated and no limit was provided by the CSMS" + }, + "CompositeScheduleDefaultLimitWatts": { + "variable_name": "CompositeScheduleDefaultLimitWatts", + "characteristics": { + "unit": "W", + "minLimit": 0, + "supportsMonitoring": true, + "dataType": "integer" + }, + "attributes": [ + { + "type": "Actual", + "mutability": "ReadWrite", + "value": 33120 + } + ], + "type": "integer", + "description": "Default watts limit applied when composite schedule is calculated and no limit was provided by the CSMS" + }, + "CompositeScheduleDefaultNumberPhases": { + "variable_name": "CompositeScheduleDefaultNumberPhases", + "characteristics": { + "unit": "W", + "minLimit": 1, + "maxLimit": 3, + "supportsMonitoring": true, + "dataType": "integer" + }, + "attributes": [ + { + "type": "Actual", + "mutability": "ReadWrite", + "value": 3 + } + ], + "type": "integer", + "description": "Default number of phases applied when composite schedule is calculated and no limit was provided by the CSMS" + }, + "SupplyVoltage": { + "variable_name": "SupplyVoltage", + "characteristics": { + "unit": "V", + "minLimit": 0, + "supportsMonitoring": true, + "dataType": "integer" + }, + "attributes": [ + { + "type": "Actual", + "mutability": "ReadWrite", + "value": 230 + } + ], + "type": "integer", + "description": "Supply voltage of the grid. This value is only used in case a conversion between smart charging amp and watt limits is required" } }, "required": [ diff --git a/include/ocpp/v16/charge_point_configuration.hpp b/include/ocpp/v16/charge_point_configuration.hpp index 3d434b473..7e9171a3b 100644 --- a/include/ocpp/v16/charge_point_configuration.hpp +++ b/include/ocpp/v16/charge_point_configuration.hpp @@ -86,6 +86,18 @@ class ChargePointConfiguration { KeyValue getSupportedChargingProfilePurposeTypesKeyValue(); int32_t getMaxCompositeScheduleDuration(); KeyValue getMaxCompositeScheduleDurationKeyValue(); + std::optional getCompositeScheduleDefaultLimitAmps(); + std::optional getCompositeScheduleDefaultLimitAmpsKeyValue(); + void setCompositeScheduleDefaultLimitAmps(int32_t limit_amps); + std::optional getCompositeScheduleDefaultLimitWatts(); + std::optional getCompositeScheduleDefaultLimitWattsKeyValue(); + void setCompositeScheduleDefaultLimitWatts(int32_t limit_watts); + std::optional getCompositeScheduleDefaultNumberPhases(); + std::optional getCompositeScheduleDefaultNumberPhasesKeyValue(); + void setCompositeScheduleDefaultNumberPhases(int32_t number_phases); + std::optional getSupplyVoltage(); + std::optional getSupplyVoltageKeyValue(); + void setSupplyVoltage(int32_t supply_voltage); std::string getSupportedCiphers12(); KeyValue getSupportedCiphers12KeyValue(); std::string getSupportedCiphers13(); diff --git a/include/ocpp/v16/profile.hpp b/include/ocpp/v16/profile.hpp index ec4699717..e3ed30f52 100644 --- a/include/ocpp/v16/profile.hpp +++ b/include/ocpp/v16/profile.hpp @@ -44,11 +44,15 @@ std::vector calculate_profile(const DateTime& now, const DateTim EnhancedChargingSchedule calculate_composite_schedule(std::vector& combined_schedules, const DateTime& now, const DateTime& end, - std::optional charging_rate_unit); + std::optional charging_rate_unit, + const int32_t default_number_phases, + const int32_t supply_voltage); EnhancedChargingSchedule calculate_composite_schedule(const EnhancedChargingSchedule& charge_point_max, const EnhancedChargingSchedule& tx_default, - const EnhancedChargingSchedule& tx); + const EnhancedChargingSchedule& tx, const float default_limit_A, + const float default_limit_W, const int32_t default_number_phases, + const int32_t supply_voltage); } // namespace ocpp::v16 diff --git a/include/ocpp/v16/smart_charging.hpp b/include/ocpp/v16/smart_charging.hpp index 990f3b61a..4d7461638 100644 --- a/include/ocpp/v16/smart_charging.hpp +++ b/include/ocpp/v16/smart_charging.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -39,11 +40,11 @@ class SmartChargingHandler { private: std::map> connectors; std::shared_ptr database_handler; + std::shared_ptr configuration; std::map stack_level_charge_point_max_profiles_map; std::mutex charge_point_max_profiles_map_mutex; std::mutex tx_default_profiles_map_mutex; std::mutex tx_profiles_map_mutex; - bool allow_charging_profile_without_start_schedule; std::unique_ptr clear_profiles_timer; @@ -57,7 +58,7 @@ class SmartChargingHandler { public: SmartChargingHandler(std::map>& connectors, std::shared_ptr database_handler, - const bool allow_charging_profile_without_start_schedule); + std::shared_ptr configuration); /// /// \brief validates the given \p profile according to the specification diff --git a/include/ocpp/v201/ctrlr_component_variables.hpp b/include/ocpp/v201/ctrlr_component_variables.hpp index 07a5180df..485bcf84b 100644 --- a/include/ocpp/v201/ctrlr_component_variables.hpp +++ b/include/ocpp/v201/ctrlr_component_variables.hpp @@ -208,6 +208,10 @@ extern const ComponentVariable& ExternalControlSignalsEnabled; extern const RequiredComponentVariable& LimitChangeSignificance; extern const ComponentVariable& NotifyChargingLimitWithSchedules; extern const RequiredComponentVariable& PeriodsPerSchedule; +extern const RequiredComponentVariable& CompositeScheduleDefaultLimitAmps; +extern const RequiredComponentVariable& CompositeScheduleDefaultLimitWatts; +extern const RequiredComponentVariable& CompositeScheduleDefaultNumberPhases; +extern const RequiredComponentVariable& SupplyVoltage; extern const ComponentVariable& Phases3to1; extern const RequiredComponentVariable& ChargingProfileMaxStackLevel; extern const RequiredComponentVariable& ChargingScheduleChargingRateUnit; diff --git a/include/ocpp/v201/profile.hpp b/include/ocpp/v201/profile.hpp index cfbe2e1e9..b88e50814 100644 --- a/include/ocpp/v201/profile.hpp +++ b/include/ocpp/v201/profile.hpp @@ -72,21 +72,30 @@ std::vector calculate_profile(const DateTime& now, const DateTim /// \param now the start of the composite schedule /// \param end the end (i.e. duration) of the composite schedule /// \param charging_rate_unit the units to use (defaults to Amps) -/// \return the calculated composite schedule +/// \param default_number_phases default number of phases if no existing period limit applies +/// \param supply_voltage Supply voltage of the grid. This value is only used in case a conversion between smart +/// charging amp and watt limits is required \return the calculated composite schedule CompositeSchedule calculate_composite_schedule(std::vector& combined_schedules, const DateTime& now, const DateTime& end, - std::optional charging_rate_unit); + std::optional charging_rate_unit, + const int32_t default_number_phases, const int32_t supply_voltage); /// \brief calculate the combined composite schedule from all of the different types of /// CompositeSchedules /// \param charge_point_max the composite schedule for ChargePointMax profiles /// \param tx_default the composite schedule for TxDefault profiles /// \param tx the composite schedule for Tx profiles -/// \return the calculated combined composite schedule -/// \note all composite schedules must have the same units configured +/// \param default_limit_A default amps limit if no existing period limit applies +/// \param default_limit_W default watts limit if no existing period limit applies +/// \param default_number_phases default number of phases if no existing period limit applies +/// \param supply_voltage Supply voltage of the grid. This value is only used in case a conversion between smart +/// charging amp and watt limits is required \return the calculated combined composite schedule \note all composite +/// schedules must have the same units configured CompositeSchedule calculate_composite_schedule(const CompositeSchedule& charging_station_external_constraints, const CompositeSchedule& charging_station_max, - const CompositeSchedule& tx_default, const CompositeSchedule& tx); + const CompositeSchedule& tx_default, const CompositeSchedule& tx, + const int32_t default_limit_A, const int32_t default_limit_W, + const int32_t default_number_phases, const int32_t supply_voltage); } // namespace v201 } // namespace ocpp \ No newline at end of file diff --git a/lib/ocpp/v16/charge_point_configuration.cpp b/lib/ocpp/v16/charge_point_configuration.cpp index 60abc1748..cdfcef547 100644 --- a/lib/ocpp/v16/charge_point_configuration.cpp +++ b/lib/ocpp/v16/charge_point_configuration.cpp @@ -350,14 +350,116 @@ int32_t ChargePointConfiguration::getMaxCompositeScheduleDuration() { return this->config["Internal"]["MaxCompositeScheduleDuration"]; } -std::string ChargePointConfiguration::getSupportedCiphers12() { +std::optional ChargePointConfiguration::getCompositeScheduleDefaultLimitAmps() { + if (this->config["Internal"].contains("CompositeScheduleDefaultLimitAmps")) { + return this->config["Internal"]["CompositeScheduleDefaultLimitAmps"]; + } + return std::nullopt; +} + +std::optional ChargePointConfiguration::getCompositeScheduleDefaultLimitAmpsKeyValue() { + const auto opt_value = this->getCompositeScheduleDefaultLimitAmps(); + if (opt_value.has_value()) { + KeyValue kv; + kv.key = "CompositeScheduleDefaultLimitAmps"; + kv.readonly = false; + kv.value = std::to_string(opt_value.value()); + return kv; + } + return std::nullopt; +} + +void ChargePointConfiguration::setCompositeScheduleDefaultLimitAmps(int32_t limit_amps) { + if (this->getCompositeScheduleDefaultLimitAmps() != std::nullopt) { + this->config["Internal"]["CompositeScheduleDefaultLimitAmps"] = limit_amps; + this->setInUserConfig("Internal", "CompositeScheduleDefaultLimitAmps", limit_amps); + } +} + +std::optional ChargePointConfiguration::getCompositeScheduleDefaultLimitWatts() { + if (this->config["Internal"].contains("CompositeScheduleDefaultLimitWatts")) { + return this->config["Internal"]["CompositeScheduleDefaultLimitWatts"]; + } + return std::nullopt; +} + +std::optional ChargePointConfiguration::getCompositeScheduleDefaultLimitWattsKeyValue() { + const auto opt_value = this->getCompositeScheduleDefaultLimitWatts(); + if (opt_value.has_value()) { + KeyValue kv; + kv.key = "CompositeScheduleDefaultLimitWatts"; + kv.readonly = false; + kv.value = std::to_string(opt_value.value()); + return kv; + } + return std::nullopt; +} + +void ChargePointConfiguration::setCompositeScheduleDefaultLimitWatts(int32_t limit_watts) { + if (this->getCompositeScheduleDefaultLimitWatts() != std::nullopt) { + this->config["Internal"]["CompositeScheduleDefaultLimitWatts"] = limit_watts; + this->setInUserConfig("Internal", "CompositeScheduleDefaultLimitWatts", limit_watts); + } +} + +std::optional ChargePointConfiguration::getCompositeScheduleDefaultNumberPhases() { + if (this->config["Internal"].contains("CompositeScheduleDefaultNumberPhases")) { + return this->config["Internal"]["CompositeScheduleDefaultNumberPhases"]; + } + return std::nullopt; +} + +std::optional ChargePointConfiguration::getCompositeScheduleDefaultNumberPhasesKeyValue() { + const auto opt_value = this->getCompositeScheduleDefaultNumberPhases(); + if (opt_value.has_value()) { + KeyValue kv; + kv.key = "CompositeScheduleDefaultNumberPhases"; + kv.readonly = false; + kv.value = std::to_string(opt_value.value()); + return kv; + } + return std::nullopt; +} +void ChargePointConfiguration::setCompositeScheduleDefaultNumberPhases(int32_t number_phases) { + if (this->getCompositeScheduleDefaultNumberPhases() != std::nullopt) { + this->config["Internal"]["CompositeScheduleDefaultNumberPhases"] = number_phases; + this->setInUserConfig("Internal", "CompositeScheduleDefaultNumberPhases", number_phases); + } +} + +std::optional ChargePointConfiguration::getSupplyVoltage() { + if (this->config["Internal"].contains("SupplyVoltage")) { + return this->config["Internal"]["SupplyVoltage"]; + } + return std::nullopt; +} + +std::optional ChargePointConfiguration::getSupplyVoltageKeyValue() { + const auto opt_value = this->getSupplyVoltage(); + if (opt_value.has_value()) { + KeyValue kv; + kv.key = "SupplyVoltage"; + kv.readonly = false; + kv.value = std::to_string(opt_value.value()); + return kv; + } + return std::nullopt; +} + +void ChargePointConfiguration::setSupplyVoltage(int32_t supply_voltage) { + if (this->getSupplyVoltage() != std::nullopt) { + this->config["Internal"]["SupplyVoltage"] = supply_voltage; + this->setInUserConfig("Internal", "SupplyVoltage", supply_voltage); + } +} + +std::string ChargePointConfiguration::getSupportedCiphers12() { std::vector supported_ciphers = this->config["Internal"]["SupportedCiphers12"]; return boost::algorithm::join(supported_ciphers, ":"); } std::string ChargePointConfiguration::getSupportedCiphers13() { - std::vector supported_ciphers = this->config["Internal"]["SupportedCiphers13"]; return boost::algorithm::join(supported_ciphers, ":"); } @@ -2843,6 +2945,18 @@ std::optional ChargePointConfiguration::get(CiString<50> key) { if (key == "MaxCompositeScheduleDuration") { return this->getMaxCompositeScheduleDurationKeyValue(); } + if (key == "CompositeScheduleDefaultLimitAmps") { + return this->getCompositeScheduleDefaultLimitAmpsKeyValue(); + } + if (key == "CompositeScheduleDefaultLimitWatts") { + return this->getCompositeScheduleDefaultLimitWattsKeyValue(); + } + if (key == "CompositeScheduleDefaultNumberPhases") { + return this->getCompositeScheduleDefaultNumberPhasesKeyValue(); + } + if (key == "SupplyVoltage") { + return this->getSupplyVoltageKeyValue(); + } if (key == "WebsocketPingPayload") { return this->getWebsocketPingPayloadKeyValue(); } @@ -3508,6 +3622,71 @@ ConfigurationStatus ChargePointConfiguration::set(CiString<50> key, CiString<500 } } + if (key == "CompositeScheduleDefaultLimitAmps") { + if (this->getCompositeScheduleDefaultLimitAmps() == std::nullopt) { + return ConfigurationStatus::NotSupported; + } + try { + auto [valid, _value] = is_positive_integer(value.get()); + if (not valid) { + return ConfigurationStatus::Rejected; + } + this->setCompositeScheduleDefaultLimitAmps(_value); + } catch (const std::invalid_argument& e) { + return ConfigurationStatus::Rejected; + } catch (const std::out_of_range& e) { + return ConfigurationStatus::Rejected; + } + } + if (key == "CompositeScheduleDefaultLimitWatts") { + if (this->getCompositeScheduleDefaultLimitWatts() == std::nullopt) { + return ConfigurationStatus::NotSupported; + } + try { + auto [valid, _value] = is_positive_integer(value.get()); + if (not valid) { + return ConfigurationStatus::Rejected; + } + this->setCompositeScheduleDefaultLimitWatts(_value); + } catch (const std::invalid_argument& e) { + return ConfigurationStatus::Rejected; + } catch (const std::out_of_range& e) { + return ConfigurationStatus::Rejected; + } + } + if (key == "CompositeScheduleDefaultNumberPhases") { + if (this->getCompositeScheduleDefaultNumberPhases() == std::nullopt) { + return ConfigurationStatus::NotSupported; + } + try { + const auto _value = std::stoi(value.get()); + if (_value <= 0 or _value > 3) { + return ConfigurationStatus::Rejected; + } + this->setCompositeScheduleDefaultNumberPhases(_value); + } catch (const std::invalid_argument& e) { + return ConfigurationStatus::Rejected; + } catch (const std::out_of_range& e) { + return ConfigurationStatus::Rejected; + } + } + if (key == "SupplyVoltage") { + if (this->getSupplyVoltage() == std::nullopt) { + return ConfigurationStatus::NotSupported; + } + try { + const auto [valid, _value] = is_positive_integer(value.get()); + if (not valid) { + return ConfigurationStatus::Rejected; + } + this->setSupplyVoltage(_value); + } catch (const std::invalid_argument& e) { + return ConfigurationStatus::Rejected; + } catch (const std::out_of_range& e) { + return ConfigurationStatus::Rejected; + } + } + if (key == "VerifyCsmsAllowWildcards") { if (isBool(value.get())) { this->setVerifyCsmsAllowWildcards(ocpp::conversions::string_to_bool(value.get())); diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index e3bb980f6..791795b6e 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -171,9 +171,8 @@ ChargePointImpl::ChargePointImpl(const std::string& config, const fs::path& shar this->connectors.insert(std::make_pair(id, std::make_shared(id))); } - this->smart_charging_handler = std::make_unique( - this->connectors, this->database_handler, - this->configuration->getAllowChargingProfileWithoutStartSchedule().value_or(false)); + this->smart_charging_handler = + std::make_unique(this->connectors, this->database_handler, this->configuration); this->load_charging_profiles(); // ISO15118 PnC handlers diff --git a/lib/ocpp/v16/profile.cpp b/lib/ocpp/v16/profile.cpp index eb56fcbaf..cf3e497a2 100644 --- a/lib/ocpp/v16/profile.cpp +++ b/lib/ocpp/v16/profile.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -17,15 +18,6 @@ using std::chrono::duration_cast; using std::chrono::seconds; namespace { -// TODO(james-ctc): get the maximum charge defaults from configuration -// TODO(james-ctc): get the low voltage value from configuration (230V, 110V etc.) - -// the default is to allow maximum charge -constexpr float default_limit_A = 48.0; // in Amps -constexpr float default_limit_W = 33120.0; // in Watts -constexpr std::int32_t default_number_phases = - ocpp::v16::DEFAULT_AND_MAX_NUMBER_PHASES; // also the maximum number of phases -constexpr float low_voltage = 230; // in Volts using ocpp::v16::EnhancedChargingSchedulePeriod; @@ -87,7 +79,8 @@ void update_itt(const int schedule_duration, std::vector convert_limit(const ocpp::v16::period_entry_t* const entry, - const ocpp::v16::ChargingRateUnit selected_unit) { + const ocpp::v16::ChargingRateUnit selected_unit, + const int32_t default_number_phases, const int32_t supply_voltage) { assert(entry != nullptr); float limit = entry->limit; std::int32_t number_phases = entry->number_phases.value_or(default_number_phases); @@ -95,9 +88,9 @@ std::pair convert_limit(const ocpp::v16::period_entry_t* co // if the units are the same - don't change the values if (selected_unit != entry->charging_rate_unit) { if (selected_unit == ocpp::v16::ChargingRateUnit::A) { - limit = entry->limit / (low_voltage * number_phases); + limit = entry->limit / (supply_voltage * number_phases); } else { - limit = entry->limit * (low_voltage * number_phases); + limit = entry->limit * (supply_voltage * number_phases); } } @@ -406,7 +399,9 @@ std::vector calculate_profile(const DateTime& now, const DateTim /// \return the calculated composite schedule EnhancedChargingSchedule calculate_composite_schedule(std::vector& in_combined_schedules, const DateTime& in_now, const DateTime& in_end, - std::optional in_charging_rate_unit) { + std::optional in_charging_rate_unit, + const int32_t default_number_phases, + const int32_t supply_voltage) { const ChargingRateUnit selected_unit = (in_charging_rate_unit) ? in_charging_rate_unit.value() : ChargingRateUnit::A; const auto now = floor_seconds(in_now); @@ -451,7 +446,8 @@ EnhancedChargingSchedule calculate_composite_schedule(std::vectorstack_level}); if (chosen->end < next_earliest) { @@ -473,7 +469,9 @@ EnhancedChargingSchedule calculate_composite_schedule(std::vector @@ -45,10 +46,8 @@ bool validate_schedule(const ChargingSchedule& schedule, const int charging_sche SmartChargingHandler::SmartChargingHandler(std::map>& connectors, std::shared_ptr database_handler, - const bool allow_charging_profile_without_start_schedule) : - connectors(connectors), - database_handler(database_handler), - allow_charging_profile_without_start_schedule(allow_charging_profile_without_start_schedule) { + std::shared_ptr configuration) : + connectors(connectors), database_handler(database_handler), configuration(configuration) { this->clear_profiles_timer = std::make_unique(); this->clear_profiles_timer->interval([this]() { this->clear_expired_profiles(); }, hours(HOURS_PER_DAY)); } @@ -143,12 +142,23 @@ EnhancedChargingSchedule SmartChargingHandler::calculate_enhanced_composite_sche } } - auto composite_charge_point_max = - ocpp::v16::calculate_composite_schedule(charge_point_max, start_time, end_time, charging_rate_unit); - auto composite_tx_default = - ocpp::v16::calculate_composite_schedule(tx_default, start_time, end_time, charging_rate_unit); - auto composite_tx = ocpp::v16::calculate_composite_schedule(tx, start_time, end_time, charging_rate_unit); - return ocpp::v16::calculate_composite_schedule(composite_charge_point_max, composite_tx_default, composite_tx); + const float default_amps_limit = + this->configuration->getCompositeScheduleDefaultLimitAmps().value_or(DEFAULT_LIMIT_AMPS); + const float default_watts_limit = + this->configuration->getCompositeScheduleDefaultLimitWatts().value_or(DEFAULT_LIMIT_WATTS); + const int32_t default_number_phases = + this->configuration->getCompositeScheduleDefaultNumberPhases().value_or(DEFAULT_AND_MAX_NUMBER_PHASES); + const int32_t supply_voltage = this->configuration->getSupplyVoltage().value_or(LOW_VOLTAGE); + + 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); + auto composite_tx_default = ocpp::v16::calculate_composite_schedule( + tx_default, start_time, end_time, charging_rate_unit, default_number_phases, supply_voltage); + auto composite_tx = ocpp::v16::calculate_composite_schedule(tx, start_time, end_time, charging_rate_unit, + default_number_phases, supply_voltage); + return ocpp::v16::calculate_composite_schedule(composite_charge_point_max, composite_tx_default, composite_tx, + default_amps_limit, default_watts_limit, default_number_phases, + supply_voltage); } bool SmartChargingHandler::validate_profile( @@ -163,7 +173,7 @@ bool SmartChargingHandler::validate_profile( if (profile.chargingProfileKind == ChargingProfileKindType::Absolute && !profile.chargingSchedule.startSchedule) { EVLOG_warning << "INVALID PROFILE - Absolute Profile Kind with no given startSchedule"; - if (this->allow_charging_profile_without_start_schedule) { + if (this->configuration->getAllowChargingProfileWithoutStartSchedule().value_or(false)) { EVLOG_warning << "Allowing profile because AllowChargingProfileWithoutStartSchedule is configured"; profile.chargingSchedule.startSchedule = ocpp::DateTime(); } else { @@ -188,7 +198,7 @@ bool SmartChargingHandler::validate_profile( } if (!profile.chargingSchedule.startSchedule) { EVLOG_warning << "INVALID PROFILE - Recurring Profile Kind with no startSchedule"; - if (this->allow_charging_profile_without_start_schedule) { + if (this->configuration->getAllowChargingProfileWithoutStartSchedule().value_or(false)) { EVLOG_warning << "Allowing profile because AllowChargingProfileWithoutStartSchedule is configured"; profile.chargingSchedule.startSchedule = ocpp::DateTime(); } else { diff --git a/lib/ocpp/v201/ctrlr_component_variables.cpp b/lib/ocpp/v201/ctrlr_component_variables.cpp index 16e6e3e1f..93cba64f1 100644 --- a/lib/ocpp/v201/ctrlr_component_variables.cpp +++ b/lib/ocpp/v201/ctrlr_component_variables.cpp @@ -1163,6 +1163,26 @@ const RequiredComponentVariable& PeriodsPerSchedule = { "PeriodsPerSchedule", }), }; +const RequiredComponentVariable& CompositeScheduleDefaultLimitAmps = { + ControllerComponents::SmartChargingCtrlr, + std::nullopt, + std::optional({"CompositeScheduleDefaultLimitAmps"}), +}; +const RequiredComponentVariable& CompositeScheduleDefaultLimitWatts = { + ControllerComponents::SmartChargingCtrlr, + std::nullopt, + std::optional({"CompositeScheduleDefaultLimitWatts"}), +}; +const RequiredComponentVariable& CompositeScheduleDefaultNumberPhases = { + ControllerComponents::SmartChargingCtrlr, + std::nullopt, + std::optional({"CompositeScheduleDefaultNumberPhases"}), +}; +const RequiredComponentVariable& SupplyVoltage = { + ControllerComponents::SmartChargingCtrlr, + std::nullopt, + std::optional({"SupplyVoltage"}), +}; const ComponentVariable& Phases3to1 = { ControllerComponents::SmartChargingCtrlr, std::nullopt, diff --git a/lib/ocpp/v201/profile.cpp b/lib/ocpp/v201/profile.cpp index f28f5dd8c..d810c0822 100644 --- a/lib/ocpp/v201/profile.cpp +++ b/lib/ocpp/v201/profile.cpp @@ -61,17 +61,18 @@ void update_itt(const int schedule_duration, std::vector convert_limit(const ocpp::v201::period_entry_t* const entry, - const ocpp::v201::ChargingRateUnitEnum selected_unit) { + const ocpp::v201::ChargingRateUnitEnum selected_unit, + const int32_t default_number_phases, const int32_t supply_voltage) { assert(entry != nullptr); float limit = entry->limit; - std::int32_t number_phases = entry->number_phases.value_or(ocpp::DEFAULT_AND_MAX_NUMBER_PHASES); + std::int32_t number_phases = entry->number_phases.value_or(default_number_phases); // if the units are the same - don't change the values if (selected_unit != entry->charging_rate_unit) { if (selected_unit == ocpp::v201::ChargingRateUnitEnum::A) { - limit = entry->limit / (ocpp::LOW_VOLTAGE * number_phases); + limit = entry->limit / (supply_voltage * number_phases); } else { - limit = entry->limit * (ocpp::LOW_VOLTAGE * number_phases); + limit = entry->limit * (supply_voltage * number_phases); } } @@ -348,7 +349,8 @@ std::vector calculate_profile(const DateTime& now, const DateTim CompositeSchedule calculate_composite_schedule(std::vector& in_combined_schedules, const DateTime& in_now, const DateTime& in_end, - std::optional charging_rate_unit) { + std::optional charging_rate_unit, + const int32_t default_number_phases, const int32_t supply_voltage) { // Defaults to ChargingRateUnitEnum::A if not set. const ChargingRateUnitEnum selected_unit = @@ -403,7 +405,8 @@ CompositeSchedule calculate_composite_schedule(std::vector& in_c current = earliest; } else { // there is a schedule to use - const auto [limit, number_phases] = convert_limit(chosen, selected_unit); + const auto [limit, number_phases] = + convert_limit(chosen, selected_unit, default_number_phases, supply_voltage); ChargingSchedulePeriod charging_schedule_period{elapsed_seconds(current, now), limit, std::nullopt, number_phases}; @@ -433,10 +436,9 @@ CompositeSchedule calculate_composite_schedule(std::vector& in_c /// \param[in] current_charging_rate_unit_enum details of the current composite schedule charging_rate_unit for /// conversion. /// -ChargingSchedulePeriod -minimize_charging_schedule_period_by_limit(const int current, const ChargingSchedulePeriod& prevailing_period, - const ChargingSchedulePeriod& candidate_period, - const ChargingRateUnitEnum current_charging_rate_unit_enum) { +ChargingSchedulePeriod minimize_charging_schedule_period_by_limit( + const int current, const ChargingSchedulePeriod& prevailing_period, const ChargingSchedulePeriod& candidate_period, + const ChargingRateUnitEnum current_charging_rate_unit_enum, const int32_t default_number_phases) { auto adjusted_period = prevailing_period; @@ -447,9 +449,9 @@ minimize_charging_schedule_period_by_limit(const int current, const ChargingSche if (prevailing_period.limit == NO_LIMIT_SPECIFIED && candidate_period.limit != NO_LIMIT_SPECIFIED) { adjusted_period = candidate_period; } else if (candidate_period.limit != NO_LIMIT_SPECIFIED) { - const auto charge_point_max_phases = candidate_period.numberPhases.value_or(DEFAULT_AND_MAX_NUMBER_PHASES); + const auto charge_point_max_phases = candidate_period.numberPhases.value_or(default_number_phases); - const auto period_max_phases = prevailing_period.numberPhases.value_or(DEFAULT_AND_MAX_NUMBER_PHASES); + const auto period_max_phases = prevailing_period.numberPhases.value_or(default_number_phases); adjusted_period.numberPhases = std::min(charge_point_max_phases, period_max_phases); if (current_charging_rate_unit_enum == ChargingRateUnitEnum::A) { @@ -470,7 +472,9 @@ minimize_charging_schedule_period_by_limit(const int current, const ChargingSche CompositeSchedule calculate_composite_schedule(const CompositeSchedule& charging_station_external_constraints, const CompositeSchedule& charging_station_max, - const CompositeSchedule& tx_default, const CompositeSchedule& tx) { + const CompositeSchedule& tx_default, const CompositeSchedule& tx, + const int32_t default_limit_A, const int32_t default_limit_W, + const int32_t default_number_phases, const int32_t supply_voltage) { CompositeSchedule combined{ .chargingSchedulePeriod = {}, @@ -482,7 +486,7 @@ CompositeSchedule calculate_composite_schedule(const CompositeSchedule& charging }; const float default_limit = - (tx_default.chargingRateUnit == ChargingRateUnitEnum::A) ? DEFAULT_LIMIT_AMPS : DEFAULT_LIMIT_WATTS; + (tx_default.chargingRateUnit == ChargingRateUnitEnum::A) ? default_limit_A : default_limit_W; int current_period = 0; @@ -517,8 +521,7 @@ CompositeSchedule calculate_composite_schedule(const CompositeSchedule& charging update_itt(0, tx_itt, tx.chargingSchedulePeriod.end(), period_tx, duration_tx); - ChargingSchedulePeriod last{ - .startPeriod = 1, .limit = NO_LIMIT_SPECIFIED, .numberPhases = DEFAULT_AND_MAX_NUMBER_PHASES}; + ChargingSchedulePeriod last{.startPeriod = 1, .limit = NO_LIMIT_SPECIFIED, .numberPhases = default_number_phases}; while (current_period < end) { @@ -528,7 +531,7 @@ CompositeSchedule calculate_composite_schedule(const CompositeSchedule& charging // create an unset period to override as needed. ChargingSchedulePeriod period{ - .startPeriod = NO_START_PERIOD, .limit = NO_LIMIT_SPECIFIED, .numberPhases = DEFAULT_AND_MAX_NUMBER_PHASES}; + .startPeriod = NO_START_PERIOD, .limit = NO_LIMIT_SPECIFIED, .numberPhases = default_number_phases}; if (period_tx.startPeriod != NO_START_PERIOD) { period = period_tx; @@ -541,9 +544,10 @@ CompositeSchedule calculate_composite_schedule(const CompositeSchedule& charging } period = minimize_charging_schedule_period_by_limit(current_period, period, period_charging_station_max, - combined.chargingRateUnit); - period = minimize_charging_schedule_period_by_limit( - current_period, period, period_charging_station_external_constraints, combined.chargingRateUnit); + combined.chargingRateUnit, default_number_phases); + period = minimize_charging_schedule_period_by_limit(current_period, period, + period_charging_station_external_constraints, + combined.chargingRateUnit, default_number_phases); update_itt(duration, charging_station_external_constraints_itt, charging_station_external_constraints.chargingSchedulePeriod.end(), @@ -564,7 +568,7 @@ CompositeSchedule calculate_composite_schedule(const CompositeSchedule& charging if (period.startPeriod != NO_START_PERIOD) { if (!period.numberPhases.has_value()) { - period.numberPhases = DEFAULT_AND_MAX_NUMBER_PHASES; + period.numberPhases = default_number_phases; } if (period.limit == NO_LIMIT_SPECIFIED) { @@ -580,7 +584,7 @@ CompositeSchedule calculate_composite_schedule(const CompositeSchedule& charging last = period; } else { combined.chargingSchedulePeriod.push_back( - {current_period, default_limit, std::nullopt, DEFAULT_AND_MAX_NUMBER_PHASES}); + {current_period, default_limit, std::nullopt, default_number_phases}); current_period = end; } } diff --git a/lib/ocpp/v201/smart_charging.cpp b/lib/ocpp/v201/smart_charging.cpp index 74f2acc3e..4fd5f8978 100644 --- a/lib/ocpp/v201/smart_charging.cpp +++ b/lib/ocpp/v201/smart_charging.cpp @@ -598,16 +598,31 @@ CompositeSchedule SmartChargingHandler::calculate_composite_schedule( } } - auto charging_station_external_constraints = ocpp::v201::calculate_composite_schedule( - charging_station_external_constraints_periods, start_time, end_time, charging_rate_unit); - auto composite_charge_point_max = - ocpp::v201::calculate_composite_schedule(charge_point_max_periods, start_time, end_time, charging_rate_unit); - auto composite_tx_default = - ocpp::v201::calculate_composite_schedule(tx_default_periods, start_time, end_time, charging_rate_unit); - auto composite_tx = ocpp::v201::calculate_composite_schedule(tx_periods, start_time, end_time, charging_rate_unit); + const auto default_amps_limit = + this->device_model->get_optional_value(ControllerComponentVariables::CompositeScheduleDefaultLimitAmps) + .value_or(DEFAULT_LIMIT_AMPS); + const auto default_watts_limit = + this->device_model->get_optional_value(ControllerComponentVariables::CompositeScheduleDefaultLimitWatts) + .value_or(DEFAULT_LIMIT_WATTS); + const auto default_number_phases = + this->device_model->get_optional_value(ControllerComponentVariables::CompositeScheduleDefaultNumberPhases) + .value_or(DEFAULT_AND_MAX_NUMBER_PHASES); + const auto supply_voltage = + this->device_model->get_optional_value(ControllerComponentVariables::SupplyVoltage).value_or(LOW_VOLTAGE); + + auto charging_station_external_constraints = + ocpp::v201::calculate_composite_schedule(charging_station_external_constraints_periods, start_time, end_time, + charging_rate_unit, default_number_phases, supply_voltage); + auto composite_charge_point_max = ocpp::v201::calculate_composite_schedule( + charge_point_max_periods, start_time, end_time, charging_rate_unit, default_number_phases, supply_voltage); + auto composite_tx_default = ocpp::v201::calculate_composite_schedule( + tx_default_periods, start_time, end_time, charging_rate_unit, default_number_phases, supply_voltage); + 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); + charging_station_external_constraints, composite_charge_point_max, composite_tx_default, composite_tx, + default_amps_limit, default_watts_limit, default_number_phases, supply_voltage); // Set the EVSE ID for the resulting CompositeSchedule composite_schedule.evseId = evse_id; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 893fc1e96..de47e1e34 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,11 @@ +set(CONFIG_DIR_V16 "${CMAKE_CURRENT_BINARY_DIR}/resources/v16/") set(MIGRATION_FILES_LOCATION_V16 "${CMAKE_CURRENT_BINARY_DIR}/resources/v16/migration_files") set(MIGRATION_FILES_LOCATION_V201 "${CMAKE_CURRENT_BINARY_DIR}/resources/v201/migration_files") +set(CONFIG_FILE_LOCATION_V16 ${CMAKE_CURRENT_SOURCE_DIR}/config/v16/resources/config.json) +set(USER_CONFIG_FILE_LOCATION_V16 ${CMAKE_CURRENT_SOURCE_DIR}/config/v16/resources/user_config.json) +set(CONFIG_FILE_RESOURCES_LOCATION_V16 "${CMAKE_CURRENT_BINARY_DIR}/resources/config/v16/config.json") +set(USER_CONFIG_FILE_RESOURCES_LOCATION_V16 "${CMAKE_CURRENT_BINARY_DIR}/resources/config/v16/user_config.json") + set(MIGRATION_FILES_DEVICE_MODEL_LOCATION_V201 "${CMAKE_CURRENT_BINARY_DIR}/resources/v201/device_model_migration_files") set(DEVICE_MODEL_DB_LOCATION_V201 "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/everest/modules/OCPP201/device_model_storage.db") set(DEVICE_MODEL_RESOURCES_LOCATION_V201 "${CMAKE_CURRENT_BINARY_DIR}/resources/config/v201") @@ -19,6 +25,9 @@ add_executable(libocpp_unit_tests target_compile_definitions(libocpp_unit_tests PRIVATE + CONFIG_FILE_LOCATION_V16="${CONFIG_FILE_RESOURCES_LOCATION_V16}" + USER_CONFIG_FILE_LOCATION_V16="${USER_CONFIG_FILE_RESOURCES_LOCATION_V16}" + CONFIG_DIR_V16="${CONFIG_DIR_V16}" MIGRATION_FILES_LOCATION_V16="${MIGRATION_FILES_LOCATION_V16}" MIGRATION_FILES_LOCATION_V201="${MIGRATION_FILES_LOCATION_V201}" MIGRATION_FILE_VERSION_V16=${MIGRATION_FILE_VERSION_V16} @@ -31,6 +40,10 @@ target_compile_definitions(libocpp_unit_tests add_custom_command(TARGET libocpp_unit_tests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/unittest_device_model.db ${CMAKE_CURRENT_BINARY_DIR}/resources/unittest_device_model.db COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/resources/unittest_device_model_missing_required.db ${CMAKE_CURRENT_BINARY_DIR}/resources/unittest_device_model_missing_required.db + COMMAND ${CMAKE_COMMAND} -E copy ${CONFIG_FILE_LOCATION_V16} ${CONFIG_FILE_RESOURCES_LOCATION_V16} + COMMAND ${CMAKE_COMMAND} -E copy ${USER_CONFIG_FILE_LOCATION_V16} ${USER_CONFIG_FILE_RESOURCES_LOCATION_V16} + COMMAND ${CMAKE_COMMAND} -E remove_directory ${CONFIG_DIR_V16} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${OCPP1_6_CONFIG_DIR} ${CONFIG_DIR_V16} COMMAND ${CMAKE_COMMAND} -E remove_directory ${MIGRATION_FILES_LOCATION_V16} COMMAND ${CMAKE_COMMAND} -E copy_directory ${MIGRATION_FILES_SOURCE_DIR_V16} ${MIGRATION_FILES_LOCATION_V16} COMMAND ${CMAKE_COMMAND} -E remove_directory ${MIGRATION_FILES_LOCATION_V201} diff --git a/tests/config/v16/resources/config.json b/tests/config/v16/resources/config.json new file mode 100644 index 000000000..933c7933d --- /dev/null +++ b/tests/config/v16/resources/config.json @@ -0,0 +1,59 @@ +{ + "Internal": { + "ChargePointId": "cp001", + "CentralSystemURI": "127.0.0.1:8180/steve/websocket/CentralSystemService/", + "ChargeBoxSerialNumber": "cp001", + "ChargePointModel": "Yeti", + "ChargePointVendor": "Pionix", + "FirmwareVersion": "0.1", + "LogMessagesFormat": [], + "AllowChargingProfileWithoutStartSchedule": true + }, + "Core": { + "AuthorizeRemoteTxRequests": false, + "ClockAlignedDataInterval": 900, + "ConnectionTimeOut": 10, + "ConnectorPhaseRotation": "0.RST,1.RST", + "GetConfigurationMaxKeys": 100, + "HeartbeatInterval": 86400, + "LocalAuthorizeOffline": false, + "LocalPreAuthorize": false, + "MeterValuesAlignedData": "Energy.Active.Import.Register", + "MeterValuesSampledData": "Energy.Active.Import.Register", + "MeterValueSampleInterval": 0, + "NumberOfConnectors": 1, + "ResetRetries": 1, + "StopTransactionOnEVSideDisconnect": true, + "StopTransactionOnInvalidId": true, + "StopTxnAlignedData": "Energy.Active.Import.Register", + "StopTxnSampledData": "Energy.Active.Import.Register", + "SupportedFeatureProfiles": "Core,FirmwareManagement,RemoteTrigger,Reservation,LocalAuthListManagement,SmartCharging", + "TransactionMessageAttempts": 1, + "TransactionMessageRetryInterval": 10, + "UnlockConnectorOnEVSideDisconnect": true + }, + "FirmwareManagement": { + "SupportedFileTransferProtocols": "FTP" + }, + "LocalAuthListManagement": { + "LocalAuthListEnabled": true, + "LocalAuthListMaxLength": 42, + "SendLocalListMaxLength": 42 + }, + "SmartCharging": { + "ChargeProfileMaxStackLevel": 42, + "ChargingScheduleAllowedChargingRateUnit": "Current", + "ChargingScheduleMaxPeriods": 42, + "MaxChargingProfilesInstalled": 42 + }, + "Security": { + "SecurityProfile": 0 + }, + "PnC": { + "ISO15118PnCEnabled": true, + "ContractValidationOffline": true + }, + "CostAndPrice": { + "CustomDisplayCostAndPrice": false + } +} diff --git a/tests/config/v16/resources/user_config.json b/tests/config/v16/resources/user_config.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/tests/config/v16/resources/user_config.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/tests/lib/ocpp/v16/database_stub.hpp b/tests/lib/ocpp/v16/database_stub.hpp index b6875103d..5920f5367 100644 --- a/tests/lib/ocpp/v16/database_stub.hpp +++ b/tests/lib/ocpp/v16/database_stub.hpp @@ -137,6 +137,7 @@ class DbTestBase : public testing::Test { std::map> connectors; std::shared_ptr database_handler; std::unique_ptr database_interface; + std::shared_ptr configuration; void add_connectors(unsigned int n) { for (unsigned int i = 0; i <= n; i++) { @@ -155,6 +156,10 @@ class DbTestBase : public testing::Test { database_interface = std::make_unique(); database_handler = std::make_shared(std::move(database_interface), init_script_path, 1); + std::ifstream ifs(CONFIG_FILE_LOCATION_V16); + const std::string config_file((std::istreambuf_iterator(ifs)), (std::istreambuf_iterator())); + configuration = + std::make_shared(config_file, CONFIG_DIR_V16, USER_CONFIG_FILE_LOCATION_V16); } void TearDown() override { diff --git a/tests/lib/ocpp/v16/profile_testsA.cpp b/tests/lib/ocpp/v16/profile_testsA.cpp index 5302763e0..48b512a30 100644 --- a/tests/lib/ocpp/v16/profile_testsA.cpp +++ b/tests/lib/ocpp/v16/profile_testsA.cpp @@ -24,6 +24,7 @@ using std::chrono::seconds; constexpr int default_numberPhases = 3; constexpr float default_limit_A{48.0}; constexpr float default_limit_W{33120.0}; +constexpr int default_supply_voltage = 230; // ---------------------------------------------------------------------------- // Test charging profiles @@ -1347,7 +1348,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleEmpty) { DateTime now("2024-01-01T12:00:00Z"); DateTime end(now.to_time_point() + minutes(10)); std::vector combined_schedules{}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expect a schedule of duration 10 minutes with defaults EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1365,7 +1367,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleExact) { DateTime now("2024-01-01T12:00:00Z"); DateTime end(now.to_time_point() + minutes(10)); std::vector combined_schedules{{now, end, 24.0, {3}, 1, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expect a schedule of duration 10 minutes with the schedule EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1384,7 +1387,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleExactShort) { DateTime end(now.to_time_point() + minutes(10)); std::vector combined_schedules{ {now, DateTime(end.to_time_point() - seconds(1)), 24.0, {3}, 1, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expect a schedule of duration 10 minutes with the schedule EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1406,7 +1410,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleExactLong) { DateTime end(now.to_time_point() + minutes(10)); std::vector combined_schedules{ {DateTime(now.to_time_point() - seconds(1)), end, 24.0, {3}, 1, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expect a schedule of duration 10 minutes with the schedule EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1430,7 +1435,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleExactAlmost) { 1, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // std::cout << combined_schedules << std::endl; // std::cout << res << std::endl; @@ -1462,7 +1468,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleSingleLong) { 1, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expect a schedule of duration 10 minutes with info from the schedule EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1486,7 +1493,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleSingleShort) { 1, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expect a schedule of duration 10 minutes with info from the schedule + default EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1513,7 +1521,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleSingleDelayedStartLong) { 1, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expecting default, then schedule EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1540,7 +1549,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleSingleDelayedStartShort) { 1, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expecting default, then schedule, then default EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1577,7 +1587,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleOverlapStart) { 1, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expecting schedule stack level 1 then schedule stack level 21 EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1611,7 +1622,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleOverlapEnd) { 1, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expecting schedule stack level 21 then schedule stack level 1 EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1645,7 +1657,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleOverlapMiddle) { 1, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expecting schedule stack level 1 then schedule stack level 21 and then back to 1 EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1682,7 +1695,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleOverlapIgnore) { 31, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expecting schedule stack level 31 only EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1713,7 +1727,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleNoGapA) { 31, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expecting 2 schedules EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1747,7 +1762,8 @@ TEST(ProfileTestsA, calculateCompositeScheduleNoGapB) { 31, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expecting 2 schedules EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1781,7 +1797,8 @@ TEST(ProfileTestsA, calculateCompositeSchedule1sOverlapA) { 31, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expecting 2 schedules EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1815,7 +1832,8 @@ TEST(ProfileTestsA, calculateCompositeSchedule1sOverlapB) { 31, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // std::cout << combined_schedules << std::endl; // std::cout << res << std::endl; @@ -1851,7 +1869,8 @@ TEST(ProfileTestsA, calculateCompositeSchedule1SGap) { 31, ChargingRateUnit::A, std::nullopt}}; - auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + auto res = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, default_numberPhases, + default_supply_voltage); // expecting 2 schedules EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1877,7 +1896,8 @@ TEST(ProfileTestsA, calculateCompositeSchedule1SGap) { TEST(ProfileTestsA, combinedEmpty) { const auto start = DateTime{"2024-01-01T12:00:00Z"}; EnhancedChargingSchedule schedule{ChargingRateUnit::A, {}, 600, start, 10.0}; - const auto res = calculate_composite_schedule(schedule, schedule, schedule); + const auto res = calculate_composite_schedule(schedule, schedule, schedule, default_limit_A, default_limit_W, + default_numberPhases, default_supply_voltage); EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); EXPECT_EQ(res.duration.value_or(-1), 600); EXPECT_EQ(res.startSchedule, start); @@ -1894,7 +1914,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); + const auto res = calculate_composite_schedule(schedule, tx_default_schedule, schedule, default_limit_A, + default_limit_W, default_numberPhases, default_supply_voltage); EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); EXPECT_EQ(res.duration.value_or(-1), 600); EXPECT_EQ(res.startSchedule, start); @@ -1912,7 +1933,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); + const auto res = calculate_composite_schedule(schedule, tx_default_schedule, tx_schedule, default_limit_A, + default_limit_W, default_numberPhases, default_supply_voltage); EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); EXPECT_EQ(res.duration.value_or(-1), 600); EXPECT_EQ(res.startSchedule, start); @@ -1931,7 +1953,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); + const auto res = calculate_composite_schedule(cpm_schedule, tx_default_schedule, tx_schedule, default_limit_A, + default_limit_W, default_numberPhases, default_supply_voltage); EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); EXPECT_EQ(res.duration.value_or(-1), 600); EXPECT_EQ(res.startSchedule, start); @@ -1956,7 +1979,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); + const auto res = calculate_composite_schedule(cpm_schedule, tx_default_schedule, tx_schedule, default_limit_A, + default_limit_W, default_numberPhases, default_supply_voltage); // std::cout << res << std::endl; EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); @@ -1995,7 +2019,8 @@ TEST(ProfileTestsA, combinedOverlapB) { start, std::nullopt}; - const auto res = calculate_composite_schedule(cpm_schedule, tx_default_schedule, tx_schedule); + const auto res = calculate_composite_schedule(cpm_schedule, tx_default_schedule, tx_schedule, default_limit_A, + default_limit_W, default_numberPhases, default_supply_voltage); // std::cout << res << std::endl; EXPECT_EQ(res.chargingRateUnit, ChargingRateUnit::A); diff --git a/tests/lib/ocpp/v16/profile_testsB.cpp b/tests/lib/ocpp/v16/profile_testsB.cpp index 0a7795031..816a8704d 100644 --- a/tests/lib/ocpp/v16/profile_testsB.cpp +++ b/tests/lib/ocpp/v16/profile_testsB.cpp @@ -276,7 +276,7 @@ TEST(DateTime, init) { TEST_F(ProfileTestsB, init) { add_connectors(2); // map doesn't include connector 0, database does - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); ChargingProfile profile{ 101, // chargingProfileId 20, // stackLevel @@ -304,7 +304,7 @@ TEST_F(ProfileTestsB, validate_profileA) { connectors[connector_id]->transaction = std::make_shared(-1, connector_id, "1234", "4567", meter_start, std::nullopt, timestamp, nullptr); // map doesn't include connector 0, database does - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); auto tmp_profile = profileA; EXPECT_TRUE( handler.validate_profile(tmp_profile, 0, true, 100, 10, 10, {ChargingRateUnit::A, ChargingRateUnit::W})); @@ -333,7 +333,7 @@ TEST_F(ProfileTestsB, validate_profileB) { connectors[connector_id]->transaction = std::make_shared(-1, connector_id, "1234", "4567", meter_start, std::nullopt, timestamp, nullptr); // map doesn't include connector 0, database does - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); auto tmp_profile = profileB; EXPECT_TRUE( handler.validate_profile(tmp_profile, 0, true, 100, 10, 10, {ChargingRateUnit::A, ChargingRateUnit::W})); @@ -352,7 +352,7 @@ TEST_F(ProfileTestsB, validate_profileB) { TEST_F(ProfileTestsB, tx_default_0) { add_connectors(5); // map doesn't include connector 0, database does - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); ChargingProfile profile{ 201, // chargingProfileId 22, // stackLevel @@ -377,7 +377,7 @@ TEST_F(ProfileTestsB, single_profile) { connectors[1]->transaction = std::make_shared(-1, connector, "1234", "4567", meter_start, std::nullopt, timestamp, nullptr); // map doesn't include connector 0, database does - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileA, 1); @@ -402,7 +402,7 @@ TEST_F(ProfileTestsB, startup_no_charge) { // no active transaction // map doesn't include connector 0, database does - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileNoCharge, 1); @@ -457,7 +457,7 @@ TEST_F(ProfileTestsB, get_valid_profiles_absolute) { connectors[1]->transaction = std::make_shared(-1, connector, "1234", "4567", 100, std::nullopt, start_time, nullptr); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileStackA, 1); handler.add_tx_default_profile(profileStackB, 1); @@ -485,7 +485,7 @@ TEST_F(ProfileTestsB, get_valid_profiles_absolute_delay) { absoluteB.validFrom = ocpp::DateTime(now + minutes(5)); absoluteB.chargingSchedule.startSchedule = ocpp::DateTime(now + minutes(5)); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileStackA, 1); handler.add_tx_default_profile(absoluteB, 1); @@ -516,7 +516,7 @@ TEST_F(ProfileTestsB, get_valid_profiles_relative) { relativeB.chargingProfileKind = ChargingProfileKindType::Relative; relativeB.chargingSchedule.startSchedule = std::nullopt; - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(relativeA, 1); handler.add_tx_default_profile(relativeB, 1); @@ -549,7 +549,7 @@ TEST_F(ProfileTestsB, get_valid_profiles_relative_delay) { relativeB.chargingSchedule.startSchedule = ocpp::DateTime(now + minutes(5)); // relativeB.chargingSchedule.startSchedule = std::nullopt; - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(relativeA, 1); handler.add_tx_default_profile(relativeB, 1); @@ -578,7 +578,7 @@ TEST_F(ProfileTestsB, single_absolute) { auto absoluteA = profileStackA; - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(absoluteA, 1); handler.add_tx_default_profile(profileStackC, 1); @@ -610,7 +610,7 @@ TEST_F(ProfileTestsB, stack_absolute) { connectors[1]->transaction = std::make_shared(-1, connector, "1234", "4567", 100, std::nullopt, start_time, nullptr); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileStackA, 1); handler.add_tx_default_profile(profileStackB, 1); @@ -657,7 +657,7 @@ TEST_F(ProfileTestsB, stack_absolute_delay) { absoluteB.validFrom = absoluteA.validTo; absoluteB.chargingSchedule.startSchedule = absoluteA.validTo; - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(absoluteA, 1); handler.add_tx_default_profile(absoluteB, 1); @@ -708,7 +708,7 @@ TEST_F(ProfileTestsB, stack_absolute_delay_overlap) { absoluteB.validFrom = ocpp::DateTime(now + minutes(5)); absoluteB.chargingSchedule.startSchedule = ocpp::DateTime(now + minutes(5)); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileStackA, 1); handler.add_tx_default_profile(absoluteB, 1); @@ -761,7 +761,7 @@ TEST_F(ProfileTestsB, stack_relative) { relativeB.chargingProfileKind = ChargingProfileKindType::Relative; relativeB.chargingSchedule.startSchedule = std::nullopt; - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(relativeA, 1); handler.add_tx_default_profile(relativeB, 1); diff --git a/tests/lib/ocpp/v16/profile_testsC.cpp b/tests/lib/ocpp/v16/profile_testsC.cpp index 596f07cbf..314965aa2 100644 --- a/tests/lib/ocpp/v16/profile_testsC.cpp +++ b/tests/lib/ocpp/v16/profile_testsC.cpp @@ -236,7 +236,7 @@ TEST_F(ProfileTestsC, DailyRecurringNotValidYet) { DateTime start_time("2024-01-01T07:55:00Z"); DateTime end_time("2024-01-01T08:05:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurring, connector_id); auto valid_profiles = handler.get_valid_profiles(start_time, end_time, connector_id); @@ -258,7 +258,7 @@ TEST_F(ProfileTestsC, DailyRecurringAlmostValid) { DateTime start_time("2024-01-01T11:55:00Z"); DateTime end_time("2024-01-01T12:05:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurring, connector_id); #ifdef DEBUG_PROFILE @@ -296,7 +296,7 @@ TEST_F(ProfileTestsC, DailyRecurringDuring) { DateTime start_time("2024-01-01T15:00:00Z"); DateTime end_time("2024-01-01T15:10:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurring, connector_id); auto valid_profiles = handler.get_valid_profiles(start_time, end_time, connector_id); @@ -320,7 +320,7 @@ TEST_F(ProfileTestsC, DailyRecurringApproachingEnd) { DateTime start_time("2024-01-01T17:55:00Z"); DateTime end_time("2024-01-01T18:05:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurring, connector_id); auto valid_profiles = handler.get_valid_profiles(start_time, end_time, connector_id); @@ -348,7 +348,7 @@ TEST_F(ProfileTestsC, DailyRecurringNextDay) { DateTime start_time("2024-01-01T07:30:00Z"); DateTime end_time("2024-01-01T07:40:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurring, connector_id); auto valid_profiles = handler.get_valid_profiles(start_time, end_time, connector_id); @@ -371,7 +371,7 @@ TEST_F(ProfileTestsC, DailyRecurringNextDayStart) { DateTime start_time("2024-01-02T07:55:00Z"); DateTime end_time("2024-01-02T08:05:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurring, connector_id); auto valid_profiles = handler.get_valid_profiles(start_time, end_time, connector_id); @@ -398,7 +398,7 @@ TEST_F(ProfileTestsC, DailyRecurringApproachingInvalid) { DateTime start_time("2024-01-05T11:55:00Z"); DateTime end_time("2024-01-05T12:05:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurring, connector_id); auto valid_profiles = handler.get_valid_profiles(start_time, end_time, connector_id); @@ -428,7 +428,7 @@ TEST_F(ProfileTestsC, MinimumSession) { DateTime start_time("2024-01-05T11:55:00Z"); DateTime end_time("2024-01-05T12:05:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileMinimum, connector_id); auto valid_profiles = handler.get_valid_profiles(start_time, end_time, connector_id); @@ -450,7 +450,7 @@ TEST_F(ProfileTestsC, MinimumNoSession) { DateTime start_time("2024-01-05T11:55:00Z"); DateTime end_time("2024-01-05T12:05:00Z"); configure(); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileMinimum, connector_id); auto valid_profiles = handler.get_valid_profiles(start_time, end_time, connector_id); @@ -476,7 +476,7 @@ TEST_F(ProfileTestsC, DailyRecurringAltNotValidYet) { DateTime start_time("2024-01-01T07:55:00Z"); DateTime end_time("2024-01-01T08:05:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurringAlt, connector_id); handler.add_tx_default_profile(profileMinimum, connector_id); @@ -518,7 +518,7 @@ TEST_F(ProfileTestsC, DailyRecurringAltAlmostValid) { DateTime start_time("2024-01-01T11:55:00Z"); DateTime end_time("2024-01-01T12:05:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurringAlt, connector_id); handler.add_tx_default_profile(profileMinimum, connector_id); @@ -568,7 +568,7 @@ TEST_F(ProfileTestsC, DailyRecurringAltDuring) { DateTime start_time("2024-01-01T15:00:00Z"); DateTime end_time("2024-01-01T15:10:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurringAlt, connector_id); handler.add_tx_default_profile(profileMinimum, connector_id); @@ -610,7 +610,7 @@ TEST_F(ProfileTestsC, DailyRecurringAltApproachingEnd) { DateTime start_time("2024-01-01T17:55:00Z"); DateTime end_time("2024-01-01T18:05:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurringAlt, connector_id); handler.add_tx_default_profile(profileMinimum, connector_id); @@ -660,7 +660,7 @@ TEST_F(ProfileTestsC, DailyRecurringAltNextDay) { DateTime start_time("2024-01-01T07:30:00Z"); DateTime end_time("2024-01-01T07:40:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurringAlt, connector_id); handler.add_tx_default_profile(profileMinimum, connector_id); @@ -702,7 +702,7 @@ TEST_F(ProfileTestsC, DailyRecurringAltNextDayStart) { DateTime start_time("2024-01-02T07:55:00Z"); DateTime end_time("2024-01-02T08:05:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurringAlt, connector_id); handler.add_tx_default_profile(profileMinimum, connector_id); @@ -752,7 +752,7 @@ TEST_F(ProfileTestsC, DailyRecurringAltApproachingInvalid) { DateTime start_time("2024-01-05T11:55:00Z"); DateTime end_time("2024-01-05T12:05:00Z"); configure_transaction(session_start); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurringAlt, connector_id); handler.add_tx_default_profile(profileMinimum, connector_id); @@ -872,7 +872,7 @@ TEST_F(ProfileTestsC, Issue609During) { DateTime start_time(profile609A_startSchedule.to_time_point() + minutes(1)); DateTime end_time(start_time.to_time_point() + seconds(duration)); configure(); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profile609A, 0); handler.add_tx_default_profile(profile609B, 0); @@ -901,7 +901,7 @@ TEST_F(ProfileTestsC, Issue609Before) { DateTime start_time(profile609A_startSchedule.to_time_point() - seconds(1)); DateTime end_time(start_time.to_time_point() + seconds(duration)); configure(); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profile609A, 0); handler.add_tx_default_profile(profile609B, 0); @@ -1027,7 +1027,7 @@ TEST_F(ProfileTestsC, ChargeRateW) { DateTime start_time = profileWatts_startSchedule; DateTime end_time(start_time.to_time_point() + seconds(duration)); configure(); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileWatts, 0); handler.add_tx_default_profile(profileAmps, 0); @@ -1086,7 +1086,7 @@ TEST_F(ProfileTestsC, ChargeRateA) { DateTime start_time = profileWatts_startSchedule; DateTime end_time(start_time.to_time_point() + seconds(duration)); configure(); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileWatts, 0); handler.add_tx_default_profile(profileAmps, 0); @@ -1239,7 +1239,7 @@ TEST_F(ProfileTestsC, Combined1) { DateTime start_time = profileCombined_startSchedule; DateTime end_time(start_time.to_time_point() + seconds(duration)); configure(); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_charge_point_max_profile(profileCombinedCPM); handler.add_tx_default_profile(profileCombinedTXD, 0); @@ -1411,7 +1411,7 @@ TEST_F(ProfileTestsC, Recurring2a) { DateTime start_time = profileRecurringA_startSchedule; DateTime end_time(start_time.to_time_point() + seconds(duration)); configure(); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurringA, 0); handler.add_tx_default_profile(profileRecurringB, 0); @@ -1458,7 +1458,7 @@ TEST_F(ProfileTestsC, Recurring2b) { DateTime start_time = profileRecurringA_startSchedule; DateTime end_time(start_time.to_time_point() + seconds(duration)); configure(); - SmartChargingHandler handler(connectors, database_handler, true); + SmartChargingHandler handler(connectors, database_handler, configuration); handler.add_tx_default_profile(profileRecurringA, 0); handler.add_tx_default_profile(profileRecurringB, 0); diff --git a/tests/lib/ocpp/v16/test_composite_schedule.cpp b/tests/lib/ocpp/v16/test_composite_schedule.cpp index 15ec70f2d..40bc4083d 100644 --- a/tests/lib/ocpp/v16/test_composite_schedule.cpp +++ b/tests/lib/ocpp/v16/test_composite_schedule.cpp @@ -30,6 +30,10 @@ class CompositeScheduleTestFixture : public testing::Test { protected: void SetUp() override { this->evse_security = std::make_shared(); + std::ifstream ifs(CONFIG_FILE_LOCATION_V16); + const std::string config_file((std::istreambuf_iterator(ifs)), (std::istreambuf_iterator())); + this->configuration = + std::make_shared(config_file, CONFIG_DIR_V16, USER_CONFIG_FILE_LOCATION_V16); } void add_connector(int id) { @@ -55,7 +59,7 @@ class CompositeScheduleTestFixture : public testing::Test { std::shared_ptr> database_handler = std::make_shared>(std::move(database), init_script_path); - auto handler = new SmartChargingHandler(connectors, database_handler, true); + auto handler = new SmartChargingHandler(connectors, database_handler, configuration); return handler; } @@ -169,6 +173,7 @@ class CompositeScheduleTestFixture : public testing::Test { std::map> connectors; std::shared_ptr database_handler; std::shared_ptr evse_security; + std::shared_ptr configuration; }; TEST_F(CompositeScheduleTestFixture, CalculateEnhancedCompositeSchedule_ValidatedBaseline) { diff --git a/tests/lib/ocpp/v16/test_smart_charging_handler.cpp b/tests/lib/ocpp/v16/test_smart_charging_handler.cpp index 4179f1be9..c4a4b8959 100644 --- a/tests/lib/ocpp/v16/test_smart_charging_handler.cpp +++ b/tests/lib/ocpp/v16/test_smart_charging_handler.cpp @@ -48,6 +48,10 @@ namespace v16 { class ChargepointTestFixture : public testing::Test { protected: void SetUp() override { + std::ifstream ifs(CONFIG_FILE_LOCATION_V16); + const std::string config_file((std::istreambuf_iterator(ifs)), (std::istreambuf_iterator())); + this->configuration = + std::make_shared(config_file, CONFIG_DIR_V16, USER_CONFIG_FILE_LOCATION_V16); } void addConnector(int id) { @@ -205,7 +209,7 @@ class ChargepointTestFixture : public testing::Test { auto database = std::make_unique(database_path / (chargepoint_id + ".db")); std::shared_ptr database_handler = std::make_shared(std::move(database), init_script_path); - auto handler = new SmartChargingHandler(connectors, database_handler, true); + auto handler = new SmartChargingHandler(connectors, database_handler, configuration); return handler; } @@ -221,8 +225,7 @@ class ChargepointTestFixture : public testing::Test { auto database = std::make_unique(database_path / (chargepoint_id + ".db")); std::shared_ptr database_handler = std::make_shared(std::move(database), init_script_path); - - auto handler = new SmartChargingHandler(connectors, database_handler, true); + auto handler = new SmartChargingHandler(connectors, database_handler, configuration); return handler; } @@ -242,6 +245,7 @@ class ChargepointTestFixture : public testing::Test { // Default values used within the tests std::map> connectors; std::shared_ptr database_handler; + std::shared_ptr configuration; const int connector_id = 1; bool ignore_no_transaction = true; @@ -362,9 +366,8 @@ TEST_F(ChargepointTestFixture, ValidateProfile__ValidProfile_ChargingProfileKind const std::vector& charging_schedule_allowed_charging_rate_units{ChargingRateUnit::A}; // Create a SmartChargingHandler where allow_charging_profile_without_start_schedule is set to false addConnector(1); - auto allow_charging_profile_without_start_schedule = false; - auto handler = - new SmartChargingHandler(connectors, database_handler, allow_charging_profile_without_start_schedule); + this->configuration->setAllowChargingProfileWithoutStartSchedule(false); + auto handler = createSmartChargingHandler(); profile.chargingProfileKind = ChargingProfileKindType::Absolute; profile.chargingSchedule.startSchedule = std::nullopt; @@ -457,9 +460,8 @@ TEST_F(ChargepointTestFixture, const std::vector& charging_schedule_allowed_charging_rate_units{ChargingRateUnit::A}; // Create a SmartChargingHandler where allow_charging_profile_without_start_schedule is set to false addConnector(1); - auto allow_charging_profile_without_start_schedule = false; - auto handler = - new SmartChargingHandler(connectors, database_handler, allow_charging_profile_without_start_schedule); + this->configuration->setAllowChargingProfileWithoutStartSchedule(false); + auto handler = createSmartChargingHandler(); profile.chargingProfileKind = ChargingProfileKindType::Recurring; profile.chargingSchedule.startSchedule = std::nullopt; @@ -496,10 +498,8 @@ TEST_F(ChargepointTestFixture, ValidateProfile__RecurringNoStartScheduleNotAllow auto profile = createChargingProfile(createChargeSchedule(ChargingRateUnit::A)); const std::vector& charging_schedule_allowed_charging_rate_units{ChargingRateUnit::A}; - addConnector(1); - auto allow_charging_profile_without_start_schedule = false; - auto handler = - new SmartChargingHandler(connectors, database_handler, allow_charging_profile_without_start_schedule); + this->configuration->setAllowChargingProfileWithoutStartSchedule(false); + auto handler = createSmartChargingHandler(); profile.chargingProfileKind = ChargingProfileKindType::Recurring; profile.chargingSchedule.startSchedule = std::nullopt; diff --git a/tests/lib/ocpp/v201/test_profile.cpp b/tests/lib/ocpp/v201/test_profile.cpp index ef83f33a8..42d76cc5a 100644 --- a/tests/lib/ocpp/v201/test_profile.cpp +++ b/tests/lib/ocpp/v201/test_profile.cpp @@ -674,7 +674,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_Empty) { .scheduleStart = dt("12:00"), .chargingRateUnit = ChargingRateUnitEnum::A}; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, dt("12:00"), dt("12:10"), std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, dt("12:00"), dt("12:10"), std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -696,7 +697,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_Exact) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, ChargingRateUnitEnum::A); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, ChargingRateUnitEnum::A, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -720,7 +722,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_ShortExact) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, ChargingRateUnitEnum::A); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, ChargingRateUnitEnum::A, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -743,7 +746,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_LongExact) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, ChargingRateUnitEnum::A); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, ChargingRateUnitEnum::A, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -768,7 +772,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_AlmostExact) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -790,7 +795,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_SingleLong) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -813,7 +819,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_SingleShort) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -835,7 +842,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_SingleDelayedStartLong) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -855,7 +863,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_OverlapStart) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -875,7 +884,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_OverlapEnd) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -896,7 +906,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_OverlapMiddle) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -915,7 +926,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_OverlapIgnore) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -935,7 +947,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_NoGapA) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -955,7 +968,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_NoGapB) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -975,7 +989,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_Overlap) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -996,7 +1011,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_OverlapInverted) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -1017,7 +1033,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_1SecondGap) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -1039,7 +1056,8 @@ TEST(OCPPTypesTest, CalculateChargingSchedule_WithPhaseToUse) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt); + CompositeSchedule actual = calculate_composite_schedule(combined_schedules, now, end, std::nullopt, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -1055,8 +1073,9 @@ TEST(OCPPTypesTest, CalculateChargingScheduleCombined_Default) { }; - const CompositeSchedule actual = - calculate_composite_schedule(DEFAULT_SCHEDULE, DEFAULT_SCHEDULE, DEFAULT_SCHEDULE, DEFAULT_SCHEDULE); + const CompositeSchedule actual = calculate_composite_schedule( + DEFAULT_SCHEDULE, DEFAULT_SCHEDULE, DEFAULT_SCHEDULE, DEFAULT_SCHEDULE, DEFAULT_LIMIT_AMPS, DEFAULT_LIMIT_WATTS, + DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -1079,7 +1098,9 @@ TEST(OCPPTypesTest, CalculateChargingScheduleCombined_CombinedTxDefault) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - const CompositeSchedule actual = calculate_composite_schedule(profile, profile, tx_default_schedule, profile); + const CompositeSchedule actual = + calculate_composite_schedule(profile, profile, tx_default_schedule, profile, DEFAULT_LIMIT_AMPS, + DEFAULT_LIMIT_WATTS, DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -1110,8 +1131,9 @@ TEST(OCPPTypesTest, CalculateChargingScheduleCombined_CombinedTxDefaultTx) { .chargingRateUnit = ChargingRateUnitEnum::A, }; - const CompositeSchedule actual = - calculate_composite_schedule(DEFAULT_SCHEDULE, charging_station_max, tx_default_schedule, tx_schedule); + const CompositeSchedule actual = calculate_composite_schedule( + DEFAULT_SCHEDULE, charging_station_max, tx_default_schedule, tx_schedule, DEFAULT_LIMIT_AMPS, + DEFAULT_LIMIT_WATTS, DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -1154,8 +1176,9 @@ TEST(OCPPTypesTest, CalculateChargingScheduleCombined_CombinedOverlapTxAndTxDefa .chargingRateUnit = ChargingRateUnitEnum::A, }; - const CompositeSchedule actual = - calculate_composite_schedule(DEFAULT_SCHEDULE, charging_station_max, tx_default_schedule, tx_schedule); + const CompositeSchedule actual = calculate_composite_schedule( + DEFAULT_SCHEDULE, charging_station_max, tx_default_schedule, tx_schedule, DEFAULT_LIMIT_AMPS, + DEFAULT_LIMIT_WATTS, DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); } @@ -1202,8 +1225,9 @@ TEST(OCPPTypesTest, CalculateChargingScheduleCombined_CombinedOverlapTxTxDefault .chargingRateUnit = ChargingRateUnitEnum::A, }; - const CompositeSchedule actual = - calculate_composite_schedule(DEFAULT_SCHEDULE, charging_station_max, tx_default_schedule, tx_schedule); + const CompositeSchedule actual = calculate_composite_schedule( + DEFAULT_SCHEDULE, charging_station_max, tx_default_schedule, tx_schedule, DEFAULT_LIMIT_AMPS, + DEFAULT_LIMIT_WATTS, DEFAULT_AND_MAX_NUMBER_PHASES, LOW_VOLTAGE); ASSERT_EQ(expected, actual); }