Update the aggregate data
This commit is contained in:
parent
b0bd8fb3e2
commit
50eaf261a3
|
@ -1,3 +1,4 @@
|
|||
using InnovEnergy.App.SaliMax.Ess;
|
||||
using InnovEnergy.Lib.Utils;
|
||||
using static System.Double;
|
||||
|
||||
|
@ -141,11 +142,19 @@ public static class Aggregator
|
|||
batterySoc.Add(value);
|
||||
break;
|
||||
|
||||
case "/PvOnDc/Dc/Power" or "/SumPvPower":
|
||||
case "/PvOnDc/DcWh" or "/SumPvPower":
|
||||
pvPowerAverage.Add(value);
|
||||
break;
|
||||
|
||||
case "/Battery/Dc/Power" or "/SumDischargingBatteryPower" or "/SumChargingBatteryPower":
|
||||
|
||||
//Average Power (Watts)= Sum of Power Readings/Number of Readings
|
||||
|
||||
//Then, you can use the average power in the energy formula:
|
||||
//
|
||||
//Energy (kWh)= (Average Power / 3600) × Time (seconds)
|
||||
//
|
||||
// Dividing the Average power readings by 3600 converts the result from watt-seconds to kilowatt-hours.
|
||||
if (value < 0)
|
||||
{
|
||||
batteryDischargePower.Add(value);
|
||||
|
@ -157,16 +166,13 @@ public static class Aggregator
|
|||
}
|
||||
break;
|
||||
|
||||
case "/GridMeter/Ac/Power/Active" or "/SumGridExportPower" or "/SumGridImportPower":
|
||||
if (value < 0)
|
||||
{
|
||||
gridPowerExport.Add(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
gridPowerImport.Add(value);
|
||||
|
||||
}
|
||||
case "/GridMeter/ActivePowerExportT2" or "/SumGridExportPower":
|
||||
// we are using different register to check which value from the grid meter we need to use
|
||||
gridPowerExport.Add(value);
|
||||
break;
|
||||
|
||||
case "/GridMeter/ActivePowerImportT2" or "/SumGridImportPower":
|
||||
gridPowerImport.Add(value);
|
||||
break;
|
||||
// Add more cases as needed
|
||||
default:
|
||||
|
@ -190,29 +196,29 @@ public static class Aggregator
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AggregatedData aggregatedData = new AggregatedData
|
||||
{
|
||||
MaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0,
|
||||
MinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0,
|
||||
SumDischargingBatteryPower = batteryDischargePower.Any() ? batteryDischargePower.Sum() : 0.0,
|
||||
SumChargingBatteryPower = batteryChargePower.Any() ? batteryChargePower.Sum() : 0.0,
|
||||
SumGridExportPower = gridPowerExport.Any() ? gridPowerExport.Sum() : 0.0,
|
||||
SumGridImportPower = gridPowerImport.Any() ? gridPowerImport.Sum() : 0.0,
|
||||
SumPvPower = pvPowerAverage.Any() ? pvPowerAverage.Sum() : 0.0,
|
||||
MaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0,
|
||||
MinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0,
|
||||
SumDischargingBatteryPower = batteryDischargePower.Any() ? batteryDischargePower.Average(): 0.0,
|
||||
SumChargingBatteryPower = batteryChargePower.Any() ? batteryChargePower.Average() : 0.0,
|
||||
SumGridExportPower = gridPowerExport.Any() ? gridPowerExport.Average() : 0.0,
|
||||
SumGridImportPower = gridPowerImport.Any() ? gridPowerImport.Average() : 0.0,
|
||||
SumPvPower = pvPowerAverage.Any() ? pvPowerAverage.Average() : 0.0,
|
||||
};
|
||||
|
||||
// Print the stored CSV data for verification
|
||||
Console.WriteLine($"Max SOC: {aggregatedData.MaxSoc}");
|
||||
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
||||
Console.WriteLine($"Max SOC: {aggregatedData.MaxSoc}");
|
||||
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
||||
|
||||
Console.WriteLine($"ChargingBatteryPower: {aggregatedData.SumDischargingBatteryPower}");
|
||||
Console.WriteLine($"DischargingBatteryBattery: {aggregatedData.SumChargingBatteryPower}");
|
||||
|
||||
Console.WriteLine($"SumGridExportPower: {aggregatedData.SumGridExportPower}");
|
||||
Console.WriteLine($"SumGridImportPower: {aggregatedData.SumGridImportPower}");
|
||||
Console.WriteLine($"SumGridExportPower: {aggregatedData.SumGridExportPower}");
|
||||
Console.WriteLine($"SumGridImportPower: {aggregatedData.SumGridImportPower}");
|
||||
|
||||
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
||||
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
||||
|
||||
|
||||
Console.WriteLine("CSV data reading and storage completed.");
|
||||
|
|
Loading…
Reference in New Issue