lixiaojun
2022-07-27 96887ec041ba8ddb170c75c1492fc210735ecb37
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace IStation.Server
{
    /// <summary>
    /// 报警中断分析辅助类
    /// </summary>
    public class AlarmInterruptAnalyHelper 
    {
        //缓存
        private static List<AlarmInterruptAnalyModel> _cache=new List<AlarmInterruptAnalyModel>();
 
        /// <summary>
        /// 验证是否报警
        /// </summary>
        public static bool IsAlarm(long corpId, long monitorPointId, long? signalId, DateTime? dataTime, double thresholdValue)
        {
            var dtNow = DateTime.Now;
            var model = _cache.Find(x=>x.CorpID==corpId&&x.MonitorPointID==monitorPointId&&x.SignalID==signalId);
            if (model == null)
            {
                model = new AlarmInterruptAnalyModel();
                model.CorpID = corpId;
                model.MonitorPointID = monitorPointId;
                model.SignalID = signalId;
                model.LastTime = dtNow;
                _cache.Add(model);
            }
            if (dataTime != null)
            {
                model.LastTime = dataTime.Value;
            }
 
            var lastTime = model.LastTime;
            if (dtNow <= lastTime)
                return false;
            var fValue = Math.Floor(Math.Abs(dtNow.Subtract(lastTime).TotalSeconds));
            return fValue > thresholdValue;
        }
 
 
 
 
 
 
 
 
 
    }
}