@implements IAsyncDisposable DOBOT
@DobotStatus.ToUpper() Code: @State.Imr.CodeDobotStatus_Opc  |  @DobotStatusCodeText
Cancel
@if (IsDobotExpanded) { Control
Home Continue PowerOn
Pick
Pick Up
}
@code { [Inject] StateService State { get; set; } = default!; [Inject] CommandService Cmd { get; set; } = default!; bool IsDobotExpanded = true; void ToggleDOBOT() => IsDobotExpanded = !IsDobotExpanded; int? okCount; int? ngCount; protected override async Task OnInitializedAsync() { await State.StartAsync(); State.ImrChanged += Refresh; // DobotStatus comes from IMR state State.WorkflowChanged += Refresh; } public ValueTask DisposeAsync() { State.ImrChanged -= Refresh; State.WorkflowChanged -= Refresh; return ValueTask.CompletedTask; } private void Refresh() => InvokeAsync(StateHasChanged); private string DobotStatus { get { var s = State.Imr.DobotStatus_Opc?.ToLower() ?? ""; var e = State.Imr.CodeDobotStatus_Opc; if (e == 9999) return "off"; if (e != 0) return "error"; if (s.Contains("error") || s.Contains("fault")) return "error"; if (s.Contains("controlling") || s.Contains("move")) return "moving"; if (s.Contains("canceled")) return "canceled"; if (s.Contains("finished") || s.Contains("idle")) return "ok"; return "ok"; } } private Color DobotMudColor => DobotStatus switch { "ok" => Color.Success, "idle" => Color.Success, "moving" => Color.Info, "canceled" => Color.Warning, "error" => Color.Error, _ => Color.Default }; private string DobotStatusCodeText => State.Imr.CodeDobotStatus_Opc switch { 0 => "Dobot Waiting", 98 => "Dobot Waiting for Connection", 99 => "Dobot Reconnecting", 100 => "Dobot Running", 101 => "Dobot Disconnected", 102 => "Dobot No Data Received", 103 => "Dobot Data Not Updated", 104 => "Dobot Target Coordinates Out of Range", 105 => "Dobot Returning Home", 106 => "Dobot Checking Emergency Stop Button", 107 => "Dobot in Alarm State", 108 => "Dobot Powering On, Waiting", 109 => "Dobot Powered On", 110 => "Dobot in Drag Mode", 111 => "Dobot Waiting: Select Continue or Return Home", 112 => "Dobot OK Count Limit Reached", 113 => "Dobot NG Count Limit Reached", 999 => "Dobot Error", _ => "Unknown" }; // Dobot queue locking private bool DobotLocked(string label) => !State.CanControl || State.Workflow.DobotBusyLabel == label || State.Workflow.DobotNextLabel == label; // PickUp goes through the IMR queue private bool ImrLocked(string label) => !State.CanControl || State.Workflow.ImrBusyLabel == label || State.Workflow.ImrNextLabel == label; private Task Dobot_Cancel() => Cmd.DobotCancelAsync(); private Task Dobot_Home() => Cmd.DobotGoHomeAsync(); private Task Dobot_Continue() => Cmd.DobotContinueAsync(); private Task Dobot_PowerOn() => Cmd.DobotPowerOnAsync(); private Task PickUp_Vda() => Cmd.ImrPickupAsync(okCount ?? 0, ngCount ?? 0); }