From 1b8f7909872b76cced35736c4b9755a7f989e7ad Mon Sep 17 00:00:00 2001 From: SoulStar Date: Mon, 13 Jan 2025 21:03:06 +0800 Subject: [PATCH] =?UTF-8?q?feat=20-=20=E4=BF=AE=E6=94=B9=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Business/base/BaseAGVBusiness.cs | 25 ++- SlnMesnac.Config/AppConfig.cs | 37 +--- .../service/IAGVJobService.cs | 6 + .../service/Impl/AGVJobServiceImpl.cs | 18 ++ SlnMesnac.TouchSocket/AirPorthttpClient.cs | 13 +- SlnMesnac.TouchSocket/AirportTcpServer.cs | 19 -- SlnMesnac.TouchSocket/ApiServer.cs | 23 +- SlnMesnac.TouchSocket/TcpServer.cs | 4 - SlnMesnac.WPF/MainWindow.xaml | 196 ++---------------- .../Page/IndexPage/IndexContent.xaml | 167 +++++---------- SlnMesnac.WPF/SlnMesnac.WPF.csproj | 8 + SlnMesnac.WPF/Startup.cs | 4 +- SlnMesnac.WPF/Templates/image/background.png | Bin 0 -> 106605 bytes .../IndexPage/IndexContentViewModel.cs | 38 ++-- .../ViewModel/MainWindowViewModel.cs | 17 +- SlnMesnac.WPF/appsettings.json | 107 +--------- SlnMesnac.WPF/background.png | Bin 0 -> 106605 bytes 17 files changed, 181 insertions(+), 501 deletions(-) delete mode 100644 SlnMesnac.TouchSocket/AirportTcpServer.cs create mode 100644 SlnMesnac.WPF/Templates/image/background.png create mode 100644 SlnMesnac.WPF/background.png diff --git a/SlnMesnac.Business/base/BaseAGVBusiness.cs b/SlnMesnac.Business/base/BaseAGVBusiness.cs index acfce19..e53d27e 100644 --- a/SlnMesnac.Business/base/BaseAGVBusiness.cs +++ b/SlnMesnac.Business/base/BaseAGVBusiness.cs @@ -252,10 +252,10 @@ namespace SlnMesnac.Business.@base try { //终止小车当前任务 - result = EndTaskAndClearError(agvguid);//////////////////////////////////////////////////////////////////还没改完/////////////////////////////////////////////////////////////// - var param = _appConfig.JobConfig.Where(x => x.JobGUID == jobGuid).First(); + result = EndTaskAndClearError(agvguid); + var param = _AGVJobService.GetAGVJobByJobGuid(jobGuid); //调用小车到抓取位置 - return DownloadTask(agvguid, jobGuid, param.PointGUID, param.PointParamName); + return DownloadTask(agvguid, jobGuid, param.PointGuid, param.PointParamName); } catch (Exception ex) { @@ -371,9 +371,8 @@ namespace SlnMesnac.Business.@base } } - /// - /// 入库所有满载AGV + /// 入库所有即将满载AGV /// public void ClearFullAGV() { @@ -382,7 +381,7 @@ namespace SlnMesnac.Business.@base var list = _AGVStateService.GetAgvState(AgvType.Deliver); foreach (var record in list) { - if (record.stackcount >= BaseTaskInfoBusiness.DeliverStackNumber && record.agvworkstate == "待机") + if (record.stackcount >= BaseTaskInfoBusiness.DeliverStackNumber - 2 && record.agvworkstate == "待机") { //入库代码 EndTaskAndClearErrorAndDownloadTask(record.agvno, @@ -394,7 +393,7 @@ namespace SlnMesnac.Business.@base list = _AGVStateService.GetAgvState(AgvType.AMR); foreach (var record in list) { - if (record.stackcount >= BaseTaskInfoBusiness.AMRStackNumber && record.agvworkstate == "待机") + if (record.stackcount >= BaseTaskInfoBusiness.AMRStackNumber - 2 && record.agvworkstate == "待机") { //入库代码 EndTaskAndClearErrorAndDownloadTask(record.agvno, @@ -410,5 +409,17 @@ namespace SlnMesnac.Business.@base } } + /// + /// 下载AGV模板和点位到数据库 + /// + public bool DownloadAgvJob() + { + List joblist = new List(); + + + + + return false; + } } } diff --git a/SlnMesnac.Config/AppConfig.cs b/SlnMesnac.Config/AppConfig.cs index 4dc8c16..c383e63 100644 --- a/SlnMesnac.Config/AppConfig.cs +++ b/SlnMesnac.Config/AppConfig.cs @@ -29,64 +29,39 @@ namespace SlnMesnac.Config /// /// 系统配置 /// - #pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. +#pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable. public class AppConfig : IOptions { /// /// 日志文件路径 /// public string logPath { get; set; } - + /// /// Sql连接配置 /// public List sqlConfig { get; set; } - + /// /// PLC连接配置 /// public List plcConfig { get; set; } - + /// /// RFID连接配置 /// public List rfidConfig { get; set; } - - /// - /// 视觉机械臂连接配置 - /// - public List visionConfig { get; set; } - - /// - /// AGV配置 - /// - public List AGVConfig { get; set; } - - /// - /// 地图点位配置 - /// - public List PositionConfig { get; set; } - /// - /// 模板配置 + /// AGVC服务器IP /// - public List JobConfig { get; set; } - - - + public string AGVCIpConfig { get; set; } /// /// Redis配置 /// public string redisConfig { get; set; } - /// - /// AMR - /// - - public string AMRIP { get; set; } - /// /// AGV地址配置 /// diff --git a/SlnMesnac.Repository/service/IAGVJobService.cs b/SlnMesnac.Repository/service/IAGVJobService.cs index 3c10ab7..ce1ec76 100644 --- a/SlnMesnac.Repository/service/IAGVJobService.cs +++ b/SlnMesnac.Repository/service/IAGVJobService.cs @@ -14,6 +14,12 @@ namespace SlnMesnac.Repository.service /// List GetAGVJobList(); + /// + /// AGVGuid获取Job + /// + /// + /// + AGVJob GetAGVJobByJobGuid(string guid); /// /// 根据模板类型获取对应的AGV模板列表 diff --git a/SlnMesnac.Repository/service/Impl/AGVJobServiceImpl.cs b/SlnMesnac.Repository/service/Impl/AGVJobServiceImpl.cs index fd97676..de2a411 100644 --- a/SlnMesnac.Repository/service/Impl/AGVJobServiceImpl.cs +++ b/SlnMesnac.Repository/service/Impl/AGVJobServiceImpl.cs @@ -19,6 +19,24 @@ namespace SlnMesnac.Repository.service.Impl _logger = logger; } + public AGVJob GetAGVJobByJobGuid(string guid) + { + try + { + var list = _rep.GetList(x => x.JobGuid == guid).FirstOrDefault(); + if (list == null) + { + return new AGVJob(); + } + return list; + } + catch (Exception ex) + { + _logger.LogError($"获取列表发生错误: {ex.Message}"); + return new AGVJob(); + } + } + public List GetAGVJobList() { try diff --git a/SlnMesnac.TouchSocket/AirPorthttpClient.cs b/SlnMesnac.TouchSocket/AirPorthttpClient.cs index 8f3d53b..6e13d6e 100644 --- a/SlnMesnac.TouchSocket/AirPorthttpClient.cs +++ b/SlnMesnac.TouchSocket/AirPorthttpClient.cs @@ -31,7 +31,7 @@ namespace SlnMesnac.TouchSocket private readonly AppConfig _appConfig; private readonly ILogger _logger; private System.Net.Http.HttpClient _httpClient; - public string Url = "http://192.168.10.199:5102"; + public string Url; public AirPorthttpClient(AppConfig appConfig, ILogger logger) { @@ -58,6 +58,8 @@ namespace SlnMesnac.TouchSocket public void init() { + Url = _appConfig.AGVIpConfig; + _httpClient = new HttpClient(); } @@ -328,6 +330,15 @@ namespace SlnMesnac.TouchSocket } } + ///// + ///// AGV入库接口 + ///// + ///// + //public bool AGVInStore(string agvGuid) + //{ + + //} + ///// ///// 获取当前所有任务模板信息(目前不可用) ///// diff --git a/SlnMesnac.TouchSocket/AirportTcpServer.cs b/SlnMesnac.TouchSocket/AirportTcpServer.cs deleted file mode 100644 index 784afc4..0000000 --- a/SlnMesnac.TouchSocket/AirportTcpServer.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.Extensions.Hosting; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace SlnMesnac.TouchSocket -{ - public class AirportTcpServer : BackgroundService - { - protected override Task ExecuteAsync(CancellationToken stoppingToken) - { - return Task.CompletedTask; - } - - - } -} diff --git a/SlnMesnac.TouchSocket/ApiServer.cs b/SlnMesnac.TouchSocket/ApiServer.cs index f294450..f9398ba 100644 --- a/SlnMesnac.TouchSocket/ApiServer.cs +++ b/SlnMesnac.TouchSocket/ApiServer.cs @@ -33,14 +33,14 @@ namespace SlnMesnac.TouchSocket { public ApiServer() { - + AgvInStoreEvent += OnAGVArrival; } - public delegate void AGVArrivalStart(string message, AGVSingalEntity aGVArrivalSingalEntity); + public delegate void AGVInStoreDelegate(string agvGuid); /// /// AGV到位信号刷新 /// - public event AGVArrivalStart AGVArrivalStartEvent; + public event AGVInStoreDelegate AgvInStoreEvent; /// /// AGV到位信号接口 @@ -48,24 +48,25 @@ namespace SlnMesnac.TouchSocket /// /// [EnableCors("cors")] - [WebApi(HttpMethodType.POST)] - public object AGVSignal(string messageHeader, AGVSingalEntity aGVArrivalSingalEntity) + [WebApi(HttpMethodType.GET)] + public object AGVInStoreSignal(string agvGuid) { - AGVArrivalStartEvent?.Invoke(messageHeader, aGVArrivalSingalEntity); + AgvInStoreEvent?.Invoke(agvGuid); return "Success"; } public void SubscribeToAGVArrivalEvent() { - // 订阅 AGV 到位事件 - AGVArrivalStartEvent += OnAGVArrival; + // 订阅事件 + AgvInStoreEvent += OnAGVArrival; } // 处理 AGV 到位事件的方法 - public void OnAGVArrival(string message, AGVSingalEntity aGVArrivalSingalEntity) + public void OnAGVArrival(string agvGuid) { - Console.WriteLine($"收到AGV到位信号: {message}"); - Console.WriteLine($"AGV编号: {aGVArrivalSingalEntity.AGVNo}, 到达位置: {aGVArrivalSingalEntity.DestinationNo}"); + + + // 这里可以处理更多的业务逻辑,比如记录日志、更新系统状态等 } diff --git a/SlnMesnac.TouchSocket/TcpServer.cs b/SlnMesnac.TouchSocket/TcpServer.cs index 6ee4ed4..104f08b 100644 --- a/SlnMesnac.TouchSocket/TcpServer.cs +++ b/SlnMesnac.TouchSocket/TcpServer.cs @@ -55,8 +55,6 @@ namespace SlnMesnac.TouchSocket public delegate void RefreshClientInfo(TcpService tcpService); public event RefreshClientInfo? RefreshClientInfoEvent; - public Action RefreshStateAction; - public delegate void GetVisionData(TcpVisionEntity entity, string id); /// @@ -108,7 +106,6 @@ namespace SlnMesnac.TouchSocket { _logger.LogInformation($"客户端{client.IP}:{client.Port}接入服务成功"); RefreshClientInfoEvent?.Invoke(_service); - RefreshStateAction?.Invoke(client.IP, true); client.ResetId(client.IP); TestClientID = client.IP; VID = client.IP; @@ -117,7 +114,6 @@ namespace SlnMesnac.TouchSocket _service.Disconnected = (client, e) => { _logger.LogInformation($"客户端{client.IP}:{client.Port}断开连接"); - RefreshStateAction?.Invoke(client.IP, false); RefreshClientInfoEvent?.Invoke(_service); return EasyTask.CompletedTask; }; diff --git a/SlnMesnac.WPF/MainWindow.xaml b/SlnMesnac.WPF/MainWindow.xaml index 7a0ad7f..8d60430 100644 --- a/SlnMesnac.WPF/MainWindow.xaml +++ b/SlnMesnac.WPF/MainWindow.xaml @@ -6,9 +6,9 @@ xmlns:local="clr-namespace:SlnMesnac.WPF" mc:Ignorable="d" Title="MainWindow" Height="1080" Width="1920" - WindowState="Maximized" WindowStyle="None" ResizeMode="NoResize" Topmost="False"> + WindowState="Normal" WindowStyle="SingleBorderWindow" ResizeMode="NoResize" Topmost="False"> - + @@ -24,42 +24,22 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - + +