Update aggregate data naming and calculation
This commit is contained in:
parent
b61ca9264e
commit
08408e61d5
|
@ -101,7 +101,7 @@ public static class Aggregator
|
||||||
// Get all CSV files in the specified directory
|
// Get all CSV files in the specified directory
|
||||||
var csvFiles = Directory.GetFiles(myDirectory, "*.csv");
|
var csvFiles = Directory.GetFiles(myDirectory, "*.csv");
|
||||||
var batterySoc = new List<Double>();
|
var batterySoc = new List<Double>();
|
||||||
var pvPowerAverage = new List<Double>();
|
var pvPowerSum = new List<Double>();
|
||||||
var heatingPower = new List<Double>();
|
var heatingPower = new List<Double>();
|
||||||
var gridPowerImport = new List<Double>();
|
var gridPowerImport = new List<Double>();
|
||||||
var gridPowerExport = new List<Double>();
|
var gridPowerExport = new List<Double>();
|
||||||
|
@ -143,7 +143,7 @@ public static class Aggregator
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "/PvOnDc/DcWh" :
|
case "/PvOnDc/DcWh" :
|
||||||
pvPowerAverage.Add(value);
|
pvPowerSum.Add(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "/Battery/Dc/Power":
|
case "/Battery/Dc/Power":
|
||||||
|
@ -163,7 +163,6 @@ public static class Aggregator
|
||||||
// we are using different register to check which value from the grid meter we need to use
|
// we are using different register to check which value from the grid meter we need to use
|
||||||
gridPowerExport.Add(value);
|
gridPowerExport.Add(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "/GridMeter/ActivePowerImportT2":
|
case "/GridMeter/ActivePowerImportT2":
|
||||||
gridPowerImport.Add(value);
|
gridPowerImport.Add(value);
|
||||||
break;
|
break;
|
||||||
|
@ -203,35 +202,35 @@ public static class Aggregator
|
||||||
|
|
||||||
var dischargingEnergy = (batteryDischargePower.Any() ? batteryDischargePower.Average() : 0.0) / 3600;
|
var dischargingEnergy = (batteryDischargePower.Any() ? batteryDischargePower.Average() : 0.0) / 3600;
|
||||||
var chargingEnergy = (batteryChargePower.Any() ? batteryChargePower.Average() : 0.0) / 3600;
|
var chargingEnergy = (batteryChargePower.Any() ? batteryChargePower.Average() : 0.0) / 3600;
|
||||||
|
|
||||||
var heatingPowerAvg = (heatingPower.Any() ? heatingPower.Average() : 0.0) / 3600;
|
var heatingPowerAvg = (heatingPower.Any() ? heatingPower.Average() : 0.0) / 3600;
|
||||||
|
|
||||||
var dMaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0;
|
var dMaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0;
|
||||||
var dMinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0;
|
var dMinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0;
|
||||||
var dSumGridExportPower = gridPowerExport.Any() ? (gridPowerExport.Max() - gridPowerExport.Min()) / 1000 : 0.0;
|
var dSumGridExportPower = gridPowerExport.Any() ? gridPowerExport.Max() : 0.0;
|
||||||
var dSumGridImportPower = gridPowerImport.Any() ? (gridPowerImport.Max() - gridPowerImport.Min()) / 1000 : 0.0;
|
var dSumGridImportPower = gridPowerImport.Any() ? gridPowerImport.Max() : 0.0;
|
||||||
var dSumPvPower = pvPowerAverage.Any() ? pvPowerAverage.Average() /1000 : 0.0;
|
var dSumPvPower = pvPowerSum.Any() ? pvPowerSum.Max() : 0.0;
|
||||||
|
|
||||||
AggregatedData aggregatedData = new AggregatedData
|
AggregatedData aggregatedData = new AggregatedData
|
||||||
{
|
{
|
||||||
MaxSoc = dMaxSoc,
|
MaxSoc = dMaxSoc,
|
||||||
MinSoc = dMinSoc,
|
MinSoc = dMinSoc,
|
||||||
SumDischargingBatteryPower = dischargingEnergy,
|
DischargingBatteryPower = dischargingEnergy,
|
||||||
SumChargingBatteryPower = chargingEnergy,
|
ChargingBatteryPower = chargingEnergy,
|
||||||
SumGridExportPower = dSumGridExportPower,
|
GridExportPower = dSumGridExportPower,
|
||||||
SumGridImportPower = dSumGridImportPower,
|
GridImportPower = dSumGridImportPower,
|
||||||
SumPvPower = dSumPvPower,
|
PvPower = dSumPvPower,
|
||||||
HeatingPowerAvg = heatingPowerAvg
|
HeatingPower = heatingPowerAvg
|
||||||
};
|
};
|
||||||
|
|
||||||
// Print the stored CSV data for verification
|
// Print the stored CSV data for verification
|
||||||
Console.WriteLine($"Max SOC: {aggregatedData.MaxSoc}");
|
Console.WriteLine($"Max SOC: {aggregatedData.MaxSoc}");
|
||||||
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
||||||
|
|
||||||
Console.WriteLine($"ChargingBatteryPower: {aggregatedData.SumDischargingBatteryPower}");
|
Console.WriteLine($"ChargingBatteryPower: {aggregatedData.DischargingBatteryPower}");
|
||||||
Console.WriteLine($"DischargingBatteryBattery: {aggregatedData.SumChargingBatteryPower}");
|
Console.WriteLine($"DischargingBatteryBattery: {aggregatedData.ChargingBatteryPower}");
|
||||||
|
|
||||||
Console.WriteLine($"SumGridExportPower: {aggregatedData.SumGridExportPower}");
|
Console.WriteLine($"SumGridExportPower: {aggregatedData.GridExportPower}");
|
||||||
Console.WriteLine($"SumGridImportPower: {aggregatedData.SumGridImportPower}");
|
Console.WriteLine($"SumGridImportPower: {aggregatedData.GridImportPower}");
|
||||||
|
|
||||||
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
||||||
|
|
||||||
|
@ -247,7 +246,7 @@ public static class Aggregator
|
||||||
// Get all CSV files in the specified directory
|
// Get all CSV files in the specified directory
|
||||||
var csvFiles = Directory.GetFiles(myDirectory, "*.csv");
|
var csvFiles = Directory.GetFiles(myDirectory, "*.csv");
|
||||||
var batterySoc = new List<Double>();
|
var batterySoc = new List<Double>();
|
||||||
var pvPowerAverage = new List<Double>();
|
var pvPower = new List<Double>();
|
||||||
var gridPowerImport = new List<Double>();
|
var gridPowerImport = new List<Double>();
|
||||||
var gridPowerExport = new List<Double>();
|
var gridPowerExport = new List<Double>();
|
||||||
var batteryDischargePower = new List<Double>();
|
var batteryDischargePower = new List<Double>();
|
||||||
|
@ -289,7 +288,7 @@ public static class Aggregator
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "/SumPvPower":
|
case "/SumPvPower":
|
||||||
pvPowerAverage.Add(value);
|
pvPower.Add(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "/SumDischargingBatteryPower" :
|
case "/SumDischargingBatteryPower" :
|
||||||
|
@ -338,23 +337,23 @@ public static class Aggregator
|
||||||
{
|
{
|
||||||
MaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0,
|
MaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0,
|
||||||
MinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0,
|
MinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0,
|
||||||
SumDischargingBatteryPower = batteryDischargePower.Any() ? batteryDischargePower.Average(): 0.0,
|
DischargingBatteryPower = batteryDischargePower.Any() ? batteryDischargePower.Average(): 0.0,
|
||||||
SumChargingBatteryPower = batteryChargePower.Any() ? batteryChargePower.Average() : 0.0,
|
ChargingBatteryPower = batteryChargePower.Any() ? batteryChargePower.Average() : 0.0,
|
||||||
SumGridExportPower = gridPowerExport.Any() ? gridPowerExport.Average() : 0.0,
|
GridExportPower = gridPowerExport.Any() ? gridPowerExport.Max() : 0.0,
|
||||||
SumGridImportPower = gridPowerImport.Any() ? gridPowerImport.Average() : 0.0,
|
GridImportPower = gridPowerImport.Any() ? gridPowerImport.Max() : 0.0,
|
||||||
SumPvPower = pvPowerAverage.Any() ? pvPowerAverage.Average() : 0.0,
|
PvPower = pvPower.Any() ? pvPower.Max() : 0.0,
|
||||||
HeatingPowerAvg = heatingPowerAvg.Any() ? heatingPowerAvg.Average() : 0.0,
|
HeatingPower = heatingPowerAvg.Any() ? heatingPowerAvg.Average() : 0.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Print the stored CSV data for verification
|
// Print the stored CSV data for verification
|
||||||
Console.WriteLine($"Max SOC: {aggregatedData.MaxSoc}");
|
Console.WriteLine($"Max SOC: {aggregatedData.MaxSoc}");
|
||||||
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
||||||
|
|
||||||
Console.WriteLine($"ChargingBatteryPower: {aggregatedData.SumDischargingBatteryPower}");
|
Console.WriteLine($"ChargingBatteryPower: {aggregatedData.DischargingBatteryPower}");
|
||||||
Console.WriteLine($"DischargingBatteryBattery: {aggregatedData.SumChargingBatteryPower}");
|
Console.WriteLine($"DischargingBatteryBattery: {aggregatedData.ChargingBatteryPower}");
|
||||||
|
|
||||||
Console.WriteLine($"SumGridExportPower: {aggregatedData.SumGridExportPower}");
|
Console.WriteLine($"SumGridExportPower: {aggregatedData.GridExportPower}");
|
||||||
Console.WriteLine($"SumGridImportPower: {aggregatedData.SumGridImportPower}");
|
Console.WriteLine($"SumGridImportPower: {aggregatedData.GridImportPower}");
|
||||||
|
|
||||||
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue