fixed chart names and added extra battery properties.
This commit is contained in:
110
Pages/Home.razor
110
Pages/Home.razor
@@ -9,32 +9,48 @@
|
||||
<h1>BattSim</h1>
|
||||
|
||||
<h2>Input Data</h2>
|
||||
<p>Upload your fluvius daily csv file here.</p>
|
||||
<InputFile OnChange="LoadCsvFile" accept=".csv"/>
|
||||
@if (_isLoadingFile){ <p>Loading...</p> }
|
||||
@if (EnergyData.Length != 0){
|
||||
<RadzenChart>
|
||||
<RadzenAreaSeries Smooth=true Data="@EnergyData" CategoryProperty="Time" Title="Consumption" ValueProperty="Consumption">
|
||||
<RadzenChartTooltipOptions Visible="true" />
|
||||
</RadzenAreaSeries>
|
||||
<RadzenAreaSeries Smooth=true Data="@EnergyData" CategoryProperty="Time" Title="Production" ValueProperty="Production">
|
||||
<RadzenChartTooltipOptions Visible="true" />
|
||||
</RadzenAreaSeries>
|
||||
<RadzenCategoryAxis Formatter="@FormatObject" Padding="20" LabelAutoRotation="-45">
|
||||
<RadzenAxisTitle Text="Time" />
|
||||
</RadzenCategoryAxis>
|
||||
<RadzenValueAxis Formatter="@FormatObject">
|
||||
<RadzenGridLines Visible="true" />
|
||||
<RadzenAxisTitle Text="Energy" />
|
||||
</RadzenValueAxis>
|
||||
</RadzenChart>
|
||||
}
|
||||
<div>
|
||||
<p>Upload your Fluvius quarterly csv file here. The longer the timeframe the longer it takes to process.</p>
|
||||
<InputFile OnChange="OnFileUploaded" accept=".csv"/>
|
||||
@if (_isLoadingFile)
|
||||
{
|
||||
<p>Loading...</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (FluviusDataRaw.Count != 0)
|
||||
{
|
||||
<p>@(FluviusDataRaw.Count) entries read.</p>
|
||||
}
|
||||
|
||||
@if (FluviusDataDaily.Count != 0)
|
||||
{
|
||||
<RadzenChart>
|
||||
<RadzenAreaSeries Smooth=true Data="@FluviusDataDaily.Values" CategoryProperty="Time" Title="Consumption" ValueProperty="Consumption">
|
||||
<RadzenChartTooltipOptions Visible="true"/>
|
||||
</RadzenAreaSeries>
|
||||
<RadzenAreaSeries Smooth=true Data="@FluviusDataDaily.Values" CategoryProperty="Time" Title="Production" ValueProperty="Production">
|
||||
<RadzenChartTooltipOptions Visible="true"/>
|
||||
</RadzenAreaSeries>
|
||||
<RadzenCategoryAxis Formatter="@FormatObject" Padding="20" LabelAutoRotation="-45">
|
||||
<RadzenGridLines Visible="true"/>
|
||||
<RadzenAxisTitle Text="Time"/>
|
||||
</RadzenCategoryAxis>
|
||||
<RadzenValueAxis Formatter="@FormatObject">
|
||||
<RadzenGridLines Visible="true"/>
|
||||
<RadzenAxisTitle Text="Energy"/>
|
||||
</RadzenValueAxis>
|
||||
</RadzenChart>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
@code{
|
||||
EnergyData[] EnergyData = [];
|
||||
Dictionary<DateTime, EnergyData> FluviusDataRaw = [];
|
||||
Dictionary<DateOnly, EnergyData> FluviusDataDaily = [];
|
||||
bool _isLoadingFile = false;
|
||||
|
||||
private async Task LoadCsvFile(InputFileChangeEventArgs e)
|
||||
private async Task OnFileUploaded(InputFileChangeEventArgs e)
|
||||
{
|
||||
var file = e.File;
|
||||
if (file.ContentType != "text/csv")
|
||||
@@ -48,11 +64,8 @@
|
||||
Console.WriteLine("Reading csv file...");
|
||||
_isLoadingFile = true;
|
||||
StateHasChanged();
|
||||
|
||||
var loadingTask = DataLoader.LoadAndProcessData(file);
|
||||
var energyData = await loadingTask;
|
||||
EnergyData = energyData.ToArray();
|
||||
|
||||
FluviusDataRaw = await FluviusDataHandler.LoadAndProcessFile(file);
|
||||
FluviusDataDaily = FluviusDataHandler.GenerateDailyData(FluviusDataRaw);
|
||||
_isLoadingFile = false;
|
||||
StateHasChanged();
|
||||
Console.WriteLine("Done reading csv file!");
|
||||
@@ -64,28 +77,45 @@
|
||||
}
|
||||
|
||||
private void OnSeriesClick(){}
|
||||
private string FormatObject(object value) {
|
||||
if(value is double d) return $"{value:0.##} kWh";
|
||||
if(value is DateOnly date) return (date.Day == 1) ? date.ToString("MM/yyyy") : string.Empty;
|
||||
else return string.Empty;
|
||||
private string FormatObject(object value) {
|
||||
if(value is double d) return $"{d:0.##} kWh";
|
||||
if(value is DateTime date) return date.ToString("dd/MM/yyyy");
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
<h2>Simulate Battery</h2>
|
||||
<p>Set the battery capacity</p>
|
||||
<InputNumber @bind-value="BatteryCapacity"/>
|
||||
<Button @onclick="SimulateBattery">Simulate</Button>
|
||||
|
||||
<h2>Calculate Cost</h2>
|
||||
|
||||
<div>
|
||||
<p>Generate adjusted energy data simulating the effect of a battery with properties as configured here:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Capacity: <InputNumber @bind-value="BatteryCapacity"/> kWh</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Discharge Rate: <InputNumber @bind-value="DischargeRate"/> kW</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Charge Rate: <InputNumber @bind-value="ChargeRate"/> kW</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Round-trip Efficiency: <InputNumber @bind-value="Efficiency"/> %</p>
|
||||
</li>
|
||||
</ul>
|
||||
<Button @onclick="SimulateBattery">Simulate</Button>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
double BatteryCapacity = 0.0;
|
||||
double BatteryCapacity = 7.5;
|
||||
double DischargeRate = 3;
|
||||
double ChargeRate = 3;
|
||||
double Efficiency = 90;
|
||||
BatteryDayResult[] SimulationData = [];
|
||||
|
||||
private async Task SimulateBattery(){
|
||||
Console.WriteLine("Simulating...");
|
||||
SimulationData = BatterySimulator.SimulateBattery(EnergyData, BatteryCapacity).ToArray();
|
||||
// SimulationData = BatterySimulator.SimulateBattery(EnergyData, BatteryCapacity).ToArray();
|
||||
Console.WriteLine("Done simulating!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<h2>Calculate Cost</h2>
|
||||
|
||||
Reference in New Issue
Block a user