update
This commit is contained in:
parent
a51cfe80c8
commit
2785a8f161
|
|
@ -37,9 +37,7 @@
|
|||
@if (CurrentState != null)
|
||||
{
|
||||
<MudChip T="string"
|
||||
Icon="@(IsConnected
|
||||
? Icons.Material.Filled.CheckCircle
|
||||
: Icons.Material.Filled.Error)"
|
||||
Icon="@(IsConnected ? Icons.Material.Filled.CheckCircle : Icons.Material.Filled.Error)"
|
||||
Size="Size.Large"
|
||||
Color="@(IsConnected ? Color.Success : Color.Error)"
|
||||
Variant="Variant.Filled"
|
||||
|
|
|
|||
|
|
@ -46,3 +46,4 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -127,20 +127,6 @@ public sealed class RobotStateClient : IAsyncDisposable
|
|||
// ================= HANDLE STATE =================
|
||||
private void HandleState(StateMsg state)
|
||||
{
|
||||
//StateMsg? state;
|
||||
|
||||
//try
|
||||
//{
|
||||
// state = JsonSerializer.Deserialize<StateMsg>(
|
||||
// stateJson,
|
||||
// JsonOptionExtends.Read
|
||||
// );
|
||||
//}
|
||||
//catch
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (state?.SerialNumber == null)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -64,3 +64,4 @@ window.robotMonitor = {
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,3 +16,4 @@ public class RobotMonitorHub : Hub
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ public class RobotErrors : IError
|
|||
=> CreateError(ErrorType.INITIALIZE_ORDER, "Vui lòng kiểm tra lại OrderUpdateId", ErrorLevel.WARNING, $"OrderUpdateId {newOrderUpdateId} nhận được nhỏ hơn OrderUpdateId hiện tại là {oldOrderUpdateId}");
|
||||
public static Error Error1019()
|
||||
=> CreateError(ErrorType.INITIALIZE_ORDER, "Vui lòng kiểm tra lại Order", ErrorLevel.WARNING, "Order có node đầu tiên quá xa robot");
|
||||
public static Error Error1020()
|
||||
=> CreateError(ErrorType.INITIALIZE_ORDER, "", ErrorLevel.WARNING, "Robot đang ở đích của Order");
|
||||
|
||||
public static Error Error2001()
|
||||
=> CreateError(ErrorType.READ_PERIPHERAL_FAILURE, "2001", ErrorLevel.FATAL, "Có lỗi xảy ra trong quá trình đọc tín hiệu từ hệ thống ngoại vi(PLC)");
|
||||
|
|
|
|||
|
|
@ -403,6 +403,14 @@ public class RobotOrderController(INavigation NavigationManager,
|
|||
var nodeDeviation = startNode.NodePosition.AllowedDeviationXY == 0.0 ? NewOrderHandler.Nodes.Length == 1 ? 0.3 : 0.5 : startNode.NodePosition.AllowedDeviationXY;
|
||||
var distance = Localization.DistanceTo(startNode.NodePosition.X, startNode.NodePosition.Y);
|
||||
if (distance > nodeDeviation) throw new OrderException(RobotErrors.Error1019());
|
||||
|
||||
if (NewOrderHandler.Nodes.Length > 1)
|
||||
{
|
||||
Node endNode = NewOrderHandler.Nodes[^1];
|
||||
nodeDeviation = endNode.NodePosition.AllowedDeviationXY == 0.0 ? 0.2 : endNode.NodePosition.AllowedDeviationXY;
|
||||
distance = Localization.DistanceTo(endNode.NodePosition.X, endNode.NodePosition.Y);
|
||||
if (distance < nodeDeviation) throw new OrderException(RobotErrors.Error1020());
|
||||
}
|
||||
HandleNewOrder(NewOrderHandler);
|
||||
}
|
||||
}
|
||||
|
|
@ -414,7 +422,7 @@ public class RobotOrderController(INavigation NavigationManager,
|
|||
{
|
||||
ErrorManager.AddError(orEx.Error, TimeSpan.FromSeconds(10));
|
||||
Logger.Warning($"Lỗi khi xử lí Order: {orEx.Error.ErrorDescription}");
|
||||
HandleOrderStop();
|
||||
if (Nodes.Length == 0) HandleOrderStop();
|
||||
}
|
||||
else Logger.Warning($"Lỗi khi xử lí Order: {orEx.Message}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ public class RobotStatePublisher(
|
|||
RobotStates _robotState,
|
||||
RobotConnection _robotConnection) : BackgroundService
|
||||
{
|
||||
private bool? _lastRobotConnectionState;
|
||||
|
||||
private readonly PeriodicTimer _timer = new(TimeSpan.FromMilliseconds(1000)); // 1 giây/lần
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
|
|
@ -28,26 +26,8 @@ public class RobotStatePublisher(
|
|||
try
|
||||
{
|
||||
// ===== SEND STATE =====
|
||||
var state = _robotState.GetStateMsg();
|
||||
//var json = JsonSerializer.Serialize(state, JsonOptionExtends.Write);
|
||||
|
||||
await _hubContext.Clients.All
|
||||
.SendAsync("ReceiveState", state, stoppingToken);
|
||||
|
||||
// ===== SEND ROBOT CONNECTION (ONLY WHEN CHANGED) =====
|
||||
var isConnected = _robotConnection.IsConnected;
|
||||
|
||||
if (_lastRobotConnectionState != isConnected)
|
||||
{
|
||||
_lastRobotConnectionState = isConnected;
|
||||
|
||||
await _hubContext.Clients.All
|
||||
.SendAsync(
|
||||
"ReceiveRobotConnection",
|
||||
isConnected, // payload only bool
|
||||
stoppingToken
|
||||
);
|
||||
}
|
||||
await _hubContext.Clients.All.SendAsync("ReceiveState", _robotState.GetStateMsg(), stoppingToken);
|
||||
await _hubContext.Clients.All.SendAsync("ReceiveRobotConnection", _robotConnection.IsConnected, stoppingToken);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ public class SimulationNavigation : INavigation, IDisposable
|
|||
|
||||
protected const int CycleHandlerMilliseconds = 50;
|
||||
private const double Scale = 1;
|
||||
//private WatchTimer<SimulationNavigation>? NavigationTimer;
|
||||
private HighPrecisionTimer<SimulationNavigation>? NavigationTimer;
|
||||
private WatchTimer<SimulationNavigation>? NavigationTimer;
|
||||
//private HighPrecisionTimer<SimulationNavigation>? NavigationTimer;
|
||||
|
||||
protected double TargetAngle = 0;
|
||||
protected PID? RotatePID;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user