ningshuxia
2023-04-13 13aeccc4305083d2d61274709a0066511fae42a1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.Model.Monitor 
{
    /// <summary>
    /// 过滤参数
    /// </summary>
    public class FilterParameters : JsonModel<FilterParameters>
    {
        /// <summary>
        /// 最大阀值
        /// </summary>
        public double? MaxThresholdValue { get; set; }
 
        /// <summary>
        /// 最小阀值
        /// </summary>
        public double? MinThresholdValue { get; set; }
 
        /// <summary>
        /// 突变阀值
        /// </summary>
        public double? MutThresholdValue { get; set; }
 
        /// <summary>
        /// 过滤
        /// </summary>
        public bool Filter(double value_current, double? value_pre)
        {
            if (MaxThresholdValue != null)
            {
                if (value_current > MaxThresholdValue.Value)
                {
                    return false;
                }
            }
            if (MinThresholdValue != null)
            {
                if (value_current < MinThresholdValue.Value)
                {
                    return false;
                }
            }
            if (value_pre != null)
            {
                if (MutThresholdValue != null)
                {
                    if (Math.Abs(value_current - value_pre.Value) > MutThresholdValue)
                    {
                        return false;
                    }
                }
            }
            return true;
        }
    }
}