This commit is contained in:
Đăng Nguyễn 2025-12-31 14:59:56 +07:00
parent 5c1851e92f
commit b7e7d70855
5 changed files with 33 additions and 28 deletions

View File

@ -134,6 +134,7 @@
</div> </div>
@code { @code {
[Parameter] public RobotMonitorDto? MonitorData { get; set; } [Parameter] public RobotMonitorDto? MonitorData { get; set; }
[Parameter] public bool IsConnected { get; set; } [Parameter] public bool IsConnected { get; set; }
@ -282,6 +283,7 @@
// Điều chỉnh kích thước dựa trên ZoomScale // Điều chỉnh kích thước dựa trên ZoomScale
// Tăng kích thước lên 1.5x để robot to hơn // Tăng kích thước lên 1.5x để robot to hơn
double scaleFactor = 2 / ZoomScale; // Tăng kích thước hiển thị double scaleFactor = 2 / ZoomScale; // Tăng kích thước hiển thị
scaleFactor = scaleFactor < 1 ? 1 : scaleFactor;
double width = RobotWidthMeters * scaleFactor; double width = RobotWidthMeters * scaleFactor;
double height = RobotLengthMeters * scaleFactor; double height = RobotLengthMeters * scaleFactor;

View File

@ -116,7 +116,7 @@ public class HighPrecisionTimer<T>(int Interval, Action Callback, Logger<T>? Log
Thread.Start(); Thread.Start();
} }
} }
else throw new ObjectDisposedException(nameof(WatchTimer<T>)); else throw new ObjectDisposedException(nameof(HighPrecisionTimer<T>));
} }
public void Stop() public void Stop()

View File

@ -1,5 +1,4 @@
using MudBlazor; using RobotApp.Common.Shares.Dtos;
using RobotApp.Common.Shares.Dtos;
using RobotApp.Common.Shares.Enums; using RobotApp.Common.Shares.Enums;
using RobotApp.Interfaces; using RobotApp.Interfaces;
using RobotApp.Services.Exceptions; using RobotApp.Services.Exceptions;
@ -9,7 +8,6 @@ using RobotApp.VDA5050.Order;
using RobotApp.VDA5050.State; using RobotApp.VDA5050.State;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Data; using System.Data;
using System.Xml.Linq;
using Action = RobotApp.VDA5050.InstantAction.Action; using Action = RobotApp.VDA5050.InstantAction.Action;
namespace RobotApp.Services.Robot; namespace RobotApp.Services.Robot;
@ -31,7 +29,7 @@ public class RobotOrderController(INavigation NavigationManager,
public int LastNodeSequenceId => LastNode is null ? 0 : LastNode.SequenceId; public int LastNodeSequenceId => LastNode is null ? 0 : LastNode.SequenceId;
public (NodeState[], EdgeStateDto[]) CurrentPath => GetCurrentPath(); public (NodeState[], EdgeStateDto[]) CurrentPath => GetCurrentPath();
private const int CycleHandlerMilliseconds = 100; private const int CycleHandlerMilliseconds = 200;
private WatchTimer<RobotOrderController>? OrderTimer; private WatchTimer<RobotOrderController>? OrderTimer;
private readonly Dictionary<string, Action[]> OrderActions = []; private readonly Dictionary<string, Action[]> OrderActions = [];
@ -435,7 +433,7 @@ public class RobotOrderController(INavigation NavigationManager,
private EdgeStateDto[] SplitChecking(Node lastNode, Node nearLastNode, VDA5050.Order.Edge edge) private EdgeStateDto[] SplitChecking(Node lastNode, Node nearLastNode, VDA5050.Order.Edge edge)
{ {
List<EdgeStateDto> pathEdges = []; List<EdgeStateDto> pathEdges = [];
var splitStartPath = RobotPathPlanner.PathSplit([lastNode, nearLastNode], [edge], 0.1); var splitStartPath = RobotPathPlanner.PathSplit([lastNode, nearLastNode], [edge], 0.5);
if (splitStartPath is not null && splitStartPath.Length > 0) if (splitStartPath is not null && splitStartPath.Length > 0)
{ {
int index = 0; int index = 0;
@ -450,17 +448,31 @@ public class RobotOrderController(INavigation NavigationManager,
index = i; index = i;
} }
} }
for (int i = index; i < splitStartPath.Length - 1; i++) if (edge.Trajectory is null || edge.Trajectory.Degree == 1)
{ {
pathEdges.Add(new() pathEdges.Add(new()
{ {
StartX = splitStartPath[i].NodePosition.X, StartX = splitStartPath[index].NodePosition.X,
StartY = splitStartPath[i].NodePosition.Y, StartY = splitStartPath[index].NodePosition.Y,
EndX = splitStartPath[i + 1].NodePosition.X, EndX = nearLastNode.NodePosition.X,
EndY = splitStartPath[i + 1].NodePosition.Y, EndY = nearLastNode.NodePosition.Y,
Degree = 1, Degree = 1,
}); });
} }
else
{
for (int i = index; i < splitStartPath.Length - 1; i++)
{
pathEdges.Add(new()
{
StartX = splitStartPath[i].NodePosition.X,
StartY = splitStartPath[i].NodePosition.Y,
EndX = splitStartPath[i + 1].NodePosition.X,
EndY = splitStartPath[i + 1].NodePosition.Y,
Degree = 1,
});
}
}
} }
return [.. pathEdges]; return [.. pathEdges];
} }

View File

@ -1,14 +1,5 @@
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using RobotApp.Common.Shares;
using RobotApp.Hubs; using RobotApp.Hubs;
using RobotApp.Interfaces;
using RobotApp.Services.State;
using RobotApp.VDA5050.State;
using RobotApp.VDA5050.Type;
using RobotApp.VDA5050.Visualization;
using System.Text.Json;
namespace RobotApp.Services.Robot; namespace RobotApp.Services.Robot;

View File

@ -68,7 +68,7 @@ public class WatchTimerAsync<T>(int Interval, Func<Task> Callback, Logger<T>? Lo
Timer.Change(Interval, Timeout.Infinite); Timer.Change(Interval, Timeout.Infinite);
} }
} }
else throw new ObjectDisposedException(nameof(WatchTimer<T>)); else throw new ObjectDisposedException(nameof(WatchTimerAsync<T>));
} }
public void Stop() public void Stop()