Compare commits
No commits in common. "3cf82b3153951daf294b3c60274021900c6ee6e4" and "efebd4221b3b3b434648bea01836e569e2d903e9" have entirely different histories.
3cf82b3153
...
efebd4221b
|
@ -98,15 +98,10 @@ public static class Aggregator
|
||||||
private static AggregatedData CreateAverage(String myDirectory, Int64 afterTimestamp, Int64 beforeTimestamp)
|
private static AggregatedData CreateAverage(String myDirectory, Int64 afterTimestamp, Int64 beforeTimestamp)
|
||||||
{
|
{
|
||||||
// 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 socAverage = new List<Double>();
|
||||||
var batteryAvgSoc = new List<Double>(); // this is only used for the daily data.
|
var pvPowerAverage = new List<Double>();
|
||||||
var pvPowerAverage = new List<Double>();
|
var batteryPowerAverage = new List<Double>();
|
||||||
var gridPowerImport = new List<Double>();
|
|
||||||
var gridPowerExport = new List<Double>();
|
|
||||||
var batteryDischargePower = new List<Double>();
|
|
||||||
var batteryChargePower = new List<Double>();
|
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine("-----------------------------------------------------------------------------------------------------------------");
|
Console.WriteLine("-----------------------------------------------------------------------------------------------------------------");
|
||||||
Console.WriteLine("File timestamp should start after "+ afterTimestamp);
|
Console.WriteLine("File timestamp should start after "+ afterTimestamp);
|
||||||
|
@ -137,41 +132,18 @@ public static class Aggregator
|
||||||
{
|
{
|
||||||
switch (variableName)
|
switch (variableName)
|
||||||
{
|
{
|
||||||
case "/Battery/Soc" or "/MinSoc" or "/MaxSoc":
|
case "/Battery/Soc" or "/AvgSoc":
|
||||||
batterySoc.Add(value);
|
socAverage.Add(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "/AvgSoc":
|
case "/PvOnDc/Dc/Power" or "/AvgPvPower":
|
||||||
batteryAvgSoc.Add(value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "/PvOnDc/Dc/Power" or "/SumPvPower":
|
|
||||||
pvPowerAverage.Add(value);
|
pvPowerAverage.Add(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "/Battery/Dc/Power" or "/SumDischargingBatteryPower" or "/SumChargingBatteryPower":
|
case "/Battery/Dc/Power" or "/BatteryPowerAverage":
|
||||||
if (value < 0)
|
batteryPowerAverage.Add(value);
|
||||||
{
|
|
||||||
batteryDischargePower.Add(value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
batteryChargePower.Add(value);
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
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
|
// Add more cases as needed
|
||||||
default:
|
default:
|
||||||
// Code to execute when variableName doesn't match any condition
|
// Code to execute when variableName doesn't match any condition
|
||||||
|
@ -197,29 +169,15 @@ public static class Aggregator
|
||||||
|
|
||||||
AggregatedData aggregatedData = new AggregatedData
|
AggregatedData aggregatedData = new AggregatedData
|
||||||
{
|
{
|
||||||
MaxSoc = batterySoc.Any() ? batterySoc.Max() : 0.0,
|
AvgSoc = socAverage.Any() ? socAverage.Average() : 0.0,
|
||||||
MinSoc = batterySoc.Any() ? batterySoc.Min() : 0.0,
|
AvgPvPower = pvPowerAverage.Any() ? pvPowerAverage.Average() : 0.0,
|
||||||
AvgSoc = batteryAvgSoc.Any() ? batteryAvgSoc.Average() : 0.0,
|
BatteryPowerAverage = batteryPowerAverage.Any() ? batteryPowerAverage.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,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Print the stored CSV data for verification
|
// Print the stored CSV data for verification
|
||||||
Console.WriteLine($"Max SOC: {aggregatedData.MaxSoc}");
|
Console.WriteLine($"SOC: {aggregatedData.AvgSoc}");
|
||||||
Console.WriteLine($"Min SOC: {aggregatedData.MinSoc}");
|
Console.WriteLine($"PvPower: {aggregatedData.AvgPvPower}");
|
||||||
|
Console.WriteLine($"Battery: {aggregatedData.BatteryPowerAverage}");
|
||||||
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("CSV data reading and storage completed.");
|
Console.WriteLine("CSV data reading and storage completed.");
|
||||||
Console.WriteLine("-----------------------------------------------------------------------------------------------------------------");
|
Console.WriteLine("-----------------------------------------------------------------------------------------------------------------");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue