Browse Source

修改计数方式

callm 3 days ago
parent
commit
732fec8ed3
3 changed files with 231 additions and 122 deletions
  1. 0 4
      FileWatcher/AutoAnalysisXmlByStep.cs
  2. 122 76
      FileWatcher/AutoSMTRXY.Designer.cs
  3. 109 42
      FileWatcher/AutoSMTRXY.cs

+ 0 - 4
FileWatcher/AutoAnalysisXmlByStep.cs

@@ -7,11 +7,7 @@ using System.Threading;
 using System.Windows.Forms;
 using System.Xml;
 using System.Text;
-using System.Media;
 using System.Linq;
-using NPOI.SS.Formula.Functions;
-using System.Windows.Media.TextFormatting;
-using UMESDLLService;
 
 namespace FileWatcher
 {

+ 122 - 76
FileWatcher/AutoSMTRXY.Designer.cs

@@ -40,9 +40,6 @@
             this.label5 = new System.Windows.Forms.Label();
             this.label2 = new System.Windows.Forms.Label();
             this.RemindTimer = new System.Windows.Forms.Timer(this.components);
-            this.ms_sncode = new FileWatcher.EnterTextBox();
-            this.ma_code = new FileWatcher.SearchTextBox();
-            this.li_code = new FileWatcher.SearchTextBox();
             this.RemindVoice = new System.Windows.Forms.CheckBox();
             this.SN = new System.Windows.Forms.RadioButton();
             this.Counter = new System.Windows.Forms.RadioButton();
@@ -51,7 +48,6 @@
             this.BaudRate = new System.Windows.Forms.TextBox();
             this.label3 = new System.Windows.Forms.Label();
             this.label6 = new System.Windows.Forms.Label();
-            this.ComPort = new FileWatcher.SerialPortCombox();
             this.Timer = new System.Windows.Forms.Timer(this.components);
             this.pr_pcbacount = new System.Windows.Forms.NumericUpDown();
             this.label7 = new System.Windows.Forms.Label();
@@ -62,12 +58,19 @@
             this.ToZero = new System.Windows.Forms.TextBox();
             this.label10 = new System.Windows.Forms.Label();
             this.CleanData = new System.Windows.Forms.Button();
+            this.Setting = new System.Windows.Forms.Button();
+            this.label11 = new System.Windows.Forms.Label();
+            this.CountType = new System.Windows.Forms.ComboBox();
+            this.ComPort = new FileWatcher.SerialPortCombox();
+            this.ms_sncode = new FileWatcher.EnterTextBox();
+            this.ma_code = new FileWatcher.SearchTextBox();
+            this.li_code = new FileWatcher.SearchTextBox();
             ((System.ComponentModel.ISupportInitialize)(this.pr_pcbacount)).BeginInit();
             this.SuspendLayout();
             // 
             // OperateResult
             // 
-            this.OperateResult.Location = new System.Drawing.Point(920, 22);
+            this.OperateResult.Location = new System.Drawing.Point(1188, 23);
             this.OperateResult.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.OperateResult.Name = "OperateResult";
             this.OperateResult.Size = new System.Drawing.Size(489, 535);
@@ -77,7 +80,7 @@
             // Clean
             // 
             this.Clean.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Clean.Location = new System.Drawing.Point(1096, 580);
+            this.Clean.Location = new System.Drawing.Point(1380, 580);
             this.Clean.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.Clean.Name = "Clean";
             this.Clean.Size = new System.Drawing.Size(112, 48);
@@ -177,57 +180,6 @@
             this.RemindTimer.Interval = 5000;
             this.RemindTimer.Tick += new System.EventHandler(this.RemindTimer_Tick);
             // 
-            // ms_sncode
-            // 
-            this.ms_sncode.AllPower = null;
-            this.ms_sncode.BackColor = System.Drawing.Color.White;
-            this.ms_sncode.ID = null;
-            this.ms_sncode.Location = new System.Drawing.Point(221, 430);
-            this.ms_sncode.Name = "ms_sncode";
-            this.ms_sncode.Power = null;
-            this.ms_sncode.Size = new System.Drawing.Size(333, 35);
-            this.ms_sncode.Str = null;
-            this.ms_sncode.Str1 = null;
-            this.ms_sncode.Str2 = null;
-            this.ms_sncode.TabIndex = 33;
-            this.ms_sncode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ms_sncode_KeyDown);
-            // 
-            // ma_code
-            // 
-            this.ma_code.AllPower = null;
-            this.ma_code.Caller = null;
-            this.ma_code.Condition = null;
-            this.ma_code.DBTitle = null;
-            this.ma_code.FormName = null;
-            this.ma_code.Location = new System.Drawing.Point(221, 114);
-            this.ma_code.Name = "ma_code";
-            this.ma_code.Power = null;
-            this.ma_code.ReturnData = null;
-            this.ma_code.SelectField = null;
-            this.ma_code.SetValueField = null;
-            this.ma_code.Size = new System.Drawing.Size(436, 41);
-            this.ma_code.TabIndex = 29;
-            this.ma_code.TableName = null;
-            this.ma_code.TextBoxEnable = false;
-            // 
-            // li_code
-            // 
-            this.li_code.AllPower = null;
-            this.li_code.Caller = null;
-            this.li_code.Condition = null;
-            this.li_code.DBTitle = null;
-            this.li_code.FormName = null;
-            this.li_code.Location = new System.Drawing.Point(221, 191);
-            this.li_code.Name = "li_code";
-            this.li_code.Power = null;
-            this.li_code.ReturnData = null;
-            this.li_code.SelectField = null;
-            this.li_code.SetValueField = null;
-            this.li_code.Size = new System.Drawing.Size(436, 41);
-            this.li_code.TabIndex = 28;
-            this.li_code.TableName = null;
-            this.li_code.TextBoxEnable = false;
-            // 
             // RemindVoice
             // 
             this.RemindVoice.AutoSize = true;
