瀏覽代碼

优化只读取数据

callm 2 天之前
父節點
當前提交
8d9c54eca8
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      UAS_MES_YD/FunctionCode/Make/Make_ColorBoxWeigh.cs

+ 2 - 2
UAS_MES_YD/FunctionCode/Make/Make_ColorBoxWeigh.cs

@@ -41,7 +41,7 @@ namespace UAS_MES_NEW.Make
 
         DataTable Dbfind;
 
-        Regex re = new Regex("\\d+.\\w+");
+        Regex re = new Regex("\\d+.\\d+");
 
         string ErrorMessage;
 
@@ -262,11 +262,11 @@ namespace UAS_MES_NEW.Make
                                 Byte[] readBuffer = new Byte[len];
                                 serialPort1.Read(readBuffer, 0, len); //将数据读入缓存
                                 string weigh = Encoding.Default.GetString(readBuffer);
-                                Remark.AppendText(weigh + "\n");
                                 if (weigh != "")
                                 {
                                     weight.Text = re.Match(weigh).Value;
                                 }
+                                Remark.AppendText(weight.Text+"\n");
                             }
                             catch (Exception)
                             {