瀏覽代碼

更改温度过滤

陈子杰 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])