@@ -289,7 +241,7 @@
             // 
             // BaudRate
             // 
-            this.BaudRate.Location = new System.Drawing.Point(550, 35);
+            this.BaudRate.Location = new System.Drawing.Point(990, 222);
             this.BaudRate.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.BaudRate.Name = "BaudRate";
             this.BaudRate.Size = new System.Drawing.Size(146, 35);
@@ -300,7 +252,7 @@
             // 
             this.label3.AutoSize = true;
             this.label3.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label3.Location = new System.Drawing.Point(426, 35);
+            this.label3.Location = new System.Drawing.Point(866, 222);
             this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(104, 38);
@@ -311,21 +263,13 @@
             // 
             this.label6.AutoSize = true;
             this.label6.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label6.Location = new System.Drawing.Point(48, 35);
+            this.label6.Location = new System.Drawing.Point(895, 170);
             this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(75, 38);
             this.label6.TabIndex = 41;
             this.label6.Text = "串口";
             // 
-            // ComPort
-            // 
-            this.ComPort.Location = new System.Drawing.Point(218, 35);
-            this.ComPort.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
-            this.ComPort.Name = "ComPort";
-            this.ComPort.Size = new System.Drawing.Size(176, 40);
-            this.ComPort.TabIndex = 40;
-            // 
             // Timer
             // 
             this.Timer.Interval = 2000;
@@ -356,7 +300,7 @@
             // 
             // Read
             // 
-            this.Read.Location = new System.Drawing.Point(749, 267);
+            this.Read.Location = new System.Drawing.Point(988, 279);
             this.Read.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.Read.Name = "Read";
             this.Read.Size = new System.Drawing.Size(146, 35);
@@ -366,7 +310,7 @@
             // 
             this.label8.AutoSize = true;
             this.label8.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label8.Location = new System.Drawing.Point(666, 261);
+            this.label8.Location = new System.Drawing.Point(905, 273);
             this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label8.Name = "label8";
             this.label8.Size = new System.Drawing.Size(75, 38);
@@ -375,7 +319,7 @@
             // 
             // Write
             // 
-            this.Write.Location = new System.Drawing.Point(749, 319);
+            this.Write.Location = new System.Drawing.Point(988, 331);
             this.Write.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.Write.Name = "Write";
             this.Write.Size = new System.Drawing.Size(146, 35);
@@ -385,7 +329,7 @@
             // 
             this.label9.AutoSize = true;
             this.label9.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label9.Location = new System.Drawing.Point(666, 316);
