Compare commits

..

No commits in common. "3cf82b3153951daf294b3c60274021900c6ee6e4" and "efebd4221b3b3b434648bea01836e569e2d903e9" have entirely different histories.

1 changed files with 16 additions and 58 deletions

View File

@ -99,14 +99,9 @@ public static class Aggregator
{
// Get all CSV files in the specified directory
var csvFiles = Directory.GetFiles(myDirectory, "*.csv");
var batterySoc = new List<Double>();
var batteryAvgSoc = new List<Double>(); // this is only used for the daily data.
var socAverage = new List<Double>();
var pvPowerAverage = new List<Double>();
var gridPowerImport = new List<Double>();
var gridPowerExport = new List<Double>();
var batteryDischargePower = new List<Double>();
var batteryChargePower = new List<Double>();
var batteryPowerAverage = new List<Double>();
Console.WriteLine("-----------------------------------------------------------------------------------------------------------------");
Console.WriteLine("File timestamp should start after "+ afterTimestamp);
@ -137,41 +132,18 @@ public static class Aggregator
{
switch (variableName)
{
case "/Battery/Soc" or "/MinSoc" or "/MaxSoc":
batterySoc.Add(value);
case "/Battery/Soc" or "/AvgSoc":
socAverage.Add(value);
break;
case "/AvgSoc":
batteryAvgSoc.Add(value);
break;
case "/PvOnDc/Dc/Power" or "/SumPvPower":
case "/PvOnDc/Dc/Power" or "/AvgPvPower":
pvPowerAverage.Add(value);
break;
case "/Battery/Dc/Power" or "/SumDischargingBatteryPower" or "/SumChargingBatteryPower":
if (value < 0)
{
batteryDischargePower.Add(value);
}
else
{
batteryChargePower.Add(value);
}
case "/Battery/Dc/Power" or "/BatteryPowerAverage":
batteryPowerAverage.Add(value);
break;
case "/GridMeter/Ac/Power/Active" or "/SumGridExportPower" or "/SumGridImportPower":
if (value < 0)
{
gridPowerExport.Add(value);
}
else
{
gridPowerImport.Add(value);
}
break;
// Add more cases as needed
default:
// Code to execute when variableName doesn't match any condition
@ -197,29 +169,15 @@ public static class Aggregator
AggregatedData aggregatedData = new AggregatedData
{
MaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0,
MinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0,
AvgSoc = batteryAvgSoc.Any() ? batteryAvgSoc.Average() : 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,
AvgSoc = socAverage.Any() ? socAverage.Average() : 0.0,
AvgPvPower = pvPowerAverage.Any() ? pvPowerAverage.Average() : 0.0,
BatteryPowerAverage = batteryPowerAverage.Any() ? batteryPowerAverage.Average() : 0.0
};
// Print the stored CSV data for verification
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($"Min SOC: {aggregatedData.MinSoc}");
Console.WriteLine($"SOC: {aggregatedData.AvgSoc}");
Console.WriteLine($"PvPower: {aggregatedData.AvgPvPower}");
Console.WriteLine($"Battery: {aggregatedData.BatteryPowerAverage}");
Console.WriteLine("CSV data reading and storage completed.");
Console.WriteLine("-----------------------------------------------------------------------------------------------------------------");