Browse Source

电子秤调试修改

callm 6 months ago
parent
commit
c3d6c6e388

+ 3 - 13
UAS_MES_HGS/FunctionCode/Make/Make_ColorBoxWeigh.cs

@@ -282,24 +282,14 @@ namespace UAS_MES_NEW.Make
                         {
                             try
                             {
-                                Thread.Sleep(100);
                                 int len = serialPort1.BytesToRead;
                                 Byte[] readBuffer = new Byte[len];
                                 serialPort1.Read(readBuffer, 0, len); //将数据读入缓存
                                 string weigh = Encoding.Default.GetString(readBuffer);
-                                if (weigh != "" && weigh.Length > 10)
+                                Remark.AppendText(weigh + "\n");
+                                if (weigh != "")
                                 {
-                                    int firstIndex = weigh.IndexOf("="); // 查找第一个"="的索引  
-                                    int secondIndex = weigh.IndexOf("=", firstIndex + 1); // 查找第二个"="的索引  
-                                    string result = weigh.Substring(firstIndex + 1, secondIndex - firstIndex - 1);// 提取第一个"="和第二个"="之间的字符
-                                    result = new string(result.ToCharArray().Reverse().ToArray());
-                                    int index = 0;
-                                    while (index < result.Length && result[index] == '0')
-                                    {
-                                        index++;
-                                    }
-                                    result = result.Substring(index);
-                                    weight.Text = result;
+                                    weight.Text = weigh;
                                 }
                             }
                             catch (Exception)

+ 3 - 14
UAS_MES_HGS/FunctionCode/SystemSetting/SystemSetting_ScaleTest.cs

@@ -78,25 +78,14 @@ namespace UAS_MES_NEW.SystemSetting
                         {
                             try
                             {
-                                Thread.Sleep(100);
                                 int len = serialPort1.BytesToRead;
                                 Byte[] readBuffer = new Byte[len];
                                 serialPort1.Read(readBuffer, 0, len); //将数据读入缓存
                                 string weigh = Encoding.Default.GetString(readBuffer);
-                                if (weigh != ""&& weigh.Length>10)
+                                Remark.AppendText(weigh + "\n");
+                                if (weigh != "")
                                 {
-                                    int firstIndex = weigh.IndexOf("="); // 查找第一个"="的索引  
-                                    int secondIndex = weigh.IndexOf("=", firstIndex + 1); // 查找第二个"="的索引  
-                                    string result = weigh.Substring(firstIndex + 1, secondIndex - firstIndex - 1);// 提取第一个"="和第二个"="之间的字符
-                                    result = new string(result.ToCharArray().Reverse().ToArray());
-                                    int index = 0;
-                                    while (index < result.Length && result[index] == '0')
-                                    {
-                                        index++;
-                                    }
-                                    result = result.Substring(index);
-                                    Remark.AppendText(result+"\n");
-                                    Weight.Text = result;
+                                    Weight.Text = weigh;
                                 }
                             }
                             catch (Exception)