diff --git a/modules/simulation/DCSupplySimulator/main/power_supply_DCImpl.cpp b/modules/simulation/DCSupplySimulator/main/power_supply_DCImpl.cpp index 677cf6017..95d3e0cac 100644 --- a/modules/simulation/DCSupplySimulator/main/power_supply_DCImpl.cpp +++ b/modules/simulation/DCSupplySimulator/main/power_supply_DCImpl.cpp @@ -13,34 +13,37 @@ namespace main { void power_supply_DCImpl::init() { this->connector_voltage = 0.0; this->connector_current = 0.0; - this->init_capabilities(); this->power_supply_thread_handle = std::thread(&power_supply_DCImpl::power_supply_worker, this); } -void power_supply_DCImpl::init_capabilities() { - this->capabilities.bidirectional = this->config.bidirectional; - this->capabilities.current_regulation_tolerance_A = 2.0; - this->capabilities.peak_current_ripple_A = 2.0; - this->capabilities.max_export_voltage_V = static_cast(this->config.max_voltage); - this->capabilities.min_export_voltage_V = static_cast(this->config.min_voltage); - this->capabilities.max_export_current_A = static_cast(this->config.max_current); - this->capabilities.min_export_current_A = static_cast(this->config.min_current); - this->capabilities.max_export_power_W = static_cast(this->config.max_power); - this->capabilities.max_import_voltage_V = static_cast(this->config.max_voltage); - this->capabilities.min_import_voltage_V = static_cast(this->config.min_voltage); - this->capabilities.max_import_current_A = static_cast(this->config.max_current); - this->capabilities.min_import_current_A = static_cast(this->config.min_current); - this->capabilities.max_import_power_W = static_cast(this->config.max_power); - this->capabilities.conversion_efficiency_import = 0.85; - this->capabilities.conversion_efficiency_export = 0.9; +static auto get_capabilities_from_config(const Conf& config) { + types::power_supply_DC::Capabilities cap; + + cap.bidirectional = config.bidirectional; + cap.current_regulation_tolerance_A = 2.0f; + cap.peak_current_ripple_A = 2.0f; + cap.max_export_voltage_V = static_cast(config.max_voltage); + cap.min_export_voltage_V = static_cast(config.min_voltage); + cap.max_export_current_A = static_cast(config.max_current); + cap.min_export_current_A = static_cast(config.min_current); + cap.max_export_power_W = static_cast(config.max_power); + cap.max_import_voltage_V = static_cast(config.max_voltage); + cap.min_import_voltage_V = static_cast(config.min_voltage); + cap.max_import_current_A = static_cast(config.max_current); + cap.min_import_current_A = static_cast(config.min_current); + cap.max_import_power_W = static_cast(config.max_power); + cap.conversion_efficiency_import = 0.85f; + cap.conversion_efficiency_export = 0.9f; + + return cap; } void power_supply_DCImpl::ready() { } types::power_supply_DC::Capabilities power_supply_DCImpl::handle_getCapabilities() { - return this->capabilities; + return get_capabilities_from_config(this->config); } void power_supply_DCImpl::handle_setMode(types::power_supply_DC::Mode& value) {