+            this.label9.Location = new System.Drawing.Point(905, 328);
             this.label9.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label9.Name = "label9";
             this.label9.Size = new System.Drawing.Size(75, 38);
@@ -394,7 +338,7 @@
             // 
             // ToZero
             // 
-            this.ToZero.Location = new System.Drawing.Point(749, 375);
+            this.ToZero.Location = new System.Drawing.Point(988, 387);
             this.ToZero.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.ToZero.Name = "ToZero";
             this.ToZero.Size = new System.Drawing.Size(146, 35);
@@ -404,7 +348,7 @@
             // 
             this.label10.AutoSize = true;
             this.label10.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label10.Location = new System.Drawing.Point(666, 372);
+            this.label10.Location = new System.Drawing.Point(905, 384);
             this.label10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label10.Name = "label10";
             this.label10.Size = new System.Drawing.Size(75, 38);
@@ -424,11 +368,108 @@
             this.CleanData.UseVisualStyleBackColor = true;
             this.CleanData.Click += new System.EventHandler(this.CleanData_Click);
             // 
+            // Setting
+            // 
+            this.Setting.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.Setting.Location = new System.Drawing.Point(961, 83);
+            this.Setting.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.Setting.Name = "Setting";
+            this.Setting.Size = new System.Drawing.Size(128, 56);
+            this.Setting.TabIndex = 53;
+            this.Setting.Text = "设置参数";
+            this.Setting.UseVisualStyleBackColor = true;
+            this.Setting.Click += new System.EventHandler(this.Setting_Click);
+            // 
+            // label11
+            // 
+            this.label11.AutoSize = true;
+            this.label11.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label11.Location = new System.Drawing.Point(850, 439);
+            this.label11.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label11.Name = "label11";
+            this.label11.Size = new System.Drawing.Size(133, 38);
+            this.label11.TabIndex = 55;
+            this.label11.Text = "计数方式";
+            // 
+            // CountType
+            // 
+            this.CountType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.CountType.FormattingEnabled = true;
+            this.CountType.Items.AddRange(new object[] {
+            "PLC",
+            "计数器"});
+            this.CountType.Location = new System.Drawing.Point(990, 445);
+            this.CountType.Name = "CountType";
+            this.CountType.Size = new System.Drawing.Size(137, 32);
+            this.CountType.TabIndex = 54;
+            // 
+            // ComPort
+            // 
+            this.ComPort.Location = new System.Drawing.Point(988, 174);
+            this.ComPort.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.ComPort.Name = "ComPort";
+            this.ComPort.Size = new System.Drawing.Size(148, 40);
+            this.ComPort.TabIndex = 40;
+            // 
+            // ms_sncode
+            // 
+            this.ms_sncode.AllPower = null;
+            this.ms_sncode.BackColor = System.Drawing.Color.White;
+            this.ms_sncode.ID = null;
+            this.ms_sncode.Location = new System.Drawing.Point(221, 430);
+            this.ms_sncode.Name = "ms_sncode";
+            this.ms_sncode.Power = null;
+            this.ms_sncode.Size = new System.Drawing.Size(333, 35);
+            this.ms_sncode.Str = null;
+            this.ms_sncode.Str1 = null;
+            this.ms_sncode.Str2 = null;
+            this.ms_sncode.TabIndex = 33;
+            this.ms_sncode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ms_sncode_KeyDown);
+            // 
+            // ma_code
+            // 
+            this.ma_code.AllPower = null;
+            this.ma_code.Caller = null;
+            this.ma_code.Condition = null;
+            this.ma_code.DBTitle = null;
+            this.ma_code.FormName = null;
+            this.ma_code.Location = new System.Drawing.Point(221, 114);
+            this.ma_code.Name = "ma_code";
+            this.ma_code.Power = null;
+            this.ma_code.ReturnData = null;
+            this.ma_code.SelectField = null;
+            this.ma_code.SetValueField = null;
+            this.ma_code.Size = new System.Drawing.Size(436, 41);
+            this.ma_code.TabIndex = 29;
+            this.ma_code.TableName = null;
+            this.ma_code.TextBoxEnable = false;
+            // 
+            // li_code
+            // 
+            this.li_code.AllPower = null;
+            this.li_code.Caller = null;
+            this.li_code.Condition = null;
+            this.li_code.DBTitle = null;
+            this.li_code.FormName = null;
+            this.li_code.Location = new System.Drawing.Point(221, 191);
+            this.li_code.Name = "li_code";
+            this.li_code.Power = null;
+            this.li_code.ReturnData = null;
+            this.li_code.SelectField = null;
+            this.li_code.SetValueField = null;
+            this.li_code.Size = new System.Drawing.Size(436, 41);
+            this.li_code.TabIndex = 28;
+            this.li_code.TableName = null;
+            this.li_code.TextBoxEnable = false;
+            // 
             // AutoSMTRXY
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(1443, 640);
+            this.ClientSize = new System.Drawing.Size(1710, 640);
+            this.Controls.Add(this.label11);
+            this.Controls.Add(this.CountType);
+            this.Controls.Add(this.Setting);
             this.Controls.Add(this.CleanData);
             this.Controls.Add(this.ToZero);
             this.Controls.Add(this.label10);
