From b3855dde0cb86819d17391432ad566564e4b66d7 Mon Sep 17 00:00:00 2001
From: peizhiyong <zhiyong.pei@broconcentric.com>
Date: 星期二, 19 八月 2025 10:06:57 +0800
Subject: [PATCH] 连续NG报警功能,单机台生产数据划分白夜班功能以及S3S5相同位置缺陷放射位置优化
---
src/Bro.M141.Process/M141Process_ImageCheck.cs | 144 +++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 135 insertions(+), 9 deletions(-)
diff --git a/src/Bro.M141.Process/M141Process_ImageCheck.cs b/src/Bro.M141.Process/M141Process_ImageCheck.cs
index dfcf451..854498c 100644
--- a/src/Bro.M141.Process/M141Process_ImageCheck.cs
+++ b/src/Bro.M141.Process/M141Process_ImageCheck.cs
@@ -9,6 +9,7 @@
using Microsoft.VisualBasic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
+using NPOI.SS.Formula.Functions;
using NPOI.SS.UserModel;
using NPOI.Util;
using NPOI.XSSF.UserModel;
@@ -450,7 +451,8 @@
public ResponseMessage ProductDataUpload(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
{
ResponseMessage msg = new ResponseMessage();
- string inputSequence = Plc1.Read(1536, 1, out _)[0].ToString();
+ int numplca = Plc1.Read(1536, 1, out _)[0];
+ string inputSequence = numplca.ToString();
var productList = new List<int>() { 1 }.Select(u =>
{
@@ -458,6 +460,10 @@
return FindProductBySequence(sequence, true);
}).ToList();
+ if (PlcNumForAll == -1)
+ {
+ PlcNumForAll = numplca;
+ }
int waitInterval = 300;
int repeatTime = M141Config.DetectTimeout / waitInterval;
@@ -488,6 +494,9 @@
{
////mysqlhelper.GetS2Result(productList[0].SEQUENCE);
Plc1.WriteSingleAddress(1526, mysqlhelper.GetS2Result(productList[0].SEQUENCE) ? 1 : 2, out _);
+
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{string.Join(",", productList.Select(u => u.PID))}妫�娴嬪弽棣坽mysqlhelper.GetS2Result(productList[0].SEQUENCE)}");
+
}
else
{
@@ -496,9 +505,128 @@
Plc1.WriteSingleAddress(1516, 1, out _);
+ //if (M141Config.ISupMES && (M141Config.MESchannel == -1 || M141Config.MESchannel == 1))
+ //{
+ // if (M141Config.numpro >= 50)
+ // {
+ // M141Config.numpro = 0;
+ // }
+
+ // if (productList[0].Result == "OK")
+ // {
+ // M141Config.numpro++;
+ // }
+
+ // //mqtt.demes(productList[0], M141Config.zwoid);
+ // string Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(productList[0], M141Config.zwoid, M141Config.numpro)).Result;
+ // if (Msgreceice == null)
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{productList[0].PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
+ // }
+ // else
+ // {
+ // try
+ // {
+ // var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(Msgreceice);
+
+ // if (obj.zstatus == "200")
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{productList[0].PID}鏁版嵁涓婁紶MES鎴愬姛 {Msgreceice}");
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{productList[0].PID}鏁版嵁涓婁紶MES澶辫触 {Msgreceice}");
+ // }
+ // }
+ // catch
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{productList[0].PID}鏁版嵁涓婁紶MES寮傚父 {Msgreceice}");
+ // }
+ // }
+
+
+
+ // lock (plcnumlock)
+ // {
+ // int differ = numplca - PlcNumForAll;
+ // if (differ > 1)
+ // {
+ // for (int i = PlcNumForAll + 1; i < numplca; i++)
+ // {
+ // try
+ // {
+ // var plist = mysqlhelper.GetProductList(i + "_1");
+ // ProductModel newp = new ProductModel();
+ // newp.SEQUENCE = plist[0].SEQUENCE;
+ // newp.PID = plist[0].PID;
+ // newp.BasketCode = plist[0].BasketCode;
+ // newp.Result = "NG";
+ // newp.SN = plist[0].SN;
+ // var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result;
+
+ // }
+ // catch
+ // {
+
+ // }
+ // }
+ // }
+ // else if (differ != -29998)
+ // {
+ // for (int i = PlcNumForAll + 1; i <= 29999; i++)
+ // {
+ // try
+ // {
+ // var plist = mysqlhelper.GetProductList(i + "_1");
+ // ProductModel newp = new ProductModel();
+ // newp.SEQUENCE = plist[0].SEQUENCE;
+ // newp.PID = plist[0].PID;
+ // newp.BasketCode = plist[0].BasketCode;
+ // newp.Result = "NG";
+ // newp.SN = plist[0].SN;
+ // var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result;
+
+ // }
+ // catch
+ // {
+
+ // }
+ // }
+
+
+
+ // for (int i = 1; i < numplca; i++)
+ // {
+ // try
+ // {
+ // var plist = mysqlhelper.GetProductList(i + "_1");
+ // ProductModel newp = new ProductModel();
+ // newp.SEQUENCE = plist[0].SEQUENCE;
+ // newp.PID = plist[0].PID;
+ // newp.BasketCode = plist[0].BasketCode;
+ // newp.Result = "NG";
+ // newp.SN = plist[0].SN;
+ // var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.zwoid, M141Config.numpro)).Result;
+
+ // }
+ // catch
+ // {
+
+ // }
+ // }
+
+
+ // }
+ // PlcNumForAll = numplca;
+ // }
+
+ //}
+
return msg;
}
+ object plcnumlock = new object();
+ int PlcNumForAll = -1;
private bool _isDemoStarted = false;
[ProcessMethod("OfflineDemo", "OfflineDemo", "绂荤嚎娴嬭瘯", InvokeType.CalibInvoke)]
@@ -552,7 +680,7 @@
continue;
}
- var sn = nameDatas[0]+"_1";
+ var sn = nameDatas[0] + "_1";
var imageSeq = nameDatas[2][^1].ToString();
var measureBind = M141Config.MeasureBindCollection.FirstOrDefault(u => u.ImageSaveSeq == imageSeq);
@@ -739,17 +867,20 @@
- private void UpdateProductResultAsync(ProductModel p)
+ private void UpdateProductResultAsync(ProductModel p, string name)
{
UpdateProductResult(p, out bool isOK);
_taskFactory.StartNew(() =>
{
_csvHead = p.GetCSVHead(ref _specHeadList, ref _positionList);
- CSVRecordAsync($"ProductRecord_{DateTime.Now.ToString("yyyyMMdd")}.csv", p.GetCSVData(_specHeadList, _positionList), _csvHead);
+ //CSVRecordAsync($"ProductRecord_{DateTime.Now.ToString("yyyyMMdd")}.csv", p.GetCSVData(_specHeadList, _positionList), _csvHead);
+ CSVRecordAsync(name, p.GetCSVData(_specHeadList, _positionList), _csvHead);
//_manager_P_Product.UpdateProductResult(p.ID, p.PID, p.SN, p.Result);
});
+ //杩炵画NG鏁版嵁璁板綍
+ CheckContinuousNGAlarmAsync(p);
}
@@ -857,10 +988,5 @@
public object data { get; set; }
}
-
-
-
-
-
}
}
--
Gitblit v1.8.0