From a97ac998301461e6284595b1cf2c7b40ce5b2459 Mon Sep 17 00:00:00 2001
From: kingno <30263@KINGNO>
Date: 星期四, 03 四月 2025 14:09:36 +0800
Subject: [PATCH] 优化数据库字段的json传输 新增打印机

---
 libs/PFW/Bro.Common.Model.dll                     |    0 
 src/Bro.M135.Common/FrmProductList.cs             |    3 
 src/Bro.M135.Common/MESHelper.cs                  |    3 
 src/Bro.M141.Process/UI/UIPrinter.cs              |   41 ++++++++-
 src/Bro.M141.Process/Bro.M141.Process.csproj      |    1 
 src/Bro.M141.Process/M141Process.cs               |   17 +--
 src/Bro.M141.Process/M141Process_ImageCheck.cs    |   31 +++++++
 libs/PFW/Bro.UI.Model.Winform.dll                 |    0 
 libs.zip                                          |    0 
 src/Bro.M141_AOI1.Process/AOI1Process.cs          |    1 
 src/Bro.M135.Common/ProductModel.cs               |    5 
 src/Bro.M141.Process/M141Process_Mysql.cs         |  117 +++++++++++++++++++++++-----
 src/Bro.M135.DBManager/Models/P_PRODUCT_DETAIL.cs |   11 +-
 13 files changed, 179 insertions(+), 51 deletions(-)

diff --git a/libs.zip b/libs.zip
new file mode 100644
index 0000000..c2bcad3
--- /dev/null
+++ b/libs.zip
Binary files differ
diff --git a/libs/PFW/Bro.Common.Model.dll b/libs/PFW/Bro.Common.Model.dll
index 4e37bb5..35b05bb 100644
--- a/libs/PFW/Bro.Common.Model.dll
+++ b/libs/PFW/Bro.Common.Model.dll
Binary files differ
diff --git a/libs/PFW/Bro.UI.Model.Winform.dll b/libs/PFW/Bro.UI.Model.Winform.dll
index 03d9e68..f5ad904 100644
--- a/libs/PFW/Bro.UI.Model.Winform.dll
+++ b/libs/PFW/Bro.UI.Model.Winform.dll
Binary files differ
diff --git a/src/Bro.M135.Common/FrmProductList.cs b/src/Bro.M135.Common/FrmProductList.cs
index ea835a5..13fc454 100644
--- a/src/Bro.M135.Common/FrmProductList.cs
+++ b/src/Bro.M135.Common/FrmProductList.cs
@@ -1,4 +1,5 @@
 锘縰sing Bro.Common.Helper;
+using Bro.Common.Interface;
 using Bro.Common.Model;
 using Bro.UI.Model.Winform;
 using Sunny.UI;
