using Microsoft.Extensions.Logging; using Seyounth.Hyosung.Core.Agv.HikModels; using Seyounth.Hyosung.Data.Services; namespace Seyounth.Hyosung.Core.Agv; public class HyosungAgvService( ILoggerFactory loggerFactory, IAgvBinService agvBinService, ITrayService trayService, IDictService dictService) : IHyosungAgvService { private readonly HikAgv _agv = new HikAgv(loggerFactory.CreateLogger()); public async Task StorageAsync(string trayCode) { AgvStatusInfo? status; do { status = await _agv.GetAgvStatus("BB", "4083"); await Task.Delay(1000); } while (status is null); var tray = await trayService.GetByCode(trayCode); var height = (int)Math.Ceiling((double)(tray.StackHeight / 10.0)!); var bin = await agvBinService.GetAvailableBin(height); AgvPosition start = new AgvPosition() { PositionCode = "A1", Type = "00" }; var stop = new AgvPosition() { PositionCode = bin.CtnrCode, Type = "05" }; var ctnrType = await dictService.GetKeyAsync("AgvRackType", height.ToString()); await _agv.CarryToAsync(start, stop, ctnrType, 120, "1"); await agvBinService.BindAsync(bin); } }