Commit d31df789 LN

bug修改

1 个父辈 f0bd4276
......@@ -1274,7 +1274,7 @@ namespace OnlineStore.DeviceLibrary
{
return true;
}
if (IOValue(IO_Type.StopCylinder_Check2).Equals(IO_VALUE.HIGH) || IOValue(IO_Type.StopCylinder_Check1).Equals(IO_VALUE.HIGH))
if (IOValue(IO_Type.StopCylinder_Check2).Equals(IO_VALUE.HIGH) )
{
return true;
}
......
......@@ -84,69 +84,78 @@ namespace OnlineStore.DeviceLibrary
private static bool CheckTrayNum(string ip, int num)
{
RFIDData data = new RFIDData(ip);
List<RfidCacheInfo> list = LastRfidMap.GetOrAdd(ip, new List<RfidCacheInfo>());
if (list.Count > 0)
try
{
RFIDData data = new RFIDData(ip);
List<RfidCacheInfo> list = LastRfidMap.GetOrAdd(ip, new List<RfidCacheInfo>());
int readNumIndex = -1;
string listStr = "";
for (int i = 0; i < list.Count; i++)
if (list.Count > 0)
{
RfidCacheInfo cacheInfo = list[i];
if (cacheInfo.Data.Num.Equals(num))
int readNumIndex = -1;
string listStr = "";
for (int i = 0; i < list.Count; i++)
{
listStr += "【" + cacheInfo.Data.Num + "," + cacheInfo.Used + "," + cacheInfo.UpdateTime.ToLongTimeString() + "】";
readNumIndex = i;
}
}
if (readNumIndex == -1)
{
list.Add(new RfidCacheInfo(data, true));
if (list.Count > 3)
RfidCacheInfo cacheInfo = list[i];
if (cacheInfo.Data.Num.Equals(num))
{
listStr += "【" + cacheInfo.Data.Num + "," + cacheInfo.Used + "," + cacheInfo.UpdateTime.ToLongTimeString() + "】";
readNumIndex = i;
}
}
if (readNumIndex == -1)
{
list.RemoveAt(0);
list.Add(new RfidCacheInfo(data, true));
if (list.Count > 3)
{
list.RemoveAt(0);
}
LastRfidMap.AddOrUpdate(ip, list, (key, value) => value);
LogUtil.error("CheckTrayNum托盘号验证: [" + ip + "][" + num + "],未找到此托盘缓存,增加次托盘到缓存。缓存数据:" + listStr);
return true;
}
LastRfidMap.AddOrUpdate(ip, list, (key, value) => value);
LogUtil.error("CheckTrayNum托盘号验证: [" + ip + "][" + num + "],未找到此托盘缓存,增加次托盘到缓存。缓存数据:" + listStr);
return true;
}
else if (readNumIndex == (list.Count - 1))
{
//是最后一个
if (list[readNumIndex].Used)
else if (readNumIndex == (list.Count - 1))
{
LogUtil.error("CheckTrayNum托盘号验证失败: [" + ip + "][" + num + "],缓存记录当前托盘已使用。缓存数据:" + listStr);
return false;
//是最后一个
if (list[readNumIndex].Used)
{
LogUtil.error("CheckTrayNum托盘号验证失败: [" + ip + "][" + num + "],缓存记录当前托盘已使用。缓存数据:" + listStr);
return false;
}
else
{
//更改状态
list[readNumIndex].Used = true;
LastRfidMap.AddOrUpdate(ip, list, (key, value) => value);
int preIndex = readNumIndex - 1;
//上一个已使用
if (list.Count > preIndex && preIndex >= 0)
{
if (!list[preIndex].Used)
{
LogUtil.error("CheckTrayNum托盘号验证失败: [" + ip + "][" + num + "],缓存记录上一个托盘未使用,更新当前托盘为已用。缓存数据:" + listStr);
return false;
}
}
}
}
//不是最后一个
else
{
//更改状态
list[readNumIndex].Used = true;
LastRfidMap.AddOrUpdate(ip, list, (key, value) => value);
//上一个已使用
if (list.Count > readNumIndex - 1)
{
if (!list[readNumIndex - 1].Used)
{
LogUtil.error("CheckTrayNum托盘号验证失败: [" + ip + "][" + num + "],缓存记录上一个托盘未使用,更新当前托盘为已用。缓存数据:" + listStr);
return false;
}
}
LogUtil.error("CheckTrayNum托盘号验证失败: [" + ip + "][" + num + "],当前托盘索引=" + readNumIndex + ",总缓存托盘数=" + list.Count + ",不是最后一个缓存托盘号,更新当前托盘为已用。缓存数据:" + listStr);
return false;
}
}
//不是最后一个
else
{
//更改状态
list[readNumIndex].Used = true;
LastRfidMap.AddOrUpdate(ip, list, (key, value) => value);
LogUtil.error("CheckTrayNum托盘号验证失败: [" + ip + "][" + num + "],当前托盘索引=" + readNumIndex + ",总缓存托盘数=" + list.Count + ",不是最后一个缓存托盘号,更新当前托盘为已用。缓存数据:" + listStr);
return false;
}
}
}
catch (Exception ex)
{
LogUtil.error(" CheckTrayNum [" + ip + "][" + num + "] 出错:" + ex.ToString());
}
return true;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!