@@ -117,7 +118,7 @@
             {
                 this.Invoke(() =>
                 {
-                    var specList = p.Details.SelectMany(u => u.SpecList ?? new List<Spec>()).ToList();
+                    var specList = p.Details.SelectMany(u => u.SpecList ?? new List<ISpec>()).ToList();
                     specList.AddRange(p.Details.SelectMany(u => u.ResultList.SelectMany(s => s.Specs.Select(m => (Spec)m))));
                     specList.Sort((a, b) => string.Compare(a.Code, b.Code));
 
diff --git a/src/Bro.M135.Common/MESHelper.cs b/src/Bro.M135.Common/MESHelper.cs
index 57429e0..273c5c0 100644
--- a/src/Bro.M135.Common/MESHelper.cs
+++ b/src/Bro.M135.Common/MESHelper.cs
@@ -1,4 +1,5 @@
 锘縰sing Bro.Common.Helper;
+using Bro.Common.Interface;
 using Bro.Common.Model;
 using Newtonsoft.Json;
 using System.ComponentModel;
@@ -50,7 +51,7 @@
             data.result = isOK ? MES_OK : MES_NG;
 
             var specList = p.Details.SelectMany(u => u.ResultList.SelectMany(u => u.Specs)).ToList();
-            specList.AddRange(p.Details.SelectMany(u => u.SpecList ?? new List<Spec>()));
+            specList.AddRange(p.Details.SelectMany(u => u.SpecList ?? new List<ISpec>()));
 
             specList.ForEach(s =>
             {
diff --git a/src/Bro.M135.Common/ProductModel.cs b/src/Bro.M135.Common/ProductModel.cs
index ecca1b3..780342e 100644
--- a/src/Bro.M135.Common/ProductModel.cs
+++ b/src/Bro.M135.Common/ProductModel.cs
@@ -1,4 +1,5 @@
 锘縰sing Bro.Common.Helper;
+using Bro.Common.Interface;
 using Bro.Common.Model;
 using Bro.M135.DBManager;
 using Newtonsoft.Json;
@@ -53,11 +54,11 @@
             {
                 if (!string.IsNullOrWhiteSpace(d.FAIData))
                 {
-                    d.SpecList = JsonConvert.DeserializeObject<List<Spec>>(d.FAIData);
+                    d.SpecList = JsonConvert.DeserializeObject<List<ISpec>>(d.FAIData);
                 }
                 else
                 {
-                    d.SpecList = new List<Spec>();
+                    d.SpecList = new List<ISpec>();
                 }
 
                 if (!string.IsNullOrWhiteSpace(d.DefectDesc))
diff --git a/src/Bro.M135.DBManager/Models/P_PRODUCT_DETAIL.cs b/src/Bro.M135.DBManager/Models/P_PRODUCT_DETAIL.cs
index 2e123da..a0904bf 100644
--- a/src/Bro.M135.DBManager/Models/P_PRODUCT_DETAIL.cs
+++ b/src/Bro.M135.DBManager/Models/P_PRODUCT_DETAIL.cs
@@ -1,4 +1,5 @@
-锘縰sing Bro.Common.Model;
+锘縰sing Bro.Common.Interface;
+using Bro.Common.Model;
 using Bro.DataBase.Model;
 using System.ComponentModel.DataAnnotations.Schema;
 
@@ -13,11 +14,11 @@
         public string FAIData { get; set; } = "";
         public bool IsDone { get; set; } = false;
 
-        [NotMapped]
+        //[NotMapped]
         public List<DetectResult> ResultList { get; set; } = new List<DetectResult>();
-        [NotMapped]
-        public List<Spec> SpecList { get; set; } = new List<Spec>();
-        [NotMapped]
+        //[NotMapped]
+        public List<ISpec> SpecList { get; set; } = new List<ISpec>();
+        //[NotMapped]
         public List<string> DefectList { get; set; } = new List<string>();
     }
 }
diff --git a/src/Bro.M141.Process/Bro.M141.Process.csproj b/src/Bro.M141.Process/Bro.M141.Process.csproj
index 07e9f21..2407a98 100644
--- a/src/Bro.M141.Process/Bro.M141.Process.csproj
+++ b/src/Bro.M141.Process/Bro.M141.Process.csproj
@@ -52,6 +52,7 @@
   </ItemGroup>-->
 
 	<ItemGroup>
+		<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.1.6" />
 		<PackageReference Include="NPOI" Version="2.7.1" />
 		<PackageReference Include="ScottPlot.WinForms" Version="4.1.58" />
 		<PackageReference Include="System.ServiceModel.Duplex" Version="4.8.1" />
diff --git a/src/Bro.M141.Process/M141Process.cs b/src/Bro.M141.Process/M141Process.cs
index 4444bcc..d92a3cf 100644
--- a/src/Bro.M141.Process/M141Process.cs
+++ b/src/Bro.M141.Process/M141Process.cs
@@ -72,11 +72,11 @@
         }
 
         public PLCBase Plc1;
+        PLCBase Plc2;
         Thread ThHeartPlc;
         public override void Open()
         {
             base.Open();
-
             ML = DeviceCollection.FirstOrDefault(u => u is MachineLearningBase) as MachineLearningBase;
             if (ML == null)
             {
@@ -145,7 +145,6 @@
                 Thread.Sleep(3000);
             }
         }
-
 
         /// <summary>
         /// 缃戠粶棰勭儹
@@ -271,6 +270,10 @@
                 else
                 {
                     p.BasketCode = mysqlhelper.Getbasketcode(p.SEQUENCE);
+                    if ("NoRead".Equals(p.BasketCode))
+                    {
+                        LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"{p.PID}_{p.SEQUENCE}鑾峰彇妗嗗叿鐮佸け璐� 璧嬪�糔oread");
+                    }
                 }
 
                 mysqlhelper.NewProduct(p);
@@ -370,22 +373,16 @@
                                     var errorSpec = _errorSpec.Copy();
                                     errorSpec.Code = "妫�娴婽BD";
                                     errorSpec.ActualValue = -999;
-                                    DetectResult ngResult = new DetectResult() { Specs = new List<ISpec>() { errorSpec }, PID = u.Key };
+                                    DetectResult ngResult = new DetectResult() { Specs = new List<ISpec>() { errorSpec }, PID = u.Key ,Id=Guid.NewGuid().ToString()};
                                     ngResults.Add(ngResult);
                                 }
                             }
                         });
