ソースを参照

更改温度过滤

陈子杰 2 ヶ月 前
コミット
b918515f70
1 ファイル変更23 行追加2 行削除
  1. 23 2
      SCADA_DAQ/Customer/Service/CustomerService.cs

+ 23 - 2
SCADA_DAQ/Customer/Service/CustomerService.cs

@@ -58,6 +58,8 @@ namespace SCADA_DAQ.Customer.Service
 
         public bool[] Result = new bool[8];
 
+        private int OutOfRangeCount = 0;
+
 
 
         /// <summary>
@@ -132,11 +134,30 @@ namespace SCADA_DAQ.Customer.Service
                     var currentTemp = TempTransfer(data.temperature[i].TcTempString, out Result[i]) * (double)gain.Gain + (double)gain.Offset;
                     if (FirstScan)
                     {
-                        Temps[i] = Math.Abs( currentTemp - OldTemps[i]) / 5 < CustomerEnv.TempSettingModelValue.Rate ? currentTemp : OldTemps[i];
+                        if (Math.Abs(currentTemp - OldTemps[i]) / 5 < CustomerEnv.TempSettingModelValue.Rate)
+                        {
+                            Temps[i] = currentTemp;
+                        }
+                        else
+                        {
+                            OutOfRangeCount++;
+                            if (OutOfRangeCount > 2)
+                            {
+                                Temps[i] = currentTemp;
+                                OutOfRangeCount = 0;
+                            }
+                            else
+                            {
+                                Temps[i] = OldTemps[i];
+
+                            }
+
+                        }
                     }
                     else
                     {
-                        Temps[i] = currentTemp;                 
+                        Temps[i] = currentTemp;
+                        
                     }
                     OldTemps[i] = Temps[i];
                     if (Result[i])