From 48f005ea04ee8ce6c9a044dd2fcb0febc7f74788 Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期四, 25 十二月 2025 21:22:21 +0800
Subject: [PATCH] S5数据保存及数据上传逻辑添加日志,手动打印条码区分S6和S9
---
src/Bro.M141.Process/UI/UIPrinter.resx | 4
src/Bro.M141.Process/UI/UIPrinter.cs | 73 ++++
src/Bro.M141_AOI1.Process/AOI1Process.cs | 308 ++++++++++++---------
src/Bro.M141.Process/M141Process.cs | 378 +++++++++++++-------------
src/Bro.M141.Process/UI/UIPrinter.Designer.cs | 18 +
5 files changed, 444 insertions(+), 337 deletions(-)
diff --git a/src/Bro.M141.Process/M141Process.cs b/src/Bro.M141.Process/M141Process.cs
index 37671b9..8e5de8c 100644
--- a/src/Bro.M141.Process/M141Process.cs
+++ b/src/Bro.M141.Process/M141Process.cs
@@ -1404,212 +1404,212 @@
}
_ct = DateTime.Now;
- if (M141Config.ISupMES && (M141Config.MESchannel == -1 || M141Config.MESchannel == 1))
- {
- if (M141Config.numpro >= 50)
- {
- M141Config.numpro = 0;
- }
+ //if (M141Config.ISupMES && (M141Config.MESchannel == -1 || M141Config.MESchannel == 1))
+ //{
+ // if (M141Config.numpro >= 50)
+ // {
+ // M141Config.numpro = 0;
+ // }
- string Msgreceice = null;
+ // string Msgreceice = null;
- if (pList[0].Result == "OK")
- {
- //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
- {
- if (M141Config.ISupNG)
- {
- Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(pList[0], M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鍚姩NG涓婁紶");
+ // if (pList[0].Result == "OK")
+ // {
+ // //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
+ // {
+ // if (M141Config.ISupNG)
+ // {
+ // Msgreceice = Task.Run(() => mqtt.MESForProduceAsync(pList[0], M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鍚姩NG涓婁紶");
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鍏抽棴NG涓婁紶");
- }
- }
- M141Config.mesnum2++;
- if (Msgreceice == null && !M141Config.ISupNG)
- {
- if (!M141Config.ISupNG)
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鏁版嵁NG锛屽紑鍚叧闂璑G涓婁紶MES");
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
- }
- }
- else
- {
- try
- {
- var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(Msgreceice);
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鍏抽棴NG涓婁紶");
+ // }
+ // }
+ // M141Config.mesnum2++;
+ // if (Msgreceice == null && !M141Config.ISupNG)
+ // {
+ // if (!M141Config.ISupNG)
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鏁版嵁NG锛屽紑鍚叧闂璑G涓婁紶MES");
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES寮傚父 杩斿洖鏁版嵁涓簄ull");
+ // }
+ // }
+ // else
+ // {
+ // try
+ // {
+ // var obj = JsonConvert.DeserializeObject<AutoLineMacBarcodeQueueBak>(Msgreceice);
- if (obj.zstatus == "200")
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES鎴愬姛 {Msgreceice}");
+ // if (obj.zstatus == "200")
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES鎴愬姛 {Msgreceice}");
- if (M141Config.Isprint && !string.IsNullOrEmpty(obj.tary_label))
- {
- StartPrint(obj.tary_label, "Honeywell PX240S(300 dpi)");
- }
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES澶辫触 {Msgreceice}");
- }
- }
- catch
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES寮傚父 {Msgreceice}");
- }
- }
+ // if (M141Config.Isprint && !string.IsNullOrEmpty(obj.tary_label))
+ // {
+ // StartPrint(obj.tary_label, "Honeywell PX240S(300 dpi)");
+ // }
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"浜у搧{pList[0].PID}鏁版嵁涓婁紶MES澶辫触 {Msgreceice}");
+ // }
+ // }
+ // catch
+ // {
+ // 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}");
+ // int numplca = Convert.ToInt32(pList[0].SEQUENCE.Split('_')[0]);
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"plc缁欏嚭鐨勪骇鍝佸簭鍙蜂负{numplca}");
- lock (plcnumlock)//1-29999
- {
+ // lock (plcnumlock)//1-29999
+ // {
- if (PlcNumForAll == -1)
- {
- PlcNumForAll = numplca;
- }
+ // if (PlcNumForAll == -1)
+ // {
+ // PlcNumForAll = numplca;
+ // }
- int differ = numplca - PlcNumForAll;
+ // int differ = numplca - PlcNumForAll;
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"涓や釜浜у搧涓棿鐨勫樊鍊糳iffer涓簕differ}");
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"涓や釜浜у搧涓棿鐨勫樊鍊糳iffer涓簕differ}");
- 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.Zword = plist[0].Zword;
- newp.Result = "NG";
- newp.SN = plist[0].SN;
+ // 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.Zword = plist[0].Zword;
+ // newp.Result = "NG";
+ // newp.SN = plist[0].SN;
- if (M141Config.IsfinDevice)
- {
- SummaryAllprodata(newp);
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
- }
- if (M141Config.ISupNG)
- {
- var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- M141Config.mesnum2++;
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
- }
+ // if (M141Config.IsfinDevice)
+ // {
+ // SummaryAllprodata(newp);
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
+ // }
+ // if (M141Config.ISupNG)
+ // {
+ // var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ // M141Config.mesnum2++;
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
+ // }
- }
- catch
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{i + "_1"}涓婁紶澶辫触");
- }
- }
- }
- else if (differ == -29998 && differ == 1 && differ == 0)
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鐢熶骇杩囩▼涓湭澶卞幓浜у搧");
- }
- else if (differ < 0 && differ > -29998)
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PlcNumForAll涓簕PlcNumForAll}锛宯umplca涓簕numplca}");
- //浜у搧浠庢柊璁℃暟鏃�
- 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.Zword = plist[0].Zword;
- newp.BasketCode = plist[0].BasketCode;
- newp.Result = "NG";
- newp.SN = plist[0].SN;
- if (M141Config.IsfinDevice)
- {
- SummaryAllprodata(newp);
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
- }
- if (M141Config.ISupNG)
- {
- var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- M141Config.mesnum2++;
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
- }
+ // }
+ // catch
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{i + "_1"}涓婁紶澶辫触");
+ // }
+ // }
+ // }
+ // else if (differ == -29998 && differ == 1 && differ == 0)
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鐢熶骇杩囩▼涓湭澶卞幓浜у搧");
+ // }
+ // else if (differ < 0 && differ > -29998)
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PlcNumForAll涓簕PlcNumForAll}锛宯umplca涓簕numplca}");
+ // //浜у搧浠庢柊璁℃暟鏃�
+ // 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.Zword = plist[0].Zword;
+ // newp.BasketCode = plist[0].BasketCode;
+ // newp.Result = "NG";
+ // newp.SN = plist[0].SN;
+ // if (M141Config.IsfinDevice)
+ // {
+ // SummaryAllprodata(newp);
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
+ // }
+ // if (M141Config.ISupNG)
+ // {
+ // var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ // M141Config.mesnum2++;
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
+ // }
+ // else
+ // {
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
+ // }
- }
- catch
- {
+ // }
+ // 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.Zword = plist[0].Zword;
- newp.Result = "NG";
- newp.SN = plist[0].SN;
- if (M141Config.IsfinDevice)
- {
- SummaryAllprodata(newp);
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
- }
- if (M141Config.ISupNG)
- {
- var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
- M141Config.mesnum2++;
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍏抽棴NG涓婁紶");
- }
+ // }
+ // }
+ // 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.Zword = plist[0].Zword;
+ // newp.Result = "NG";
+ // newp.SN = plist[0].SN;
+ // if (M141Config.IsfinDevice)
+ // {
+ // SummaryAllprodata(newp);
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鎻愬墠NG鍔犲叆姹囨�绘暟鎹姤琛ㄧ粺璁�");
+ // }
+ // if (M141Config.ISupNG)
+ // {
+ // var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ // M141Config.mesnum2++;
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧{newp.PID}鍚姩NG涓婁紶");
+ // }
+ // else
+ // {
+ // 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, $"numplca锛屽墠绔橬G鎺掓枡涓攑lc瑙﹀彂娓呴浂浜у搧{newp.PID}鏁版嵁涓婁紶,缁撴灉涓簕newp.Result}");
- }
- catch
- {
- }
- }
- }
- PlcNumForAll = numplca;
- }
+ // //var tems = Task.Run(() => mqtt.MESForProduceAsync(newp, M141Config.mesnum2.ToString(), M141Config.numpro)).Result;
+ // //M141Config.mesnum2++;
+ // //LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"numplca锛屽墠绔橬G鎺掓枡涓攑lc瑙﹀彂娓呴浂浜у搧{newp.PID}鏁版嵁涓婁紶,缁撴灉涓簕newp.Result}");
+ // }
+ // catch
+ // {
+ // }
+ // }
+ // }
+ // PlcNumForAll = numplca;
+ // }
- }
- else
- {
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插叧闂璵es杩炴帴鎴栬�呮暟鎹笂浼犳帴鍙�");
- }
+ //}
+ //else
+ //{
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"宸插叧闂璵es杩炴帴鎴栬�呮暟鎹笂浼犳帴鍙�");
+ //}
}
//ReplyPlcData(positionName, config.TriggerValue);
diff --git a/src/Bro.M141.Process/UI/UIPrinter.Designer.cs b/src/Bro.M141.Process/UI/UIPrinter.Designer.cs
index 1366f7b..7e3017f 100644
--- a/src/Bro.M141.Process/UI/UIPrinter.Designer.cs
+++ b/src/Bro.M141.Process/UI/UIPrinter.Designer.cs
@@ -45,11 +45,12 @@
button6 = new Button();
label3 = new Label();
textBox8 = new TextBox();
+ button4 = new Button();
SuspendLayout();
//
// button2
//
- button2.Location = new Point(154, 51);
+ button2.Location = new Point(229, 51);
button2.Margin = new Padding(3, 2, 3, 2);
button2.Name = "button2";
button2.Size = new Size(93, 46);
@@ -65,7 +66,7 @@
button1.Name = "button1";
button1.Size = new Size(93, 46);
button1.TabIndex = 2;
- button1.Text = "鎵撳嵃";
+ button1.Text = "S5鎵撳嵃鏉$爜";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
@@ -201,10 +202,22 @@
textBox8.Size = new Size(151, 21);
textBox8.TabIndex = 18;
//
+ // button4
+ //
+ button4.Location = new Point(126, 51);
+ button4.Margin = new Padding(3, 2, 3, 2);
+ button4.Name = "button4";
+ button4.Size = new Size(93, 46);
+ button4.TabIndex = 19;
+ button4.Text = "S9鎵撳嵃鏉$爜";
+ button4.UseVisualStyleBackColor = true;
+ button4.Click += button4_Click;
+ //
// UIPrinter
//
AutoScaleDimensions = new SizeF(6F, 13F);
AutoScaleMode = AutoScaleMode.Font;
+ Controls.Add(button4);
Controls.Add(textBox8);
Controls.Add(label3);
Controls.Add(button6);
@@ -248,5 +261,6 @@
private Button button6;
private Label label3;
private TextBox textBox8;
+ private Button button4;
}
}
diff --git a/src/Bro.M141.Process/UI/UIPrinter.cs b/src/Bro.M141.Process/UI/UIPrinter.cs
index 0278d89..ba876a4 100644
--- a/src/Bro.M141.Process/UI/UIPrinter.cs
+++ b/src/Bro.M141.Process/UI/UIPrinter.cs
@@ -74,6 +74,53 @@
this.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
this.printDocument1.Print();
+ //this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)1";
+ //this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh);
+
+ //this.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
+ //this.printDocument1.Print();
+
+
+
+ }
+ catch
+ {
+
+ }
+
+ int statuscode = GetPrinterStatusCodeInt();
+ string status = GetPrinterStatusMessage(statuscode);
+
+ //Config141
+ try
+ {
+ Process141.PlcwritePrinter(1520, 0);
+ Process141.PlcwritePrinter(1510, 1);
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ }
+ public void StartPrint1(string str)
+ {
+ try
+ {
+ ttwith = 240;
+ ttheigh = 80;
+ message = str;
+
+ if (string.IsNullOrEmpty(message))
+ {
+ message = textBox1.Text;
+ }
+
+ //this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)";
+ //this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh);
+
+ //this.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
+ //this.printDocument1.Print();
+
this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)1";
this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh);
@@ -97,12 +144,11 @@
Process141.PlcwritePrinter(1520, 0);
Process141.PlcwritePrinter(1510, 1);
}
- catch(Exception ex)
+ catch (Exception ex)
{
MessageBox.Show(ex.Message);
- }
+ }
}
-
//C229M2508250500002
private void printDocument_Print(object sender, PrintPageEventArgs e)
@@ -143,7 +189,7 @@
writer.Options = options;
Bitmap map = writer.Write(numvalue);
- e.Graphics.DrawImage(map, new System.Drawing.Point(90,4));
+ e.Graphics.DrawImage(map, new System.Drawing.Point(90, 4));
// 鍦ㄤ簩缁寸爜涓嬫柟鐢诲唴瀹规枃瀛�
@@ -411,7 +457,16 @@
}
StartPrint(message);
}
-
+ private void button4_Click(object sender, EventArgs e)
+ {
+ message = textBox1.Text;
+ if (string.IsNullOrEmpty(message))
+ {
+ MessageBox.Show("鎵撳嵃鍐呭涓嶅彲涓虹┖");
+ return;
+ }
+ StartPrint1(message);
+ }
//棰勮
private void button2_Click(object sender, EventArgs e)
@@ -449,7 +504,7 @@
//bmp.SetResolution(320, 160);
- Graphics g = Graphics.FromImage(bmp);//鍒╃敤璇ュ浘鐗囧璞$敓鎴愨�滅敾鏉库��
+ Graphics g = Graphics.FromImage(bmp);//鍒╃敤璇ュ浘鐗囧璞$敓鎴愨�滅敾鏉库�漨o
Font font = new Font("Arial", 8 * Scale);//璁剧疆瀛椾綋棰滆壊
Font font2 = new Font("Arial", 11 * Scale);//璁剧疆瀛椾綋棰滆壊
@@ -791,7 +846,7 @@
int pronum = 0;
private void button6_Click(object sender, EventArgs e)//sn,result,zword,zno,entray
{
- string Msg = Task.Run(() => Process141.mqtt.MESForProduceAsync(new ProductModel() { SN = textBox3.Text, Result = textBox4.Text ,Zword= textBox5.Text}, textBox8.Text, Convert.ToInt32(textBox6.Text), textBox7.Text)).Result;
+ string Msg = Task.Run(() => Process141.mqtt.MESForProduceAsync(new ProductModel() { SN = textBox3.Text, Result = textBox4.Text, Zword = textBox5.Text }, textBox8.Text, Convert.ToInt32(textBox6.Text), textBox7.Text)).Result;
if (Msg == null)
{
CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ 鐗╂枡 杩斿洖鏁版嵁涓� null");
@@ -802,8 +857,6 @@
}
}
-
-
-
+
}
}
diff --git a/src/Bro.M141.Process/UI/UIPrinter.resx b/src/Bro.M141.Process/UI/UIPrinter.resx
index af32865..8b2ff64 100644
--- a/src/Bro.M141.Process/UI/UIPrinter.resx
+++ b/src/Bro.M141.Process/UI/UIPrinter.resx
@@ -1,7 +1,7 @@
锘�<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
- Microsoft ResX Schema
+ Microsoft ResX Schema
Version 2.0
@@ -48,7 +48,7 @@
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
-
+
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
diff --git a/src/Bro.M141_AOI1.Process/AOI1Process.cs b/src/Bro.M141_AOI1.Process/AOI1Process.cs
index f4c2e15..7b7e435 100644
--- a/src/Bro.M141_AOI1.Process/AOI1Process.cs
+++ b/src/Bro.M141_AOI1.Process/AOI1Process.cs
@@ -615,131 +615,145 @@
return msg;
}
- [ProcessMethod("", "MESupdata", "MES姝e父涓婁紶鍗曚釜OK浜у搧鑾峰彇鏉$爜", InvokeType.TestInvoke)]
- public ResponseMessage MESupdata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+ ////[ProcessMethod("", "MESupdata", "MES姝e父涓婁紶鍗曚釜OK浜у搧鑾峰彇鏉$爜", InvokeType.TestInvoke)]
+ ////public ResponseMessage MESupdata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+ ////{
+ //// ResponseMessage msg = new ResponseMessage();
+
+ //// Plc3 = invokeDevice as PLCBase;
+ //// //涓婁紶鍙嶉缁撴灉
+ //// bool Issuccess = false;
+ //// bool Issuccess1 = false;
+
+ //// string tary_label = string.Empty;
+
+ //// string tary_label1 = string.Empty;
+
+ //// var plcnum = Plc3.Read(2100, 1, out _);
+ //// var plcnum1 = Plc3.Read(2102, 1, out _);
+ //// if (plcnum[0] == 0)
+ //// {
+ //// Issuccess = true;
+ //// }
+ //// else
+ //// {
+ //// Issuccess = UpMES(plcnum[0] + "_1", "N", out tary_label);
+ //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label))
+ //// {
+ //// StartPrint(tary_label, "Honeywell PX240S(300 dpi)");
+ //// }
+ //// }
+ //// if (plcnum1[0] == 0)
+ //// {
+ //// Issuccess1 = true;
+ //// }
+ //// else
+ //// {
+ //// Issuccess1 = UpMES(plcnum1[0] + "_1", "N", out tary_label1);
+
+ //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1))
+ //// {
+ //// StartPrint(tary_label1, "Honeywell PX240S(300 dpi)");
+ //// }
+ //// }
+ //// if (Issuccess && Issuccess1)
+ //// {
+ //// Plc3.WriteSingleAddress(2120, 1, out _);
+ //// }
+ //// else
+ //// {
+ //// Plc3.WriteSingleAddress(2120, 2, out _);
+ //// }
+ //// return msg;
+ ////}
+
+ ////[ProcessMethod("", "MESupFinallydata", "MES涓婁紶鍗曚釜灏剧洏OK浜у搧鑾峰彇鏉$爜", InvokeType.TestInvoke)]
+ ////public ResponseMessage MESupFinallydata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+ ////{
+ //// ResponseMessage msg = new ResponseMessage();
+
+ //// Plc3 = invokeDevice as PLCBase;
+ //// //涓婁紶鍙嶉缁撴灉
+ //// bool Issuccess = false;
+ //// bool Issuccess1 = false;
+
+ //// string tary_label = string.Empty;
+
+ //// string tary_label1 = string.Empty;
+
+ //// var plcnum = Plc3.Read(2100, 1, out _);
+ //// var plcnum1 = Plc3.Read(2102, 1, out _);
+ //// if (plcnum[0] != 0|| plcnum1[0] != 0)
+ //// {
+ //// if (plcnum[0] == 0)
+ //// {
+ //// Issuccess1 = UpMES(plcnum1[0] + "_1", "Y", out tary_label1);
+ //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1))
+ //// {
+ //// StartPrint(tary_label1, "Honeywell PX240S(300 dpi)");
+ //// }
+ //// }
+ //// else if(plcnum1[0] == 0)
+ //// {
+ //// Issuccess = UpMES(plcnum[0] + "_1", "Y", out tary_label);
+ //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label))
+ //// {
+ //// StartPrint(tary_label, "Honeywell PX240S(300 dpi)");
+ //// }
+ //// }
+ //// else if (plcnum[0] != 0 && plcnum1[0] != 0)
+ //// {
+ //// Issuccess = UpMES(plcnum[0] + "_1", "N", out tary_label);
+ //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1))
+ //// {
+ //// StartPrint(tary_label1, "Honeywell PX240S(300 dpi)");
+ //// }
+ //// Issuccess1 = UpMES(plcnum1[0] + "_1", "Y", out tary_label1);
+ //// if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label))
+ //// {
+ //// StartPrint(tary_label, "Honeywell PX240S(300 dpi)");
+ //// }
+ //// }
+ //// }
+
+ //// if (Issuccess && Issuccess1)
+ //// {
+ //// Plc3.WriteSingleAddress(2120, 1, out _);
+ //// }
+ //// else
+ //// {
+ //// Plc3.WriteSingleAddress(2120, 2, out _);
+ //// }
+ //// return msg;
+ ////}
+
+ //private bool UpMES(string PLCNum ,string endtray , out string result )
+ //{
+ // var plist = mysqlhelper.GetProductList(PLCNum);
+ // ProductModel newp = new ProductModel();
+ // newp.SEQUENCE = plist[0].SEQUENCE;
+ // newp.PID = plist[0].PID;
+ // newp.BasketCode = plist[0].BasketCode;
+ // newp.Zword = plist[0].Zword;
+ // newp.Result = "OK";
+ // newp.SN = plist[0].SN;
+ // bool isok = UptoMES(newp, endtray, out result);
+ // return isok;
+
+ //}
+
+ [ProcessMethod("", "PLCreadTosave", "PLC鏁版嵁璇诲彇淇濆瓨", InvokeType.TestInvoke)]
+ public ResponseMessage PLCreadTosave(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
{
ResponseMessage msg = new ResponseMessage();
- Plc3 = invokeDevice as PLCBase;
- //涓婁紶鍙嶉缁撴灉
- bool Issuccess = false;
- bool Issuccess1 = false;
+ var plcnum11 = Plc3.Read(1542, 1, out _);
+ var plcnum12 = Plc3.Read(1544, 1, out _);
- string tary_label = string.Empty;
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"PLC淇℃伅璁板綍淇濆瓨瑙﹀彂 鑾峰彇PLC搴忓彿{plcnum11[0]}鍜寋plcnum12[0]}");
- string tary_label1 = string.Empty;
- var plcnum = Plc3.Read(2100, 1, out _);
- var plcnum1 = Plc3.Read(2102, 1, out _);
- if (plcnum[0] == 0)
- {
- Issuccess = true;
- }
- else
- {
- Issuccess = UpMES(plcnum[0] + "_1", "N", out tary_label);
- if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label))
- {
- StartPrint(tary_label, "Honeywell PX240S(300 dpi)");
- }
- }
- if (plcnum1[0] == 0)
- {
- Issuccess1 = true;
- }
- else
- {
- Issuccess1 = UpMES(plcnum1[0] + "_1", "N", out tary_label1);
-
- if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1))
- {
- StartPrint(tary_label1, "Honeywell PX240S(300 dpi)");
- }
- }
- if (Issuccess && Issuccess1)
- {
- Plc3.WriteSingleAddress(2120, 1, out _);
- }
- else
- {
- Plc3.WriteSingleAddress(2120, 2, out _);
- }
return msg;
- }
-
- [ProcessMethod("", "MESupFinallydata", "MES涓婁紶鍗曚釜灏剧洏OK浜у搧鑾峰彇鏉$爜", InvokeType.TestInvoke)]
- public ResponseMessage MESupFinallydata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
- {
- ResponseMessage msg = new ResponseMessage();
-
- Plc3 = invokeDevice as PLCBase;
- //涓婁紶鍙嶉缁撴灉
- bool Issuccess = false;
- bool Issuccess1 = false;
-
- string tary_label = string.Empty;
-
- string tary_label1 = string.Empty;
-
- var plcnum = Plc3.Read(2100, 1, out _);
- var plcnum1 = Plc3.Read(2102, 1, out _);
- if (plcnum[0] != 0|| plcnum1[0] != 0)
- {
- if (plcnum[0] == 0)
- {
- Issuccess1 = UpMES(plcnum1[0] + "_1", "Y", out tary_label1);
- if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1))
- {
- StartPrint(tary_label1, "Honeywell PX240S(300 dpi)");
- }
- }
- else if(plcnum1[0] == 0)
- {
- Issuccess = UpMES(plcnum[0] + "_1", "Y", out tary_label);
- if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label))
- {
- StartPrint(tary_label, "Honeywell PX240S(300 dpi)");
- }
- }
- else if (plcnum[0] != 0 && plcnum1[0] != 0)
- {
- Issuccess = UpMES(plcnum[0] + "_1", "N", out tary_label);
- if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label1))
- {
- StartPrint(tary_label1, "Honeywell PX240S(300 dpi)");
- }
- Issuccess1 = UpMES(plcnum1[0] + "_1", "Y", out tary_label1);
- if (M141Config.Isprint && !string.IsNullOrEmpty(tary_label))
- {
- StartPrint(tary_label, "Honeywell PX240S(300 dpi)");
- }
- }
- }
-
- if (Issuccess && Issuccess1)
- {
- Plc3.WriteSingleAddress(2120, 1, out _);
- }
- else
- {
- Plc3.WriteSingleAddress(2120, 2, out _);
- }
- return msg;
- }
-
- private bool UpMES(string PLCNum ,string endtray , out string result )
- {
- var plist = mysqlhelper.GetProductList(PLCNum);
- ProductModel newp = new ProductModel();
- newp.SEQUENCE = plist[0].SEQUENCE;
- newp.PID = plist[0].PID;
- newp.BasketCode = plist[0].BasketCode;
- newp.Zword = plist[0].Zword;
- newp.Result = "OK";
- newp.SN = plist[0].SN;
- bool isok = UptoMES(newp, endtray, out result);
- return isok;
-
}
private bool UptoMES( ProductModel pro, string endtray, out string result)
@@ -784,7 +798,6 @@
result = string.Empty;
return false;
}
-
}
}
@@ -799,14 +812,17 @@
bool Issuccess1 = false;
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅璁板綍淇濆瓨瑙﹀彂");
+ //LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅璁板綍淇濆瓨瑙﹀彂");
var plcnum = Plc3.Read(2100, 1, out _);
+
Issuccess = GetProImformation(plcnum[0]);
var plcnum1 = Plc3.Read(2102, 1, out _);
Issuccess1 = GetProImformation(plcnum1[0]);
-
+
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅璁板綍淇濆瓨瑙﹀彂 鑾峰彇PLC搴忓彿{plcnum[0]}鍜寋plcnum1[0]}");
+
if (Issuccess && Issuccess1)
{
Plc3.WriteSingleAddress(2120, 1, out _);
@@ -869,11 +885,16 @@
bool Issuccess = false;
bool Issuccess1 = false;
+ // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅涓婁紶mes瑙﹀彂");
var plcnum = Plc3.Read(2100, 1, out _);
Issuccess = GetProImformation(plcnum[0]);
var plcnum1 = Plc3.Read(2102, 1, out _);
Issuccess1 = GetProImformation(plcnum1[0]);
+
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅涓婁紶mes瑙﹀彂锛岃幏鍙朠LC搴忓彿{plcnum[0]}鍜寋plcnum1[0]}");
+
+ string saveTary_ID=string.Empty;
if (!Issuccess && !Issuccess1)
{
@@ -881,12 +902,12 @@
return msg;
}
- LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅涓婁紶MES瑙﹀彂");
+ LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"浜у搧淇℃伅涓婁紶MES瑙﹀彂锛屼骇鍝佷俊鎭暟閲忎负锛歿M141Config.Productioncode.Count}");
if (M141Config.Productioncode.Count == 50)
- {
+ {
//浜у搧姝e父涓婁紶
- while(M141Config.Productioncode.Count>0)
+ while (M141Config.Productioncode.Count>0)
{
ProductModel newp = new ProductModel();
newp.SEQUENCE = M141Config.Productioncode[0].SEQUENCE;
@@ -900,10 +921,12 @@
if (!isok)
{
Plc3.WriteSingleAddress(2120, 2, out _);
+ return msg;
}
if (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID))
{
- StartPrint(tary_ID, "Honeywell PX240S(300 dpi)");
+ saveTary_ID = tary_ID;
+ StartPrint(tary_ID, "Honeywell PX240S(300 dpi)");
M141Config.MES_codes.Add(new MES_code
{
Printers_code = tary_ID
@@ -912,6 +935,7 @@
}
M141Config.Productioncode.RemoveAt(0);
}
+ M141Config.Productioncode.Clear();
}
else if (M141Config.Productioncode.Count > 50)
{
@@ -919,20 +943,24 @@
for (int i = 0; i < 50; i++)
{
ProductModel newp = new ProductModel();
- newp.SEQUENCE = M141Config.Productioncode[-1].SEQUENCE;
- newp.PID = M141Config.Productioncode[-1].PID;
- newp.BasketCode = M141Config.Productioncode[-1].BasketCode;
- newp.Zword = M141Config.Productioncode[-1].Zword;
+ int count = M141Config.Productioncode.Count;
+ newp.SEQUENCE = M141Config.Productioncode[count - 1].SEQUENCE;
+ newp.PID = M141Config.Productioncode[count - 1].PID;
+ newp.BasketCode = M141Config.Productioncode[count - 1].BasketCode;
+ newp.Zword = M141Config.Productioncode[count - 1].Zword;
newp.Result = "OK";
- newp.SN = M141Config.Productioncode[-1].SN;
+ newp.SN = M141Config.Productioncode[count - 1].SN;
string tary_ID = string.Empty;
bool isok = UptoMES(newp, "N", out tary_ID);
if (!isok)
{
Plc3.WriteSingleAddress(2120, 2, out _);
+ return msg;
+
}
if (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID))
{
+ saveTary_ID = tary_ID;
StartPrint(tary_ID, "Honeywell PX240S(300 dpi)");
M141Config.MES_codes.Add(new MES_code
{
@@ -940,11 +968,11 @@
});
LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"鏉$爜锛歿tary_ID}宸茶Е鍙慡6鎵撳嵃骞朵笖淇濆瓨");
}
- M141Config.Productioncode.RemoveAt(-1);
+ M141Config.Productioncode.RemoveAt(count - 1);
}
M141Config.Productioncode.Clear();
}
- else if (M141Config.Productioncode.Count < 50)
+ else if (M141Config.Productioncode.Count > 0 && M141Config.Productioncode.Count < 50)
{
//浜у搧缂哄皯闇�瑕侀澶栫殑鏉$爜琛ユ晳
while (M141Config.Productioncode.Count > 0)
@@ -971,9 +999,11 @@
if (!isok)
{
Plc3.WriteSingleAddress(2120, 2, out _);
+ return msg;
}
if (M141Config.Isprint && !string.IsNullOrEmpty(tary_ID))
{
+ saveTary_ID = tary_ID;
StartPrint(tary_ID, "Honeywell PX240S(300 dpi)");
M141Config.MES_codes.Add(new MES_code
{
@@ -983,16 +1013,26 @@
}
M141Config.Productioncode.RemoveAt(0);
}
+ M141Config.Productioncode.Clear();
+ }
+ else if (M141Config.Productioncode.Count == 0)
+ {
+ if (M141Config.Isprint && !string.IsNullOrEmpty(saveTary_ID))
+ {
+ StartPrint(saveTary_ID, "Honeywell PX240S(300 dpi)");
+ }
}
if (Issuccess && Issuccess1)
{
Plc3.WriteSingleAddress(2120, 1, out _);
+ return msg;
}
else
{
Plc3.WriteSingleAddress(2120, 2, out _);
+ return msg;
}
- return msg;
+
}
[ProcessMethod("", "MESup1", "MES涓婁紶杩涙枡鍙g┖绡�", InvokeType.TestInvoke)]
@@ -1074,7 +1114,6 @@
return msg;
}
-
[ProcessMethod("", "MESup2", "MES涓婁紶杩涙枡鍙f弧杞�", InvokeType.TestInvoke)]
public ResponseMessage MESup2(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -1330,5 +1369,6 @@
}
return msg;
}
+
}
}
--
Gitblit v1.8.0