-
                         detectResults.AddRange(ngResults);
                         resultList.AddRange(detectResults);
-
-
                     }
-
-
                     RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedMonitorId, resultList);
                     RunCustomizedMethod(products, triggerText, triggerSource, imgSet, measureBind.CustomizedCombineMethodId, resultList);
-
                 }
                 catch (Exception ex)
                 {
@@ -952,7 +949,7 @@
                         CSVRecordAsync($"{positionName}_Record_{DateTime.Now.ToString("yyyyMMdd")}.csv", data, head);
 
                         //UpdatePositionResultToDB(detail);
-                        var seqData = p.SEQUENCE.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries).ToList();
+                        //var seqData = p.SEQUENCE.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries).ToList();
 
                         mysqlhelper.UpdateProduct(p);
                         if (positionSet.IsLastPosition)
diff --git a/src/Bro.M141.Process/M141Process_ImageCheck.cs b/src/Bro.M141.Process/M141Process_ImageCheck.cs
index e76e5cf..222cddc 100644
--- a/src/Bro.M141.Process/M141Process_ImageCheck.cs
+++ b/src/Bro.M141.Process/M141Process_ImageCheck.cs
@@ -3,10 +3,12 @@
 using Bro.Common.Interface;
 using Bro.Common.Model;
 using Bro.M135.Common;
+using Bro.M135.DBManager;
 using HalconDotNet;
 using Microsoft.VisualBasic;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
+using NPOI.Util;
 using Sunny.UI;
 using System.Data;
 using System.Data.SqlTypes;
@@ -28,6 +30,9 @@
         Dictionary<string, List<double>> dicdate = new Dictionary<string, List<double>>();
         ManualResetEvent set1 = new ManualResetEvent(false);
         ManualResetEvent set2 = new ManualResetEvent(false);
+
+
+        public event Action<string> StartPrinter;
 
         [ProcessMethod("ImageCheck", "ImageCheckOperation", "閫氱敤鍥剧墖妫�娴嬫搷浣�", InvokeType.TestInvoke)]
         public ResponseMessage ImageCheckOperation(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
@@ -499,6 +504,27 @@
 
 
 
+        [ProcessMethod("printer", "printer", "鎵撳嵃鏈烘墦鍗�", InvokeType.TestInvoke)]
+        public ResponseMessage Printer(IOperationConfig config, IDevice invokeDevice, IDevice sourceDevice)
+        {
+            ResponseMessage msg = new ResponseMessage();
+
+            Plc2 = invokeDevice as PLCBase;
+            string message = "";
+            StartPrinter.Invoke(message);
+            return msg;
+        }
+
+
+        public void PlcwritePrinter(int add,int value)
+        {
+            Plc2.WriteSingleAddress(add,value,out _);
+        }
+
+
+
+
+
 
         protected List<ISpec> GetSpecListFromConfigSelection(List<SpecSelector> specSelectors)
         {
@@ -508,9 +534,10 @@
                 var spec = M141Config.SpecCollection.FirstOrDefault(s => s.Code == u.SpecCode);
                 if (spec != null)
                 {
-                    var temp = spec.Copy<Spec>();
+                    var temp = spec.Copy();
                     temp.ActualValue = null;
                     temp.MeasureResult = null;
+                    temp.Source = "";
                     specList.Add(temp);
                 }
             });