@@ -463,7 +504,9 @@
             this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.MaximizeBox = false;
             this.Name = "AutoSMTRXY";
-            this.Text = "过站数据统计2026-03-18";
+            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+            this.Text = "过站数据统计2026-08-19";
             this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
             this.Load += new System.EventHandler(this.Form1_Load);
             ((System.ComponentModel.ISupportInitialize)(this.pr_pcbacount)).EndInit();
@@ -506,6 +549,9 @@
         private System.Windows.Forms.TextBox ToZero;
         private System.Windows.Forms.Label label10;
         private System.Windows.Forms.Button CleanData;
+        private System.Windows.Forms.Button Setting;
+        private System.Windows.Forms.Label label11;
+        private System.Windows.Forms.ComboBox CountType;
     }
 }
 

+ 109 - 42
FileWatcher/AutoSMTRXY.cs

@@ -9,6 +9,7 @@ using System.Net;
 using System.Net.Sockets;
 using System.IO.Ports;
 using HslCommunication;
+using System.Diagnostics.PerformanceData;
 
 namespace FileWatcher
 {
@@ -64,6 +65,7 @@ namespace FileWatcher
 
         private void Form1_Load(object sender, EventArgs e)
         {
+            CountType.Text = "PLC";
             CheckForIllegalCrossThreadCalls = false;
             FormBorderStyle = FormBorderStyle.FixedSingle;
             InitDB = new Thread(ConnectDB);
@@ -82,14 +84,19 @@ namespace FileWatcher
             //获取缓存信息
             try
             {
+                ComPort.Text= BaseUtil.GetCacheData("ComPort").ToString();
                 Type.Text = BaseUtil.GetCacheData("Type").ToString();
                 li_code.Text = BaseUtil.GetCacheData("Line").ToString();
                 Read.Text = BaseUtil.GetCacheData("Read").ToString();
                 Write.Text = BaseUtil.GetCacheData("Write").ToString();
                 ToZero.Text = BaseUtil.GetCacheData("ToZero").ToString();
+                CountType.Text= BaseUtil.GetCacheData("CountType").ToString();
             }
-            catch (Exception ex) { MessageBox.Show(ex.Message); }
+            catch (Exception ex) { OperateResult.AppendText(ex.Message); }
             RemindTimer.Start();
+            this.WindowState = FormWindowState.Normal;
+            this.Size = new System.Drawing.Size(900, 400); // 替换为你需要的尺寸
+            this.CenterToScreen();
         }
 
         double lastqty = 0;
@@ -228,16 +235,29 @@ namespace FileWatcher
                 if (!dh.CheckExist("make", "ma_code='" + ma_code.Text + "'"))
                 {
                     OperateResult.AppendText("工单号不存在\n");
+                    OperateResult.ScrollToCaret();
                     return;
                 }
                 if (!dh.CheckExist("line", "li_code='" + li_code.Text + "'"))
                 {
                     OperateResult.AppendText("线别不存在\n");
+                    OperateResult.ScrollToCaret();
                     return;
                 }
                 string error = "";
                 if (SN.Checked)
                 {
+                    OperateResult write = plc.Write(Write.Text, 1);
+                    if (write.IsSuccess)
+                    {
+                        OperateResult.AppendText("通过,发送指令" + Write.Text + "写入1\n");
+                        OperateResult.ScrollToCaret();
+                    }
+                    else
+                    {
+                        OperateResult.AppendText("写入失败\n");
+                        OperateResult.ScrollToCaret();
+                    }
                     System.Data.DataTable dt = (System.Data.DataTable)dh.ExecuteSql("select MSL_MAINSN from makesnlist where msl_sncode='" + ms_sncode.Text + "'", "select");
                     if (dt.Rows.Count > 0)
                     {
@@ -245,12 +265,17 @@ namespace FileWatcher
                         if (LogicHandler.CS_SetResultRXY(ma_code.Text, li_code.Text, MainSN, "0", li_code.Text, "OK", out error))
                         {
                             OperateResult.AppendText("SN:" + MainSN + "采集成功\n");
+                            OperateResult. ScrollToCaret();
+                            ms_sncode.Clear();
                         }
                         else
                         {
                             OperateResult.AppendText(error + "\n");
+                            OperateResult.ScrollToCaret();
+                            ms_sncode.Clear();
                         }
                     }
+                    ms_sncode.Clear();
                 }
             }
         }
