Skip to content

Commit

Permalink
DCSupplySimulator: use static function instead of member function for…
Browse files Browse the repository at this point in the history
… capabilities

Also do not store capabilities globally, just get them from the config at
runtime.

Signed-off-by: Moritz Barsnick <[email protected]>
  • Loading branch information
barsnick committed Feb 8, 2024
1 parent a312969 commit 2a95eb6
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions modules/simulation/DCSupplySimulator/main/power_supply_DCImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(this->config.max_voltage);
this->capabilities.min_export_voltage_V = static_cast<float>(this->config.min_voltage);
this->capabilities.max_export_current_A = static_cast<float>(this->config.max_current);
this->capabilities.min_export_current_A = static_cast<float>(this->config.min_current);
this->capabilities.max_export_power_W = static_cast<float>(this->config.max_power);
this->capabilities.max_import_voltage_V = static_cast<float>(this->config.max_voltage);
this->capabilities.min_import_voltage_V = static_cast<float>(this->config.min_voltage);
this->capabilities.max_import_current_A = static_cast<float>(this->config.max_current);
this->capabilities.min_import_current_A = static_cast<float>(this->config.min_current);
this->capabilities.max_import_power_W = static_cast<float>(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<float>(config.max_voltage);
cap.min_export_voltage_V = static_cast<float>(config.min_voltage);
cap.max_export_current_A = static_cast<float>(config.max_current);
cap.min_export_current_A = static_cast<float>(config.min_current);
cap.max_export_power_W = static_cast<float>(config.max_power);
cap.max_import_voltage_V = static_cast<float>(config.max_voltage);
cap.min_import_voltage_V = static_cast<float>(config.min_voltage);
cap.max_import_current_A = static_cast<float>(config.max_current);
cap.min_import_current_A = static_cast<float>(config.min_current);
cap.max_import_power_W = static_cast<float>(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) {
Expand Down

0 comments on commit 2a95eb6

Please sign in to comment.