76 lines
2.4 KiB
Plaintext
76 lines
2.4 KiB
Plaintext
@using RobotNet.VDA5050.State
|
|
|
|
<MudPaper Class="pa-4" Elevation="2">
|
|
@if (ShowNameCard)
|
|
{
|
|
<MudText Typo="Typo.h6" Class="mb-3">Battery State</MudText>
|
|
}
|
|
@if (BatteryState != null)
|
|
{
|
|
<MudSimpleTable Elevation="0">
|
|
<tbody>
|
|
<tr>
|
|
<td><strong>Charge:</strong></td>
|
|
<td>
|
|
<MudProgressLinear Value="@BatteryState.BatteryCharge"
|
|
Color="@GetBatteryColor(BatteryState.BatteryCharge)" />
|
|
@BatteryState.BatteryCharge.ToString("F1")%
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Voltage:</strong></td>
|
|
<td>@BatteryState.BatteryVoltage?.ToString("F2") V</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Health:</strong></td>
|
|
<td>@BatteryState.BatteryHealth.ToString("F1")%</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Charging:</strong></td>
|
|
<td>
|
|
@if (BatteryState.Charging)
|
|
{
|
|
<MudChip T="string" Size="Size.Small" Color="Color.Info">Yes</MudChip>
|
|
}
|
|
else
|
|
{
|
|
<MudChip T="string" Size="Size.Small" Color="Color.Default">No</MudChip>
|
|
}
|
|
</td>
|
|
</tr>
|
|
@if (BatteryState.Reach > 0)
|
|
{
|
|
<tr>
|
|
<td><strong>Reach:</strong></td>
|
|
<td>@BatteryState.Reach?.ToString("F0") m</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</MudSimpleTable>
|
|
}
|
|
else
|
|
{
|
|
<MudText Typo="Typo.body2" Align="Align.Center">No battery data available</MudText>
|
|
}
|
|
</MudPaper>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public bool ShowNameCard { get; set; } = true;
|
|
|
|
public BatteryState? BatteryState { get; set; }
|
|
|
|
private Color GetBatteryColor(double charge)
|
|
{
|
|
if (charge > 50) return Color.Success;
|
|
if (charge > 20) return Color.Warning;
|
|
return Color.Error;
|
|
}
|
|
|
|
public void Update(BatteryState? batteryState)
|
|
{
|
|
BatteryState = batteryState;
|
|
StateHasChanged();
|
|
}
|
|
}
|