@@ -585,7 +612,7 @@
             resultList.ForEach(u => u.SetResult());
             var defects = resultList.GetDefectDescList();
 
-            var ngSpecCodes = p.Details.SelectMany(u => u.SpecList ?? new List<Spec>()).Where(u => u.MeasureResult != true).Select(u => u.Code);
+            var ngSpecCodes = p.Details.SelectMany(u => u.SpecList ?? new List<ISpec>()).Where(u => u.MeasureResult != true).Select(u => u.Code);
             var ngDefectDescList = p.Details.SelectMany(u => u.DefectList ?? new List<string>()).ToList();
 
             defects.AddRange(ngSpecCodes);
diff --git a/src/Bro.M141.Process/M141Process_Mysql.cs b/src/Bro.M141.Process/M141Process_Mysql.cs
index b9f00c8..632a3be 100644
--- a/src/Bro.M141.Process/M141Process_Mysql.cs
+++ b/src/Bro.M141.Process/M141Process_Mysql.cs
@@ -1,5 +1,6 @@
 锘縰sing Bro.Common.Helper;
 using Bro.Common.Interface;
+using Bro.Common.Model;
 using Bro.M135.Common;
 using MySql.Data.MySqlClient;
 using Newtonsoft.Json;
@@ -11,6 +12,7 @@
 using System.Text;
 using System.Threading.Tasks;
 using Windows.Globalization.PhoneNumberFormatting;
+using static Org.BouncyCastle.Math.EC.ECCurve;
 using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
 
 namespace Bro.M141.Process
@@ -29,7 +31,7 @@
             connStrAll = $"server={IP};port=3306;user id=root;password=123456;database=BroDB;charset=utf8";
         }
 
-        public void Operatoremysql(string sql, string connStr)//鎿嶄綔
+        public bool Operatoremysql(string sql, string connStr)//鎿嶄綔
         {
             MySqlConnection con = new MySqlConnection(connStr);
             try
@@ -41,12 +43,16 @@
                 con.Open();
                 MySqlCommand coon = new MySqlCommand(sql, con);
                 coon.ExecuteNonQuery();
+                con.Close();
             }
             catch (Exception e)
             {
-                CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴撴搷浣滃紓甯� {sql} {e.ToString()}");
+                con.Close();
+                return false;
+                //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴撴搷浣滃紓甯� {sql} {e.ToString()}");
             }
-            con.Close();
+            return true;
+
         }
 
         public DataTable selectdt(string str, string connStr)//鏌ヨ琛ㄦ牸
@@ -62,12 +68,14 @@
                 con.Open();
                 MySqlDataAdapter da = new MySqlDataAdapter(str, con);
                 da.Fill(dt);
+                con.Close();
             }
             catch (Exception e)
             {
-                CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴撴煡璇㈠紓甯� {str} {e.ToString()}");
+                //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴撴煡璇㈠紓甯� {str} {e.ToString()}");
+                con.Close();
+                return null;
             }
-            con.Close();
             return dt;
         }
 
@@ -89,9 +97,8 @@
             }
             catch (Exception e)
             {
-                CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴撴煡璇㈡暟鎹紓甯� {str}  {e.ToString()}");
+                //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴撴煡璇㈡暟鎹紓甯� {str}  {e.ToString()}");
             }
