added BillingHistory
This commit is contained in:
@ -24,6 +24,10 @@ add_executable(Sim_C__
|
|||||||
src/config.h
|
src/config.h
|
||||||
src/services/Cost/NetworkProvider.cpp
|
src/services/Cost/NetworkProvider.cpp
|
||||||
src/services/Cost/NetworkProvider.h
|
src/services/Cost/NetworkProvider.h
|
||||||
|
src/services/Cost/BillCharge.cpp
|
||||||
|
src/services/Cost/BillCharge.h
|
||||||
|
src/services/CostHistory.cpp
|
||||||
|
src/services/CostHistory.h
|
||||||
)
|
)
|
||||||
find_package(doctest CONFIG REQUIRED)
|
find_package(doctest CONFIG REQUIRED)
|
||||||
find_package(spdlog CONFIG REQUIRED)
|
find_package(spdlog CONFIG REQUIRED)
|
||||||
|
|||||||
@ -8,7 +8,7 @@ float Building::Metadata::special_rate_consumption() const {
|
|||||||
return SpecialRateConsumption;
|
return SpecialRateConsumption;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Building::Metadata::set_special_rate_consumption(float special_rate_consumption) {
|
void Building::Metadata::set_special_rate_consumption(const float special_rate_consumption) {
|
||||||
SpecialRateConsumption = special_rate_consumption;
|
SpecialRateConsumption = special_rate_consumption;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,10 +16,50 @@ float Building::Metadata::special_rate_generation() const {
|
|||||||
return SpecialRateGeneration;
|
return SpecialRateGeneration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Building::Metadata::set_special_rate_generation(float special_rate_generation) {
|
void Building::Metadata::set_special_rate_generation(const float special_rate_generation) {
|
||||||
SpecialRateGeneration = special_rate_generation;
|
SpecialRateGeneration = special_rate_generation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
short Building::Metadata::grid_level() const
|
||||||
|
{
|
||||||
|
return GridLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Building::Metadata::set_grid_level(const short value)
|
||||||
|
{
|
||||||
|
GridLevel = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Building::Metadata::grid_operator()
|
||||||
|
{
|
||||||
|
return GridOperator;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Building::Metadata::set_grid_operator(std::string value)
|
||||||
|
{
|
||||||
|
GridOperator = std::move(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
float Building::Metadata::consumption_net_price() const
|
||||||
|
{
|
||||||
|
return ConsumptionNetPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Building::Metadata::set_consumption_net_price(const float value)
|
||||||
|
{
|
||||||
|
ConsumptionNetPrice = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
float Building::Metadata::generation_net_price() const
|
||||||
|
{
|
||||||
|
return GenerationNetPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Building::Metadata::set_generation_net_price(const float value)
|
||||||
|
{
|
||||||
|
GenerationNetPrice = value;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<float> &Building::Simulation_Values::generation_after_community() {
|
std::vector<float> &Building::Simulation_Values::generation_after_community() {
|
||||||
return GenerationAfterCommunity;
|
return GenerationAfterCommunity;
|
||||||
}
|
}
|
||||||
@ -261,20 +301,20 @@ void Building::Base::set_cost(std::unique_ptr<Building::Cost> cost) {
|
|||||||
Cost = std::move(cost);
|
Cost = std::move(cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Building::Simulation_Values> &Building::Base::values() {
|
std::shared_ptr<Building::Simulation_Values>& Building::Base::values() {
|
||||||
return Values;
|
return Values;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Building::Base::set_values(std::unique_ptr<Simulation_Values> values) {
|
void Building::Base::set_values(std::shared_ptr<Simulation_Values> values) {
|
||||||
Values = std::move(values);
|
Values = std::move(values);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<Building::Metadata> &Building::Base::metadata() {
|
std::shared_ptr<Building::Metadata> &Building::Base::metadata() {
|
||||||
return Metadata;
|
return Metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Building::Base::set_metadata(std::unique_ptr<Building::Metadata> metadata) {
|
void Building::Base::set_metadata(const std::shared_ptr<Building::Metadata>& metadata) {
|
||||||
Metadata = std::move(metadata);
|
Metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,38 +9,25 @@
|
|||||||
|
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
#include "../Config.h"
|
#include "../Config.h"
|
||||||
|
#include "../services/CostHistory.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Building {
|
namespace Building
|
||||||
class CostValues {
|
{
|
||||||
|
|
||||||
|
class Cost
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
float Consumption{0.0f};
|
std::shared_ptr<CostHistory> CostValuesWith{};
|
||||||
float Generation{0.0f};
|
std::shared_ptr<CostHistory> CostValuesWithOut{};
|
||||||
float ConsumptionWithCommunity{0.0f};
|
|
||||||
float GenerationWithCommunity{0.0f};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
float consumption() { return Consumption; }
|
std::shared_ptr<CostHistory>& get_cost_values_with() { return CostValuesWith; }
|
||||||
void set_consumption(const float consumption) { Consumption = consumption; }
|
std::shared_ptr<CostHistory>& get_cost_values_without() { return CostValuesWithOut; }
|
||||||
float generation() { return Generation; }
|
|
||||||
void set_generation(const float generation) { Generation = generation; }
|
|
||||||
float consumption_with_community() { return ConsumptionWithCommunity; }
|
|
||||||
void set_consumption_with_community(const float consumption) { ConsumptionWithCommunity = consumption; }
|
|
||||||
float generation_with_community() { return Generation; }
|
|
||||||
void set_generation_with_community(const float generation) { GenerationWithCommunity = generation; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Cost {
|
class Simulation_Values
|
||||||
private:
|
{
|
||||||
std::shared_ptr<CostValues> CostValuesWith{};
|
|
||||||
std::shared_ptr<CostValues> CostValuesWithOut{};
|
|
||||||
|
|
||||||
public:
|
|
||||||
std::shared_ptr<CostValues> &get_cost_values_with() { return CostValuesWith; }
|
|
||||||
std::shared_ptr<CostValues> &get_cost_values_without() { return CostValuesWithOut; }
|
|
||||||
};
|
|
||||||
|
|
||||||
class Simulation_Values {
|
|
||||||
private:
|
private:
|
||||||
std::vector<float> ConsumptionAfterOwnCoverage = std::vector(VALUE_COUNT, 0.0f);
|
std::vector<float> ConsumptionAfterOwnCoverage = std::vector(VALUE_COUNT, 0.0f);
|
||||||
std::vector<float> OwnUsage = std::vector(VALUE_COUNT, 0.0f);
|
std::vector<float> OwnUsage = std::vector(VALUE_COUNT, 0.0f);
|
||||||
@ -67,19 +54,19 @@ namespace Building {
|
|||||||
public:
|
public:
|
||||||
Simulation_Values() = default;
|
Simulation_Values() = default;
|
||||||
|
|
||||||
std::vector<float> &consumption_after_own_coverage();
|
std::vector<float>& consumption_after_own_coverage();
|
||||||
|
|
||||||
void set_community_coverage(std::vector<float> community_coverage);
|
void set_community_coverage(std::vector<float> community_coverage);
|
||||||
|
|
||||||
std::vector<float> &own_usage();
|
std::vector<float>& own_usage();
|
||||||
|
|
||||||
void set_own_usage(std::vector<float> own_usage);
|
void set_own_usage(std::vector<float> own_usage);
|
||||||
|
|
||||||
std::vector<float> &needed_con();
|
std::vector<float>& needed_con();
|
||||||
|
|
||||||
void set_needed_con(std::vector<float> needed_con);
|
void set_needed_con(std::vector<float> needed_con);
|
||||||
|
|
||||||
std::vector<float> &needed_gen();
|
std::vector<float>& needed_gen();
|
||||||
|
|
||||||
void set_needed_gen(std::vector<float> needed_gen);
|
void set_needed_gen(std::vector<float> needed_gen);
|
||||||
|
|
||||||
@ -91,21 +78,21 @@ namespace Building {
|
|||||||
|
|
||||||
void set_relativeSelfGeneration(float relativeSelfGeneration);
|
void set_relativeSelfGeneration(float relativeSelfGeneration);
|
||||||
|
|
||||||
std::vector<float> &generation_after_community();
|
std::vector<float>& generation_after_community();
|
||||||
|
|
||||||
void generation_after_community(const std::vector<float> &generation_after_community);
|
void generation_after_community(const std::vector<float>& generation_after_community);
|
||||||
|
|
||||||
std::vector<float> &consumption_after_community();
|
std::vector<float>& consumption_after_community();
|
||||||
|
|
||||||
void consumption_after_community(const std::vector<float> &consumption_after_community);
|
void consumption_after_community(const std::vector<float>& consumption_after_community);
|
||||||
|
|
||||||
std::vector<float> &generation_to_community();
|
std::vector<float>& generation_to_community();
|
||||||
|
|
||||||
void generation_to_community(const std::vector<float> &generation_to_community);
|
void generation_to_community(const std::vector<float>& generation_to_community);
|
||||||
|
|
||||||
std::vector<float> &consumption_from_community();
|
std::vector<float>& consumption_from_community();
|
||||||
|
|
||||||
void consumption_from_community(const std::vector<float> &consumption_from_community);
|
void consumption_from_community(const std::vector<float>& consumption_from_community);
|
||||||
|
|
||||||
float con_from_community_relative() const;
|
float con_from_community_relative() const;
|
||||||
|
|
||||||
@ -133,7 +120,8 @@ namespace Building {
|
|||||||
void set_generation_to_community_sum(float values);
|
void set_generation_to_community_sum(float values);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Metadata {
|
class Metadata
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
std::string Name{};
|
std::string Name{};
|
||||||
float AnnualConsumption{0.0f};
|
float AnnualConsumption{0.0f};
|
||||||
@ -146,73 +134,79 @@ namespace Building {
|
|||||||
short GridPower{0};
|
short GridPower{0};
|
||||||
float SpecialRateConsumption{0.0f};
|
float SpecialRateConsumption{0.0f};
|
||||||
float SpecialRateGeneration{0.0f};
|
float SpecialRateGeneration{0.0f};
|
||||||
|
short GridLevel{0};
|
||||||
|
std::string GridOperator;
|
||||||
|
float ConsumptionNetPrice{0.0f};
|
||||||
|
float GenerationNetPrice{0.0f};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Metadata() = default;
|
Metadata() = default;
|
||||||
|
|
||||||
std::string name() const;
|
std::string name() const;
|
||||||
|
void set_name(const std::string& name);
|
||||||
void set_name(const std::string &name);
|
|
||||||
|
|
||||||
float annual_consumption() const;
|
float annual_consumption() const;
|
||||||
|
|
||||||
void set_annual_consumption(float annual_consumption);
|
void set_annual_consumption(float annual_consumption);
|
||||||
|
|
||||||
float annual_generation() const;
|
float annual_generation() const;
|
||||||
|
|
||||||
void set_annual_generation(float annual_generation);
|
void set_annual_generation(float annual_generation);
|
||||||
|
|
||||||
std::vector<float> &consumption_profile();
|
std::vector<float>& consumption_profile();
|
||||||
|
|
||||||
void set_consumption_profile(std::vector<float> consumption_profile);
|
void set_consumption_profile(std::vector<float> consumption_profile);
|
||||||
|
|
||||||
std::vector<float> &generation_profile();
|
std::vector<float>& generation_profile();
|
||||||
|
|
||||||
void set_generation_profile(std::vector<float> generation_profile);
|
void set_generation_profile(std::vector<float> generation_profile);
|
||||||
|
|
||||||
std::string consumption_profile_name() const;
|
std::string consumption_profile_name() const;
|
||||||
|
void set_consumption_profile_name(const std::string& consumption_profile_name);
|
||||||
void set_consumption_profile_name(const std::string &consumption_profile_name);
|
|
||||||
|
|
||||||
std::string generation_profile_name() const;
|
std::string generation_profile_name() const;
|
||||||
|
void set_generation_profile_name(const std::string& generation_profile_name);
|
||||||
void set_generation_profile_name(const std::string &generation_profile_name);
|
|
||||||
|
|
||||||
short connection_power() const;
|
short connection_power() const;
|
||||||
|
|
||||||
void set_connection_power(short connection_power);
|
void set_connection_power(short connection_power);
|
||||||
|
|
||||||
short grid_power() const;
|
short grid_power() const;
|
||||||
|
|
||||||
void set_grid_power(short grid_power);
|
void set_grid_power(short grid_power);
|
||||||
|
|
||||||
float special_rate_consumption() const;
|
float special_rate_consumption() const;
|
||||||
|
|
||||||
void set_special_rate_consumption(float special_rate_consumption);
|
void set_special_rate_consumption(float special_rate_consumption);
|
||||||
|
|
||||||
float special_rate_generation() const;
|
float special_rate_generation() const;
|
||||||
|
|
||||||
void set_special_rate_generation(float special_rate_generation);
|
void set_special_rate_generation(float special_rate_generation);
|
||||||
|
|
||||||
|
short grid_level() const;
|
||||||
|
void set_grid_level(short value);
|
||||||
|
|
||||||
|
std::string grid_operator();
|
||||||
|
void set_grid_operator(std::string value);
|
||||||
|
|
||||||
|
float consumption_net_price() const;
|
||||||
|
void set_consumption_net_price(float value);
|
||||||
|
|
||||||
|
float generation_net_price() const;
|
||||||
|
void set_generation_net_price(float value);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Base : public Model<Base> {
|
class Base : public Model<Base>
|
||||||
|
{
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Cost> Cost{};
|
std::unique_ptr<Cost> Cost{};
|
||||||
std::unique_ptr<Simulation_Values> Values{};
|
std::shared_ptr<Simulation_Values> Values{};
|
||||||
std::unique_ptr<Metadata> Metadata{};
|
std::shared_ptr<Metadata> Metadata{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::unique_ptr<Building::Cost> &cost();
|
std::unique_ptr<Building::Cost>& cost();
|
||||||
|
|
||||||
void set_cost(std::unique_ptr<Building::Cost> cost);
|
void set_cost(std::unique_ptr<Building::Cost> cost);
|
||||||
|
|
||||||
std::unique_ptr<Simulation_Values> &values();
|
std::shared_ptr<Building::Simulation_Values>& values();
|
||||||
|
|
||||||
void set_values(std::unique_ptr<Simulation_Values> values);
|
void set_values(std::shared_ptr<Simulation_Values> values);
|
||||||
|
|
||||||
std::unique_ptr<Building::Metadata> &metadata();
|
std::shared_ptr<Building::Metadata>& metadata();
|
||||||
|
|
||||||
void set_metadata(std::unique_ptr<Building::Metadata> metadata);
|
void set_metadata(const std::shared_ptr<Building::Metadata>& metadata);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ class Energy_Tariff {
|
|||||||
public:
|
public:
|
||||||
float consumption_tariff{0.0f};
|
float consumption_tariff{0.0f};
|
||||||
float generation_tariff{0.0f};
|
float generation_tariff{0.0f};
|
||||||
|
float bill_charge;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
11
src/services/Cost/BillCharge.cpp
Normal file
11
src/services/Cost/BillCharge.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
//
|
||||||
|
// Created by stani on 3/12/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "BillCharge.h"
|
||||||
|
|
||||||
|
void BillCharge::apply(std::unique_ptr<Building::Base>& building, std::unique_ptr<Community>& community)
|
||||||
|
{
|
||||||
|
const std::shared_ptr<CostHistory>& valuesWith = building->cost()->get_cost_values_with();
|
||||||
|
valuesWith->add_cost_point("Bill charge",1.0,community->energy_tariff().bill_charge);
|
||||||
|
}
|
||||||
17
src/services/Cost/BillCharge.h
Normal file
17
src/services/Cost/BillCharge.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
//
|
||||||
|
// Created by stani on 3/12/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef BILLCHARGE_H
|
||||||
|
#define BILLCHARGE_H
|
||||||
|
#include "../../interfaces/ICostComponent.h"
|
||||||
|
|
||||||
|
|
||||||
|
class BillCharge : public ICostComponent {
|
||||||
|
public:
|
||||||
|
void apply(std::unique_ptr<Building::Base>& building, std::unique_ptr<Community>& community) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //BILLCHARGE_H
|
||||||
@ -5,14 +5,19 @@
|
|||||||
#include "NetworkProvider.h"
|
#include "NetworkProvider.h"
|
||||||
|
|
||||||
|
|
||||||
void NetworkProvider::apply(std::unique_ptr<Building::Base> &building, std::unique_ptr<Community> &community) {
|
void NetworkProvider::apply(std::unique_ptr<Building::Base>& building, std::unique_ptr<Community>& community)
|
||||||
std::shared_ptr<Building::CostValues> &valuesWith = building->cost()->get_cost_values_with();
|
{
|
||||||
std::shared_ptr<Building::CostValues> &valuesWithout = building->cost()->get_cost_values_without();
|
const std::shared_ptr<CostHistory>& valuesWith = building->cost()->get_cost_values_with();
|
||||||
|
const std::shared_ptr<CostHistory>& valuesWithout = building->cost()->get_cost_values_without();
|
||||||
|
const std::shared_ptr<Building::Metadata>& metadata = building->metadata();
|
||||||
|
const std::shared_ptr<Building::Simulation_Values>& values = building->values();
|
||||||
|
//With Community
|
||||||
|
valuesWith->add_cost_point("Net Consumption",metadata->consumption_net_price(),values->consumption_after_community_sum());
|
||||||
|
valuesWith->add_cost_point("Net Generation",metadata->consumption_net_price(),values->consumption_after_community_sum());
|
||||||
|
valuesWith->add_cost_point("Community Consumption", community->energy_tariff().consumption_tariff, values->consumption_after_community_sum());
|
||||||
|
valuesWith->add_cost_point("Generation Consumption", -community->energy_tariff().generation_tariff, values->generation_after_community_sum());
|
||||||
|
|
||||||
//Todo tariffs
|
//Without Community
|
||||||
valuesWithout->set_consumption(building->values()->needed_con_sum()*building->metadata()->special_rate_consumption());
|
valuesWithout->add_cost_point("Net Consumption",metadata->consumption_net_price(),values->needed_con_sum());
|
||||||
valuesWithout->set_generation(building->values()->needed_gen_sum()*-building->metadata()->special_rate_generation());
|
valuesWithout->add_cost_point("Net Generation",metadata->generation_net_price(),values->needed_gen_sum());
|
||||||
|
|
||||||
valuesWithout->set_consumption(building->values()->generation_to_community_sum()*-community->energy_tariff().consumption_tariff);
|
|
||||||
valuesWithout->set_generation(building->values()->consumption_from_community_sum()*-community->energy_tariff().generation_tariff);
|
|
||||||
}
|
}
|
||||||
|
|||||||
5
src/services/CostHistory.cpp
Normal file
5
src/services/CostHistory.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
//
|
||||||
|
// Created by stani on 3/12/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "CostHistory.h"
|
||||||
50
src/services/CostHistory.h
Normal file
50
src/services/CostHistory.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
//
|
||||||
|
// Created by stani on 3/12/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef COSTHISTORY_H
|
||||||
|
#define COSTHISTORY_H
|
||||||
|
#include <numeric>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
|
class CostHistory {
|
||||||
|
public:
|
||||||
|
struct CostPoint {
|
||||||
|
std::string name;
|
||||||
|
double value;
|
||||||
|
double amount;
|
||||||
|
|
||||||
|
CostPoint(std::string name, double value, double amount)
|
||||||
|
: name(std::move(name)), value(value), amount(amount) {}
|
||||||
|
|
||||||
|
double total() const {
|
||||||
|
return value * amount;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<CostPoint> costPoints;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void add_cost_point(const std::string &name, double value, double amount) {
|
||||||
|
if (amount==0.0) return;
|
||||||
|
costPoints.emplace_back(name, value, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
double total_cost() const {
|
||||||
|
return std::accumulate(costPoints.begin(), costPoints.end(), 0.0,
|
||||||
|
[](double sum, const CostPoint &point) {
|
||||||
|
return sum + point.total();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<CostPoint> &get_cost_points() const {
|
||||||
|
return costPoints;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //COSTHISTORY_H
|
||||||
Reference in New Issue
Block a user