Files
sim/tests/model/Factory.h
2025-03-14 10:47:54 +01:00

105 lines
3.3 KiB
C++

//
// Created by stani on 3/10/2025.
//
#ifndef FACTORY_H
#define FACTORY_H
#include <memory>
#include "../../src/model/Building.h"
#include "../../src/model/Community.h"
#include "../../src/model/Energy_Tariff.h"
#include "../../src/Config.h"
namespace Building {
class Cost;
}
class Factory {
public:
std::unique_ptr<Building::Simulation_Values> static create_test_simulation_values() {
auto values = std::make_unique<Building::Simulation_Values>();
auto communityCoverage = std::vector<float>();
auto ownUsage = std::vector<float>();
auto neededCon = std::vector<float>();
auto neededGen = std::vector<float>();
for (int i = 0; i < 5; i++) {
communityCoverage.push_back(static_cast<float>(i) * 10.0f);
ownUsage.push_back(static_cast<float>(i) * 5.0f);
neededCon.push_back(static_cast<float>(i) * 3.0f);
neededGen.push_back(static_cast<float>(i) * 2.0f);
}
values->set_community_coverage(std::move(communityCoverage));
values->set_own_usage(std::move(ownUsage));
values->set_needed_con(std::move(neededCon));
values->set_needed_gen(std::move(neededGen));
return values;
}
std::unique_ptr<Building::Metadata> static create_test_metadata() {
auto metadata = std::make_unique<Building::Metadata>();
metadata->set_name("Test Building");
metadata->set_annual_consumption(3000.0f);
metadata->set_annual_generation(0.0f);
metadata->set_consumption_profile_name("Profile_1");
metadata->set_generation_profile_name("Profile_2");
metadata->set_connection_power(1);
metadata->set_grid_power(50);
metadata->set_consumption_net_price(0.10f);
metadata->set_generation_net_price(0.12f);
metadata->set_special_rate_consumption(0.15f);
metadata->set_special_rate_generation(0.10f);
auto consumptionProfile = std::vector<float>();
auto generationProfile = std::vector<float>();
for (int i = 0; i < VALUE_COUNT; i++) {
// Populate with test values
consumptionProfile.push_back(static_cast<float>(i) * (VALUE_COUNT % 100));
generationProfile.push_back(static_cast<float>(i) * (VALUE_COUNT % 50));
}
metadata->set_consumption_profile(std::move(consumptionProfile));
metadata->set_generation_profile(std::move(generationProfile));
return metadata;
}
std::unique_ptr<Building::Base> static create_test_building() {
auto building = std::make_unique<Building::Base>();
building->set_values(create_test_simulation_values());
building->set_metadata(create_test_metadata());
return building;
}
Energy_Tariff static create_test_energy_tariff() {
return {};
}
std::unique_ptr<Community> static create_test_community() {
auto community = std::make_unique<Community>();
community->set_name("Test Community");
std::vector<std::unique_ptr<Building::Base> > buildings;
for (int i = 0; i < 10; i++) {
buildings.push_back(create_test_building());
}
community->set_buildings(std::move(buildings));
community->set_energy_tariff(create_test_energy_tariff());
return community;
}
};
#endif //FACTORY_H