From a587c3fef521ccf454716f4eeccadaca7fb77f86 Mon Sep 17 00:00:00 2001 From: jace.tang <1536884497@qq.com> Date: 星期一, 13 六月 2022 11:33:03 +0800 Subject: [PATCH] 1.merge(上次更新内容未发全,下为补充) 2.补偿配置界面设置隐藏,无法通过界面修改 3.标准块模式默认保存图片,和图片保存开关脱钩 4.增加标准块补偿CSV数据输出 5.修改原有OPC输出事件,新的输出事件添加触发值输出。版本号升级到1.0.2022.0613 --- SizeDetection.cs | 35 +++++++++++++++++++++++++++++------ 1 files changed, 29 insertions(+), 6 deletions(-) diff --git a/SizeDetection.cs b/SizeDetection.cs index 5656971..d883a81 100644 --- a/SizeDetection.cs +++ b/SizeDetection.cs @@ -232,6 +232,7 @@ timeStr, CommonUtil.StepControl.ToString())); HObject hImage = null; + string tempFileName = ""; try { Thread.Sleep(50); @@ -242,7 +243,7 @@ { return; } - string tempFileName = GetCurrentProductSN(detectID); + tempFileName = GetCurrentProductSN(detectID); string productNo = GetProductNo(detectID); int times = 3; @@ -334,6 +335,10 @@ btyLength += compL; btyWidth += compW; + //闄愬埗绮惧害5浣� + btyLength = Math.Round(btyLength, 5); + btyWidth = Math.Round(btyWidth, 5); + lengthMeasureState = (btyLength >= opcConfig.batteryLengthLimit.Min && btyLength <= opcConfig.batteryLengthLimit.Max) ? MeasureState.OK : MeasureState.NG; widthMeasureState = (btyWidth >= opcConfig.batteryWidthLimit.Min && btyWidth <= opcConfig.batteryWidthLimit.Max) ? MeasureState.OK : MeasureState.NG; @@ -342,7 +347,7 @@ { ms = MeasureState.OK; - if (opcConfig.IsSaveSizeOKImage) + if (opcConfig.IsSaveSizeOKImage || CommonUtil.DetectionOption == DetectionOption.doStandardBlock) { DateTime dt = DateTime.Now; @@ -390,13 +395,13 @@ } else { - Type t = opcConfig.standardCompensationL.GetType(); + Type t = opcConfig.compensationL.GetType(); FieldInfo fi = t.GetField(string.Format("station{0}", CommonUtil.mainForm.PlateID)); - compL = (double)fi.GetValue(opcConfig.standardCompensationL); + compL = (double)fi.GetValue(opcConfig.compensationL); - t = opcConfig.standardCompensationW.GetType(); + t = opcConfig.compensationW.GetType(); fi = t.GetField(string.Format("station{0}", CommonUtil.mainForm.PlateID)); - compW = (double)fi.GetValue(opcConfig.standardCompensationW); + compW = (double)fi.GetValue(opcConfig.compensationW); btyLength += compL; btyWidth += compW; @@ -462,6 +467,7 @@ catch (Exception ex) { CommonUtil.WriteLog(LogType.Exc, string.Format("浜у搧灏哄妫�娴嬪嚭鐜板紓甯革細{0}", ex.Message)); + fileName = VisionDetect.SaveImageAs(hImage, $"{CommonUtil.ProductSizeImageDir}_NA\\{tempFileName}"); } finally { @@ -652,8 +658,25 @@ { GregorianCalendar gc = new GregorianCalendar(); int weekOfYear = gc.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Monday); + + var weekPlusStr = ConfigurationManager.AppSettings["WeekPlus"]; + int weekPlus = 0; + if (!int.TryParse(weekPlusStr, out weekPlus)) + { + weekPlus = 0; + } + weekOfYear += weekPlus; string week = weekOfYear.ToString().Length == 1 ? "0" + weekOfYear.ToString() : weekOfYear.ToString(); + + var yearPlusStr = ConfigurationManager.AppSettings["YearPlus"]; + int yearPlus = 0; + if (!int.TryParse(yearPlusStr, out yearPlus)) + { + yearPlus = 0; + } string year = dt.Year.ToString().Substring(dt.Year.ToString().Length - 1, 1); + year = (int.Parse(year) + yearPlus).ToString(); + return year + week; } } -- Gitblit v1.8.0