From 34a3a32621d3b2ef547f9673a6495a36b3b1e4f3 Mon Sep 17 00:00:00 2001 From: anerx <512464164@qq.com> Date: Wed, 19 Mar 2025 20:29:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E6=96=87=E4=BB=B6=E6=97=A5?= =?UTF-8?q?=E5=BF=97=20=E4=BB=A5=E5=8F=8A=E6=9B=B4=E6=96=B0AGVBug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Seyounth.Hyosung.Core/Agv/HikAgv.cs | 4 +-- .../Agv/HyosungAgvService.cs | 2 +- .../Services/AgvBinService.cs | 8 +++--- Seyounth.Hyosung/App.xaml.cs | 4 +++ Seyounth.Hyosung/Seyounth.Hyosung.csproj | 4 +++ Seyounth.Hyosung/ViewModels/HomeViewModel.cs | 15 +++++++++++ Seyounth.Hyosung/nlog.config | 26 +++++++++++++++++++ 7 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 Seyounth.Hyosung/nlog.config diff --git a/Seyounth.Hyosung.Core/Agv/HikAgv.cs b/Seyounth.Hyosung.Core/Agv/HikAgv.cs index 5807b9f..e931405 100644 --- a/Seyounth.Hyosung.Core/Agv/HikAgv.cs +++ b/Seyounth.Hyosung.Core/Agv/HikAgv.cs @@ -51,8 +51,8 @@ public class HikAgv(ILogger logger) var input = new { reqCode = GetRequestCode(), - ctnrType, - taskType, + ctnrTyp = ctnrType, + taskTyp = taskType, priority, agvCode = "4083", positionCodePath = new object[] diff --git a/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs b/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs index 68212a8..d215582 100644 --- a/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs +++ b/Seyounth.Hyosung.Core/Agv/HyosungAgvService.cs @@ -10,7 +10,7 @@ public class HyosungAgvService( ITrayService trayService, IDictService dictService) : IHyosungAgvService { - private readonly HikAgv _agv = new HikAgv(loggerFactory.CreateLogger()); + private readonly HikAgv _agv = new(loggerFactory.CreateLogger()); public async Task StorageAsync(string trayCode) diff --git a/Seyounth.Hyosung.Data/Services/AgvBinService.cs b/Seyounth.Hyosung.Data/Services/AgvBinService.cs index e31dc87..74211c1 100644 --- a/Seyounth.Hyosung.Data/Services/AgvBinService.cs +++ b/Seyounth.Hyosung.Data/Services/AgvBinService.cs @@ -8,12 +8,12 @@ public class AgvBinService : IAgvBinService { private readonly List _cache; - private readonly IRepository repository; + private readonly IRepository _repository; public AgvBinService(IServiceProvider provider) { - repository = provider.CreateScope().ServiceProvider.GetRequiredService>(); - _cache = repository.GetList(); + _repository = provider.CreateScope().ServiceProvider.GetRequiredService>(); + _cache = _repository.GetList(); } public async Task GetAvailableBin(int height) @@ -40,6 +40,6 @@ public class AgvBinService : IAgvBinService { entity.IsFree = false; _cache.First(e => e.Id == entity.Id).IsFree = false; - return repository.UpdateAsync(entity); + return _repository.UpdateAsync(entity); } } \ No newline at end of file diff --git a/Seyounth.Hyosung/App.xaml.cs b/Seyounth.Hyosung/App.xaml.cs index e947825..222115e 100644 --- a/Seyounth.Hyosung/App.xaml.cs +++ b/Seyounth.Hyosung/App.xaml.cs @@ -10,6 +10,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using NLog.Extensions.Logging; using Seyounth.Hyosung.Core.Printer; using Seyounth.Hyosung.Runtime; using Seyounth.Hyosung.Services; @@ -31,6 +32,9 @@ public partial class App : Application { var builder = Host .CreateApplicationBuilder(); + builder.Logging.ClearProviders(); + builder.Logging.SetMinimumLevel(LogLevel.Trace); + builder.Logging.AddNLog("nlog.config"); builder.Configuration.AddJsonFile("PrintTemp.json", true, true); builder.Configuration.AddJsonFile("appsettings.json", true, true); builder.Services.Configure(builder.Configuration.GetSection("Print")); diff --git a/Seyounth.Hyosung/Seyounth.Hyosung.csproj b/Seyounth.Hyosung/Seyounth.Hyosung.csproj index 5e3e7b1..4957b0c 100644 --- a/Seyounth.Hyosung/Seyounth.Hyosung.csproj +++ b/Seyounth.Hyosung/Seyounth.Hyosung.csproj @@ -12,6 +12,7 @@ + @@ -22,6 +23,9 @@ PreserveNewest + + PreserveNewest + diff --git a/Seyounth.Hyosung/ViewModels/HomeViewModel.cs b/Seyounth.Hyosung/ViewModels/HomeViewModel.cs index 2d59bd5..ecfee3b 100644 --- a/Seyounth.Hyosung/ViewModels/HomeViewModel.cs +++ b/Seyounth.Hyosung/ViewModels/HomeViewModel.cs @@ -1,4 +1,5 @@ using System.Collections.ObjectModel; +using System.Windows.Threading; using CommunityToolkit.Mvvm.ComponentModel; using Seyounth.Hyosung.Data.Models; using Seyounth.Hyosung.Data.Models.Plc; @@ -36,5 +37,19 @@ public partial class HomeViewModel : ObservableObject _yarnCarTypes.Add("C"); _yarnCarTypes.Add("D"); _varieties = new ObservableCollection(varietyService.GetAll()); + DispatcherTimer timer = new DispatcherTimer(); + timer = new DispatcherTimer(); + // 设置定时器间隔,这里设置为 1 秒,可根据实际需求调整 + timer.Interval = TimeSpan.FromSeconds(1); + // 为定时器的 Tick 事件添加处理方法 + timer.Tick += Timer_Tick; + // 启动定时器 + timer.Start(); + } + + private void Timer_Tick(object? sender, EventArgs e) + { + Stack1 = _runtime.Stack1; + Stack2 = _runtime.Stack2; } } \ No newline at end of file diff --git a/Seyounth.Hyosung/nlog.config b/Seyounth.Hyosung/nlog.config new file mode 100644 index 0000000..75c64ff --- /dev/null +++ b/Seyounth.Hyosung/nlog.config @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file