From 86f899fa91e811415614dff1a699141144bfc802 Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期五, 12 十二月 2025 13:25:37 +0800
Subject: [PATCH] S5上传mes逻辑修改及打印机逻辑修改和数据库存储数据增加
---
src/Bro.M141.Process/M141Process.cs | 59 +++++++++++++++++++----------------------------------------
1 files changed, 19 insertions(+), 40 deletions(-)
diff --git a/src/Bro.M141.Process/M141Process.cs b/src/Bro.M141.Process/M141Process.cs
index 44a3c5a..37671b9 100644
--- a/src/Bro.M141.Process/M141Process.cs
+++ b/src/Bro.M141.Process/M141Process.cs
@@ -103,6 +103,7 @@
public PLCBase Plc1;
bool devicestate = false;
PLCBase Plc2;
+ public PLCBase Plc3;
public Thread ThHeartPlc;
public RabbitMQHelper mqtt;
@@ -322,7 +323,7 @@
AlarmTypeList.Add(item2.alarmtype);
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"鎶ヨ绫诲埆{item2.alarmtype}鍔犲叆闃熷垪,闃熷垪涓暟涓簕AlarmTypeList.Count}");
+
}
}
}
@@ -338,8 +339,7 @@
{
StateDIC[StateDICKey] = new List<int>();
-
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"鎶ヨ绫诲埆{StateDICKey}鍔犲叆瀛楀吀锛歋tateDIC");
+
}
@@ -362,7 +362,7 @@
CSVdata = csvdata,
};
AlarmType.Add(item.alarmtype, alarmData);
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"鎶ヨ{item.alarmname}绫诲埆{key}浣滀负key鍔犲叆AlarmType瀛楀吀");
+
}
alarmData.CSVhead += $",{item.alarmname}";
@@ -642,6 +642,10 @@
if (measureBind.WorkPosition == "P1" && M141Config.StationCode == "S5" && detectResults.GetDefectDescList().Count == 0)
{
+ var defecttem1 = detectResults.SelectMany(u => u.AllNetResults).SelectMany(m => m.DetectDetails).Select(detail => detail.ClassName).ToList();
+
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Detail, $"{products[0].SN} S3S5妫�娴� 缂洪櫡鍚嶇О闆嗗悎涓簕string.Join(",", defecttem1)}");
+
var defecttem = detectResults.SelectMany(u => u.AllNetResults.SelectMany(m => m.DetectDetails)).Where(u => u.ClassName == M141Config.defectname).ToList();
List<Netdefectdetail> Netdefectdetails = mysqlhelper.GetNetdefectdetails(products[0].SEQUENCE);
@@ -893,7 +897,6 @@
});
}
-
public async Task RunImageCheckAsync(List<ProductModel> products, string triggerText, string triggerSource, MeasureBind measureBind)
{
await Task.Run(() =>
@@ -972,7 +975,6 @@
});
}
-
private void RunCustomizedMethod(List<ProductModel> products, string triggerText, string triggerSource, IImageSet imgSet, string methodId, List<DetectResult> resultList)
{
try
@@ -1019,10 +1021,6 @@
LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鑷畾涔夋娴嬭繃绋嬪紓甯革紝{ex.GetExceptionMessage()}");
}
}
-
-
-
-
#region plc
public ResponseMessage RunImageCheck_plc(IOperationConfig config)
@@ -1101,7 +1099,6 @@
CheckPositionDoneAsync_plc(measureBinds[0].WorkPosition, inputSequence, config, cameraIds);
-
return msg;
}
@@ -1152,8 +1149,6 @@
LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鐩告満{camera.Name}妫�娴嬪墠娓呯悊缂撳瓨瀹屾垚");
}
});
-
-
inputSequence = triggerDatas[triggerDatas.Length - 1];
@@ -1245,7 +1240,6 @@
{
try
{
-
string index = config.TriggerStr.Split(',')[1];
var positionSet = M141Config.WorkPositionCollection.FirstOrDefault(u => u.PositionName == positionName);
@@ -1421,8 +1415,9 @@
if (pList[0].Result == "OK")
{
- M141Config.numpro++;
- Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(pList[0], M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ //M141Config.numpro++;
+ //Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(pList[0], M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}姹囨�籓K鏆傛椂涓嶄笂浼�");
}
else
{
@@ -1461,11 +1456,8 @@
if (M141Config.Isprint && !string.IsNullOrEmpty(obj.tary_label))
{
- StartPrint(obj.tary_label);
+ StartPrint(obj.tary_label, "Honeywell PX240S(300 dpi)");
}
-
-
-
}
else
{
@@ -1477,8 +1469,6 @@
LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES寮傚父 {Msgreceice}");
}
}
-
-
int numplca = Convert.ToInt32(pList[0].SEQUENCE.Split('_')[0]);
LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"plc缁欏嚭鐨勪骇鍝佸簭鍙蜂负{numplca}");
@@ -1568,9 +1558,6 @@
{
LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
}
- //var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- //M141Config.mesnum2++;
- //LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PlcNumForAll锛屽墠绔橬G鎺掓枡涓攑lc瑙﹀彂娓呴浂浜у搧{newp.PID}鏁版嵁涓婁紶,缁撴灉涓簕newp.Result}");
}
catch
@@ -1703,7 +1690,7 @@
data += "NA,";
}
}
- CSVRecordAsync($"AllDeviceProductRecord.csv", data, Head);
+ CSVRecordAsync($"AllDeviceProductRecord_{DateTime.Now.ToString("yyyyMMdd")}.csv", data, Head);
}
catch (Exception exx)
@@ -1897,20 +1884,16 @@
}
-
-
-
-
#region 鎵撳嵃鏈虹浉鍏�
PrintDocument printDocument1 = new PrintDocument();
string Printmessage = "";
- public void StartPrint(string str)
+ public void StartPrint(string str, string PrinterName)
{
try
{
- int ttwith = 320;
- int ttheigh = 160;
+ int ttwith = 240;
+ int ttheigh = 80;
Printmessage = str;
this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)";
@@ -1926,6 +1909,7 @@
}
}
+
//C229M2508250500002
@@ -1950,7 +1934,7 @@
writer.Options = options;
Bitmap map = writer.Write(Printmessage);
- e.Graphics.DrawImage(map, new System.Drawing.Point(90, 10));
+ e.Graphics.DrawImage(map, new System.Drawing.Point(90, 4));
// 鍦ㄤ簩缁寸爜涓嬫柟鐢诲唴瀹规枃瀛�
using (Font font = new Font("Arial", 10))
@@ -1959,7 +1943,7 @@
// 璁╂枃瀛楀眳涓埌浜岀淮鐮佷笅鏂�
SizeF textSize = e.Graphics.MeasureString(Printmessage, font);
float textX = 90 + (map.Width - textSize.Width) / 2;
- float textY = 10 + map.Height;
+ float textY = 1 + map.Height;
e.Graphics.DrawString(Printmessage, font, brush3, textX, textY);
}
@@ -1976,11 +1960,6 @@
#endregion
-
-
-
-
-
}
--
Gitblit v1.8.0