-
             con.Close();
             return strr;
         }
@@ -111,13 +118,22 @@
                 string str1 = "select id from forlocal  order by id desc limit 1";
                 string index = selectmysql(str1, connStrLocal);
 
-                string str2 = $"delete from forlocal where id < ({index}-1000)";
-                Operatoremysql(str2, connStrLocal);
+                if (!string.IsNullOrEmpty(index))
+                {
+                    string str2 = $"delete from forlocal where id < ({index}-1000)";
+                    Operatoremysql(str2, connStrLocal);
+                }
 
+                string mysqlstr = $"insert into forlocal (basketcode,pid,plcnum,sn,data,time) values('{pro.BasketCode}','{pro.PID}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All })}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')";
 
-                string mysqlstr = $"insert into forlocal (basketcode,pid,plcnum,sn,data,time) values('{pro.BasketCode}','{pro.PID}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro)}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')";
-
-                Operatoremysql(mysqlstr, connStrLocal);
+                if (Operatoremysql(mysqlstr, connStrLocal))
+                {
+                    CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鏁版嵁搴揻orlocal鎻掑叆鏁版嵁鎴愬姛");
+                }
+                else
+                {
+                    CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"鏁版嵁搴揻orlocal鎻掑叆鏁版嵁寮傚け璐�  {mysqlstr}");
+                }
             }
             catch (Exception e)
             {
@@ -129,8 +145,54 @@
         {
             try
             {
-                string mysqlstr = $"update forlocal set data='{JsonConvert.SerializeObject(pro)}' where plcnum='{pro.SEQUENCE}'";
-                Operatoremysql(mysqlstr, connStrLocal);
+                if (pro.Details!=null)
+                {
+                    foreach (var item in pro.Details)
+                    {
+                        if (item.ResultList!=null)
+                        {
+                            item.ResultList.ForEach(u =>
+                            {
+                                if (u.NetResults != null)
+                                {
+                                    u.NetResults.ForEach(x =>
+                                    {
+                                        if (x.DetectDetails != null)
+                                        {
+                                            var distinctItems = x.DetectDetails.GroupBy(i => new { i.ClassName, i.FinalResult }) // 鏍规嵁Id鍜孨ame鍘婚噸
+                             .Select(g => g.First()) // 閫夋嫨姣忎釜缁勭殑绗竴涓厓绱�
+                             .ToList();
+                                            x.DetectDetails = distinctItems;
+                                        }
+                                    });
+                                }
+                            });
+                        }
+                    }
+                }
+
+
+
+                JsonSerializerSettings settings = new JsonSerializerSettings
+                {
+                    TypeNameHandling = TypeNameHandling.All
+                };
+
+                string jsondata = JsonConvert.SerializeObject(pro, settings);
+
+
+                //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"{jsondata}");
+
+                string mysqlstr = $"update forlocal set data='{jsondata}' where plcnum='{pro.SEQUENCE}'";
+
+                if (Operatoremysql(mysqlstr, connStrLocal))
+                {
+                    CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鏁版嵁搴揻orlocal鏇存柊鏁版嵁鎴愬姛");
+                }
+                else
+                {
+                    CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"鏁版嵁搴揻orlocal鏇存柊鏁版嵁澶辫触 {mysqlstr}");
+                }
             }
             catch (Exception e)
             {
@@ -151,14 +213,24 @@
 
                     string str1 = "select id from forall  order by id desc limit 1";
                     string index = selectmysql(str1, connStrAll);
-
-                    string str2 = $"delete from forall where id < ({index}-1000)";
-                    Operatoremysql(str2, connStrAll);
+                    if (!string.IsNullOrEmpty(index))
+                    {
+                        string str2 = $"delete from forall where id < ({index}-1000)";
+                        Operatoremysql(str2, connStrAll);
+                    }
 
 
-                    string mysqlstr = $"insert into forall (basketcode,device,plcnum,sn,data,time) values('{pro.BasketCode}','{devicestr}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro)}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')";
+                    string mysqlstr = $"insert into forall (basketcode,device,plcnum,sn,data,time) values('{pro.BasketCode}','{devicestr}','{pro.SEQUENCE}','{pro.SN}','{JsonConvert.SerializeObject(pro, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All })}','{DateTime.Now.ToString("yyyyMMddHHmmss")}')";
 
-                    Operatoremysql(mysqlstr, connStrAll);
+                    if (Operatoremysql(mysqlstr, connStrAll))
+                    {
+                        CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Action, $"鏁版嵁搴揻orall鎻掑叆鏁版嵁鎴愬姛");
+                    }
+                    else
+                    {
+                        CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Error, $"鏁版嵁搴揻orall鎻掑叆鏁版嵁寮傚け璐�  {mysqlstr}");
+                    }
+
                 }
                 catch (Exception e)
                 {
@@ -179,13 +251,14 @@
                 }
                 else
                 {
-                    ProductModel p = JsonConvert.DeserializeObject<ProductModel>(str, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All });
+                    ProductModel p = null;
+                    p = JsonConvert.DeserializeObject<ProductModel>(str, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All });
                     return p;
                 }
             }
             catch (Exception e)
             {
-                CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴揻orlocal鏇存柊鏁版嵁寮傚父 {e.ToString()}");
+                CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴揻orlocal鑾峰彇瀵硅薄寮傚父 {e.ToString()}");
             }
             return null;
         }
