122 lines
3.8 KiB
Plaintext
122 lines
3.8 KiB
Plaintext
@page "/"
|
|
@using Radzen
|
|
@using Radzen.Blazor
|
|
@using BattSim.Models
|
|
@using BattSim.Services
|
|
|
|
<PageTitle>BattSim</PageTitle>
|
|
|
|
<h1>BattSim</h1>
|
|
|
|
<h2>Input Data</h2>
|
|
<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{
|
|
Dictionary<DateTime, EnergyData> FluviusDataRaw = [];
|
|
Dictionary<DateOnly, EnergyData> FluviusDataDaily = [];
|
|
bool _isLoadingFile = false;
|
|
|
|
private async Task OnFileUploaded(InputFileChangeEventArgs e)
|
|
{
|
|
var file = e.File;
|
|
if (file.ContentType != "text/csv")
|
|
{
|
|
Console.WriteLine("Only CSV files are allowed!");
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
Console.WriteLine("Reading csv file...");
|
|
_isLoadingFile = true;
|
|
StateHasChanged();
|
|
FluviusDataRaw = await FluviusDataHandler.LoadAndProcessFile(file);
|
|
FluviusDataDaily = FluviusDataHandler.GenerateDailyData(FluviusDataRaw);
|
|
_isLoadingFile = false;
|
|
StateHasChanged();
|
|
Console.WriteLine("Done reading csv file!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine($"Error loading file: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
private void OnSeriesClick(){}
|
|
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>
|
|
<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 = 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();
|
|
Console.WriteLine("Done simulating!");
|
|
}
|
|
}
|
|
|
|
<h2>Calculate Cost</h2>
|