|
|
|
@@ -158,6 +158,8 @@ namespace GeBoShi.SysCtrl |
|
|
|
/// 界面光源值
|
|
|
|
/// </summary>
|
|
|
|
private int FrmLightValue = 0;
|
|
|
|
|
|
|
|
private string ImgDirSN = "";
|
|
|
|
#region 处理类型
|
|
|
|
private class ScanPhotoInfo
|
|
|
|
{
|
|
|
|
@@ -1038,7 +1040,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Log($"二次判断2", $"(图像{liPhotoIndex})-缺陷未获得", WarningEnum.Low, false);
|
|
|
|
Log($"二次判断2", $"(图像{liPhotoIndex})-缺陷未获得,是否包含在({string.Join(",", DefectItemsPuaseNameList.ToArray())})或({string.Join(",", curRecord.ProductInfo.DefectPauseOption.ToArray())})中。", WarningEnum.Low, false);
|
|
|
|
#if false
|
|
|
|
curRecord.dicPhoto_Defect.TryUpdate(liPhotoIndex, false, true);
|
|
|
|
#endif
|
|
|
|
@@ -1086,7 +1088,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
if (confMgr.SysConfigParams.CamImag.AutoSave && !string.IsNullOrEmpty(confMgr.SysConfigParams.CamImag.SavePath))
|
|
|
|
{
|
|
|
|
Records curRecord = Hashtable.Synchronized(htTask)[currKey] as Records;
|
|
|
|
string dirPath = Util.CreateSubDir(confMgr.SysConfigParams.CamImag.SavePath, new List<string> { $"{curRecord.BarCode}_{curRecord.BarCodeName}" });
|
|
|
|
string dirPath = Util.CreateSubDir(confMgr.SysConfigParams.CamImag.SavePath, new List<string> { $"{curRecord.BarCode}_{curRecord.BarCodeName}_{ImgDirSN}" });
|
|
|
|
//OpenCvSharp.Extensions.BitmapConverter.ToBitmap(img).Save($"{dirPath}Cam1-{Cam1Cnt}.bmp", ImageFormat.Bmp);
|
|
|
|
|
|
|
|
AddImageSave($"{dirPath}Cam1-{Cam1Cnt}.bmp", img);
|
|
|
|
@@ -1131,7 +1133,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
//边缘异常计数
|
|
|
|
marginException++;
|
|
|
|
Records curRecord = Hashtable.Synchronized(htTask)[currKey] as Records;
|
|
|
|
string dirPath = Util.CreateSubDir(confMgr.SysConfigParams.CamImag.SavePath, new List<string> { $"{curRecord.BarCode}_{curRecord.BarCodeName}" });
|
|
|
|
string dirPath = Util.CreateSubDir(confMgr.SysConfigParams.CamImag.SavePath, new List<string> { $"{curRecord.BarCode}_{curRecord.BarCodeName}_{ImgDirSN}" });
|
|
|
|
AddImageSave($"{dirPath}Cam1-{Cam1Cnt}.bmp", img);
|
|
|
|
Log($"图像预处理", $"(相机1-图像{Cam1Cnt})-裁边异常:{marginWidth0}-{_marginWidth1} 》 {10 * confMgr.SysConfigParams.Cm2px_x}", WarningEnum.Normal, false);
|
|
|
|
}
|
|
|
|
@@ -1261,7 +1263,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
if (confMgr.SysConfigParams.CamImag.AutoSave && !string.IsNullOrEmpty(confMgr.SysConfigParams.CamImag.SavePath))
|
|
|
|
{
|
|
|
|
Records curRecord = Hashtable.Synchronized(htTask)[currKey] as Records;
|
|
|
|
string dirPath = Util.CreateSubDir(confMgr.SysConfigParams.CamImag.SavePath, new List<string> { $"{curRecord.BarCode}_{curRecord.BarCodeName}" });
|
|
|
|
string dirPath = Util.CreateSubDir(confMgr.SysConfigParams.CamImag.SavePath, new List<string> { $"{curRecord.BarCode}_{curRecord.BarCodeName}_{ImgDirSN}" });
|
|
|
|
//OpenCvSharp.Extensions.BitmapConverter.ToBitmap(img).Save($"{dirPath}Cam2-{Cam2Cnt}.bmp", ImageFormat.Bmp);
|
|
|
|
|
|
|
|
AddImageSave($"{dirPath}Cam2-{Cam2Cnt}.bmp", img);
|
|
|
|
@@ -1305,7 +1307,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
//边缘异常计数
|
|
|
|
marginException++;
|
|
|
|
Records curRecord = Hashtable.Synchronized(htTask)[currKey] as Records;
|
|
|
|
string dirPath = Util.CreateSubDir(confMgr.SysConfigParams.CamImag.SavePath, new List<string> { $"{curRecord.BarCode}_{curRecord.BarCodeName}" });
|
|
|
|
string dirPath = Util.CreateSubDir(confMgr.SysConfigParams.CamImag.SavePath, new List<string> { $"{curRecord.BarCode}_{curRecord.BarCodeName}_{ImgDirSN}" });
|
|
|
|
AddImageSave($"{dirPath}Cam2-{Cam2Cnt}.bmp", img);
|
|
|
|
Log($"图像预处理", $"(相机2-图像{Cam2Cnt})-裁边异常:{marginWidth0}-{_marginWidth2} 》 {10 * confMgr.SysConfigParams.Cm2px_x}", WarningEnum.Normal, false);
|
|
|
|
}
|
|
|
|
@@ -2138,7 +2140,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
else
|
|
|
|
OnAutoRuning(new RunEventArgs(res.bmp));
|
|
|
|
|
|
|
|
string dirPath = Util.CreateSubDir(confMgr.SysConfigParams.DefectSrcImag.SavePath, new List<string> { $"{ res.record.BarCode}_{ res.record.BarCodeName}" });
|
|
|
|
string dirPath = Util.CreateSubDir(confMgr.SysConfigParams.DefectSrcImag.SavePath, new List<string> { $"{ res.record.BarCode}_{ res.record.BarCodeName}_{ImgDirSN}" });
|
|
|
|
if (confMgr.SysConfigParams.DefectSrcImag.AutoSave)//保存所有原图
|
|
|
|
{
|
|
|
|
AddImageSave($"{dirPath}{res.photoIndex}.bmp", res.bmp);
|
|
|
|
@@ -2211,7 +2213,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
//保存打标小图
|
|
|
|
if (confMgr.SysConfigParams.DefectSmallImag.AutoSave)
|
|
|
|
{
|
|
|
|
dirPath = Util.CreateSubDir(confMgr.SysConfigParams.DefectSmallImag.SavePath, new List<string> { $"{res.record.BarCode}_{res.record.BarCodeName}" });
|
|
|
|
dirPath = Util.CreateSubDir(confMgr.SysConfigParams.DefectSmallImag.SavePath, new List<string> { $"{res.record.BarCode}_{res.record.BarCodeName}_{ImgDirSN}" });
|
|
|
|
string filename = $"{dirPath}{res.photoIndex}_X{defectInfo.X}_Y{defectInfo.Y}_W{defectInfo.Width}_H{defectInfo.Height}_目标{defectInfo.Target}_类别{defectInfo.Code}_置信度{defectInfo.ZXD}.jpg";
|
|
|
|
//OpenCvSharp.Extensions.BitmapConverter.ToBitmap(res.lstDefectBmp[i]).Save(filename, ImageFormat.Jpeg);
|
|
|
|
AddImageSave(filename, res.lstDefectBmp[i]);
|
|
|
|
@@ -2243,7 +2245,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
time += $"->打标小图保存({stopWatch.ElapsedMilliseconds})";
|
|
|
|
|
|
|
|
//有瑕疵打标图必需保存 Jpeg
|
|
|
|
dirPath = Util.CreateSubDir(confMgr.SysConfigParams.DefectSplicImag.SavePath, new List<string> { $"{res.record.BarCode}_{res.record.BarCodeName}" });
|
|
|
|
dirPath = Util.CreateSubDir(confMgr.SysConfigParams.DefectSplicImag.SavePath, new List<string> { $"{res.record.BarCode}_{res.record.BarCodeName}_{ImgDirSN}" });
|
|
|
|
if (confMgr.SysConfigParams.DefectSplicImag.AutoSave)//保存瑕疵图
|
|
|
|
{
|
|
|
|
AddImageSave($"{dirPath}{res.photoIndex}_tag.jpg", res.bmpTag);
|
|
|
|
@@ -2263,7 +2265,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
step = 9;
|
|
|
|
//Log($"检测完成", "保存CSV", WarningEnum.Normal, false);
|
|
|
|
//保存CSV
|
|
|
|
dirPath = Util.CreateSubDir(confMgr.SysConfigParams.DefectSplicImag.SavePath, new List<string> { $"{res.record.BarCode}_{res.record.BarCodeName}" });
|
|
|
|
dirPath = Util.CreateSubDir(confMgr.SysConfigParams.DefectSplicImag.SavePath, new List<string> { $"{res.record.BarCode}_{res.record.BarCodeName}_{ImgDirSN}" });
|
|
|
|
//bool b = Utils.ExcelUtil.DataTable2CSV($"{dirPath}{res.photoIndex}.csv", res.excelTable);
|
|
|
|
AddImageSave($"{dirPath}{res.photoIndex}.csv", res.excelTable);
|
|
|
|
//AddTextEvent(DateTime.Now,$"打标完成", $"{res.tag}.xlsx {(b ? "保存成功!" : "保存失败!")}");
|
|
|
|
@@ -3252,7 +3254,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
bool ret = true;
|
|
|
|
_FatherFrm = fatherFrm;
|
|
|
|
string barCodeName = "", len = "0", batchId = "", reelId = "";
|
|
|
|
if(string.IsNullOrEmpty(name))
|
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
|
name = "未找到";
|
|
|
|
//运行前清除过期图片文件
|
|
|
|
//DateTime st = DateTime.Now;
|
|
|
|
@@ -3268,7 +3270,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
Log("运行", "产品条码为空!", WarningEnum.Low);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//禾欣数据 sn,长度数量, 批号, 卷号
|
|
|
|
if (!string.IsNullOrWhiteSpace(confMgr.SysConfigParams.ErpDBConStr) && !string.IsNullOrWhiteSpace(confMgr.SysConfigParams.ErpSql) && !string.IsNullOrWhiteSpace(sn))
|
|
|
|
{
|
|
|
|
@@ -3295,7 +3297,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
{
|
|
|
|
Product model;
|
|
|
|
//禾欣客户使用
|
|
|
|
if(confMgr.SysConfigParams.CustomerName == "hexin")
|
|
|
|
if (confMgr.SysConfigParams.CustomerName == "hexin")
|
|
|
|
{
|
|
|
|
errStep = 1;
|
|
|
|
//SHNY-PX-6-***
|
|
|
|
@@ -3323,15 +3325,15 @@ namespace GeBoShi.SysCtrl |
|
|
|
string mjson = GetMesJson(sn);
|
|
|
|
string mfid = "";
|
|
|
|
string httprel = "";
|
|
|
|
if(MesReturn(mjson, out mfid, out httprel))
|
|
|
|
if (MesReturn(mjson, out mfid, out httprel))
|
|
|
|
{
|
|
|
|
Log("Mes", $"Mes反馈({httprel})", WarningEnum.Normal, false);
|
|
|
|
JObject Param = JObject.Parse(httprel);
|
|
|
|
name = Param["List"][0]["Mname"].ToString();
|
|
|
|
barCodeName = name;
|
|
|
|
len = Param["List"][0]["PQty"].ToString();
|
|
|
|
batchId = Param["List"][0]["FID"].ToString();
|
|
|
|
reelId = Param["List"][0]["RawMFid"].ToString();
|
|
|
|
batchId = Param["List"][0]["FID"].ToString();
|
|
|
|
reelId = Param["List"][0]["RawMFid"].ToString();
|
|
|
|
//根据mfid查询检测标准
|
|
|
|
model = PdtService.GetModelNavByMFID(mfid);
|
|
|
|
if (model == null)
|
|
|
|
@@ -3339,7 +3341,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
Log("Mes", $"MFID({mfid})对应配方不存在,请先添加产品配方设置!", WarningEnum.Normal);
|
|
|
|
//弹窗添加配方
|
|
|
|
MesSelectPdt mesSelectPdt = new MesSelectPdt(mfid);
|
|
|
|
if(mesSelectPdt.ShowDialog() == DialogResult.OK)
|
|
|
|
if (mesSelectPdt.ShowDialog() == DialogResult.OK)
|
|
|
|
{
|
|
|
|
model = PdtService.GetModelNavByMFID(mfid);
|
|
|
|
Log("Mes", $"MFID({mfid})绑定配方({model.Name})成功!", WarningEnum.Normal);
|
|
|
|
@@ -3385,7 +3387,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
batchId = batch;
|
|
|
|
reelId = reel;
|
|
|
|
double t;
|
|
|
|
cnt = double.TryParse(cnt, out t) ?cnt:"0";
|
|
|
|
cnt = double.TryParse(cnt, out t) ? cnt : "0";
|
|
|
|
model = PdtService.GetModelNavByName(DefectName);
|
|
|
|
}
|
|
|
|
if (model == null)
|
|
|
|
@@ -3462,7 +3464,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
//显示二次判定项和打标项
|
|
|
|
OnAutoRuning(new RunEventArgs(model));
|
|
|
|
//加载所有二次判断
|
|
|
|
|
|
|
|
|
|
|
|
//显示光源亮度
|
|
|
|
OnAutoRuning(new RunEventArgs(model.LightValue));
|
|
|
|
//计米器清空
|
|
|
|
@@ -3491,8 +3493,9 @@ namespace GeBoShi.SysCtrl |
|
|
|
// Log("内存", $"相机2清空内存失败!", WarningEnum.High);
|
|
|
|
// return false;
|
|
|
|
//}
|
|
|
|
//电机启动
|
|
|
|
StartMotion();
|
|
|
|
//判断是否已经有同名称产品存图
|
|
|
|
ImgDirSN = DateTime.Now.ToString("HHmmss");
|
|
|
|
|
|
|
|
|
|
|
|
pStopWatch.Restart();
|
|
|
|
pRunSpeedWatch.Restart();
|
|
|
|
@@ -3531,6 +3534,9 @@ namespace GeBoShi.SysCtrl |
|
|
|
|
|
|
|
//获取模型label
|
|
|
|
GetDefectAllLabel();
|
|
|
|
|
|
|
|
//电机启动
|
|
|
|
StartMotion();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
|