Quellcode durchsuchen

睿德数据采集修改

callm vor 20 Stunden
Ursprung
Commit
ed093a263b
4 geänderte Dateien mit 58 neuen und 16 gelöschten Zeilen
  1. 14 14
      FileWatcher/AutoMakeQTY.cs
  2. 2 1
      FileWatcher/AutoSMTRXY.Designer.cs
  3. 41 0
      FileWatcher/AutoSMTRXY.cs
  4. 1 1
      FileWatcher/Program.cs

+ 14 - 14
FileWatcher/AutoMakeQTY.cs

@@ -150,20 +150,20 @@ namespace FileWatcher
                     lastqty = 0;
                 }
                 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");
-                }
+                //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");
+                //}
                 lastqty = qty;
             }
         }

+ 2 - 1
FileWatcher/AutoSMTRXY.Designer.cs

@@ -321,6 +321,7 @@
             // Timer
             // 
             this.Timer.Interval = 2000;
+            this.Timer.Tick += new System.EventHandler(this.Timer_Tick);
             // 
             // pr_pcbacount
             // 
@@ -377,7 +378,7 @@
             this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.MaximizeBox = false;
             this.Name = "AutoSMTRXY";
-            this.Text = "UAS设备数据解析 2023-06-29  10:05";
+            this.Text = "过站数据统计2026-03-18";
             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();

+ 41 - 0
FileWatcher/AutoSMTRXY.cs

@@ -305,6 +305,47 @@ namespace FileWatcher
             StopWatch.Enabled = false;
             OperateResult.AppendText("停止执行监控\n");
         }
+        bool realwritedata = false;
 
+        private void Timer_Tick(object sender, EventArgs e)
+        {
+            if (serialPort1.IsOpen)
+            {
+                if (!realwritedata)
+                {
+                    byte[] data = HexStringToBytes("01 03 00 01 00 06 94 08");
+                    serialPort1.Write(data, 0, data.Length);
+                }
+            }
+        }
+
+        private byte[] HexStringToBytes(string hs)//十六进制字符串转byte
+        {
+            string a = hs.Replace(" ", "");
+            int bytelength = 0;
+            if (a.Length % 2 == 0)
+            {
+                bytelength = a.Length / 2;
+            }
+            else
+            {
+                bytelength = a.Length / 2 + 1;
+            }
+            byte[] b = new byte[bytelength];
+            //逐个字符变为16进制字节数据
+            for (int i = 0; i < bytelength; i++)
+            {
+                if (i == bytelength - 1)
+                {
+                    b[i] = Convert.ToByte(a.Substring(i * 2), 16);
+                }
+                else
+                {
+                    b[i] = Convert.ToByte(a.Substring(i * 2, 2), 16);
+                }
+            }
+            //按照指定编码将字节数组变为字符串
+            return b;
+        }
     }
 }

+ 1 - 1
FileWatcher/Program.cs

@@ -48,7 +48,7 @@ namespace FileWatcher
                 {
                     //Application.Run(new UploadMakePlan());
                     //Application.Run(new AutoAnalysisXmlByStep());
-                    Application.Run(new AutoSMTRXY());
+                    Application.Run(new AutoMakeQTY());
                 }
                 else
                 {