Explorar o código

称重单位控制

Hcsy %!s(int64=8) %!d(string=hai) anos
pai
achega
c942819ef3
Modificáronse 1 ficheiros con 6 adicións e 3 borrados
  1. 6 3
      UAS-MES/FunctionCode/Make/Make_CartonBoxWeigh.cs

+ 6 - 3
UAS-MES/FunctionCode/Make/Make_CartonBoxWeigh.cs

@@ -42,7 +42,8 @@ namespace UAS_MES.Make
         int MaxWeight;
         //最小重量
         int MinWeight;
-
+        //重量倍率
+        int Wetghtunit =1;
         DataTable ListC = new DataTable();
 
         Thread InitPrint;
@@ -116,15 +117,17 @@ namespace UAS_MES.Make
                     string _weight = dt.Rows[0]["pr_cartongw"].ToString();
                     string _maxweight = dt.Rows[0]["pr_cartonmaxw"].ToString();
                     string _minweight = dt.Rows[0]["pr_cartonminw"].ToString();
+                    string pa_pr_cartonunit = dt.Rows[0]["pr_cartonunit"].ToString();
                     Weight = int.Parse(_weight == "" ? "0" : _weight);
                     MaxWeight = int.Parse(_maxweight == "" ? "0" : _maxweight);
                     MinWeight = int.Parse(_minweight == "" ? "0" : _minweight);
                     pa_totalqty = int.Parse(dt.Rows[0]["pa_totalqty"].ToString());
+                    Wetghtunit = int.Parse(pa_pr_cartonunit == "kg" ?"1000":"1");
                     if (Weight - MinWeight == MaxWeight - Weight)
                         pr_cartongw.Text = Weight + "±" + (MaxWeight - Weight);
                     else
                         pr_cartongw.Text = MinWeight + "-" + MaxWeight;
-                    int ActualWeight = int.Parse(weight.Text == "" ? "0" : weight.Text);
+                    double ActualWeight = double.Parse(weight.Text == "" ? "0" : weight.Text);
                     //称量合格或不合格都记录重量
                     if (ActualWeight >= MinWeight && ActualWeight <= MaxWeight)
                     {
@@ -164,7 +167,7 @@ namespace UAS_MES.Make
                         {
                             try
                             {
-                                weight.Text = Regex.Replace(serialPort1.ReadLine(), "\\D+", "");
+                                weight.Text = Double.Parse(Regex.Replace(serialPort1.ReadLine(), "\\D+", ""))/ Wetghtunit+"";
                             }
                             catch (Exception)
                             {