55 lines
1.7 KiB
C#
Raw Permalink Normal View History

2025-03-16 03:17:36 +08:00
using Microsoft.Extensions.Logging;
using Seyounth.Hyosung.Core.Agv.HikModels;
2025-03-23 13:09:36 +08:00
using Seyounth.Hyosung.Data.Entities;
2025-03-16 03:17:36 +08:00
using Seyounth.Hyosung.Data.Services;
namespace Seyounth.Hyosung.Core.Agv;
public class HyosungAgvService(
ILoggerFactory loggerFactory,
IAgvBinService agvBinService,
ITrayService trayService,
IDictService dictService) : IHyosungAgvService
{
2025-03-19 20:29:11 +08:00
private readonly HikAgv _agv = new(loggerFactory.CreateLogger<HikAgv>());
2025-03-16 03:17:36 +08:00
2025-03-20 19:32:49 +08:00
public async Task StorageAsync(string trayCode)
2025-03-16 03:17:36 +08:00
{
AgvStatusInfo? status;
do
{
status = await _agv.GetAgvStatus("BB", "4083");
await Task.Delay(1000);
} while (status is null);
var tray = await trayService.GetByCode(trayCode);
2025-03-23 13:55:15 +08:00
var height = (int)Math.Ceiling((double)((tray.StackHeight ?? 0) / 10.0)!);
2025-03-16 03:17:36 +08:00
var bin = await agvBinService.GetAvailableBin(height);
AgvPosition start = new AgvPosition()
{
PositionCode = "A1",
Type = "00"
};
var stop = new AgvPosition()
{
PositionCode = bin.CtnrCode,
Type = "05"
};
2025-03-23 13:55:15 +08:00
if (!string.IsNullOrEmpty(bin.HeightCode))
await UnBin(bin);
2025-03-20 00:43:24 +08:00
var ctnrType = await dictService.GetKeyAsync("AgvRackType", bin.Height.ToString());
2025-03-23 13:09:36 +08:00
if (string.IsNullOrEmpty(ctnrType))
ctnrType = "14";
bin.HeightCode = ctnrType;
2025-03-23 13:55:15 +08:00
var taskCode = await _agv.CarryToAsync(start, stop, ctnrType, 120, "1");
await _agv.WaitingForTaskCompletedAsync(taskCode);
2025-03-16 03:17:36 +08:00
await agvBinService.BindAsync(bin);
2025-03-23 13:09:36 +08:00
}
public async Task UnBin(AgvBinEntity bin)
{
await _agv.UnBin(bin);
2025-03-16 03:17:36 +08:00
}
}