79 lines
3.2 KiB
Plaintext
79 lines
3.2 KiB
Plaintext
@implements IAsyncDisposable
|
|
|
|
<div>
|
|
@if (State.Conveyor.WriteError != null)
|
|
{
|
|
<MudAlert Severity="Severity.Error" Dense="true" Class="mt-1" Style="font-size:0.7rem;">
|
|
@State.Conveyor.WriteError
|
|
</MudAlert>
|
|
}
|
|
|
|
<MudText Typo="Typo.caption" Class="sec-title mt-2">Conveyor 1</MudText>
|
|
<div class="op-grid-3">
|
|
@CoilBtn("Ready", () => State.Conveyor.C1Ready, (v) => SetCoil("c1", "ready", v))
|
|
@CoilBtn("In", () => State.Conveyor.C1In, (v) => SetCoil("c1", "in", v))
|
|
@CoilBtn("Out", () => State.Conveyor.C1Out, (v) => SetCoil("c1", "out", v))
|
|
@CoilBtn("IMRin", () => State.Conveyor.C1IMRin, (v) => SetCoil("c1", "imr-in", v))
|
|
@CoilBtn("IMRout", () => State.Conveyor.C1IMRout, (v) => SetCoil("c1", "imr-out", v))
|
|
@CoilBtn("Goods", () => State.Conveyor.C1HasGoods, (v) => SetCoil("c1", "has-goods", v))
|
|
@CoilBtn("Empty", () => State.Conveyor.C1NotGoods, (v) => SetCoil("c1", "not-goods", v))
|
|
</div>
|
|
|
|
<MudText Typo="Typo.caption" Class="sec-title mt-2">Conveyor 2</MudText>
|
|
<div class="op-grid-3">
|
|
@CoilBtn("Ready", () => State.Conveyor.C2Ready, (v) => SetCoil("c2", "ready", v))
|
|
@CoilBtn("In", () => State.Conveyor.C2In, (v) => SetCoil("c2", "in", v))
|
|
@CoilBtn("Out", () => State.Conveyor.C2Out, (v) => SetCoil("c2", "out", v))
|
|
@CoilBtn("Goods", () => State.Conveyor.C2HasGoods, (v) => SetCoil("c2", "has-goods", v))
|
|
@CoilBtn("Empty", () => State.Conveyor.C2NotGoods, (v) => SetCoil("c2", "not-goods", v))
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter] public bool? ReadOnly { get; set; }
|
|
|
|
[Inject] StateService State { get; set; } = default!;
|
|
[Inject] CommandService Cmd { get; set; } = default!;
|
|
|
|
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 Refresh() => InvokeAsync(StateHasChanged);
|
|
|
|
private bool IsDisabled => ReadOnly ?? (State.Workflow.IsRunning || !State.CanControl);
|
|
|
|
private Task SetCoil(string c, string coil, bool v) => Cmd.ConveyorSetCoilAsync(c, coil, v);
|
|
|
|
private RenderFragment CoilBtn(string label, Func<bool?> getter, Action<bool> setter) => __builder =>
|
|
{
|
|
bool on = getter() == true;
|
|
<MudButton Size="Size.Small"
|
|
Variant="@(on ? Variant.Filled : Variant.Outlined)"
|
|
Color="@(on ? Color.Success : Color.Default)"
|
|
Disabled="@IsDisabled"
|
|
OnClick="@(() => setter(!on))">
|
|
@label
|
|
</MudButton>
|
|
};
|
|
}
|
|
|
|
<style>
|
|
.sec-title { display:block; color:#9CA3AF; margin-bottom:4px; }
|
|
.op-grid-3 { display:grid; grid-template-columns:repeat(3, 1fr); gap:5px; }
|
|
</style>
|