Commit 8737200d 张东亮

rfid读取异常

1 个父辈 8b465734
...@@ -211,6 +211,12 @@ namespace OnlineStore.ACPackingStore ...@@ -211,6 +211,12 @@ namespace OnlineStore.ACPackingStore
} }
//this.Close(); //this.Close();
try
{
RFIDManager.Close();
AgvClient.Dispose();
}
finally { }
System.Environment.Exit(System.Environment.ExitCode); System.Environment.Exit(System.Environment.ExitCode);
} }
} }
...@@ -332,9 +338,6 @@ namespace OnlineStore.ACPackingStore ...@@ -332,9 +338,6 @@ namespace OnlineStore.ACPackingStore
{ {
停止所有料仓TToolStripMenuItem_Click(null, null); 停止所有料仓TToolStripMenuItem_Click(null, null);
} }
RFIDManager.Close();
AgvClient.Dispose();
} }
private void btnClearLog_Click(object sender, EventArgs e) private void btnClearLog_Click(object sender, EventArgs e)
{ {
......
...@@ -73,7 +73,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -73,7 +73,7 @@ namespace OnlineStore.DeviceLibrary
IOManager.Init(); IOManager.Init();
//先初始化设备 //先初始化设备
RFIDManager.Open(rfidList.ToArray());
//初始化摄像机配置 //初始化摄像机配置
CodeManager.LoadConfig(); CodeManager.LoadConfig();
...@@ -153,8 +153,6 @@ namespace OnlineStore.DeviceLibrary ...@@ -153,8 +153,6 @@ namespace OnlineStore.DeviceLibrary
StartTime = DateTime.Now; StartTime = DateTime.Now;
//AgvClient.SetCancelState(false); //AgvClient.SetCancelState(false);
RFIDManager.Open(rfidList.ToArray());
mainTimer.Enabled = false; mainTimer.Enabled = false;
isInSuddenDown = false; isInSuddenDown = false;
isNoAirCheck = false; isNoAirCheck = false;
......
...@@ -3,6 +3,7 @@ using OnlineStore.Common; ...@@ -3,6 +3,7 @@ using OnlineStore.Common;
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
...@@ -15,7 +16,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -15,7 +16,7 @@ namespace OnlineStore.DeviceLibrary
private static Asa.RFID.ReadAll readHao; private static Asa.RFID.ReadAll readHao;
private static Asa.RFID.ReadAll readPu; private static Asa.RFID.ReadAll readPu;
private static bool IsOpen = false; private static bool IsOpen = false;
private static ConcurrentDictionary<string, List<RfidCacheInfo>> LastRfidMap = new ConcurrentDictionary<string, List<RfidCacheInfo>>(); private static Dictionary<string, string> LastRfidMap = new Dictionary<string, string>();
public static void Open(string[] iparray) public static void Open(string[] iparray)
{ {
if (IsOpen) if (IsOpen)
...@@ -29,13 +30,13 @@ namespace OnlineStore.DeviceLibrary ...@@ -29,13 +30,13 @@ namespace OnlineStore.DeviceLibrary
{ {
port = 13000; port = 13000;
} }
LogUtil.info($"RFID Server Open,HaoBin port={port},PuYue port={port + 1}");
readHao = new Asa.RFID.ReadAll("TheRFID") { Type = Asa.RFID.DeviceType.HaoBin }; readHao = new Asa.RFID.ReadAll("TheRFID") { Type = Asa.RFID.DeviceType.HaoBin };
readHao.Received += ReadAll_Received; ; readHao.Received += ReadAll_Received; ;
readHao.Start(port); readHao.Start(port);
readPu = new Asa.RFID.ReadAll("TheRFID") { Type = Asa.RFID.DeviceType.PuYue }; readPu = new Asa.RFID.ReadAll("TheRFID") { Type = Asa.RFID.DeviceType.PuYue };
readPu.Received += ReadAll_Received; readPu.Received += ReadAll_Received;
readPu.Start(port + 1); readPu.Start(port + 1);
LogUtil.info($"RFID Server Open,HaoBin port={port},PuYue port={port + 1}");
IsOpen = true; IsOpen = true;
} }
catch (Exception ex) catch (Exception ex)
...@@ -46,23 +47,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -46,23 +47,15 @@ namespace OnlineStore.DeviceLibrary
private static void ReadAll_Received(string ip, string id) private static void ReadAll_Received(string ip, string id)
{ {
List<RfidCacheInfo> list = LastRfidMap.GetOrAdd(ip, new List<RfidCacheInfo>()); if (LastRfidMap.ContainsKey(ip))
int count = list.Count;
if (count > 0)
{
RfidCacheInfo last = list[count - 1];
if (!last.Data.StrData.Equals(id))
{ {
RFIDData data = new RFIDData(id); LastRfidMap[ip] = id;
list.Add(new RfidCacheInfo(data)); }
if (list.Count > 3) else
{ {
list.RemoveAt(0); LastRfidMap.Add(ip, id);
} }
LogUtil.debug("ReadAll_Received[" + ip + "][" + id + "]加入缓存"); LogUtil.debug("ReadAll_Received[" + ip + "][" + id + "]加入缓存");
LastRfidMap.AddOrUpdate(ip, list, (key, value) => value);
}
}
} }
private static void ReadAll_Log(string ip, string log) private static void ReadAll_Log(string ip, string log)
...@@ -111,6 +104,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -111,6 +104,10 @@ namespace OnlineStore.DeviceLibrary
{ {
LogUtil.error("ReadRFID[" + ip + "] [" + isClear + "] 出错:" + ex.ToString()); LogUtil.error("ReadRFID[" + ip + "] [" + isClear + "] 出错:" + ex.ToString());
} }
if (LastRfidMap.ContainsKey(ip))
{
return new RFIDData() { StrData = LastRfidMap[ip] };
}
return new RFIDData(); return new RFIDData();
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!