S5数据保存及数据上传逻辑添加日志,手动打印条码区分S6和S9
| | |
| | | } |
| | | _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}汇总OK暂时不上传"); |
| | | } |
| | | 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}汇总OK暂时不上传"); |
| | | // } |
| | | // 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,开启关闭NG上传MES"); |
| | | } |
| | | else |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{pList[0].PID}数据上传MES异常 返回数据为null"); |
| | | } |
| | | } |
| | | 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,开启关闭NG上传MES"); |
| | | // } |
| | | // else |
| | | // { |
| | | // LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"产品{pList[0].PID}数据上传MES异常 返回数据为null"); |
| | | // } |
| | | // } |
| | | // 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, $"两个产品中间的差值differ为{differ}"); |
| | | // LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"两个产品中间的差值differ为{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},numplca为{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},numplca为{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,前站NG排料且plc触发清零产品{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,前站NG排料且plc触发清零产品{newp.PID}数据上传,结果为{newp.Result}"); |
| | | // } |
| | | // catch |
| | | // { |
| | | // } |
| | | // } |
| | | // } |
| | | // PlcNumForAll = numplca; |
| | | // } |
| | | |
| | | } |
| | | else |
| | | { |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"已关闭mes连接或者数据上传接口"); |
| | | } |
| | | //} |
| | | //else |
| | | //{ |
| | | // LogAsync(DateTime.Now, EnumHelper.LogLevel.Information, $"已关闭mes连接或者数据上传接口"); |
| | | //} |
| | | } |
| | | |
| | | //ReplyPlcData(positionName, config.TriggerValue); |
| | |
| | | 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); |
| | |
| | | button1.Name = "button1"; |
| | | button1.Size = new Size(93, 46); |
| | | button1.TabIndex = 2; |
| | | button1.Text = "打印"; |
| | | button1.Text = "S5打印条码"; |
| | | button1.UseVisualStyleBackColor = true; |
| | | button1.Click += button1_Click; |
| | | // |
| | |
| | | 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); |
| | |
| | | private Button button6; |
| | | private Label label3; |
| | | private TextBox textBox8; |
| | | private Button button4; |
| | | } |
| | | } |
| | |
| | | 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); |
| | | |
| | |
| | | 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) |
| | |
| | | |
| | | 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)); |
| | | |
| | | |
| | | // 在二维码下方画内容文字 |
| | |
| | | } |
| | | 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) |
| | |
| | | |
| | | //bmp.SetResolution(320, 160); |
| | | |
| | | Graphics g = Graphics.FromImage(bmp);//利用该图片对象生成“画板” |
| | | Graphics g = Graphics.FromImage(bmp);//利用该图片对象生成“画板”mo |
| | | |
| | | Font font = new Font("Arial", 8 * Scale);//设置字体颜色 |
| | | Font font2 = new Font("Arial", 11 * Scale);//设置字体颜色 |
| | |
| | | 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"); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <root> |
| | | <!-- |
| | | Microsoft ResX Schema |
| | | Microsoft ResX Schema |
| | | |
| | | Version 2.0 |
| | | |
| | |
| | | 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 |
| | |
| | | return msg; |
| | | } |
| | | |
| | | [ProcessMethod("", "MESupdata", "MES正常上传单个OK产品获取条码", InvokeType.TestInvoke)] |
| | | public ResponseMessage MESupdata(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | | ////[ProcessMethod("", "MESupdata", "MES正常上传单个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) |
| | |
| | | result = string.Empty; |
| | | return false; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | 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 _); |
| | |
| | | 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触发,获取PLC序号{plcnum[0]}和{plcnum1[0]}"); |
| | | |
| | | string saveTary_ID=string.Empty; |
| | | |
| | | if (!Issuccess && !Issuccess1) |
| | | { |
| | |
| | | return msg; |
| | | } |
| | | |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品信息上传MES触发"); |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"产品信息上传MES触发,产品信息数量为:{M141Config.Productioncode.Count}"); |
| | | |
| | | if (M141Config.Productioncode.Count == 50) |
| | | { |
| | | { |
| | | //产品正常上传 |
| | | while(M141Config.Productioncode.Count>0) |
| | | while (M141Config.Productioncode.Count>0) |
| | | { |
| | | ProductModel newp = new ProductModel(); |
| | | newp.SEQUENCE = M141Config.Productioncode[0].SEQUENCE; |
| | |
| | | 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 |
| | |
| | | } |
| | | M141Config.Productioncode.RemoveAt(0); |
| | | } |
| | | M141Config.Productioncode.Clear(); |
| | | } |
| | | else if (M141Config.Productioncode.Count > 50) |
| | | { |
| | |
| | | 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 |
| | | { |
| | |
| | | }); |
| | | LogAsync(DateTime.Now, EnumHelper.LogLevel.Assist, $"条码:{tary_ID}已触发S6打印并且保存"); |
| | | } |
| | | 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) |
| | |
| | | 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 |
| | | { |
| | |
| | | } |
| | | 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上传进料口空篮", InvokeType.TestInvoke)] |
| | |
| | | |
| | | return msg; |
| | | } |
| | | |
| | | |
| | | [ProcessMethod("", "MESup2", "MES上传进料口满载", InvokeType.TestInvoke)] |
| | | public ResponseMessage MESup2(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice) |
| | |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | } |
| | | } |