diff --git a/RobotApp.Client/Pages/Dashboard.razor b/RobotApp.Client/Pages/Dashboard.razor
index 3a22372..ccb4971 100644
--- a/RobotApp.Client/Pages/Dashboard.razor
+++ b/RobotApp.Client/Pages/Dashboard.razor
@@ -37,17 +37,15 @@
@if (CurrentState != null)
{
- @(IsConnected ? "ONLINE" : "OFFLINE")
-
- }
+ Icon="@(IsConnected ? Icons.Material.Filled.CheckCircle : Icons.Material.Filled.Error)"
+ Size="Size.Large"
+ Color="@(IsConnected ? Color.Success : Color.Error)"
+ Variant="Variant.Filled"
+ Class="px-6 py-4 text-white"
+ Style="font-weight: bold; font-size: 1.1rem;">
+ @(IsConnected ? "ONLINE" : "OFFLINE")
+
+ }
@@ -152,7 +150,7 @@
Rounded="true"
Striped="true"
Color="@(msg.BatteryState.BatteryCharge > 50 ? Color.Success :
- msg.BatteryState.BatteryCharge > 20 ? Color.Warning : Color.Error)"
+ msg.BatteryState.BatteryCharge > 20 ? Color.Warning : Color.Error)"
Class="mb-4"
Style="height: 28px;" />
@@ -266,7 +264,7 @@
@context.Level
@@ -317,8 +315,8 @@
@context.ActionStatus
diff --git a/RobotApp.Client/Pages/RobotMonitor.razor b/RobotApp.Client/Pages/RobotMonitor.razor
index 4309da8..e51faa3 100644
--- a/RobotApp.Client/Pages/RobotMonitor.razor
+++ b/RobotApp.Client/Pages/RobotMonitor.razor
@@ -46,3 +46,4 @@
+
diff --git a/RobotApp.Client/Services/RobotStateClient.cs b/RobotApp.Client/Services/RobotStateClient.cs
index 9834846..5a6fcce 100644
--- a/RobotApp.Client/Services/RobotStateClient.cs
+++ b/RobotApp.Client/Services/RobotStateClient.cs
@@ -127,20 +127,6 @@ public sealed class RobotStateClient : IAsyncDisposable
// ================= HANDLE STATE =================
private void HandleState(StateMsg state)
{
- //StateMsg? state;
-
- //try
- //{
- // state = JsonSerializer.Deserialize(
- // stateJson,
- // JsonOptionExtends.Read
- // );
- //}
- //catch
- //{
- // return;
- //}
-
if (state?.SerialNumber == null)
return;
diff --git a/RobotApp.Client/wwwroot/js/robotMonitor.js b/RobotApp.Client/wwwroot/js/robotMonitor.js
index 10a95b6..bb850b5 100644
--- a/RobotApp.Client/wwwroot/js/robotMonitor.js
+++ b/RobotApp.Client/wwwroot/js/robotMonitor.js
@@ -64,3 +64,4 @@ window.robotMonitor = {
+
diff --git a/RobotApp/Hubs/RobotMonitorHub.cs b/RobotApp/Hubs/RobotMonitorHub.cs
index c5bf2c9..edb6900 100644
--- a/RobotApp/Hubs/RobotMonitorHub.cs
+++ b/RobotApp/Hubs/RobotMonitorHub.cs
@@ -16,3 +16,4 @@ public class RobotMonitorHub : Hub
+
diff --git a/RobotApp/Services/Robot/RobotErrors.cs b/RobotApp/Services/Robot/RobotErrors.cs
index cdaf990..f948b0d 100644
--- a/RobotApp/Services/Robot/RobotErrors.cs
+++ b/RobotApp/Services/Robot/RobotErrors.cs
@@ -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)");
diff --git a/RobotApp/Services/Robot/RobotOrderController.cs b/RobotApp/Services/Robot/RobotOrderController.cs
index f20f78c..2fdc973 100644
--- a/RobotApp/Services/Robot/RobotOrderController.cs
+++ b/RobotApp/Services/Robot/RobotOrderController.cs
@@ -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}");
}
diff --git a/RobotApp/Services/Robot/RobotStatePublisher.cs b/RobotApp/Services/Robot/RobotStatePublisher.cs
index fbda7b9..a9061ff 100644
--- a/RobotApp/Services/Robot/RobotStatePublisher.cs
+++ b/RobotApp/Services/Robot/RobotStatePublisher.cs
@@ -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
{
diff --git a/RobotApp/Services/Robot/Simulation/Navigation/SimulationNavigation.cs b/RobotApp/Services/Robot/Simulation/Navigation/SimulationNavigation.cs
index 6ddc506..9a23b8f 100644
--- a/RobotApp/Services/Robot/Simulation/Navigation/SimulationNavigation.cs
+++ b/RobotApp/Services/Robot/Simulation/Navigation/SimulationNavigation.cs
@@ -23,8 +23,8 @@ public class SimulationNavigation : INavigation, IDisposable
protected const int CycleHandlerMilliseconds = 50;
private const double Scale = 1;
- //private WatchTimer? NavigationTimer;
- private HighPrecisionTimer? NavigationTimer;
+ private WatchTimer? NavigationTimer;
+ //private HighPrecisionTimer? NavigationTimer;
protected double TargetAngle = 0;
protected PID? RotatePID;