@@ -203,7 +276,7 @@
             }
             catch (Exception e)
             {
-                CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴揻orlocal鏇存柊鏁版嵁寮傚父 {e.ToString()}");
+                //CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"鏁版嵁搴揻orlocal鑾峰彇寮傚父 {e.ToString()}");
             }
             return "NoRead";
         }
diff --git a/src/Bro.M141.Process/UI/UIPrinter.cs b/src/Bro.M141.Process/UI/UIPrinter.cs
index df1b2f1..df40e5c 100644
--- a/src/Bro.M141.Process/UI/UIPrinter.cs
+++ b/src/Bro.M141.Process/UI/UIPrinter.cs
@@ -38,7 +38,12 @@
         {
             base.OnProcessUpdated();
             printDocument1.PrintPage += new PrintPageEventHandler(printDocument_Print);
+
+            Process141.StartPrinter += StartPrint;
+            textBox1.Text = "Broconcentric";
         }
+
+
 
         PrintDocument printDocument1 = new PrintDocument();
         int ttwith = (int)(80 * 4);
@@ -47,15 +52,37 @@
 
         public void StartPrint(string str)
         {
-            ttwith = 320;
-            ttheigh = 160;
-            message = str;
+            try
+            {
+                ttwith = 320;
+                ttheigh = 160;
+                message = str;
 
-            this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)";
-            this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh);
+                if (string.IsNullOrEmpty(message))
+                {
+                    message = textBox1.Text;
+                }
 
-            this.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
-            this.printDocument1.Print();
+                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();
+
+            }
+            catch
+            {
+
+            }
+
+            int statuscode = GetPrinterStatusCodeInt();
+            string status = GetPrinterStatusMessage(statuscode);
+
+
+            //   Config141
+            Process141.PlcwritePrinter(1520, 0);
+
+            Process141.PlcwritePrinter(1510, 1);
 
         }
 
diff --git a/src/Bro.M141_AOI1.Process/AOI1Process.cs b/src/Bro.M141_AOI1.Process/AOI1Process.cs
index 78b73b9..3b6bd8b 100644
--- a/src/Bro.M141_AOI1.Process/AOI1Process.cs
+++ b/src/Bro.M141_AOI1.Process/AOI1Process.cs
@@ -34,7 +34,6 @@
         public override void Open()
         {
             base.Open();
-
         }
 
         [ProcessMethod("", "PositionCheck_P1", "宸ヤ綅1妫�娴�", InvokeType.TestInvoke)]

--
Gitblit v1.8.0