From 417d5011c0b774fb9c8776def2a3e3f18528ad91 Mon Sep 17 00:00:00 2001
From: xcd <834800634@qq.com>
Date: 星期二, 17 十一月 2020 15:48:22 +0800
Subject: [PATCH] 1. 修改高度检测和长宽检测精度为小数点后5位 2. 添加启动时写入产品结果NA 3. 添加连续NG报警和数据库报警配置
---
M423DATA脚本/dbo.WarningConfigure-update20201117.sql | 4 ++
HeightDetection.cs | 4 +-
MainForm.cs | 47 +++++++++++++++++++++--
app.config | 2 +
SizeDetection.cs | 4 ++
CarrierBarcodeCtrl.cs | 4 +
6 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/CarrierBarcodeCtrl.cs b/CarrierBarcodeCtrl.cs
index 168d417..aaa1b0f 100644
--- a/CarrierBarcodeCtrl.cs
+++ b/CarrierBarcodeCtrl.cs
@@ -93,8 +93,10 @@
else
{
if (temp.Length == 13)
+ {
CarrierBarcode = temp;
- temp = "";
+ temp = "";
+ }
}
}
}
diff --git a/HeightDetection.cs b/HeightDetection.cs
index 7d4663d..c237cda 100644
--- a/HeightDetection.cs
+++ b/HeightDetection.cs
@@ -305,11 +305,11 @@
double standardGap = opcConfig.batteryHeightLimit.Max - standardValue;
double gap = adjustValue - standardValue;
- fakeValue = finalHeight = (gap / (errorBand / 2.0)) * standardGap + standardValue;
+ fakeValue = finalHeight = Math.Round(((gap / (errorBand / 2.0)) * standardGap + standardValue), 5);
if (finalHeight < opcConfig.batteryHeightLimit.Min || finalHeight > opcConfig.batteryHeightLimit.Max)
{
- fakeValue = standardValue + (CommonUtil.random.NextDouble() - 0.5) * 2.0 * standardGap;
+ fakeValue = Math.Round((standardValue + (CommonUtil.random.NextDouble() - 0.5) * 2.0 * standardGap), 5);
}
if (isEnableRawData)
diff --git "a/M423DATA\350\204\232\346\234\254/dbo.WarningConfigure-update20200510.sql" "b/M423DATA\350\204\232\346\234\254/dbo.WarningConfigure-update20201117.sql"
similarity index 98%
rename from "M423DATA\350\204\232\346\234\254/dbo.WarningConfigure-update20200510.sql"
rename to "M423DATA\350\204\232\346\234\254/dbo.WarningConfigure-update20201117.sql"
index 7cb4c86..aa7aae4 100644
--- "a/M423DATA\350\204\232\346\234\254/dbo.WarningConfigure-update20200510.sql"
+++ "b/M423DATA\350\204\232\346\234\254/dbo.WarningConfigure-update20201117.sql"
@@ -341,3 +341,7 @@
(Val,Type,Content,Solution)
values(48,1,N'涓嬫枡宸ヤ綅鎰熷簲鍏夌氦寮傚父鎶ヨ',N'1.涓嬫枡宸ヤ綅鏈鏈変骇鍝侊紝浣嗘槸浼犳劅鍣ㄦ病鏈夋娴嬪緱鍒版垨鑰呮槸浜у搧琚涓哄彇璧扮殑鎯呭喌锛屼細閫犳垚姝ゆ姤璀︼紱
2.涓嬫枡宸ヤ綅鏈病鏈変骇鍝侊紝浣嗘槸浼犳劅鍣ㄦ娴嬪埌浜嗕俊鍙凤紝鍙兘鏄紶鎰熷櫒璇劅搴旀垨鑰呭綋鍓嶇殑涓嬫枡宸ヤ綅涓婃湁寮傜墿鎴栬�呮槸璁や负鏀剧疆浜嗕骇鍝併��')
+
+insert into WarningConfigure
+(Val,Type,Content,Solution)
+values(2000,1,N'浜у搧杩炵画NG瓒呰繃璁惧畾娆℃暟鎶ヨ',N'璇烽�氭姤鐩稿叧浜哄憳锛岃澶囧浣嶅嵆鍙户缁�')
diff --git a/MainForm.cs b/MainForm.cs
index 726e365..45e464d 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -203,6 +203,20 @@
CommonUtil.IsRunning = true;
SetControls();
+
+ opc.Write(OPCOutputTag.DetectResult_OK, false);
+ opc.Write(OPCOutputTag.DetectResult_NG, false);
+ CommonUtil.WriteLog(LogType.Inf, "鍒濆鍖栦笅鏂橬A");
+
+ string continuousNGStr = ConfigurationManager.AppSettings["ContinuousNGThreshold"];
+ if (int.TryParse(continuousNGStr, out int temp))
+ {
+ _continuousNGThreshold = temp;
+ }
+ else
+ {
+ _continuousNGThreshold = 999;
+ }
}
public void Stop()
@@ -592,6 +606,9 @@
lblEmptyQuantity.Text = measureResultTTL.EmptyQuantity.ToString();
}
+ int _continuousNGThreshold = 999;
+ int _continuousNG = 0;
+
#region PLC 鐩戝惉
void OPCEventHandler(object sender, EventTool.ListenEventArgs e)
{
@@ -611,11 +628,12 @@
MeasureState pState = MeasureState.NA;
int detectID = CommonUtil.StepControl.GetUnloadStepID();
+ ProductMeasureResult x = null;
if (detectID > 0)
{
- var x = (from t in productTestCollection
- where t.DetectID == detectID
- select t
+ x = (from t in productTestCollection
+ where t.DetectID == detectID
+ select t
).FirstOrDefault();
if (x != default(ProductMeasureResult))
{
@@ -647,18 +665,28 @@
case MeasureState.OK:
opc.Write(OPCOutputTag.DetectResult_OK, true);
opc.Write(OPCOutputTag.DetectResult_NG, false);
+
+ CommonUtil.WriteLog(LogType.Inf, $"{x.DetectID}|{x.ProductNo}浜у搧搴旀斁鍏K Tray");
+
+ _continuousNG = 0;
break;
case MeasureState.NG:
opc.Write(OPCOutputTag.DetectResult_OK, false);
opc.Write(OPCOutputTag.DetectResult_NG, true);
+ CommonUtil.WriteLog(LogType.Inf, $"{x.DetectID}|{x.ProductNo}浜у搧搴旀斁鍏G Tray");
CommonUtil.StepControl.RemoveById(detectID);
+
+ _continuousNG++;
break;
default:
opc.Write(OPCOutputTag.DetectResult_OK, false);
opc.Write(OPCOutputTag.DetectResult_NG, false);
+ CommonUtil.WriteLog(LogType.Inf, $"{x.DetectID}|{x.ProductNo}浜у搧搴旀斁鍏A Tray");
CommonUtil.StepControl.RemoveById(detectID);
+
+ _continuousNG = 0;
break;
}
#endregion
@@ -682,6 +710,15 @@
DisplayCycleTime((int)Math.Round(ts.TotalMilliseconds));
}
unloadTime = DateTime.Now;
+
+ if (_continuousNG >= _continuousNGThreshold)
+ {
+ //鑴氭湰涓缃姤璀︾爜2000琛ㄧず杩炵画NG娆℃暟鍒拌揪璁惧畾鎶ヨ涓婇檺
+ opc.Write(OPCInputTag.Alarm, 2000);
+
+ CommonUtil.WriteLog(LogType.Inf, $"浜у搧杩炵画NG{_continuousNG}娆★紝鎶ヨ鎻愮ず");
+ _continuousNG = 0;
+ }
//
}
break;
@@ -878,8 +915,10 @@
if ((bool)item.value)
{
//opc.Write(OPCInputTag.UnloadBatteryDone, false);
-
int batteryId = CommonUtil.StepControl.GetUnloadBatteryID();
+
+ CommonUtil.WriteLog(LogType.Inf, $"鐢垫睜涓嬫枡鍒颁綅,Id:{batteryId}");
+
CommonUtil.StepControl.RemoveById(batteryId);
detectionData.SaveTrayBarcode(batteryId);
}
diff --git a/SizeDetection.cs b/SizeDetection.cs
index 5656971..5a5e868 100644
--- a/SizeDetection.cs
+++ b/SizeDetection.cs
@@ -334,6 +334,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;
diff --git a/app.config b/app.config
index c96c6b0..ad32d53 100644
--- a/app.config
+++ b/app.config
@@ -46,6 +46,8 @@
<add key="EnableRawData" value="false"/>
<add key="HeightStandard" value="4.4"/>
<add key="ErrorBand" value="2.0"/>
+
+ <add key="ContiousNGThreshold" value="3"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
--
Gitblit v1.8.0