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;
|
}
|
|
|
|
|
|
|
|
|
|
}
|
}
|