From 2c79e797a723a59c2afc4b05069618ae48df587d Mon Sep 17 00:00:00 2001 From: jace.tang <1536884497@qq.com> Date: 星期二, 14 六月 2022 14:11:50 +0800 Subject: [PATCH] 1.标准块存图路径修改 --- HeightDetection.cs | 33 +++++++++++++++++++++++++++------ 1 files changed, 27 insertions(+), 6 deletions(-) diff --git a/HeightDetection.cs b/HeightDetection.cs index 2df4a4a..415b929 100644 --- a/HeightDetection.cs +++ b/HeightDetection.cs @@ -73,6 +73,7 @@ HObject ihImage = null; HObject hi = new HObject(); + string tempFileName = ""; try { opc.Write(OPCOutputTag.DetectionStart2, false); @@ -128,7 +129,7 @@ int slotNum = (CommonUtil.mainForm.PlateID + 1) % 5 + 1; - string tempFileName = slotNum.ToString() + "_" + productNo.Trim().Replace("/", "").Replace("\"", "'") + "_" + DateTime.Now.ToString("HHmmssff") + "_" + detectID.ToString(); + tempFileName = slotNum.ToString() + "_" + productNo.Trim().Replace("/", "").Replace("\"", "'") + "_" + DateTime.Now.ToString("HHmmssff") + "_" + detectID.ToString(); if (productNo.Trim().Length == CommonUtil.ProductNoLength) { string productNoFileName = CommonUtil.ProductNoImageDir + @"\" + productNo + "_" + detectID.ToString(); @@ -197,9 +198,9 @@ if (batteryHeight[0] != 999.999 && batteryHeight[0] != -999.999) { double compv = 0.0; - Type t = opcConfig.standardCompensationZ.GetType(); + Type t = opcConfig.compensationZ.GetType(); FieldInfo fi = t.GetField(string.Format("station{0}", (CommonUtil.mainForm.PlateID + 1) % 5 + 1)); - compv = (double)fi.GetValue(opcConfig.standardCompensationZ); + compv = (double)fi.GetValue(opcConfig.compensationZ); batteryHeight[0] += compv; } @@ -228,18 +229,32 @@ if (heightResult != MeasureState.OK) { - heightFileName = VisionDetect.SaveImageAs(hi, CommonUtil.ProductHeightImageDir + $"_{heightResult.ToString()}\\{ tempFileName}"); + + if (CommonUtil.DetectionOption == DetectionOption.doStandardBlock) + { + VisionDetect.SaveImageAs(hi, CommonUtil.ProductHeightImageDir + @"\" + tempFileName); + } + else + { + heightFileName = VisionDetect.SaveImageAs(hi, CommonUtil.ProductHeightImageDir + $"_{heightResult.ToString()}\\{ tempFileName}"); + } + } else { - if (opcConfig.IsSaveHeightOKImage) + if (opcConfig.IsSaveHeightOKImage||CommonUtil.DetectionOption == DetectionOption.doStandardBlock) { //DateTime dt = DateTime.Now; - //if (dt.Second >= 10 && dt.Second <= 15) + if (CommonUtil.DetectionOption == DetectionOption.doStandardBlock) + { + VisionDetect.SaveImageAs(hi, CommonUtil.ProductHeightImageDir + @"\" + tempFileName); + } + else { VisionDetect.SaveImageAs(hi, CommonUtil.ProductHeightImageDir + @"_OK\" + tempFileName); } + } } @@ -260,6 +275,12 @@ catch (Exception ex) { CommonUtil.WriteLog(LogType.Exc, string.Format("妫�娴嬩骇鍝佹潯鐮佸拰鍘氬害杩囩▼涓嚭鐜板紓甯革細{0}", ex.Message)); + + if (string.IsNullOrWhiteSpace(tempFileName)) + { + tempFileName = DateTime.Now.ToString("HHmmssfff"); + } + VisionDetect.SaveImageAs(ihImage, $"{CommonUtil.ProductSizeImageDir}_NA\\{tempFileName}"); } finally { -- Gitblit v1.8.0