浏览代码

彩盒称重,重量检测修改

Hcsy 8 年之前
父节点
当前提交
f83b9c7a74
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      UAS-MES/FunctionCode/Make/Make_ColorBoxWeigh.cs

+ 11 - 0
UAS-MES/FunctionCode/Make/Make_ColorBoxWeigh.cs

@@ -35,6 +35,7 @@ namespace UAS_MES.Make
         //是否通过串口获取数据
         bool GetData = true;
         string LastSncode;
+        bool WeightChange = false;
 
         string ErrorMessage;
 
@@ -121,6 +122,10 @@ namespace UAS_MES.Make
                                 }
                             }
                             //如果未打开串口设置为0
+                            if (pr_colorboxunit.Text == "kg" && !WeightChange)
+                            {
+                                weight.Text = (float.Parse(weight.Text) / 1000).ToString();
+                            }
                             double ActualWeight = double.Parse(weight.Text == "" ? "0" : weight.Text);
                             if ((ActualWeight >= MinWeight) && (ActualWeight <= MaxWeight))
                             {
@@ -173,7 +178,13 @@ namespace UAS_MES.Make
                             {
                                 weight.Text = Regex.Replace(serialPort1.ReadLine(), "\\D+", "");
                                 if (pr_colorboxunit.Text == "kg")
+                                {
                                     weight.Text = (float.Parse(weight.Text) / 1000).ToString();
+                                    WeightChange = true;
+                                }
+                                else {
+                                    WeightChange = false;
+                                }
                             }
                             catch (Exception)
                             {