From 5fce13039a6f0228fc99a57f7a1d2d987dbfc5cd Mon Sep 17 00:00:00 2001 From: SoulStar Date: Mon, 20 Jan 2025 19:44:42 +0800 Subject: [PATCH] =?UTF-8?q?feat=20-=20RFID=E5=B7=A5=E4=BD=8D=E8=AF=86?= =?UTF-8?q?=E5=88=ABPLC=E5=86=99=E5=85=A5=E5=8A=9F=E8=83=BD=E5=AE=8C?= =?UTF-8?q?=E6=88=90=20-=20=E6=96=B0=E5=A2=9E=E8=AF=BB=E5=86=99=E5=99=A8?= =?UTF-8?q?=E5=92=8C=E6=A0=87=E7=AD=BE=E7=BB=B4=E6=8A=A4=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HighWayIot.Plc/HighWayIot.Plc.csproj | 2 +- HighWayIot.Plc/PlcConnect.cs | 2 +- HighWayIot.Plc/PlcHelper/BasePlcHelper.cs | 8 +- HighWayIot.Plc/PlcHelper/WorkStationHelper.cs | 8 +- .../HighWayIot.Repository.csproj | 6 +- ...id_setting.cs => ZxReaderSettingEntity.cs} | 32 +- .../domain/ZxTagSettingEntity.cs | 54 ++++ ...ngService.cs => ZxReaderSettingService.cs} | 42 ++- .../service/ZxTagSettingService.cs | 109 +++++++ HighWayIot.Rfid/RfidDataAnalyse.cs | 4 +- .../HighWayIot.TouchSocket.csproj | 35 +-- .../TouchSocketTcpClient.cs | 69 ++++- HighWayIot.TouchSocket/app.config | 31 ++ HighWayIot.TouchSocket/packages.config | 14 +- HighWayIot.Winform/App.config | 20 ++ .../Business/WorkStationBusiness.cs | 174 ++++++++++- HighWayIot.Winform/HighWayIot.Winform.csproj | 19 +- HighWayIot.Winform/MainForm/BaseForm.cs | 5 + .../RFIDParamSettingPage.Designer.cs | 282 +++++++++++++++--- .../ParamConfigPages/RFIDParamSettingPage.cs | 124 ++++++-- .../RFIDParamSettingPage.resx | 8 +- .../UpdateRfidWindow.Designer.cs | 127 -------- .../ParamConfigPages/UpdateRfidWindow.cs | 43 --- .../ParamConfigPages/UpdateRfidWindow.resx | 120 -------- 24 files changed, 886 insertions(+), 452 deletions(-) rename HighWayIot.Repository/domain/{Zx_rfid_setting.cs => ZxReaderSettingEntity.cs} (50%) create mode 100644 HighWayIot.Repository/domain/ZxTagSettingEntity.cs rename HighWayIot.Repository/service/{Zx_rfid_settingService.cs => ZxReaderSettingService.cs} (57%) create mode 100644 HighWayIot.Repository/service/ZxTagSettingService.cs create mode 100644 HighWayIot.TouchSocket/app.config delete mode 100644 HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.Designer.cs delete mode 100644 HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.cs delete mode 100644 HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.resx diff --git a/HighWayIot.Plc/HighWayIot.Plc.csproj b/HighWayIot.Plc/HighWayIot.Plc.csproj index 330708d..9354a9f 100644 --- a/HighWayIot.Plc/HighWayIot.Plc.csproj +++ b/HighWayIot.Plc/HighWayIot.Plc.csproj @@ -51,7 +51,7 @@ - + diff --git a/HighWayIot.Plc/PlcConnect.cs b/HighWayIot.Plc/PlcConnect.cs index 9da2a3a..4aa7804 100644 --- a/HighWayIot.Plc/PlcConnect.cs +++ b/HighWayIot.Plc/PlcConnect.cs @@ -41,7 +41,7 @@ namespace HighWayIot.Plc { plc.CommunicationPipe = new HslCommunication.Core.Pipe.PipeTcpNet(Ip, 2001) { - ConnectTimeOut = 1000, // 连接超时时间,单位毫秒 + ConnectTimeOut = 3000, // 连接超时时间,单位毫秒 SleepTime = 0, SocketKeepAliveTime = -1, IsPersistentConnection = true, diff --git a/HighWayIot.Plc/PlcHelper/BasePlcHelper.cs b/HighWayIot.Plc/PlcHelper/BasePlcHelper.cs index 0d01c11..ecf6e5b 100644 --- a/HighWayIot.Plc/PlcHelper/BasePlcHelper.cs +++ b/HighWayIot.Plc/PlcHelper/BasePlcHelper.cs @@ -8,12 +8,12 @@ namespace HighWayIot.Plc.PlcHelper { public class BasePlcHelper { - public PlcConnect PlcInstance = PlcConnect.Instance; + //public PlcConnect PlcInstance = PlcConnect.Instance; - public BasePlcHelper() - { + //public BasePlcHelper() + //{ - } + //} } } diff --git a/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs index 9eec30d..ba6cfcc 100644 --- a/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs +++ b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs @@ -14,11 +14,15 @@ namespace HighWayIot.Plc.PlcHelper /// /// /// - public bool WriteStationSingal(RgvStationEnum rgvStation, int deviceNo) + public bool WriteStationSingal(int rgvStationNo, int deviceNo) { int point = 0x600; + + //选择是哪个小车 point += deviceNo * 32; - point += (int)rgvStation; + + //选择是小车的哪个点位 + point += rgvStationNo; bool result = PlcConnect.PlcWrite($"B{point.ToString("X")}", true, DataTypeEnum.Bool).IsSuccess; diff --git a/HighWayIot.Repository/HighWayIot.Repository.csproj b/HighWayIot.Repository/HighWayIot.Repository.csproj index d380f02..55f815a 100644 --- a/HighWayIot.Repository/HighWayIot.Repository.csproj +++ b/HighWayIot.Repository/HighWayIot.Repository.csproj @@ -62,13 +62,15 @@ + - + - + + diff --git a/HighWayIot.Repository/domain/Zx_rfid_setting.cs b/HighWayIot.Repository/domain/ZxReaderSettingEntity.cs similarity index 50% rename from HighWayIot.Repository/domain/Zx_rfid_setting.cs rename to HighWayIot.Repository/domain/ZxReaderSettingEntity.cs index 0529751..77a3f46 100644 --- a/HighWayIot.Repository/domain/Zx_rfid_setting.cs +++ b/HighWayIot.Repository/domain/ZxReaderSettingEntity.cs @@ -9,12 +9,11 @@ using System.Threading.Tasks; namespace HighWayIot.Repository.domain { /// - /// + /// RFID配置表 /// - [SugarTable("zx_rfid_setting")] - public class Zx_rfid_setting + [SugarTable("zx_rfid_reader_setting")] + public class ZxReaderSettingEntity { - /// /// 备 注: @@ -28,23 +27,28 @@ namespace HighWayIot.Repository.domain /// 默认值: /// [SugarColumn(ColumnName = "rfid_ip")] - public string RfidIp { get; set; } + public string RfidIp { get; set; } = string.Empty; - /// - /// 备 注:RFID编号 - /// 默认值: - /// - [SugarColumn(ColumnName = "rfid_epc")] - public string RfidEpc { get; set; } + ///// + ///// 备 注:RFID编号 + ///// 默认值: + ///// + //[SugarColumn(ColumnName = "rfid_epc")] + //public string RfidEpc { get; set; } = string.Empty; /// /// 备 注:工位编号 /// 默认值: /// - [SugarColumn(ColumnName = "workstate_no")] - public int? WorkstateNo { get; set; } - + [SugarColumn(ColumnName = "workstation_no")] + public string WorkstationNo { get; set; } = string.Empty; + ///// + ///// 备 注:是否连接成功 + ///// 默认值: + ///// + //[SugarColumn(ColumnName = "is_connected")] + //public bool? IsConnected { get; set; } } } diff --git a/HighWayIot.Repository/domain/ZxTagSettingEntity.cs b/HighWayIot.Repository/domain/ZxTagSettingEntity.cs new file mode 100644 index 0000000..612b480 --- /dev/null +++ b/HighWayIot.Repository/domain/ZxTagSettingEntity.cs @@ -0,0 +1,54 @@ +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Principal; +using System.Text; +using System.Threading.Tasks; + +namespace HighWayIot.Repository.domain +{ + /// + /// RFID配置表 + /// + [SugarTable("zx_rfid_tag_setting")] + public class ZxTagSettingEntity + { + + /// + /// 备 注: + /// 默认值: + /// + [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 备 注:标签EPC + /// 默认值: + /// + [SugarColumn(ColumnName = "rfid_epc")] + public string RfidEpc { get; set; } = string.Empty; + + ///// + ///// 备 注:RFID编号 + ///// 默认值: + ///// + //[SugarColumn(ColumnName = "rfid_epc")] + //public string RfidEpc { get; set; } = string.Empty; + + /// + /// 备 注:小车编号 + /// 默认值: + /// + [SugarColumn(ColumnName = "device_no")] + public string DeviceNo { get; set; } = string.Empty; + + ///// + ///// 备 注:是否连接成功 + ///// 默认值: + ///// + //[SugarColumn(ColumnName = "is_connected")] + //public bool? IsConnected { get; set; } + } + +} diff --git a/HighWayIot.Repository/service/Zx_rfid_settingService.cs b/HighWayIot.Repository/service/ZxReaderSettingService.cs similarity index 57% rename from HighWayIot.Repository/service/Zx_rfid_settingService.cs rename to HighWayIot.Repository/service/ZxReaderSettingService.cs index ca82ba1..cf000bb 100644 --- a/HighWayIot.Repository/service/Zx_rfid_settingService.cs +++ b/HighWayIot.Repository/service/ZxReaderSettingService.cs @@ -9,11 +9,11 @@ using System.Threading.Tasks; namespace HighWayIot.Repository.service { - public class Zx_rfid_settingService + public class ZxReaderSettingService { - private static readonly Lazy lazy = new Lazy(() => new Zx_rfid_settingService()); + private static readonly Lazy lazy = new Lazy(() => new ZxReaderSettingService()); - public static Zx_rfid_settingService Instance + public static ZxReaderSettingService Instance { get { @@ -22,17 +22,17 @@ namespace HighWayIot.Repository.service } private LogHelper log = LogHelper.Instance; - Repository _repository => new Repository("sqlserver"); + Repository _repository => new Repository("sqlserver"); /// /// 查询所有RFID设备信息 /// /// - public List GetRfidInfos(Expression> expression = null) + public List GetReaderInfos(Expression> expression = null) { try { - List entity; + List entity; if (expression != null) { entity = _repository.GetList(expression); @@ -51,17 +51,17 @@ namespace HighWayIot.Repository.service } /// - /// 查询指定RFID设备信息 + /// 根据IP查询读写器工位信息 /// /// - public Zx_rfid_setting GetRfidInfoById(int id) + public string GetWorkstateNoByIp(string ip) { try { - Zx_rfid_setting entity; - entity = _repository.GetById(id); + ZxReaderSettingEntity entity; + entity = _repository.GetFirst(x => x.RfidIp == ip); - return entity; + return entity.WorkstationNo; } catch (Exception ex) { @@ -75,7 +75,7 @@ namespace HighWayIot.Repository.service /// /// /// - public bool UpdateRfidInfo(Zx_rfid_setting entity) + public bool UpdateReaderInfo(ZxReaderSettingEntity entity) { try { @@ -87,5 +87,23 @@ namespace HighWayIot.Repository.service return false; } } + + /// + /// 修改信息 + /// + /// + /// + public bool UpdateRangeReaderInfo(List entitys) + { + try + { + return _repository.UpdateRange(entitys); + } + catch (Exception ex) + { + log.Error("RFID集合信息修改异常", ex); + return false; + } + } } } diff --git a/HighWayIot.Repository/service/ZxTagSettingService.cs b/HighWayIot.Repository/service/ZxTagSettingService.cs new file mode 100644 index 0000000..136b99f --- /dev/null +++ b/HighWayIot.Repository/service/ZxTagSettingService.cs @@ -0,0 +1,109 @@ +using HighWayIot.Log4net; +using HighWayIot.Repository.domain; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace HighWayIot.Repository.service +{ + public class ZxTagSettingService + { + private static readonly Lazy lazy = new Lazy(() => new ZxTagSettingService()); + + public static ZxTagSettingService Instance + { + get + { + return lazy.Value; + } + } + + private LogHelper log = LogHelper.Instance; + Repository _repository => new Repository("sqlserver"); + + /// + /// 查询所有RFID标签信息 + /// + /// + public List GetTagInfos(Expression> expression = null) + { + try + { + List entity; + if (expression != null) + { + entity = _repository.GetList(expression); + } + else + { + entity = _repository.GetList(); + } + return entity; + } + catch (Exception ex) + { + log.Error("RFID标签信息获取异常", ex); + return null; + } + } + + /// + /// 根据EPC查询指定RFID标签DeviceNo信息 + /// + /// + public string GetTagDeviceNoByEPC(string Epc) + { + try + { + ZxTagSettingEntity entity; + entity = _repository.GetFirst(x => x.RfidEpc == Epc); + + return entity.DeviceNo; + } + catch (Exception ex) + { + log.Error("RFID标签信息获取异常", ex); + return null; + } + } + + /// + /// 修改标签信息 + /// + /// + /// + public bool UpdateTagInfo(ZxTagSettingEntity entity) + { + try + { + return _repository.Update(entity); + } + catch (Exception ex) + { + log.Error("RFID标签信息修改异常", ex); + return false; + } + } + + /// + /// 修改标签信息 + /// + /// + /// + public bool UpdateRangeTagInfo(List entitys) + { + try + { + return _repository.UpdateRange(entitys); + } + catch (Exception ex) + { + log.Error("RFID标签集合信息修改异常", ex); + return false; + } + } + } +} diff --git a/HighWayIot.Rfid/RfidDataAnalyse.cs b/HighWayIot.Rfid/RfidDataAnalyse.cs index 368520e..86b1fea 100644 --- a/HighWayIot.Rfid/RfidDataAnalyse.cs +++ b/HighWayIot.Rfid/RfidDataAnalyse.cs @@ -67,8 +67,8 @@ namespace HighWayIot.Rfid index += 2; //取读到标签的EPC - Array.Copy(DataBytes, index, EPCData.EPC, 0, 12); - index += 12; + Array.Copy(DataBytes, index, EPCData.EPC, 0, 4); + index += 4; entity.Data.Add(EPCData); } diff --git a/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj b/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj index 94d4302..487d403 100644 --- a/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj +++ b/HighWayIot.TouchSocket/HighWayIot.TouchSocket.csproj @@ -36,22 +36,22 @@ ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - - ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + ..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll - - ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll + + ..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll - - ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + ..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll - - ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + ..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll @@ -59,11 +59,11 @@ - - ..\packages\TouchSocket.3.0.9\lib\net472\TouchSocket.dll + + ..\packages\TouchSocket.3.0.12\lib\net472\TouchSocket.dll - - ..\packages\TouchSocket.Core.3.0.9\lib\net472\TouchSocket.Core.dll + + ..\packages\TouchSocket.Core.3.0.12\lib\net472\TouchSocket.Core.dll @@ -71,16 +71,17 @@ + - - - {DEABC30C-EC6F-472E-BD67-D65702FDAF74} HighWayIot.Log4net + + + \ No newline at end of file diff --git a/HighWayIot.TouchSocket/TouchSocketTcpClient.cs b/HighWayIot.TouchSocket/TouchSocketTcpClient.cs index 46c0d66..1f645b7 100644 --- a/HighWayIot.TouchSocket/TouchSocketTcpClient.cs +++ b/HighWayIot.TouchSocket/TouchSocketTcpClient.cs @@ -1,5 +1,7 @@ using HighWayIot.Log4net; using System; +using System.Collections.Generic; +using System.Net.Sockets; using System.Text; using System.Threading.Tasks; using TouchSocket.Core; @@ -10,40 +12,51 @@ namespace HighWayIot.TouchSocket { public class TouchSocketTcpClient { + /// + /// 日志 + /// private static LogHelper _logHelper = LogHelper.Instance; + /// + /// 懒加载 + /// private static readonly Lazy lazy = new Lazy(() => new TouchSocketTcpClient()); public static TouchSocketTcpClient Instance => lazy.Value; - TcpClient client = new TcpClient(); + /// + /// 所有的客户端 + /// + public Dictionary Clients = new Dictionary(); - public async void TcpClient(string ip, string port) + public Action GetMessageAction; + + public async Task CreateTcpClient(string ip, string port) { - client.Connecting = (client, e) => + TcpClient tcpClient = new TcpClient(); + + tcpClient.Connecting = (client, e) => { return EasyTask.CompletedTask; };//有客户端正在连接 - client.Connected = (client, e) => + tcpClient.Connected = (client, e) => { return EasyTask.CompletedTask; };//有客户端成功连接 - client.Closing = (client, e) => + tcpClient.Closing = (client, e) => { return EasyTask.CompletedTask; };//有客户端正在断开连接,只有当主动断开时才有效。 - client.Closed = (client, e) => + tcpClient.Closed = (client, e) => { return EasyTask.CompletedTask; };//有客户端断开连接 - client.Received = async (client, e) => + tcpClient.Received = async (client, e) => { - //从客户端收到信息 - var mes = e.ByteBlock.Span.ToString(Encoding.UTF8); - client.Logger.Info($"已从{client.IP}接收到信息:{mes}"); + GetMessageAction.Invoke(e.ByteBlock.Span.ToArray(), client.IP); }; - await client.SetupAsync(new TouchSocketConfig() + await tcpClient.SetupAsync(new TouchSocketConfig() .SetRemoteIPHost($"{ip}:{port}") .ConfigureContainer(a => { @@ -53,11 +66,14 @@ namespace HighWayIot.TouchSocket Result result = Result.Default; //不断尝试重连 do { - result = await client.TryConnectAsync(); + _logHelper.Info($"连接{ip}:{port}"); + result = await tcpClient.TryConnectAsync(); } while (!result.IsSuccess); - - return; + _logHelper.Info($"{ip}:{port}连接成功"); + Clients.Add(ip, tcpClient); + + return true; } /// @@ -65,11 +81,11 @@ namespace HighWayIot.TouchSocket /// /// Bytes /// - public async Task Send(byte[] message) + public async Task Send(string ip, byte[] message) { try { - await client.SendAsync(message); + await Clients[ip].SendAsync(message); return true; } catch (Exception e) @@ -79,5 +95,26 @@ namespace HighWayIot.TouchSocket } } + /// + /// 客户端释放 + /// + /// + /// + public async Task DisposeClient(string ip) + { + try + { + await Clients[ip].CloseAsync(); + Clients[ip].Dispose(); + Clients.Remove(ip); + return true; + } + catch (Exception e) + { + _logHelper.Error("释放客户端发生错误" + e); + return false; + } + } + } } diff --git a/HighWayIot.TouchSocket/app.config b/HighWayIot.TouchSocket/app.config new file mode 100644 index 0000000..9c003b0 --- /dev/null +++ b/HighWayIot.TouchSocket/app.config @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HighWayIot.TouchSocket/packages.config b/HighWayIot.TouchSocket/packages.config index e080f8b..5bc89d6 100644 --- a/HighWayIot.TouchSocket/packages.config +++ b/HighWayIot.TouchSocket/packages.config @@ -1,11 +1,11 @@  - - - - - - - + + + + + + + \ No newline at end of file diff --git a/HighWayIot.Winform/App.config b/HighWayIot.Winform/App.config index 98452d4..601d9fb 100644 --- a/HighWayIot.Winform/App.config +++ b/HighWayIot.Winform/App.config @@ -13,6 +13,26 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HighWayIot.Winform/Business/WorkStationBusiness.cs b/HighWayIot.Winform/Business/WorkStationBusiness.cs index 4d6d0fb..676aa76 100644 --- a/HighWayIot.Winform/Business/WorkStationBusiness.cs +++ b/HighWayIot.Winform/Business/WorkStationBusiness.cs @@ -1,12 +1,184 @@ -using System; +using HighWayIot.Log4net; +using HighWayIot.Plc.PlcEntity; +using HighWayIot.Plc.PlcHelper; +using HighWayIot.Repository.domain; +using HighWayIot.Repository.service; +using HighWayIot.Rfid; +using HighWayIot.Rfid.Entity; +using HighWayIot.TouchSocket; +using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using TouchSocket.Core; +using Timer = System.Threading.Timer; namespace HighWayIot.Winform.Business { + /// + /// 工位RFID识别业务 + /// public class WorkStationBusiness { + /// + /// 日志 + /// + private LogHelper _logHelper = LogHelper.Instance; + + /// + /// PLC + /// + private WorkStationHelper _workStationHelper = new WorkStationHelper(); + + /// + /// 读写器服务类 + /// + private ZxReaderSettingService _readerService = ZxReaderSettingService.Instance; + + /// + /// 读写器实体类 + /// + private List _readerSetting; + + /// + /// 标签服务类 + /// + private ZxTagSettingService _tagrService = ZxTagSettingService.Instance; + + /// + /// 标签实体类 + /// + private List _tagSetting; + + /// + /// RFID数据分析 + /// + private RfidDataAnalyse _rfidDataAnalyse = new RfidDataAnalyse(); + + /// + /// TCP客户端 + /// + private TouchSocketTcpClient _touchSocketTcpClient = TouchSocketTcpClient.Instance; + + /// + /// 刷新器 + /// + private Timer timer; + + /// + /// 是否全部连接成功 + /// + private bool IsAllConnected = false; + + public WorkStationBusiness() + { + _readerSetting = _readerService.GetReaderInfos(); + CreateAllRFIDClient(); + _touchSocketTcpClient.GetMessageAction += ReciveRFIDSingal; + timer = new Timer(new System.Threading.TimerCallback(SingalMonitor), null, 0, 2000); + } + + /// + /// 自动监视 + /// + /// + public void SingalMonitor(object o) + { + bool[] singals = _workStationHelper.ReadStationSingal(); + + for (int i = 1; i <= singals.Length; i++) + { + if (singals[i - 1] == true) + { + SendRFIDSingal(i); + } + } + } + + /// + /// 创建所有RFID客户端 + /// + public async void CreateAllRFIDClient() + { + foreach (var setting in _readerSetting) + { + await _touchSocketTcpClient.CreateTcpClient(setting.RfidIp, "20108"); + } + + _logHelper.Info("所有读写器均连接成功"); + + IsAllConnected = true; + } + + /// + /// 向指定RFID读写器发送读信号 + /// + public async void SendRFIDSingal(int no) + { + if (IsAllConnected == true) + { + ZxReaderSettingEntity setting = _readerSetting.FirstOrDefault(x => x.WorkstationNo == no.ToString()); + if (setting == null) + { + return; + } + + int i = 0; + bool result = false; + do + { + result = await _touchSocketTcpClient.Send(setting.RfidIp, _rfidDataAnalyse.Send02H(1000)); + i++; + } + while (i < 3 && result == false); + + if(result == false) + { + _logHelper.Error($"[{no}] 工位 [{setting.RfidIp}] 读写器指令发送失败!"); + } + } + } + + /// + /// 接收信息的信号 + /// + /// + public void ReciveRFIDSingal(byte[] bytes, string ip) + { + Receive02HEntity entity = _rfidDataAnalyse.Receive02H(bytes); + if(entity.TagCount != 1) + { + _logHelper.Error("返回多标签!"); + return; + } + byte[] data = entity.Data[0].EPC; + + string result = string.Join(" ", data.Select(x => x.ToString("X2"))); + + string deviceNo = _tagrService.GetTagDeviceNoByEPC(result); + string workstationNo = _readerService.GetWorkstateNoByIp(ip); + + if (string.IsNullOrEmpty(deviceNo)) + { + _logHelper.Error($"没有查询到 [{result}] 标签相关的信息!"); + return; + } + if (string.IsNullOrEmpty(workstationNo)) + { + _logHelper.Error($"没有查询到 [{ip}] 读写器相关的信息!"); + return; + } + + try + { + _workStationHelper.WriteStationSingal(int.Parse(workstationNo), int.Parse(deviceNo)); + } + catch (Exception ex) + { + _logHelper.Error("数值转换发生错误", ex); + } + } } } diff --git a/HighWayIot.Winform/HighWayIot.Winform.csproj b/HighWayIot.Winform/HighWayIot.Winform.csproj index 578a4de..729fae8 100644 --- a/HighWayIot.Winform/HighWayIot.Winform.csproj +++ b/HighWayIot.Winform/HighWayIot.Winform.csproj @@ -55,6 +55,7 @@ + Form @@ -118,12 +119,6 @@ MonitorMainPage.cs - - Form - - - UpdateRfidWindow.cs - Form @@ -216,6 +211,7 @@ BaseForm.cs + Designer LoginForm.cs @@ -254,9 +250,6 @@ MonitorMainPage.cs - - UpdateRfidWindow.cs - AddRecipeForm.cs @@ -331,6 +324,14 @@ {D0DC3CFB-6748-4D5E-B56A-76FDC72AB4B3} HighWayIot.Repository + + {29813574-49c0-4979-a5a6-47eb7c4288a0} + HighWayIot.Rfid + + + {DD18A634-1F9C-409A-8C32-C3C81B1B55B5} + HighWayIot.TouchSocket + diff --git a/HighWayIot.Winform/MainForm/BaseForm.cs b/HighWayIot.Winform/MainForm/BaseForm.cs index 377938f..2eccb60 100644 --- a/HighWayIot.Winform/MainForm/BaseForm.cs +++ b/HighWayIot.Winform/MainForm/BaseForm.cs @@ -34,6 +34,11 @@ namespace HighWayIot.Winform.MainForm /// RoleBusiness roleBusiness = new RoleBusiness(); + /// + /// 工位RFID刷新类 + /// + WorkStationBusiness workStationBusiness = new WorkStationBusiness(); + public BaseForm() { InitializeComponent(); diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs index b31f126..aad2455 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.Designer.cs @@ -31,105 +31,297 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages /// private void InitializeComponent() { - this.GetRfidButton = new System.Windows.Forms.Button(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + this.GetReaderButton = new System.Windows.Forms.Button(); this.ButtonPanel = new System.Windows.Forms.Panel(); - this.rfidDataGridView = new System.Windows.Forms.DataGridView(); + this.UpdateReaderButton = new System.Windows.Forms.Button(); + this.ReaderDataGridView = new System.Windows.Forms.DataGridView(); this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RfidIp = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.WorkstationNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RFIDSettingGroupBox = new System.Windows.Forms.GroupBox(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.panel1 = new System.Windows.Forms.Panel(); + this.UpdateRFIDButton = new System.Windows.Forms.Button(); + this.SelectRfidButton = new System.Windows.Forms.Button(); + this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.TagDataGridView = new System.Windows.Forms.DataGridView(); + this.RfidId = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RfidEpc = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.WorkstateNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DeviceNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ButtonPanel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.rfidDataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.ReaderDataGridView)).BeginInit(); + this.RFIDSettingGroupBox.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); + this.panel1.SuspendLayout(); + this.tableLayoutPanel2.SuspendLayout(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.TagDataGridView)).BeginInit(); this.SuspendLayout(); // - // GetRfidButton + // GetReaderButton // - this.GetRfidButton.Location = new System.Drawing.Point(3, 2); - this.GetRfidButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.GetRfidButton.Name = "GetRfidButton"; - this.GetRfidButton.Size = new System.Drawing.Size(103, 39); - this.GetRfidButton.TabIndex = 1; - this.GetRfidButton.Text = "查 询"; - this.GetRfidButton.UseVisualStyleBackColor = true; - this.GetRfidButton.Click += new System.EventHandler(this.GetRfidButton_Click); + this.GetReaderButton.Location = new System.Drawing.Point(6, 11); + this.GetReaderButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.GetReaderButton.Name = "GetReaderButton"; + this.GetReaderButton.Size = new System.Drawing.Size(103, 39); + this.GetReaderButton.TabIndex = 1; + this.GetReaderButton.Text = "查询读写器信息"; + this.GetReaderButton.UseVisualStyleBackColor = true; + this.GetReaderButton.Click += new System.EventHandler(this.GetReaderButton_Click); // // ButtonPanel // this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.ButtonPanel.Controls.Add(this.GetRfidButton); - this.ButtonPanel.Location = new System.Drawing.Point(0, 0); + this.ButtonPanel.Controls.Add(this.UpdateReaderButton); + this.ButtonPanel.Controls.Add(this.GetReaderButton); + this.ButtonPanel.Location = new System.Drawing.Point(3, 2); this.ButtonPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonPanel.Name = "ButtonPanel"; - this.ButtonPanel.Size = new System.Drawing.Size(1171, 61); + this.ButtonPanel.Size = new System.Drawing.Size(694, 61); this.ButtonPanel.TabIndex = 4; // - // rfidDataGridView + // UpdateReaderButton // - this.rfidDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.rfidDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.UpdateReaderButton.Location = new System.Drawing.Point(115, 11); + this.UpdateReaderButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.UpdateReaderButton.Name = "UpdateReaderButton"; + this.UpdateReaderButton.Size = new System.Drawing.Size(103, 39); + this.UpdateReaderButton.TabIndex = 2; + this.UpdateReaderButton.Text = "修改读写器信息"; + this.UpdateReaderButton.UseVisualStyleBackColor = true; + this.UpdateReaderButton.Click += new System.EventHandler(this.UpdateReaderButton_Click); + // + // ReaderDataGridView + // + this.ReaderDataGridView.AllowUserToAddRows = false; + this.ReaderDataGridView.AllowUserToDeleteRows = false; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + this.ReaderDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3; + this.ReaderDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.ReaderDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.Id, this.RfidIp, - this.RfidEpc, - this.WorkstateNo}); - this.rfidDataGridView.Location = new System.Drawing.Point(20, 66); - this.rfidDataGridView.Name = "rfidDataGridView"; - this.rfidDataGridView.RowTemplate.Height = 23; - this.rfidDataGridView.Size = new System.Drawing.Size(1135, 724); - this.rfidDataGridView.TabIndex = 5; - this.rfidDataGridView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.rfidDataGridView_CellDoubleClick); + this.WorkstationNo}); + this.ReaderDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; + this.ReaderDataGridView.Location = new System.Drawing.Point(3, 17); + this.ReaderDataGridView.Name = "ReaderDataGridView"; + this.ReaderDataGridView.RowHeadersVisible = false; + this.ReaderDataGridView.RowTemplate.Height = 23; + this.ReaderDataGridView.Size = new System.Drawing.Size(688, 842); + this.ReaderDataGridView.TabIndex = 5; // // Id // - this.Id.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.Id.FillWeight = 10F; - this.Id.HeaderText = "ID"; + this.Id.DataPropertyName = "Id"; + this.Id.HeaderText = "编号"; this.Id.Name = "Id"; + this.Id.Width = 40; // // RfidIp // this.RfidIp.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.RfidIp.FillWeight = 20F; + this.RfidIp.DataPropertyName = "RfidIp"; + this.RfidIp.FillWeight = 5F; this.RfidIp.HeaderText = "设备ip"; this.RfidIp.Name = "RfidIp"; // + // WorkstationNo + // + this.WorkstationNo.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.WorkstationNo.DataPropertyName = "WorkstationNo"; + this.WorkstationNo.FillWeight = 5F; + this.WorkstationNo.HeaderText = "工位编号"; + this.WorkstationNo.Name = "WorkstationNo"; + // + // RFIDSettingGroupBox + // + this.RFIDSettingGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.RFIDSettingGroupBox.Controls.Add(this.ReaderDataGridView); + this.RFIDSettingGroupBox.Location = new System.Drawing.Point(3, 3); + this.RFIDSettingGroupBox.Name = "RFIDSettingGroupBox"; + this.RFIDSettingGroupBox.Size = new System.Drawing.Size(694, 862); + this.RFIDSettingGroupBox.TabIndex = 6; + this.RFIDSettingGroupBox.TabStop = false; + this.RFIDSettingGroupBox.Text = "读写器配置"; + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanel1.ColumnCount = 2; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Controls.Add(this.panel1, 1, 0); + this.tableLayoutPanel1.Controls.Add(this.ButtonPanel, 0, 0); + this.tableLayoutPanel1.Location = new System.Drawing.Point(3, 3); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 1; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(1401, 65); + this.tableLayoutPanel1.TabIndex = 7; + // + // panel1 + // + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.panel1.Controls.Add(this.UpdateRFIDButton); + this.panel1.Controls.Add(this.SelectRfidButton); + this.panel1.Location = new System.Drawing.Point(703, 2); + this.panel1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(695, 61); + this.panel1.TabIndex = 5; + // + // UpdateRFIDButton + // + this.UpdateRFIDButton.Location = new System.Drawing.Point(115, 11); + this.UpdateRFIDButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.UpdateRFIDButton.Name = "UpdateRFIDButton"; + this.UpdateRFIDButton.Size = new System.Drawing.Size(103, 39); + this.UpdateRFIDButton.TabIndex = 2; + this.UpdateRFIDButton.Text = "修改标签信息"; + this.UpdateRFIDButton.UseVisualStyleBackColor = true; + this.UpdateRFIDButton.Click += new System.EventHandler(this.UpdateRFIDButton_Click); + // + // SelectRfidButton + // + this.SelectRfidButton.Location = new System.Drawing.Point(6, 11); + this.SelectRfidButton.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.SelectRfidButton.Name = "SelectRfidButton"; + this.SelectRfidButton.Size = new System.Drawing.Size(103, 39); + this.SelectRfidButton.TabIndex = 1; + this.SelectRfidButton.Text = "查询标签信息"; + this.SelectRfidButton.UseVisualStyleBackColor = true; + this.SelectRfidButton.Click += new System.EventHandler(this.SelectRfidButton_Click); + // + // tableLayoutPanel2 + // + this.tableLayoutPanel2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tableLayoutPanel2.ColumnCount = 2; + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.Controls.Add(this.groupBox1, 1, 0); + this.tableLayoutPanel2.Controls.Add(this.RFIDSettingGroupBox, 0, 0); + this.tableLayoutPanel2.Location = new System.Drawing.Point(3, 74); + this.tableLayoutPanel2.Name = "tableLayoutPanel2"; + this.tableLayoutPanel2.RowCount = 1; + this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel2.Size = new System.Drawing.Size(1401, 868); + this.tableLayoutPanel2.TabIndex = 8; + // + // groupBox1 + // + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox1.Controls.Add(this.TagDataGridView); + this.groupBox1.Location = new System.Drawing.Point(703, 3); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(695, 862); + this.groupBox1.TabIndex = 7; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "标签配置"; + // + // TagDataGridView + // + this.TagDataGridView.AllowUserToAddRows = false; + this.TagDataGridView.AllowUserToDeleteRows = false; + dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + this.TagDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; + this.TagDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.TagDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.RfidId, + this.RfidEpc, + this.DeviceNo}); + this.TagDataGridView.Dock = System.Windows.Forms.DockStyle.Fill; + this.TagDataGridView.Location = new System.Drawing.Point(3, 17); + this.TagDataGridView.Name = "TagDataGridView"; + this.TagDataGridView.RowHeadersVisible = false; + this.TagDataGridView.RowTemplate.Height = 23; + this.TagDataGridView.Size = new System.Drawing.Size(689, 842); + this.TagDataGridView.TabIndex = 5; + // + // RfidId + // + this.RfidId.DataPropertyName = "Id"; + this.RfidId.HeaderText = "编号"; + this.RfidId.Name = "RfidId"; + this.RfidId.Width = 40; + // // RfidEpc // this.RfidEpc.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.RfidEpc.FillWeight = 20F; - this.RfidEpc.HeaderText = "RFID编号"; + this.RfidEpc.DataPropertyName = "RfidEpc"; + this.RfidEpc.FillWeight = 5F; + this.RfidEpc.HeaderText = "标签EPC"; this.RfidEpc.Name = "RfidEpc"; // - // WorkstateNo + // DeviceNo // - this.WorkstateNo.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.WorkstateNo.FillWeight = 20F; - this.WorkstateNo.HeaderText = "工位编号"; - this.WorkstateNo.Name = "WorkstateNo"; + this.DeviceNo.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.DeviceNo.DataPropertyName = "DeviceNo"; + this.DeviceNo.FillWeight = 5F; + this.DeviceNo.HeaderText = "工位编号"; + this.DeviceNo.Name = "DeviceNo"; // // RFIDParamSettingPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlLight; - this.Controls.Add(this.rfidDataGridView); - this.Controls.Add(this.ButtonPanel); + this.Controls.Add(this.tableLayoutPanel2); + this.Controls.Add(this.tableLayoutPanel1); this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "RFIDParamSettingPage"; - this.Size = new System.Drawing.Size(1171, 807); + this.Size = new System.Drawing.Size(1407, 945); this.ButtonPanel.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.rfidDataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.ReaderDataGridView)).EndInit(); + this.RFIDSettingGroupBox.ResumeLayout(false); + this.tableLayoutPanel1.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.tableLayoutPanel2.ResumeLayout(false); + this.groupBox1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.TagDataGridView)).EndInit(); this.ResumeLayout(false); } #endregion - private Button GetRfidButton; + private Button GetReaderButton; private Panel ButtonPanel; - private DataGridView rfidDataGridView; + private DataGridView ReaderDataGridView; + private GroupBox RFIDSettingGroupBox; + private TableLayoutPanel tableLayoutPanel1; + private TableLayoutPanel tableLayoutPanel2; + private Panel panel1; + private Button SelectRfidButton; + private GroupBox groupBox1; + private DataGridView TagDataGridView; private DataGridViewTextBoxColumn Id; private DataGridViewTextBoxColumn RfidIp; + private DataGridViewTextBoxColumn WorkstationNo; + private DataGridViewTextBoxColumn RfidId; private DataGridViewTextBoxColumn RfidEpc; - private DataGridViewTextBoxColumn WorkstateNo; + private DataGridViewTextBoxColumn DeviceNo; + private Button UpdateReaderButton; + private Button UpdateRFIDButton; } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs index 13b1dee..38ca66f 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.cs @@ -14,45 +14,113 @@ namespace HighWayIot.Winform.UserControlPages.ParamConfigPages { public partial class RFIDParamSettingPage : UserControl { - private Zx_rfid_settingService zx_rfid_settingService = Zx_rfid_settingService.Instance; + private ZxReaderSettingService zx_rfid_reader_settingService = ZxReaderSettingService.Instance; + + private ZxTagSettingService zx_rfid_tag_settingService = ZxTagSettingService.Instance; + public RFIDParamSettingPage() { InitializeComponent(); + RefreshReaderGridView(); + RefreshTagGridView(); + ReaderDataGridView.AutoGenerateColumns = false; + TagDataGridView.AutoGenerateColumns = false; } - - - private void GetRfidButton_Click(object sender, EventArgs e) + /// + /// 刷新读写器前端页面 + /// + private void RefreshReaderGridView() { - this.rfidDataGridView.Rows.Clear(); - List list = zx_rfid_settingService.GetRfidInfos(); - foreach (var item in list) - { - this.rfidDataGridView.Rows.Add(item.Id, item.RfidIp, item.RfidEpc, item.WorkstateNo); - } - + List list = zx_rfid_reader_settingService.GetReaderInfos(); + + ReaderDataGridView.DataSource = null; + ReaderDataGridView.DataSource = list; } - private void rfidDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e) + /// + /// 刷新标签前端页面 + /// + private void RefreshTagGridView() { - // 检查是否双击了有效的行(排除列头) - if (e.RowIndex >= 0) - { - // 获取双击的行 - DataGridViewRow row = rfidDataGridView.Rows[e.RowIndex]; + List list = zx_rfid_tag_settingService.GetTagInfos(); - // 获取该行的数据 - int id = (int)row.Cells["Id"].Value; - string RfidIp = (string)row.Cells["RfidIp"].Value; - string RfidEpc = (string)row.Cells["RfidEpc"].Value; - string WorkstateNo = (string)row.Cells["WorkstateNo"].Value; - UpdateRfidWindow window = new UpdateRfidWindow(id, RfidIp,RfidEpc, WorkstateNo); - window.Show(); - - - } + TagDataGridView.DataSource = null; + TagDataGridView.DataSource = list; } - + /// + /// 查询读写器 + /// + /// + /// + private void GetReaderButton_Click(object sender, EventArgs e) + { + RefreshReaderGridView(); + } + + /// + /// 查询RFID + /// + /// + /// + private void SelectRfidButton_Click(object sender, EventArgs e) + { + RefreshTagGridView(); + } + + /// + /// 更改读写器 + /// + /// + /// + private void UpdateReaderButton_Click(object sender, EventArgs e) + { + List lists = new List(); + DataGridViewRowCollection rows = ReaderDataGridView.Rows; + foreach (DataGridViewRow row in rows) + { + ZxReaderSettingEntity entity = new ZxReaderSettingEntity() + { + Id = int.Parse(row.Cells["Id"].Value.ToString()), + RfidIp = row.Cells["RfidIp"].Value.ToString(), + WorkstationNo = row.Cells["WorkstationNo"].Value.ToString() + }; + lists.Add(entity); + } + + zx_rfid_reader_settingService.UpdateRangeReaderInfo(lists); + + RefreshReaderGridView(); + + MessageBox.Show("读写器信息修改成功"); + } + + /// + /// 更改标签 + /// + /// + /// + private void UpdateRFIDButton_Click(object sender, EventArgs e) + { + List lists = new List(); + DataGridViewRowCollection rows = TagDataGridView.Rows; + foreach (DataGridViewRow row in rows) + { + ZxTagSettingEntity entity = new ZxTagSettingEntity() + { + Id = int.Parse(row.Cells["RfidId"].Value.ToString()), + RfidEpc = row.Cells["RfidEpc"].Value.ToString(), + DeviceNo = row.Cells["DeviceNo"].Value.ToString() + }; + lists.Add(entity); + } + + zx_rfid_tag_settingService.UpdateRangeTagInfo(lists); + + RefreshReaderGridView(); + + MessageBox.Show("标签信息修改成功"); + } } } diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.resx b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.resx index ed88a1c..bde35bf 100644 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.resx +++ b/HighWayIot.Winform/UserControlPages/ParamConfigPages/RFIDParamSettingPage.resx @@ -123,10 +123,16 @@ True + + True + + + True + True - + True \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.Designer.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.Designer.cs deleted file mode 100644 index 826336c..0000000 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.Designer.cs +++ /dev/null @@ -1,127 +0,0 @@ -namespace HighWayIot.Winform.UserControlPages.ParamConfigPages -{ - partial class UpdateRfidWindow - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.RfidIptextBox = new System.Windows.Forms.TextBox(); - this.RfidEpctextBox = new System.Windows.Forms.TextBox(); - this.WorkstateNotextBox = new System.Windows.Forms.TextBox(); - this.saveButton = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(174, 56); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(65, 12); - this.label1.TabIndex = 0; - this.label1.Text = "读写器IP:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(174, 135); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(65, 12); - this.label2.TabIndex = 1; - this.label2.Text = "RFID编号:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(174, 211); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(65, 12); - this.label3.TabIndex = 2; - this.label3.Text = "工位编号:"; - // - // RfidIptextBox - // - this.RfidIptextBox.Location = new System.Drawing.Point(241, 53); - this.RfidIptextBox.Name = "RfidIptextBox"; - this.RfidIptextBox.Size = new System.Drawing.Size(159, 21); - this.RfidIptextBox.TabIndex = 3; - // - // RfidEpctextBox - // - this.RfidEpctextBox.Location = new System.Drawing.Point(241, 135); - this.RfidEpctextBox.Name = "RfidEpctextBox"; - this.RfidEpctextBox.Size = new System.Drawing.Size(159, 21); - this.RfidEpctextBox.TabIndex = 4; - // - // WorkstateNotextBox - // - this.WorkstateNotextBox.Location = new System.Drawing.Point(241, 211); - this.WorkstateNotextBox.Name = "WorkstateNotextBox"; - this.WorkstateNotextBox.Size = new System.Drawing.Size(159, 21); - this.WorkstateNotextBox.TabIndex = 5; - // - // saveButton - // - this.saveButton.Location = new System.Drawing.Point(271, 315); - this.saveButton.Name = "saveButton"; - this.saveButton.Size = new System.Drawing.Size(75, 23); - this.saveButton.TabIndex = 6; - this.saveButton.Text = "修改"; - this.saveButton.UseVisualStyleBackColor = true; - this.saveButton.Click += new System.EventHandler(this.saveButton_Click); - // - // UpdateRfidWindow - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(674, 450); - this.Controls.Add(this.saveButton); - this.Controls.Add(this.WorkstateNotextBox); - this.Controls.Add(this.RfidEpctextBox); - this.Controls.Add(this.RfidIptextBox); - this.Controls.Add(this.label3); - this.Controls.Add(this.label2); - this.Controls.Add(this.label1); - this.Name = "UpdateRfidWindow"; - this.Text = "UpdateRfidWindow"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.TextBox RfidIptextBox; - private System.Windows.Forms.TextBox RfidEpctextBox; - private System.Windows.Forms.TextBox WorkstateNotextBox; - private System.Windows.Forms.Button saveButton; - } -} \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.cs b/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.cs deleted file mode 100644 index b935882..0000000 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.cs +++ /dev/null @@ -1,43 +0,0 @@ -using HighWayIot.Repository.domain; -using HighWayIot.Repository.service; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace HighWayIot.Winform.UserControlPages.ParamConfigPages -{ - public partial class UpdateRfidWindow : Form - { - private Zx_rfid_settingService zx_rfid_settingService = Zx_rfid_settingService.Instance; - private int _id; - public UpdateRfidWindow(int id,string ip,string epc,string no) - { - _id = id; - InitializeComponent(); - RfidIptextBox.Text = ip; - RfidEpctextBox.Text = epc; - WorkstateNotextBox.Text = no; - } - - private void saveButton_Click(object sender, EventArgs e) - { - if (!int.TryParse(WorkstateNotextBox.Text,out int result)) - { - MessageBox.Show("工作状态编号必须是整数"); - return; - } - Zx_rfid_setting zx_Rfid_Setting = zx_rfid_settingService.GetRfidInfoById(_id); - zx_Rfid_Setting.RfidIp = RfidIptextBox.Text; - zx_Rfid_Setting.RfidEpc = RfidEpctextBox.Text; - zx_Rfid_Setting.WorkstateNo = result; - zx_rfid_settingService.UpdateRfidInfo(zx_Rfid_Setting); - MessageBox.Show("修改成功"); - } - } -} diff --git a/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.resx b/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.resx deleted file mode 100644 index 1af7de1..0000000 --- a/HighWayIot.Winform/UserControlPages/ParamConfigPages/UpdateRfidWindow.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file