Commit 8737200d 张东亮

rfid读取异常

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