@@ -268,11 +293,28 @@ namespace FileWatcher
             BaseUtil.SetCacheData("Read", Read.Text);
             BaseUtil.SetCacheData("Write", Write.Text);
             BaseUtil.SetCacheData("ToZero", ToZero.Text);
+            BaseUtil.SetCacheData("Type", Type.Text);
+            BaseUtil.SetCacheData("CountType", CountType.Text);
             if (!dh.CheckExist("Make", "ma_code='" + ma_code.Text + "'"))
             {
                 OperateResult.AppendText("工单号不能为空\n");
                 return;
             }
+            if (CountType.Text == "")
+            {
+                OperateResult.AppendText("请选择计数类型\n");
+                return;
+            }
+            if (ComPort.Text == "")
+            {
+                OperateResult.AppendText("请选择串口\n");
+                return;
+            }
+            if (Type.Text == "")
+            {
+                OperateResult.AppendText("请选择投入产出类型\n");
+                return;
+            }
             if (!dh.CheckExist("line", "li_code='" + li_code.Text + "'"))
             {
                 OperateResult.AppendText("线别不能为空\n");
@@ -290,15 +332,24 @@ namespace FileWatcher
             StopWatch.Enabled = true;
             try
             {
-                plc = new HslCommunication.Profinet.Panasonic.PanasonicMewtocol();
-                plc.Station = 238;
-                HslCommunication.Core.Pipe.PipeSerialPort pipe = new HslCommunication.Core.Pipe.PipeSerialPort();
-                pipe.SerialPortInni(ComPort.Text, 9600, 8, StopBits.One, Parity.Odd);
-                pipe.RtsEnable = false;
-                pipe.DtrEnable = false;
-                pipe.SleepTime = 20;
-                pipe.ReceiveTimeOut = 5000;
-                plc.CommunicationPipe = pipe;
+                if (CountType.Text == "PLC")
+                {
+                    plc = new HslCommunication.Profinet.Panasonic.PanasonicMewtocol();
+                    plc.Station = 238;
+                    HslCommunication.Core.Pipe.PipeSerialPort pipe = new HslCommunication.Core.Pipe.PipeSerialPort();
+                    pipe.SerialPortInni(ComPort.Text, 9600, 8, StopBits.One, Parity.Odd);
+                    pipe.RtsEnable = false;
+                    pipe.DtrEnable = false;
+                    pipe.SleepTime = 20;
+                    pipe.ReceiveTimeOut = 5000;
+                    plc.CommunicationPipe = pipe;
+                }
+                else
+                {
+                    serialPort1.PortName = ComPort.Text;
+                    serialPort1.BaudRate = int.Parse(BaudRate.Text);
+                    serialPort1.Open();
+                }
                 Timer.Start();
             }
             catch (Exception mes)
@@ -323,51 +374,62 @@ namespace FileWatcher
 
         private void Timer_Tick(object sender, EventArgs e)
         {
-            string error = "";
-            OperateResult<short> read = plc.ReadInt16(Read.Text);
-            if (read.IsSuccess)
+            if (CountType.Text == "PLC")
             {
-                if (read.Content != 0)
+                string error = "";
+                OperateResult<short> read = plc.ReadInt16(Read.Text);
+                //OperateResult.AppendText("读取数据\n");
+                if (read.IsSuccess)
                 {
-                    double qty = Convert.ToInt32(read.Content);
-                    if (lastqty > qty)
+                    if (read.Content != 0)
                     {
-                        lastqty = 0;
-                    }
-                    else
-                    {
-                        OperateResult write = plc.Write(Write.Text, 1);
-                        if (write.IsSuccess)
+                        double qty = Convert.ToInt32(read.Content);
+                        if (lastqty > qty)
                         {
-                            OperateResult.AppendText("通过,发送指令D50写入1\n");
+                            lastqty = 0;
                         }
                         else
                         {
-                            OperateResult.AppendText("写入失败\n");
+                            if (qty - lastqty > 0)
+                            {
+                                OperateResult write = plc.Write(Write.Text, 1);
+                                if (write.IsSuccess)
+                                {
+                                    OperateResult.AppendText("通过,发送指令" + Write.Text + "写入1\n");
+                                }
+                                else
+                                {
+                                    OperateResult.AppendText("写入失败\n");
+                                }
+                            }
                         }
+                        NowQTY.Text = qty.ToString();
+                        if (Type.Text == "投入")
+                        {
+                            string ma_inqty = dh.getFieldDataByCondition("make", "nvl(ma_inqty,0)", "ma_code='" + ma_code.Text + "'").ToString();
+                            dh.ExecuteSql("update make set ma_inqty=nvl(ma_inqty,0)+'" + (qty - lastqty) + "' where ma_code='" + ma_code.Text + "' ", "update");
+                            dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount)" +
+                                "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "')", "insert");
+                        }
+                        else
+                        {
+                            string ma_endqty = dh.getFieldDataByCondition("make", "nvl(ma_endqty,0)", "ma_code='" + ma_code.Text + "'").ToString();
+                            dh.ExecuteSql("update make set ma_endqty=nvl(ma_endqty,0)+'" + (qty - lastqty) + "' where ma_code='" + ma_code.Text + "' ", "update");
+                            dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount)" +
+                                     "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "')", "insert");
+                        }
+                        LogicHandler.CS_SetResultRXY(ma_code.Text, li_code.Text, "", qty.ToString(), li_code.Text, "OK", out error);
+                        lastqty = qty;
                     }
-                    NowQTY.Text = qty.ToString();
-                    if (Type.Text == "投入")
-                    {
-                        string ma_inqty = dh.getFieldDataByCondition("make", "nvl(ma_inqty,0)", "ma_code='" + ma_code.Text + "'").ToString();
-                        dh.ExecuteSql("update make set ma_inqty=nvl(ma_inqty,0)+'" + (qty - lastqty) + "' where ma_code='" + ma_code.Text + "' ", "update");
-                        dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount)" +
-                            "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "')", "insert");
-                    }
-                    else
-                    {
-                        string ma_endqty = dh.getFieldDataByCondition("make", "nvl(ma_endqty,0)", "ma_code='" + ma_code.Text + "'").ToString();
-                        dh.ExecuteSql("update make set ma_endqty=nvl(ma_endqty,0)+'" + (qty - lastqty) + "' where ma_code='" + ma_code.Text + "' ", "update");
-                        dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount)" +
-                                 "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "')", "insert");
-                    }
-                    LogicHandler.CS_SetResultRXY(ma_code.Text, li_code.Text, "", qty.ToString(), li_code.Text, "OK", out error);
-                    lastqty = qty;
+                }
+                else
+                {
+                    OperateResult.AppendText("Read [D60] failed: " + read.Message);
                 }
             }
             else
             {
-                MessageBox.Show("Read [D60] failed: " + read.Message);
+
             }
         }
 
@@ -408,5 +470,10 @@ namespace FileWatcher
                 plc.Write(ToZero.Text, 1);
             }
         }
+
+        private void Setting_Click(object sender, EventArgs e)
+        {
+
+        }
     }
 }