From 191661448f00745dba3b2a50f6a842cd7c737fd1 Mon Sep 17 00:00:00 2001 From: SoulStar Date: Thu, 14 May 2026 17:53:26 +0800 Subject: [PATCH] =?UTF-8?q?feat=20-=20=E6=B7=BB=E5=8A=A0=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E7=9B=98=E7=82=B9=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE=E6=97=B6=E9=97=B4=E7=AD=9B?= =?UTF-8?q?=E9=80=89=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=94=81=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.Config/DeviceInfoConfig.cs | 9 +- SlnMesnac.Rfid/Factory/RflyFactory.cs | 407 +++++++++--------- SlnMesnac.Rfid/GloalVar.cs | 2 + .../IndexPage/ChangeTypeViewModel.cs | 2 +- .../IndexPage/HistorySearchViewModel.cs | 3 + .../IndexPage/ProductionLineViewModel.cs | 73 +++- SlnMesnac.WPF/appsettings.json | 8 +- 7 files changed, 295 insertions(+), 209 deletions(-) diff --git a/SlnMesnac.Config/DeviceInfoConfig.cs b/SlnMesnac.Config/DeviceInfoConfig.cs index 9dad17f..5680e02 100644 --- a/SlnMesnac.Config/DeviceInfoConfig.cs +++ b/SlnMesnac.Config/DeviceInfoConfig.cs @@ -61,7 +61,12 @@ namespace SlnMesnac.Config /// /// 首次读取写入延迟 /// - public int? WriteDelaySet { get; set; } + public int? WriteDelaySet { get; set; } + + /// + /// 盘点间隔时间(秒) + /// + public int? InventoryIntervalSeconds { get; set; } } - + } \ No newline at end of file diff --git a/SlnMesnac.Rfid/Factory/RflyFactory.cs b/SlnMesnac.Rfid/Factory/RflyFactory.cs index 0a445e7..d569943 100644 --- a/SlnMesnac.Rfid/Factory/RflyFactory.cs +++ b/SlnMesnac.Rfid/Factory/RflyFactory.cs @@ -96,10 +96,13 @@ namespace SlnMesnac.Rfid.Factory { try { - m_deviceID = deviceid; - m_strIP = ip; - _tcpClient.SetupAsync(new TouchSocketConfig().SetRemoteIPHost($"{ip}:{port}")); - await _tcpClient.ConnectAsync(1500); + lock (GloalVar.TCPLocker) + { + m_deviceID = deviceid; + m_strIP = ip; + _tcpClient.SetupAsync(new TouchSocketConfig().SetRemoteIPHost($"{ip}:{port}")); + _tcpClient.ConnectAsync(1500).GetAwaiter().GetResult(); + } _tcpClient.Received = (client, e) => { //从客户端收到信息 @@ -186,47 +189,50 @@ namespace SlnMesnac.Rfid.Factory /// public override async Task Set_HeartBeat(byte second) { - byte[] data = new byte[3]; - data[0] = 0x00; - data[1] = second; - data[2] = 0x01; - - BaseSendDataEntity entity = new BaseSendDataEntity() + lock (GloalVar.TCPLocker) { - Code = 0xBF, - Data = data - }; + byte[] data = new byte[3]; + data[0] = 0x00; + data[1] = second; + data[2] = 0x01; - byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity); - - var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions() - { - FilterFunc = response => + BaseSendDataEntity entity = new BaseSendDataEntity() { - // 检查响应数据是否符合预期 - if (response.Memory.Length > 0) + Code = 0xBF, + Data = data + }; + + byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity); + + var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions() + { + FilterFunc = response => + { + // 检查响应数据是否符合预期 + if (response.Memory.Length > 0) + { + // 可以根据实际情况添加更多的检查逻辑 + return true; + } + return false; + } + }); + + using (var responsedData = waitClient.SendThenResponseAsync(result, 2000).GetAwaiter().GetResult()) + { + var reciveBuffer = responsedData.Memory.ToArray(); + + byte[] resultBuffer = PareReceiveBufferData(reciveBuffer, reciveBuffer.Length); + Log.Information($"{m_deviceID}接收读取指令{_stringChange.bytesToHexStr(resultBuffer, resultBuffer.Length)}"); + + if (resultBuffer[3] == 0xBF || resultBuffer[4] == 0x00) { - // 可以根据实际情况添加更多的检查逻辑 return true; } - return false; - } - }); - - using (var responsedData = await waitClient.SendThenResponseAsync(result, 2000)) - { - var reciveBuffer = responsedData.Memory.ToArray(); - - byte[] resultBuffer = PareReceiveBufferData(reciveBuffer, reciveBuffer.Length); - Log.Information($"{m_deviceID}接收读取指令{_stringChange.bytesToHexStr(resultBuffer, resultBuffer.Length)}"); - - if (resultBuffer[3] == 0xBF || resultBuffer[4] == 0x00) - { - return true; - } - else - { - return false; + else + { + return false; + } } } } @@ -541,50 +547,54 @@ namespace SlnMesnac.Rfid.Factory /// public override async Task Set_StopIdentify() { + byte[] bCRC = new byte[4]; try { - #region 指令封装 - MessagePack pMessagePack = new MessagePack(); - pMessagePack.m_pData = new byte[8]; - pMessagePack.m_pData[0] = 0xAA; - pMessagePack.m_pData[1] = 0x55; - pMessagePack.m_pData[2] = 0x02; - pMessagePack.m_pData[3] = 0x12; - pMessagePack.m_pData[4] = 0x00; - pMessagePack.m_pData[5] = 0x00; - Array.Copy(pMessagePack.m_pData, 2, bCRC, 0, 4); - pMessagePack.m_pData[6] = _stringChange.CalculateVerify(bCRC, bCRC.Length); - pMessagePack.m_pData[7] = 0x0D; - #endregion 指令封装 + lock (GloalVar.TCPLocker) + { + #region 指令封装 + MessagePack pMessagePack = new MessagePack(); + pMessagePack.m_pData = new byte[8]; + pMessagePack.m_pData[0] = 0xAA; + pMessagePack.m_pData[1] = 0x55; + pMessagePack.m_pData[2] = 0x02; + pMessagePack.m_pData[3] = 0x12; + pMessagePack.m_pData[4] = 0x00; + pMessagePack.m_pData[5] = 0x00; + Array.Copy(pMessagePack.m_pData, 2, bCRC, 0, 4); + pMessagePack.m_pData[6] = _stringChange.CalculateVerify(bCRC, bCRC.Length); + pMessagePack.m_pData[7] = 0x0D; + #endregion 指令封装 - _tcpClient.SendAsync(pMessagePack.m_pData).GetAwaiter().GetResult(); - //var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions() - //{ - // FilterFunc = response => - // { - // // 检查响应数据是否符合预期 - // if (response.Memory.Length > 0) - // { - // // 可以根据实际情况添加更多的检查逻辑 - // return true; - // } - // return false; - // } - //}); - //Log.Information($"{m_deviceID}发送停止连续盘点指令{_stringChange.bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length)}"); - //using (var responsedData = await waitClient.SendThenResponseAsync(pMessagePack.m_pData, 2000)) - //{ - // var reciveBuffer = responsedData.Memory.ToArray(); - // Log.Information($"{m_deviceID}接收停止连续盘点指令{_stringChange.bytesToHexStr(reciveBuffer, reciveBuffer.Length)}"); - // if (reciveBuffer[3] == 0x12) - // { - // return true; - // } - //} - //return false; - return true; + _tcpClient.SendAsync(pMessagePack.m_pData).GetAwaiter().GetResult(); + //var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions() + //{ + // FilterFunc = response => + // { + // // 检查响应数据是否符合预期 + // if (response.Memory.Length > 0) + // { + // // 可以根据实际情况添加更多的检查逻辑 + // return true; + // } + // return false; + // } + //}); + //Log.Information($"{m_deviceID}发送停止连续盘点指令{_stringChange.bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length)}"); + //using (var responsedData = await waitClient.SendThenResponseAsync(pMessagePack.m_pData, 2000)) + //{ + // var reciveBuffer = responsedData.Memory.ToArray(); + // Log.Information($"{m_deviceID}接收停止连续盘点指令{_stringChange.bytesToHexStr(reciveBuffer, reciveBuffer.Length)}"); + // if (reciveBuffer[3] == 0x12) + // { + // return true; + // } + //} + //return false; + return true; + } } catch (Exception e) { @@ -603,46 +613,50 @@ namespace SlnMesnac.Rfid.Factory byte[] bCRC = new byte[4]; try { - #region 指令封装 - MessagePack pMessagePack = new MessagePack(); - pMessagePack.m_pData = new byte[8]; - pMessagePack.m_pData[0] = 0xAA; - pMessagePack.m_pData[1] = 0x55; - pMessagePack.m_pData[2] = 0x02; - pMessagePack.m_pData[3] = 0x11; - pMessagePack.m_pData[4] = 0x00; - pMessagePack.m_pData[5] = 0x00; - Array.Copy(pMessagePack.m_pData, 2, bCRC, 0, 4); - pMessagePack.m_pData[6] = _stringChange.CalculateVerify(bCRC, bCRC.Length); - pMessagePack.m_pData[7] = 0x0D; - #endregion 指令封装 + lock (GloalVar.TCPLocker) + { - _tcpClient.SendAsync(pMessagePack.m_pData).GetAwaiter().GetResult(); + #region 指令封装 + MessagePack pMessagePack = new MessagePack(); + pMessagePack.m_pData = new byte[8]; + pMessagePack.m_pData[0] = 0xAA; + pMessagePack.m_pData[1] = 0x55; + pMessagePack.m_pData[2] = 0x02; + pMessagePack.m_pData[3] = 0x11; + pMessagePack.m_pData[4] = 0x00; + pMessagePack.m_pData[5] = 0x00; + Array.Copy(pMessagePack.m_pData, 2, bCRC, 0, 4); + pMessagePack.m_pData[6] = _stringChange.CalculateVerify(bCRC, bCRC.Length); + pMessagePack.m_pData[7] = 0x0D; + #endregion 指令封装 - //var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions() - //{ - // FilterFunc = response => - // { - // // 检查响应数据是否符合预期 - // if (response.Memory.Length > 0) - // { - // // 可以根据实际情况添加更多的检查逻辑 - // return true; - // } - // return false; - // } - //}); - //Log.Information($"{m_deviceID}发送连续盘点指令{_stringChange.bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length)}"); - //using (var responsedData = await waitClient.SendThenResponseAsync(pMessagePack.m_pData, 2000)) - //{ - // var reciveBuffer = responsedData.Memory.ToArray(); - // Log.Information($"{m_deviceID}接收连续盘点指令{_stringChange.bytesToHexStr(reciveBuffer, reciveBuffer.Length)}"); - // if (reciveBuffer[3] == 0x11) - // { - // return true; - // } - //} - return true; + _tcpClient.SendAsync(pMessagePack.m_pData).GetAwaiter().GetResult(); + + //var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions() + //{ + // FilterFunc = response => + // { + // // 检查响应数据是否符合预期 + // if (response.Memory.Length > 0) + // { + // // 可以根据实际情况添加更多的检查逻辑 + // return true; + // } + // return false; + // } + //}); + //Log.Information($"{m_deviceID}发送连续盘点指令{_stringChange.bytesToHexStr(pMessagePack.m_pData, pMessagePack.m_pData.Length)}"); + //using (var responsedData = await waitClient.SendThenResponseAsync(pMessagePack.m_pData, 2000)) + //{ + // var reciveBuffer = responsedData.Memory.ToArray(); + // Log.Information($"{m_deviceID}接收连续盘点指令{_stringChange.bytesToHexStr(reciveBuffer, reciveBuffer.Length)}"); + // if (reciveBuffer[3] == 0x11) + // { + // return true; + // } + //} + return true; + } } catch (Exception e) { @@ -659,6 +673,7 @@ namespace SlnMesnac.Rfid.Factory /// public override async Task Set_Write(byte[] pSelectData, string pWriteData) { + byte[] bWriteData = null; if (Convert.ToByte(pWriteData.Length % 2) != 0) { @@ -693,91 +708,95 @@ namespace SlnMesnac.Rfid.Factory try { - #region 指令封装 - //自动根据写入数据封装 - Base03HENtity rawData = new Base03HENtity() + lock (GloalVar.TCPLocker) { - TimeOut = _stringChange.IntToBytes(2, 1000), - AccessPassword = _stringChange.IntToBytes(4, 0), - SelectBank = 01, - SelectAddress = _stringChange.IntToBytes(4, 32), - SelectLength = (byte)(pSelectData.Count() * 8), - SelectData = pSelectData, - WriteBank = 01, - WriteAddress = _stringChange.IntToBytes(4, 1), - WordCount = (byte)((finalWriteData.Count() / 2)), - WriteData = finalWriteData - }; - - int selectLength = rawData.SelectLength / 8; - int wordCount = rawData.WordCount * 2; - byte[] bytes = new byte[2 + 4 + 1 + 4 + 1 + selectLength + 1 + 4 + 1 + wordCount]; - - int index = 0; - - Array.Copy(rawData.TimeOut, 0, bytes, index, 2); - index += 2; - - Array.Copy(rawData.AccessPassword, 0, bytes, index, 4); - index += 4; - - bytes[index] = rawData.SelectBank; - index++; - - Array.Copy(rawData.SelectAddress, 0, bytes, index, 4); - index += 4; - - bytes[index] = rawData.SelectLength; - index++; - - Array.Copy(rawData.SelectData, 0, bytes, index, selectLength); - index += selectLength; - - bytes[index] = rawData.WriteBank; - index++; - - Array.Copy(rawData.WriteAddress, 0, bytes, index, 4); - index += 4; - - bytes[index] = rawData.WordCount; - index++; - - Array.Copy(rawData.WriteData, 0, bytes, index, wordCount); - index += wordCount; - - BaseSendDataEntity entity = new BaseSendDataEntity() - { - Code = 0x03, - Data = bytes - }; - byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity); - #endregion 指令封装 - - var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions() - { - FilterFunc = response => + #region 指令封装 + //自动根据写入数据封装 + Base03HENtity rawData = new Base03HENtity() { - // 检查响应数据是否符合预期 - if (response.Memory.Length > 0) + TimeOut = _stringChange.IntToBytes(2, 1000), + AccessPassword = _stringChange.IntToBytes(4, 0), + SelectBank = 01, + SelectAddress = _stringChange.IntToBytes(4, 32), + SelectLength = (byte)(pSelectData.Count() * 8), + SelectData = pSelectData, + WriteBank = 01, + WriteAddress = _stringChange.IntToBytes(4, 1), + WordCount = (byte)((finalWriteData.Count() / 2)), + WriteData = finalWriteData + }; + + int selectLength = rawData.SelectLength / 8; + int wordCount = rawData.WordCount * 2; + byte[] bytes = new byte[2 + 4 + 1 + 4 + 1 + selectLength + 1 + 4 + 1 + wordCount]; + + int index = 0; + + Array.Copy(rawData.TimeOut, 0, bytes, index, 2); + index += 2; + + Array.Copy(rawData.AccessPassword, 0, bytes, index, 4); + index += 4; + + bytes[index] = rawData.SelectBank; + index++; + + Array.Copy(rawData.SelectAddress, 0, bytes, index, 4); + index += 4; + + bytes[index] = rawData.SelectLength; + index++; + + Array.Copy(rawData.SelectData, 0, bytes, index, selectLength); + index += selectLength; + + bytes[index] = rawData.WriteBank; + index++; + + Array.Copy(rawData.WriteAddress, 0, bytes, index, 4); + index += 4; + + bytes[index] = rawData.WordCount; + index++; + + Array.Copy(rawData.WriteData, 0, bytes, index, wordCount); + index += wordCount; + + BaseSendDataEntity entity = new BaseSendDataEntity() + { + Code = 0x03, + Data = bytes + }; + byte[] result = BaseRFIDDataAnalyse.BaseSendDataAnalyse(entity); + #endregion 指令封装 + + var waitClient = _tcpClient.CreateWaitingClient(new WaitingOptions() + { + FilterFunc = response => { - // 可以根据实际情况添加更多的检查逻辑 + // 检查响应数据是否符合预期 + if (response.Memory.Length > 0) + { + // 可以根据实际情况添加更多的检查逻辑 + return true; + } + return false; + } + }); + Log.Information($"{m_deviceID}发送写入指令{_stringChange.bytesToHexStr(result, result.Length)}"); + using (var responsedData = waitClient.SendThenResponseAsync(result, 2000).GetAwaiter().GetResult()) + { + var reciveBuffer = responsedData.Memory.ToArray(); + Log.Information($"{m_deviceID}接收写入指令{_stringChange.bytesToHexStr(reciveBuffer, reciveBuffer.Length)}"); + if (reciveBuffer[3] == 0x03 && reciveBuffer[4] == 0x00) + { + Log.Information($"写入成功,写入数值{pWriteData}"); return true; } - return false; - } - }); - Log.Information($"{m_deviceID}发送写入指令{_stringChange.bytesToHexStr(result, result.Length)}"); - using (var responsedData = await waitClient.SendThenResponseAsync(result, 2000)) - { - var reciveBuffer = responsedData.Memory.ToArray(); - Log.Information($"{m_deviceID}接收写入指令{_stringChange.bytesToHexStr(reciveBuffer, reciveBuffer.Length)}"); - if (reciveBuffer[3] == 0x03 && reciveBuffer[4] == 0x00) - { - Log.Information($"写入成功,写入数值{pWriteData}"); - return true; } + return false; } - return false; + } catch (Exception e) { diff --git a/SlnMesnac.Rfid/GloalVar.cs b/SlnMesnac.Rfid/GloalVar.cs index 52ee86c..0532738 100644 --- a/SlnMesnac.Rfid/GloalVar.cs +++ b/SlnMesnac.Rfid/GloalVar.cs @@ -10,5 +10,7 @@ namespace SlnMesnac.Rfid public class GloalVar { public static Dictionary HeartBeatRecoard { get; set; } = new Dictionary(); + + public static readonly object TCPLocker = new object(); } } diff --git a/SlnMesnac.WPF/ViewModel/IndexPage/ChangeTypeViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexPage/ChangeTypeViewModel.cs index a4fe8f3..2f0388c 100644 --- a/SlnMesnac.WPF/ViewModel/IndexPage/ChangeTypeViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/IndexPage/ChangeTypeViewModel.cs @@ -155,7 +155,7 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage if (res) { MessageBox.Show("停止盘点成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information); - WeakReferenceMessenger.Default.Send("Cancel", "Cancel"); + WeakReferenceMessenger.Default.Send(DeviceInfos[0].Deviceid, "Cancel"); } else { diff --git a/SlnMesnac.WPF/ViewModel/IndexPage/HistorySearchViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexPage/HistorySearchViewModel.cs index 2c5cb2a..68ac6d7 100644 --- a/SlnMesnac.WPF/ViewModel/IndexPage/HistorySearchViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/IndexPage/HistorySearchViewModel.cs @@ -103,6 +103,9 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage exp = exp.And(x => x.writestatus == QueryIsCheck.Content.ToString()); } + // 添加日期范围过滤 + exp = exp.And(x => x.writetime >= dateTime && x.writetime <= dateTime1); + //查询记录 List real_readdataInfos = databaseService._helper.Query(exp); if (real_readdataInfos.Count > 0) diff --git a/SlnMesnac.WPF/ViewModel/IndexPage/ProductionLineViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexPage/ProductionLineViewModel.cs index 0a40967..987ccd4 100644 --- a/SlnMesnac.WPF/ViewModel/IndexPage/ProductionLineViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/IndexPage/ProductionLineViewModel.cs @@ -53,9 +53,10 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage private MeshttpClient meshttpClient; public TcpServer _TcpServer; private DispatcherTimer _timer; + private Dictionary _inventoryTimers = new Dictionary(); private ObservableCollection _rfidHistoryRecords = new ObservableCollection(); private RealReadDataImpl databaseService = RealReadDataImpl.Instance; - + private System.Threading.Timer ReReadTimer; private bool IsVerify = false; private string LastWrite; private string LastRFIDEPC; @@ -167,6 +168,7 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage CurrentDateTime = DateTime.Now; }; _timer.Start(); + Log.Information("RFID输送带系统启动"); } @@ -217,6 +219,13 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage rfidList.FirstOrDefault(x => x.deviceid == real_Data.Deviceid).Set_BeginIdentify().GetAwaiter().GetResult(); CurrentState = "盘点中"; + + // 启动定时盘点 + var deviceConfig = appConfig.deviceInfoConfig.FirstOrDefault(x => x.Deviceid == real_Data.Deviceid); + if (deviceConfig?.InventoryIntervalSeconds > 0) + { + StartInventoryTimer(real_Data.Deviceid, deviceConfig.InventoryIntervalSeconds.Value); + } } /// @@ -224,6 +233,7 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage /// private void StopMessage(object o, string e) { + StopInventoryTimer(e); CurrentState = "空闲"; } @@ -287,6 +297,8 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage Deviceinfo.Add(real_DataInfo); } }); + + } /// @@ -429,14 +441,6 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage } } - /// - /// Writes data to an RFID tag - /// - private async void WriteRFID(string iCombineId, List tagInfos) - { - - } - public void RefreshEventArgs(string iCombineId, List tagInfos) { try @@ -563,6 +567,57 @@ namespace SlnMesnac.WPF.ViewModel.IndexPage } } + /// + /// 启动定时盘点 + /// + private void StartInventoryTimer(string deviceId, int intervalSeconds) + { + StopInventoryTimer(deviceId); + var timer = new DispatcherTimer + { + Interval = TimeSpan.FromMilliseconds(intervalSeconds) + }; + timer.Tick += (s, e) => OnInventoryTimerTick(deviceId); + timer.Start(); + _inventoryTimers[deviceId] = timer; + Log.Information($"设备 {deviceId} 启动定时盘点,间隔 {intervalSeconds} ms"); + } + + /// + /// 停止定时盘点 + /// + private void StopInventoryTimer(string deviceId) + { + if (_inventoryTimers.TryGetValue(deviceId, out var timer)) + { + timer.Stop(); + _inventoryTimers.Remove(deviceId); + Log.Information($"设备 {deviceId} 停止定时盘点"); + } + } + + /// + /// 定时盘点回调 + /// + private async void OnInventoryTimerTick(string deviceId) + { + try + { + var rfid = rfidList.FirstOrDefault(x => x.deviceid == deviceId); + if (rfid != null) + { + //Log.Information($"设备 {deviceId} 执行定时盘点"); + await rfid.Set_StopIdentify(); + await Task.Delay(100); + await rfid.Set_BeginIdentify(); + } + } + catch (Exception ex) + { + Log.Error($"设备 {deviceId} 定时盘点异常: {ex.Message}"); + } + } + /// /// 无限重连 /// diff --git a/SlnMesnac.WPF/appsettings.json b/SlnMesnac.WPF/appsettings.json index 219f9dd..b6de991 100644 --- a/SlnMesnac.WPF/appsettings.json +++ b/SlnMesnac.WPF/appsettings.json @@ -82,18 +82,20 @@ "Collectid": "102", "Addr": "VM006", "Deleteflag": "0", - "WriteDelaySet": 0 + "WriteDelaySet": 1000, + "InventoryIntervalSeconds": 5000 }, { "DeviceId": "10002", "Name": "Line2", - "ConnectStr": "192.168.0.7:20108", + "ConnectStr": "192.168.0.8:20109", "Connectmode": "1", "Devicetype": "RFly_I160", "Collectid": "102", "Addr": "VM006", "Deleteflag": "1", - "WriteDelaySet": 0 + "WriteDelaySet": 1000, + "InventoryIntervalSeconds": 5000 } ],