97 lines
2.9 KiB
Plaintext
97 lines
2.9 KiB
Plaintext
@implements IAsyncDisposable
|
|
|
|
<MudPaper Elevation="0" Class="pa-3" Style="background:transparent;">
|
|
|
|
<MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center"
|
|
Style="cursor:pointer" @onclick="ToggleExpand">
|
|
<MudText Typo="Typo.subtitle1">CONVEYOR</MudText>
|
|
<MudIcon Icon="@(_expanded ? Icons.Material.Filled.ExpandMore : Icons.Material.Filled.ExpandLess)" Size="Size.Small" />
|
|
</MudStack>
|
|
|
|
<div class="status-row mt-2">
|
|
<MudIcon Icon="@Icons.Material.Filled.Circle" Size="Size.Small" Color="@StatusColor" />
|
|
<div>
|
|
<MudText Typo="Typo.caption">@StatusText.ToUpper()</MudText>
|
|
<MudText Typo="Typo.caption" Style="color:#9a9a9a;">@DetailText</MudText>
|
|
</div>
|
|
</div>
|
|
|
|
@if (_expanded)
|
|
{
|
|
<ConveyorPanel />
|
|
}
|
|
|
|
</MudPaper>
|
|
|
|
@code {
|
|
[Inject] StateService State { get; set; } = default!;
|
|
|
|
private bool _expanded = true;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await State.StartAsync();
|
|
State.ConveyorChanged += Refresh;
|
|
State.WorkflowChanged += Refresh;
|
|
State.SystemChanged += Refresh;
|
|
State.LockStateChanged += Refresh;
|
|
}
|
|
|
|
public ValueTask DisposeAsync()
|
|
{
|
|
State.ConveyorChanged -= Refresh;
|
|
State.WorkflowChanged -= Refresh;
|
|
State.SystemChanged -= Refresh;
|
|
State.LockStateChanged -= Refresh;
|
|
return ValueTask.CompletedTask;
|
|
}
|
|
|
|
private void ToggleExpand() => _expanded = !_expanded;
|
|
|
|
private void Refresh() => InvokeAsync(StateHasChanged);
|
|
|
|
private bool C1Online => State.Conveyor.C1Out != null;
|
|
private bool C2Online => State.Conveyor.C2Out != null;
|
|
|
|
private bool AnyRunning =>
|
|
State.Conveyor.C1In == true ||
|
|
State.Conveyor.C1Out == true ||
|
|
State.Conveyor.C1IMRin == true ||
|
|
State.Conveyor.C1IMRout == true ||
|
|
State.Conveyor.C2In == true ||
|
|
State.Conveyor.C2Out == true;
|
|
|
|
private string StatusText
|
|
{
|
|
get
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(State.Conveyor.WriteError)) return "error";
|
|
if (AnyRunning) return "running";
|
|
if (C1Online || C2Online) return "ok";
|
|
return "off";
|
|
}
|
|
}
|
|
|
|
private Color StatusColor => StatusText switch
|
|
{
|
|
"ok" => Color.Success,
|
|
"running" => Color.Info,
|
|
"error" => Color.Error,
|
|
_ => Color.Default
|
|
};
|
|
|
|
private string DetailText =>
|
|
$"C1: {LineState(C1Online, State.Conveyor.C1In, State.Conveyor.C1Out, State.Conveyor.C1IMRin, State.Conveyor.C1IMRout)} | " +
|
|
$"C2: {LineState(C2Online, State.Conveyor.C2In, State.Conveyor.C2Out)}";
|
|
|
|
private static string LineState(bool online, params bool?[] states)
|
|
{
|
|
if (!online) return "off";
|
|
return states.Any(v => v == true) ? "running" : "ready";
|
|
}
|
|
}
|
|
|
|
<style>
|
|
.status-row { display:flex; align-items:center; gap:8px; margin-bottom:4px; }
|
|
</style>
|