Browse Source

红外计数器

callm 9 months ago
parent
commit
7374718251
2 changed files with 33 additions and 3 deletions
  1. 25 0
      FileWatcher/AutoMakeQTY.Designer.cs
  2. 8 3
      FileWatcher/AutoMakeQTY.cs

+ 25 - 0
FileWatcher/AutoMakeQTY.Designer.cs

@@ -46,6 +46,8 @@
             this.label3 = new System.Windows.Forms.Label();
             this.BaudRate = new System.Windows.Forms.TextBox();
             this.ComPort = new FileWatcher.SerialPortCombox();
+            this.NowQTY = new System.Windows.Forms.TextBox();
+            this.label4 = new System.Windows.Forms.Label();
             ((System.ComponentModel.ISupportInitialize)(this.XmlWatcher)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.ATEFile)).BeginInit();
             this.SuspendLayout();
@@ -206,11 +208,32 @@
             this.ComPort.Size = new System.Drawing.Size(176, 40);
             this.ComPort.TabIndex = 21;
             // 
+            // NowQTY
+            // 
+            this.NowQTY.Location = new System.Drawing.Point(204, 409);
+            this.NowQTY.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.NowQTY.Name = "NowQTY";
+            this.NowQTY.Size = new System.Drawing.Size(146, 35);
+            this.NowQTY.TabIndex = 26;
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label4.Location = new System.Drawing.Point(34, 406);
+            this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(133, 38);
+            this.label4.TabIndex = 25;
+            this.label4.Text = "当前计数";
+            // 
             // AutoMakeQTY
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1443, 640);
+            this.Controls.Add(this.NowQTY);
+            this.Controls.Add(this.label4);
             this.Controls.Add(this.BaudRate);
             this.Controls.Add(this.label3);
             this.Controls.Add(this.label2);
@@ -256,6 +279,8 @@
         private System.Windows.Forms.Label label2;
         private System.Windows.Forms.Label label3;
         private System.Windows.Forms.TextBox BaudRate;
+        private System.Windows.Forms.TextBox NowQTY;
+        private System.Windows.Forms.Label label4;
     }
 }
 

+ 8 - 3
FileWatcher/AutoMakeQTY.cs

@@ -117,7 +117,14 @@ namespace FileWatcher
             int len = serialPort1.BytesToRead;
             Byte[] readBuffer = new Byte[len];
             serialPort1.Read(readBuffer, 0, len); //将数据读入缓存
-            OperateResult.AppendText(BitConverter.ToString(readBuffer, 0, readBuffer.Length).Replace("-", " "));
+            string data = BitConverter.ToString(readBuffer, 0, readBuffer.Length).Replace("-", "");
+            double Num1 = double.Parse(data.Substring(8, 2)) * 10000;
+            double Num2 = double.Parse(data.Substring(10, 2)) * 1000;
+            double Num3 = double.Parse(data.Substring(12, 2)) * 100;
+            double Num4 = double.Parse(data.Substring(14, 2)) * 10;
+            double Num5 = double.Parse(data.Substring(16, 2));
+            double qty = Num1 + Num2 + Num3 + Num4 + Num5;
+            Console.WriteLine(qty);
         }
 
         private void ConnectDB()
@@ -133,8 +140,6 @@ namespace FileWatcher
             BaseUtil.SetCacheData("Type", Type.Text);
             BaseUtil.SetCacheData("ComPort", ComPort.Text);
             BaseUtil.SetCacheData("BaudRate", BaudRate.Text);
-            Timer.Interval = 1000 * 60;
-            Timer.Start();
             //设置按钮不可点击
             StartWatch.Enabled = false;
             ma_code.Enabled = false;