修改瞅瞅
This commit is contained in:
parent
4df6b668bf
commit
0314f4d403
@ -49,7 +49,7 @@ namespace DH.Devices.PLC
|
|||||||
{
|
{
|
||||||
connected = true;
|
connected = true;
|
||||||
MonitorPieces();
|
MonitorPieces();
|
||||||
TurntableOpen(18000,true);
|
TurntableOpen(2000,true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
|
|
||||||
namespace DH.Devices.Vision
|
namespace DH.Devices.Vision
|
||||||
@ -171,7 +172,7 @@ namespace DH.Devices.Vision
|
|||||||
{
|
{
|
||||||
MLResult mlResult = new MLResult();
|
MLResult mlResult = new MLResult();
|
||||||
Mat originMat=new Mat() ;
|
Mat originMat=new Mat() ;
|
||||||
Mat detectMat;
|
Mat detectMat= new Mat();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (req.mImage == null)
|
if (req.mImage == null)
|
||||||
@ -182,7 +183,7 @@ namespace DH.Devices.Vision
|
|||||||
}
|
}
|
||||||
|
|
||||||
// resize
|
// resize
|
||||||
detectMat = req.mImage;//1ms
|
detectMat = req.mImage.Clone();//1ms
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -200,9 +201,10 @@ namespace DH.Devices.Vision
|
|||||||
else if (detectMat.Channels() == 3)
|
else if (detectMat.Channels() == 3)
|
||||||
{
|
{
|
||||||
// 如果已经是三通道(BGR),则直接转换为RGB
|
// 如果已经是三通道(BGR),则直接转换为RGB
|
||||||
|
|
||||||
Cv2.CvtColor( detectMat,originMat, ColorConversionCodes.BGR2RGB);
|
// Cv2.CvtColor( detectMat,originMat, ColorConversionCodes.BGR2RGB);
|
||||||
|
// 直接使用原始图像
|
||||||
|
originMat = detectMat.Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
//输入数据转化为字节
|
//输入数据转化为字节
|
||||||
@ -225,7 +227,7 @@ namespace DH.Devices.Vision
|
|||||||
req.confThreshold, req.iouThreshold,
|
req.confThreshold, req.iouThreshold,
|
||||||
ref outputByte[0],
|
ref outputByte[0],
|
||||||
ref labellist[0]);
|
ref labellist[0]);
|
||||||
//mlResult.IsSuccess = true;
|
// mlResult.IsSuccess = true;
|
||||||
}
|
}
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
|
|
||||||
@ -257,10 +259,19 @@ namespace DH.Devices.Vision
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
req.mImage?.Dispose();
|
// 释放 Mat 资源
|
||||||
req.mImage = null;
|
if (detectMat != null)
|
||||||
|
{
|
||||||
originMat = null;
|
detectMat.Dispose();
|
||||||
|
detectMat = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (originMat != null)
|
||||||
|
{
|
||||||
|
originMat.Dispose();
|
||||||
|
originMat = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// GC.Collect();
|
// GC.Collect();
|
||||||
|
@ -317,22 +317,22 @@ namespace DHSoftware
|
|||||||
|
|
||||||
|
|
||||||
det2.CameraCollects = CameraCollects2;
|
det2.CameraCollects = CameraCollects2;
|
||||||
det1.ModelconfThreshold = Conf;
|
det2.ModelconfThreshold = Conf;
|
||||||
det1.ModelWidth = 640;
|
det2.ModelWidth = 640;
|
||||||
det1.ModelHeight = 640;
|
det2.ModelHeight = 640;
|
||||||
det1.in_lable_path = " D:\\PROJECTS\\MaodingTest1\\Vision\\cam2.txt";
|
det2.in_lable_path = " D:\\PROJECTS\\MaodingTest1\\Vision\\cam2.txt";
|
||||||
|
|
||||||
det3.CameraCollects = CameraCollects3;
|
det3.CameraCollects = CameraCollects3;
|
||||||
det1.ModelconfThreshold = Conf;
|
det3.ModelconfThreshold = Conf;
|
||||||
det1.ModelWidth = 640;
|
det3.ModelWidth = 640;
|
||||||
det1.ModelHeight = 640;
|
det3.ModelHeight = 640;
|
||||||
det1.in_lable_path = " D:\\PROJECTS\\MaodingTest1\\Vision\\cam3.txt";
|
det3.in_lable_path = " D:\\PROJECTS\\MaodingTest1\\Vision\\cam3.txt";
|
||||||
|
|
||||||
det4.CameraCollects = CameraCollects4;
|
det4.CameraCollects = CameraCollects4;
|
||||||
det1.ModelconfThreshold = Conf;
|
det4.ModelconfThreshold = Conf;
|
||||||
det1.ModelWidth = 640;
|
det4.ModelWidth = 640;
|
||||||
det1.ModelHeight = 640;
|
det4.ModelHeight = 640;
|
||||||
det1.in_lable_path = " D:\\PROJECTS\\MaodingTest1\\Vision\\cam4.txt";
|
det4.in_lable_path = " D:\\PROJECTS\\MaodingTest1\\Vision\\cam4.txt";
|
||||||
|
|
||||||
detectionList.Add(det1);
|
detectionList.Add(det1);
|
||||||
detectionList.Add(det2);
|
detectionList.Add(det2);
|
||||||
@ -401,11 +401,8 @@ namespace DHSoftware
|
|||||||
|
|
||||||
|
|
||||||
simbo2.Load(mLInit2);
|
simbo2.Load(mLInit2);
|
||||||
for(int i = 0;i<Dectection.Count;i++)
|
|
||||||
{
|
Dectection.Add(det2.Id, simbo2);
|
||||||
|
|
||||||
}
|
|
||||||
Dectection.Add(det1.Id, simbo2);
|
|
||||||
|
|
||||||
PLC.IP = "192.168.6.6";
|
PLC.IP = "192.168.6.6";
|
||||||
PLC.Port = 502;
|
PLC.Port = 502;
|
||||||
@ -480,475 +477,492 @@ namespace DHSoftware
|
|||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
// 拍照计数与物件编号一致,查找对应的产品
|
using (Mat localImageSet = imageSet.Clone()) // 复制 Mat 避免并发问题
|
||||||
ProductData product = null;
|
|
||||||
//内外壁模组多个相机的处理方法
|
|
||||||
//计算队列的方法不变
|
|
||||||
int index = PieceNumberToIndex(productNumber);
|
|
||||||
// 找到产品存放在哪个队列里
|
|
||||||
ConcurrentDictionary<uint, ProductData> tmpDic = _productLists[index];
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
int retryTimes = 100;
|
// 拍照计数与物件编号一致,查找对应的产品
|
||||||
while (product == null && retryTimes > 0)
|
ProductData product = null;
|
||||||
|
//内外壁模组多个相机的处理方法
|
||||||
|
//计算队列的方法不变
|
||||||
|
int index = PieceNumberToIndex(productNumber);
|
||||||
|
// 找到产品存放在哪个队列里
|
||||||
|
ConcurrentDictionary<uint, ProductData> tmpDic = _productLists[index];
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (tmpDic.ContainsKey(productNumber))
|
int retryTimes = 100;
|
||||||
|
while (product == null && retryTimes > 0)
|
||||||
{
|
{
|
||||||
product = tmpDic[productNumber];
|
if (tmpDic.ContainsKey(productNumber))
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Thread.Sleep(20);
|
|
||||||
}
|
|
||||||
retryTimes--;
|
|
||||||
}
|
|
||||||
// 如果产品为空,则销毁图片,提示错误
|
|
||||||
if (null == product)
|
|
||||||
{
|
|
||||||
List<uint> pnList = tmpDic.Keys.ToList();
|
|
||||||
|
|
||||||
string pnStr = "";
|
|
||||||
if (pnList != null && pnList.Count > 0)
|
|
||||||
{
|
|
||||||
pnStr = string.Join(",", pnList);
|
|
||||||
}
|
|
||||||
|
|
||||||
//LogAsync(DateTime.Now, LogLevel.Error, $"{camera.Name} 未找到产品,编号:{productNumber},队列{index}数量:{tmpDic.Count},列表:{pnStr}");
|
|
||||||
imageSet.Dispose();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 找到产品{productNumber},队列{index}数量:{tmpDic.Count}");
|
|
||||||
|
|
||||||
if (!_cameraRelatedDetectionDict.ContainsKey(camera.CameraName))
|
|
||||||
{
|
|
||||||
if (imageSet != null)
|
|
||||||
{
|
|
||||||
imageSet?.Dispose();
|
|
||||||
imageSet = null;
|
|
||||||
}
|
|
||||||
imageSet.Dispose();
|
|
||||||
// LogAsync(DateTime.Now, LogLevel.Warning, $"{camera.Name} 找到产品{productNumber},但是没有推理1");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
double totalTime = 0.0;
|
|
||||||
List<ResultState> resultStates = new List<ResultState>();
|
|
||||||
List<string>? detectionDict = _cameraRelatedDetectionDict[camera.CameraName];
|
|
||||||
if (detectionDict.Count == 0)
|
|
||||||
{
|
|
||||||
//LogAsync(DateTime.Now, LogLevel.Warning, $"{camera.Name} 找到产品{productNumber},但是没有推理3");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < detectionDict.Count; i++)
|
|
||||||
{
|
|
||||||
string detectionId = detectionDict[i];
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DetectionConfig detectConfig = null;
|
|
||||||
//找到对应的配置
|
|
||||||
if (!string.IsNullOrWhiteSpace(detectionId))
|
|
||||||
{
|
{
|
||||||
detectConfig = detectionList.FirstOrDefault(u => u.Id == detectionId);
|
product = tmpDic[productNumber];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
detectConfig = detectionList.FirstOrDefault(u => u.CameraSourceId == camera.CameraName);
|
Thread.Sleep(20);
|
||||||
|
}
|
||||||
|
retryTimes--;
|
||||||
|
}
|
||||||
|
// 如果产品为空,则销毁图片,提示错误
|
||||||
|
if (null == product)
|
||||||
|
{
|
||||||
|
List<uint> pnList = tmpDic.Keys.ToList();
|
||||||
|
|
||||||
|
string pnStr = "";
|
||||||
|
if (pnList != null && pnList.Count > 0)
|
||||||
|
{
|
||||||
|
pnStr = string.Join(",", pnList);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (detectConfig == null)
|
//LogAsync(DateTime.Now, LogLevel.Error, $"{camera.Name} 未找到产品,编号:{productNumber},队列{index}数量:{tmpDic.Count},列表:{pnStr}");
|
||||||
{
|
localImageSet.Dispose();
|
||||||
|
return;
|
||||||
//未能获得检测配置
|
}
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 找到产品{productNumber},队列{index}数量:{tmpDic.Count}");
|
||||||
#region 1.预处理
|
|
||||||
#endregion
|
|
||||||
#region 2.深度学习推理
|
|
||||||
var req = new MLRequest();
|
|
||||||
|
|
||||||
req.mImage = imageSet.Clone();
|
if (!_cameraRelatedDetectionDict.ContainsKey(camera.CameraName))
|
||||||
req.ResizeWidth = detectConfig.ModelWidth;
|
{
|
||||||
req.ResizeHeight = detectConfig.ModelHeight;
|
|
||||||
req.confThreshold = detectConfig.ModelconfThreshold;
|
|
||||||
req.iouThreshold = 0.3f;
|
|
||||||
req.out_node_name = detectConfig.ModeloutNodeName;
|
|
||||||
req.in_lable_path = detectConfig.in_lable_path;
|
|
||||||
//req.LabelNames = dc.GetLabelNames();
|
|
||||||
|
|
||||||
//HOperatorSet.WriteImage(req.HImage, "png", 0, @"D:\\666.png");
|
localImageSet.Dispose();
|
||||||
Stopwatch
|
// LogAsync(DateTime.Now, LogLevel.Warning, $"{camera.Name} 找到产品{productNumber},但是没有推理1");
|
||||||
sw = new Stopwatch();
|
|
||||||
sw.Start();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var result = Dectection[detectionId].RunInference(req);
|
|
||||||
sw.Stop();
|
double totalTime = 0.0;
|
||||||
//LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.1,产品{productNumber},耗时{sw.ElapsedMilliseconds}ms");
|
List<ResultState> resultStates = new List<ResultState>();
|
||||||
#endregion
|
List<string>? detectionDict = _cameraRelatedDetectionDict[camera.CameraName];
|
||||||
#region 3.后处理
|
|
||||||
DetectStationResult detectResult = new DetectStationResult();
|
|
||||||
if (result == null || (result != null && !result.IsSuccess))
|
for (int i = 0; i < detectionDict.Count; i++)
|
||||||
|
{
|
||||||
|
string detectionId = detectionDict[i];
|
||||||
|
try
|
||||||
{
|
{
|
||||||
detectResult.IsMLDetectDone = false;
|
DetectionConfig detectConfig = null;
|
||||||
}
|
//找到对应的配置
|
||||||
if (result != null && result.IsSuccess)
|
if (!string.IsNullOrWhiteSpace(detectionId))
|
||||||
{
|
|
||||||
detectResult.DetectDetails = result.ResultDetails;
|
|
||||||
if (detectResult.DetectDetails != null)
|
|
||||||
{
|
{
|
||||||
|
detectConfig = detectionList.FirstOrDefault(u => u.Id == detectionId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
detectConfig = detectionList.FirstOrDefault(u => u.CameraSourceId == camera.CameraName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (detectConfig == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
//未能获得检测配置
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region 1.预处理
|
||||||
|
#endregion
|
||||||
|
#region 2.深度学习推理
|
||||||
|
var req = new MLRequest();
|
||||||
|
|
||||||
|
req.mImage = localImageSet.Clone();
|
||||||
|
//req.ResizeWidth = detectConfig.ModelWidth;
|
||||||
|
//req.ResizeHeight = detectConfig.ModelHeight;
|
||||||
|
//req.confThreshold = detectConfig.ModelconfThreshold;
|
||||||
|
//req.iouThreshold = 0.3f;
|
||||||
|
//req.out_node_name = detectConfig.ModeloutNodeName;
|
||||||
|
//req.in_lable_path = detectConfig.in_lable_path;
|
||||||
|
req.ResizeWidth = 640;
|
||||||
|
req.ResizeHeight = 640;
|
||||||
|
req.confThreshold = 0.5f;
|
||||||
|
req.iouThreshold = 0.3f;
|
||||||
|
req.out_node_name = "output0";
|
||||||
|
req.in_lable_path = "D:\\PROJECTS\\MaodingTest1\\Vision\\cam1.txt";
|
||||||
|
//req.LabelNames = dc.GetLabelNames();
|
||||||
|
|
||||||
|
//HOperatorSet.WriteImage(req.HImage, "png", 0, @"D:\\666.png");
|
||||||
|
Stopwatch
|
||||||
|
sw = new Stopwatch();
|
||||||
|
sw.Start();
|
||||||
|
|
||||||
|
|
||||||
|
var result = Dectection[detectionId].RunInference(req);
|
||||||
|
sw.Stop();
|
||||||
|
//LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.1,产品{productNumber},耗时{sw.ElapsedMilliseconds}ms");
|
||||||
|
#endregion
|
||||||
|
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||||
|
{
|
||||||
|
if (pictureBox1.Image != null)
|
||||||
|
{
|
||||||
|
pictureBox1.Image.Dispose(); // 释放旧图像
|
||||||
|
}
|
||||||
|
pictureBox1.Image = result.ResultMap;
|
||||||
|
richTextBox1.AppendText($"推理成功 {productNumber}, {result.IsSuccess} 耗时 {sw.ElapsedMilliseconds}ms\n");
|
||||||
|
}));
|
||||||
|
req.mImage.Dispose();
|
||||||
|
#if true
|
||||||
|
|
||||||
|
#region 3.后处理
|
||||||
|
DetectStationResult detectResult = new DetectStationResult();
|
||||||
|
if (result == null || (result != null && !result.IsSuccess))
|
||||||
{
|
{
|
||||||
detectResult.IsMLDetectDone = false;
|
detectResult.IsMLDetectDone = false;
|
||||||
}
|
}
|
||||||
}
|
if (result != null && result.IsSuccess)
|
||||||
#endregion
|
|
||||||
#region 3.后处理
|
|
||||||
#endregion
|
|
||||||
//根据那些得分大于阈值的推理结果,判断产品是否成功
|
|
||||||
#region 4.最终过滤(逻辑过滤)
|
|
||||||
detectResult.DetectDetails?.ForEach(d =>
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
//当前检测项的 过滤条件
|
|
||||||
//var conditionList = detectConfig.DetectionFilterList
|
|
||||||
// .Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
|
||||||
// .GroupBy(u => u.ResultState)
|
|
||||||
// .OrderBy(u => u.Key)
|
|
||||||
// .ToList();
|
|
||||||
//当前检测项的 过滤条件
|
|
||||||
var conditionList = detectConfig.DetectionFilterList
|
|
||||||
.Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
|
||||||
.GroupBy(u => u.ResultState)
|
|
||||||
.OrderBy(u => u.Key)
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
if (conditionList.Count == 0)
|
|
||||||
{
|
{
|
||||||
|
detectResult.DetectDetails = result.ResultDetails;
|
||||||
if (d.LabelName.ToLower() == "ok")
|
if (detectResult.DetectDetails != null)
|
||||||
{
|
{
|
||||||
d.FinalResult = d.InferenceResult = ResultState.OK;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
d.FinalResult = d.InferenceResult = ResultState.DetectNG;
|
detectResult.IsMLDetectDone = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
#endregion
|
||||||
|
#region 3.后处理
|
||||||
|
#endregion
|
||||||
|
//根据那些得分大于阈值的推理结果,判断产品是否成功
|
||||||
|
#region 4.最终过滤(逻辑过滤)
|
||||||
|
detectResult.DetectDetails?.ForEach(d =>
|
||||||
{
|
{
|
||||||
if (detectConfig.IsMixModel)
|
|
||||||
|
|
||||||
|
//当前检测项的 过滤条件
|
||||||
|
//var conditionList = detectConfig.DetectionFilterList
|
||||||
|
// .Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
||||||
|
// .GroupBy(u => u.ResultState)
|
||||||
|
// .OrderBy(u => u.Key)
|
||||||
|
// .ToList();
|
||||||
|
//当前检测项的 过滤条件
|
||||||
|
var conditionList = detectConfig.DetectionFilterList
|
||||||
|
.Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
||||||
|
.GroupBy(u => u.ResultState)
|
||||||
|
.OrderBy(u => u.Key)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (conditionList.Count == 0)
|
||||||
{
|
{
|
||||||
d.FinalResult = d.InferenceResult = ResultState.A_NG;
|
|
||||||
|
if (d.LabelName.ToLower() == "ok")
|
||||||
|
{
|
||||||
|
d.FinalResult = d.InferenceResult = ResultState.OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
d.FinalResult = d.InferenceResult = ResultState.DetectNG;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//将所有已将筛选出来的缺陷进行过滤
|
if (detectConfig.IsMixModel)
|
||||||
d.FinalResult = d.InferenceResult = ResultState.OK;
|
{
|
||||||
|
d.FinalResult = d.InferenceResult = ResultState.A_NG;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//将所有已将筛选出来的缺陷进行过滤
|
||||||
|
d.FinalResult = d.InferenceResult = ResultState.OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
foreach (IGrouping<ResultState, DetectionFilter> group in conditionList)
|
||||||
|
{
|
||||||
|
bool b = group.ToList().Any(f =>
|
||||||
|
{
|
||||||
|
return f.FilterOperation(d);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
foreach (IGrouping<ResultState, DetectionFilter> group in conditionList)
|
if (b)
|
||||||
|
{
|
||||||
|
d.FinalResult = group.Key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// d.FinalResult = d.InferenceResult = ResultState.OK;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
#endregion
|
||||||
|
#region 5.统计缺陷过滤结果或预处理直接NG
|
||||||
|
if (detectResult.DetectDetails?.Count > 0)
|
||||||
{
|
{
|
||||||
bool b = group.ToList().Any(f =>
|
detectResult.ResultState = detectResult.DetectDetails.GroupBy(u => u.FinalResult).OrderBy(u => u.Key).First().First().FinalResult;
|
||||||
{
|
detectResult.ResultLabel = detectResult.ResultLabel;
|
||||||
return f.FilterOperation(d);
|
detectResult.ResultLabelCategoryId = detectResult.ResultLabel;//TODO:设置优先级
|
||||||
});
|
//////根据优先级设置ResultLabel
|
||||||
|
//if (detectionLabels.Count > 0)
|
||||||
|
//{
|
||||||
|
// foreach (var l in detectionLabels)
|
||||||
|
// {
|
||||||
|
// var isExist = DetectDetails.Any(o => NormalizeAndClean(o.LabelName) == NormalizeAndClean(l.LabelName) && o.FinalResult == ResultState.DetectNG);
|
||||||
|
// if (isExist)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// ResultLabelCategoryId = l.LabelCategoryId;
|
||||||
if (b)
|
// break;
|
||||||
{
|
// }
|
||||||
d.FinalResult = group.Key;
|
// }
|
||||||
break;
|
|
||||||
}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// d.FinalResult = d.InferenceResult = ResultState.OK;
|
|
||||||
//}
|
//}
|
||||||
}
|
|
||||||
});
|
|
||||||
#endregion
|
|
||||||
#region 5.统计缺陷过滤结果或预处理直接NG
|
|
||||||
if (detectResult.DetectDetails?.Count > 0)
|
|
||||||
{
|
|
||||||
detectResult.ResultState = detectResult.DetectDetails.GroupBy(u => u.FinalResult).OrderBy(u => u.Key).First().First().FinalResult;
|
|
||||||
detectResult.ResultLabel = detectResult.ResultLabel;
|
|
||||||
detectResult.ResultLabelCategoryId = detectResult.ResultLabel;//TODO:设置优先级
|
|
||||||
//////根据优先级设置ResultLabel
|
|
||||||
//if (detectionLabels.Count > 0)
|
|
||||||
//{
|
|
||||||
// foreach (var l in detectionLabels)
|
|
||||||
// {
|
|
||||||
// var isExist = DetectDetails.Any(o => NormalizeAndClean(o.LabelName) == NormalizeAndClean(l.LabelName) && o.FinalResult == ResultState.DetectNG);
|
|
||||||
// if (isExist)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// ResultLabelCategoryId = l.LabelCategoryId;
|
return;
|
||||||
// break;
|
}
|
||||||
// }
|
#endregion
|
||||||
// }
|
resultStates.Add(detectResult.ResultState);
|
||||||
|
|
||||||
|
product.ResultCollection.Add(detectResult);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//DetectStationResult temp;
|
||||||
|
////LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.4,产品{productNumber}");
|
||||||
|
//// 检测结果
|
||||||
|
//if (temp != null)
|
||||||
|
//{
|
||||||
|
// // LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.5,产品{productNumber}");
|
||||||
|
// //var totalElapsed = (temp.EndTime - temp.VisionImageSet.ImageTime).TotalMilliseconds;
|
||||||
|
// //totalTime += totalElapsed;
|
||||||
|
// resultStates.Add(temp.ResultState);
|
||||||
|
|
||||||
|
// product.ResultCollection.Add(temp);
|
||||||
|
// // LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.6,产品{productNumber}");
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// //LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 检测失败,物料编号:{productNumber},检测项:{d}");
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return;
|
// imageSet.Dispose();
|
||||||
}
|
}
|
||||||
#endregion
|
catch (Exception ex)
|
||||||
|
|
||||||
|
|
||||||
resultStates.Add(detectResult.ResultState);
|
|
||||||
|
|
||||||
product.ResultCollection.Add(detectResult);
|
|
||||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
|
||||||
{
|
{
|
||||||
pictureBox1.Image = result.ResultMap; richTextBox1.AppendText($"推理成功{productNumber},{result.IsSuccess} 推理耗时{sw.ElapsedMilliseconds}ms,总推理耗时\n");
|
// LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理异常,物料编号:{productNumber},检测项:{d}, {ex.GetExceptionMessage}");
|
||||||
|
}
|
||||||
}));
|
|
||||||
//DetectStationResult temp;
|
|
||||||
////LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.4,产品{productNumber}");
|
|
||||||
//// 检测结果
|
|
||||||
//if (temp != null)
|
|
||||||
//{
|
|
||||||
// // LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.5,产品{productNumber}");
|
|
||||||
// //var totalElapsed = (temp.EndTime - temp.VisionImageSet.ImageTime).TotalMilliseconds;
|
|
||||||
// //totalTime += totalElapsed;
|
|
||||||
// resultStates.Add(temp.ResultState);
|
|
||||||
|
|
||||||
// product.ResultCollection.Add(temp);
|
|
||||||
// // LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.6,产品{productNumber}");
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// //LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 检测失败,物料编号:{productNumber},检测项:{d}");
|
|
||||||
//}
|
|
||||||
|
|
||||||
imageSet.Dispose();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
|
//detectionDict.ForEach(d =>
|
||||||
|
//{
|
||||||
|
|
||||||
|
//});
|
||||||
|
|
||||||
|
// LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度2,产品{productNumber}");
|
||||||
|
|
||||||
|
|
||||||
|
imageSet.Dispose();
|
||||||
|
product.InferenceOne(() =>
|
||||||
{
|
{
|
||||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理异常,物料编号:{productNumber},检测项:{d}, {ex.GetExceptionMessage}");
|
;
|
||||||
}
|
}, () =>
|
||||||
}
|
|
||||||
|
|
||||||
//detectionDict.ForEach(d =>
|
|
||||||
//{
|
|
||||||
|
|
||||||
//});
|
|
||||||
|
|
||||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度2,产品{productNumber}");
|
|
||||||
|
|
||||||
|
|
||||||
imageSet.Dispose();
|
|
||||||
product.InferenceOne(() =>
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}, () =>
|
|
||||||
{
|
|
||||||
;
|
|
||||||
});
|
|
||||||
|
|
||||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理完成,产品{productNumber}");
|
|
||||||
|
|
||||||
if (!product.InferenceFinished())
|
|
||||||
{
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ProductNum_Total++;
|
|
||||||
CalculateOEE();
|
|
||||||
this.BeginInvoke(new MethodInvoker(delegate () {
|
|
||||||
|
|
||||||
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
|
||||||
|
|
||||||
richTextBox1.AppendText($"统计结果成功,{productNumber}吹气!\n");
|
|
||||||
|
|
||||||
// 设置回原来的滚动位置
|
|
||||||
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
|
||||||
richTextBox1.ScrollToCaret();
|
|
||||||
}));
|
|
||||||
#region 6.统计产品结果
|
|
||||||
if (product.ResultCollection.Any(u => u.ResultState != ResultState.OK))
|
|
||||||
{
|
|
||||||
//检测结果TBD
|
|
||||||
// CurTrigger = TriggerSettings.FirstOrDefault(u => u.TriggerType == TriggerType.B_NG);
|
|
||||||
product.ProductResult = ResultState.B_NG;
|
|
||||||
product.ProductLabelCategory = ResultState.B_NG.GetEnumDescription();
|
|
||||||
product.ProductLabel = ResultState.B_NG.GetEnumDescription();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// CurTrigger = TriggerSettings.FirstOrDefault(u => u.TriggerType == TriggerType.OK);
|
|
||||||
product.ProductResult = ResultState.OK;
|
|
||||||
product.ProductLabelCategory = ResultState.OK.GetEnumDescription();
|
|
||||||
product.ProductLabel = ResultState.OK.GetEnumDescription();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
#region 7.产品吹气
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//LogAsync(DateTime.Now, LogLevel.Information, $"推理完成,产品{product.PieceNumber}获取结果");
|
|
||||||
|
|
||||||
// 统计产品结果
|
|
||||||
//Task resultTask = product.SetProductResult(_totalDetectionNum, X017Config.IsTBDPriority, labelCategoryLists);
|
|
||||||
|
|
||||||
//await resultTask.ContinueWith(t =>
|
|
||||||
//{
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// UpdateTriggerCount(DateTime.Now, "获取结果");
|
|
||||||
// UpdateResult(DateTime.Now, camera, product.ProductResult.GetEnumDescription());
|
|
||||||
// UpdateResultNew(DateTime.Now, camera, "合计");
|
|
||||||
// LogAsync(DateTime.Now, LogLevel.Information, $"产品{product.PieceNumber}获取结果:{product.ProductResult} {(product.IsA2B ? "产品IsA2B" : "")}");
|
|
||||||
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// LogAsync(DateTime.Now, LogLevel.Information, $"产品{product.PieceNumber}获取结果异常:{product.ProductResult} {(product.IsA2B ? "产品IsA2B" : "")}," +
|
|
||||||
// $"异常信息:{ex.GetExceptionMessage}");
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 吹气
|
|
||||||
// DateTime dtNow = DateTime.Now;
|
|
||||||
// product.BlowOutTime = dtNow;
|
|
||||||
|
|
||||||
|
|
||||||
// var setting = X017Config.ProductBlowSettings.FirstOrDefault(s => product.ProductResult.Equals(s.ProductResult));
|
|
||||||
|
|
||||||
// if (setting != null)
|
|
||||||
// {
|
|
||||||
// uint NGNumC = 0;
|
|
||||||
// uint OKNumC = 0;
|
|
||||||
|
|
||||||
// CMCDLL_NET.MCF_Sorting_Get_Lose_Blow_NG_Count_Net(ref NGNumC, 0);
|
|
||||||
// CMCDLL_NET.MCF_Sorting_Get_Lose_Blow_OK_Count_Net(ref OKNumC, 0);
|
|
||||||
// _mainMotion.Blow(product.PieceNumber, setting.BindBlow);
|
|
||||||
// LogAsync(DateTime.Now, LogLevel.Action, $"产品{product.PieceNumber}吹气{NGNumC}+ {OKNumC}");
|
|
||||||
// //if (product.ProductResult == ResultState.OK)
|
|
||||||
// //{
|
|
||||||
// // //OKProcessNum++;
|
|
||||||
// // OKNum++;
|
|
||||||
// //}
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //判断超时出队
|
|
||||||
// foreach (var kvp in tmpDic)
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// ProductData dataN = kvp.Value;
|
|
||||||
// TimeSpan timeDifference = DateTime.Now - dataN.CreateTime;
|
|
||||||
// if (timeDifference.TotalMinutes >= 1)
|
|
||||||
// {
|
|
||||||
|
|
||||||
// //出队
|
|
||||||
// bool isremoved = tmpDic.TryRemove(kvp.Key, out _);
|
|
||||||
// if (isremoved)
|
|
||||||
// {
|
|
||||||
// LogAsync(DateTime.Now, LogLevel.Error, $"====产品{kvp.Key}超时出列成功" +
|
|
||||||
// $"产品结果:{dataN.ProductResult.GetEnumDescription()} {dataN.ProductResult}," +
|
|
||||||
// $"当前队列产品数量:{tmpDic.Count}====");
|
|
||||||
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// //重新生成实例 销毁之前的实例
|
|
||||||
// var saveData = dataN.GetProductData();
|
|
||||||
// var productDefects = dataN.GetDetectDetailData();
|
|
||||||
// SaveProductDataAsync(saveData, productDefects);
|
|
||||||
// dataN = null;
|
|
||||||
// }
|
|
||||||
// catch (Exception) { }
|
|
||||||
|
|
||||||
// dataN?.Dispose();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// LogAsync(DateTime.Now, LogLevel.Error, $"=====产品{kvp.Key}超时出列失败" +
|
|
||||||
// $"当前队列产品数量:{tmpDic.Count}=====");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// catch (Exception ex)
|
|
||||||
// {
|
|
||||||
// LogAsync(DateTime.Now, LogLevel.Error, $"=====产品{kvp.Key}超时出列失败" +
|
|
||||||
// $"当前队列产品数量:{tmpDic.Count}====={ex.GetExceptionMessage}");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 出列
|
|
||||||
ProductData temp = null;
|
|
||||||
|
|
||||||
int tryTimes = 5;
|
|
||||||
while (temp == null && tryTimes > 0)
|
|
||||||
{
|
|
||||||
var isSuccess = tmpDic.Remove(productNumber, out temp);
|
|
||||||
|
|
||||||
if (isSuccess)
|
|
||||||
{
|
{
|
||||||
string logStr =$"{DateTime.Now}产品{productNumber}出列成功:{isSuccess}," +
|
;
|
||||||
$"产品结果:{temp.ProductResult.GetEnumDescription()}," +
|
});
|
||||||
$"当前队列产品数量:{tmpDic.Count}";
|
|
||||||
this.BeginInvoke(new MethodInvoker(delegate () {
|
|
||||||
|
|
||||||
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
// LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理完成,产品{productNumber}");
|
||||||
|
|
||||||
richTextBox1.AppendText(logStr);
|
if (!product.InferenceFinished())
|
||||||
|
|
||||||
// 设置回原来的滚动位置
|
|
||||||
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
|
||||||
richTextBox1.ScrollToCaret();
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
tryTimes--;
|
|
||||||
Thread.Sleep(1);
|
|
||||||
}
|
|
||||||
if (temp == null)
|
|
||||||
{
|
|
||||||
//LogAsync(DateTime.Now, LogLevel.Assist, $"产品{productNumber}出列失败," +
|
|
||||||
// $"当前队列产品数量:{tmpDic.Count}");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
//重新生成实例 销毁之前的实例
|
|
||||||
var saveData = temp.GetProductData();
|
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
catch (Exception) { }
|
ProductNum_Total++;
|
||||||
finally
|
CalculateOEE();
|
||||||
|
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||||
{
|
{
|
||||||
// temp.Dispose();
|
|
||||||
temp = null;
|
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
||||||
|
|
||||||
|
richTextBox1.AppendText($"统计结果成功,{productNumber}吹气!\n");
|
||||||
|
|
||||||
|
// 设置回原来的滚动位置
|
||||||
|
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
||||||
|
richTextBox1.ScrollToCaret();
|
||||||
|
}));
|
||||||
|
#region 6.统计产品结果
|
||||||
|
if (product.ResultCollection.Any(u => u.ResultState != ResultState.OK))
|
||||||
|
{
|
||||||
|
//检测结果TBD
|
||||||
|
// CurTrigger = TriggerSettings.FirstOrDefault(u => u.TriggerType == TriggerType.B_NG);
|
||||||
|
product.ProductResult = ResultState.B_NG;
|
||||||
|
product.ProductLabelCategory = ResultState.B_NG.GetEnumDescription();
|
||||||
|
product.ProductLabel = ResultState.B_NG.GetEnumDescription();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// CurTrigger = TriggerSettings.FirstOrDefault(u => u.TriggerType == TriggerType.OK);
|
||||||
|
product.ProductResult = ResultState.OK;
|
||||||
|
product.ProductLabelCategory = ResultState.OK.GetEnumDescription();
|
||||||
|
product.ProductLabel = ResultState.OK.GetEnumDescription();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 7.产品吹气
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//LogAsync(DateTime.Now, LogLevel.Information, $"推理完成,产品{product.PieceNumber}获取结果");
|
||||||
|
|
||||||
|
// 统计产品结果
|
||||||
|
//Task resultTask = product.SetProductResult(_totalDetectionNum, X017Config.IsTBDPriority, labelCategoryLists);
|
||||||
|
|
||||||
|
//await resultTask.ContinueWith(t =>
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// UpdateTriggerCount(DateTime.Now, "获取结果");
|
||||||
|
// UpdateResult(DateTime.Now, camera, product.ProductResult.GetEnumDescription());
|
||||||
|
// UpdateResultNew(DateTime.Now, camera, "合计");
|
||||||
|
// LogAsync(DateTime.Now, LogLevel.Information, $"产品{product.PieceNumber}获取结果:{product.ProductResult} {(product.IsA2B ? "产品IsA2B" : "")}");
|
||||||
|
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// LogAsync(DateTime.Now, LogLevel.Information, $"产品{product.PieceNumber}获取结果异常:{product.ProductResult} {(product.IsA2B ? "产品IsA2B" : "")}," +
|
||||||
|
// $"异常信息:{ex.GetExceptionMessage}");
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 吹气
|
||||||
|
// DateTime dtNow = DateTime.Now;
|
||||||
|
// product.BlowOutTime = dtNow;
|
||||||
|
|
||||||
|
|
||||||
|
// var setting = X017Config.ProductBlowSettings.FirstOrDefault(s => product.ProductResult.Equals(s.ProductResult));
|
||||||
|
|
||||||
|
// if (setting != null)
|
||||||
|
// {
|
||||||
|
// uint NGNumC = 0;
|
||||||
|
// uint OKNumC = 0;
|
||||||
|
|
||||||
|
// CMCDLL_NET.MCF_Sorting_Get_Lose_Blow_NG_Count_Net(ref NGNumC, 0);
|
||||||
|
// CMCDLL_NET.MCF_Sorting_Get_Lose_Blow_OK_Count_Net(ref OKNumC, 0);
|
||||||
|
// _mainMotion.Blow(product.PieceNumber, setting.BindBlow);
|
||||||
|
// LogAsync(DateTime.Now, LogLevel.Action, $"产品{product.PieceNumber}吹气{NGNumC}+ {OKNumC}");
|
||||||
|
// //if (product.ProductResult == ResultState.OK)
|
||||||
|
// //{
|
||||||
|
// // //OKProcessNum++;
|
||||||
|
// // OKNum++;
|
||||||
|
// //}
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //判断超时出队
|
||||||
|
// foreach (var kvp in tmpDic)
|
||||||
|
// {
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// ProductData dataN = kvp.Value;
|
||||||
|
// TimeSpan timeDifference = DateTime.Now - dataN.CreateTime;
|
||||||
|
// if (timeDifference.TotalMinutes >= 1)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// //出队
|
||||||
|
// bool isremoved = tmpDic.TryRemove(kvp.Key, out _);
|
||||||
|
// if (isremoved)
|
||||||
|
// {
|
||||||
|
// LogAsync(DateTime.Now, LogLevel.Error, $"====产品{kvp.Key}超时出列成功" +
|
||||||
|
// $"产品结果:{dataN.ProductResult.GetEnumDescription()} {dataN.ProductResult}," +
|
||||||
|
// $"当前队列产品数量:{tmpDic.Count}====");
|
||||||
|
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// //重新生成实例 销毁之前的实例
|
||||||
|
// var saveData = dataN.GetProductData();
|
||||||
|
// var productDefects = dataN.GetDetectDetailData();
|
||||||
|
// SaveProductDataAsync(saveData, productDefects);
|
||||||
|
// dataN = null;
|
||||||
|
// }
|
||||||
|
// catch (Exception) { }
|
||||||
|
|
||||||
|
// dataN?.Dispose();
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// LogAsync(DateTime.Now, LogLevel.Error, $"=====产品{kvp.Key}超时出列失败" +
|
||||||
|
// $"当前队列产品数量:{tmpDic.Count}=====");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// LogAsync(DateTime.Now, LogLevel.Error, $"=====产品{kvp.Key}超时出列失败" +
|
||||||
|
// $"当前队列产品数量:{tmpDic.Count}====={ex.GetExceptionMessage}");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 出列
|
||||||
|
ProductData temp = null;
|
||||||
|
|
||||||
|
int tryTimes = 5;
|
||||||
|
while (temp == null && tryTimes > 0)
|
||||||
|
{
|
||||||
|
var isSuccess = tmpDic.Remove(productNumber, out temp);
|
||||||
|
|
||||||
|
if (isSuccess)
|
||||||
|
{
|
||||||
|
string logStr = $"{DateTime.Now}产品{productNumber}出列成功:{isSuccess}," +
|
||||||
|
$"产品结果:{temp.ProductResult.GetEnumDescription()}," +
|
||||||
|
$"当前队列产品数量:{tmpDic.Count}";
|
||||||
|
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||||
|
{
|
||||||
|
|
||||||
|
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
||||||
|
|
||||||
|
richTextBox1.AppendText(logStr);
|
||||||
|
|
||||||
|
// 设置回原来的滚动位置
|
||||||
|
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
||||||
|
richTextBox1.ScrollToCaret();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
tryTimes--;
|
||||||
|
Thread.Sleep(1);
|
||||||
|
}
|
||||||
|
if (temp == null)
|
||||||
|
{
|
||||||
|
//LogAsync(DateTime.Now, LogLevel.Assist, $"产品{productNumber}出列失败," +
|
||||||
|
// $"当前队列产品数量:{tmpDic.Count}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//重新生成实例 销毁之前的实例
|
||||||
|
var saveData = temp.GetProductData();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// temp.Dispose();
|
||||||
|
temp = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateCT((float)(dtNow - _ctTime).TotalSeconds);
|
||||||
|
//_ctTime = dtNow;
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//LogAsync(DateTime.Now, LogLevel.Error, $"流程检测未捕获的异常:{ex.GetExceptionMessage()}");
|
||||||
|
product?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateCT((float)(dtNow - _ctTime).TotalSeconds);
|
|
||||||
//_ctTime = dtNow;
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
//LogAsync(DateTime.Now, LogLevel.Error, $"流程检测未捕获的异常:{ex.GetExceptionMessage()}");
|
|
||||||
product?.Dispose();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user