You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/RfidWeb/Tool/HimAlarmManager.cs

183 lines
6.0 KiB
C#

2 weeks ago
using System;
using System.Collections.Generic;
using System.Linq;
using DB.Entity;
using DB.Service;
using NewLife.Caching;
using NewLife.Reflection;
using Tool.Model;
namespace RfidWeb
2 weeks ago
{
2 weeks ago
public class HimAlarmManager:BaseManager
2 weeks ago
{
private HmiChAlarm hmiChAlarm = new HmiChAlarm();
private HmiCqAlarm hmiCq = new HmiCqAlarm();
EsStop esStop=new EsStop();
2 weeks ago
2 weeks ago
private void SetCH_alarm(Dictionary<string, DateTime> dictionary,List<AlarmData> list)
{
var a = hmiChAlarm.GetPlcDb();
cache.Set(CacheKeyManager.CH_alarm, a,timeOut);
var dicCha = GetDic(list, "A", "CH_alarm");
for (int i = 0; i < Max; i++)
{
var obj = a.GetValue("A" + i);
if (obj != null)
{
if (dicCha.TryGetValue(i, out var value))
{
if (Convert.ToBoolean(obj))
{
if (!dictionary.ContainsKey(value))
{
dictionary[value] = DateTime.Now;
}
}
else
{
dictionary.Remove(value);
}
}
}
}
var dicChb = GetDic(list, "B", "CH_alarm");
for (int i = 0; i < Max; i++)
{
var obj = a.GetValue("B" + i);
if (obj != null)
{
if (dicChb.TryGetValue(i, out var value))
{
if (Convert.ToBoolean(obj))
{
if (!dictionary.ContainsKey(value))
{
dictionary[value] = DateTime.Now;
}
}
else
{
dictionary.Remove(value);
}
}
}
}
}
private void SetCQ_alarm(Dictionary<string, DateTime> dictionary,List<AlarmData> list)
{
var a = hmiCq.GetPlcDb();
cache.Set(CacheKeyManager.CQ_alarm, a,timeOut);
var dicCqA = GetDic(list, "A", "CQ_alarm");
for (int i = 0; i < Max; i++)
{
var obj = a.GetValue("A" + i);
if (obj != null)
{
if (dicCqA.TryGetValue(i, out var value))
{
if (Convert.ToBoolean(obj))
{
if (!dictionary.ContainsKey(value))
{
dictionary[value] = DateTime.Now;
}
}
else
{
dictionary.Remove(value);
}
}
}
}
var dicCqB =GetDic(list, "B", "CQ_alarm");
for (int i = 0; i < Max; i++)
{
var obj = a.GetValue("B" + i);
if (obj != null)
{
if (dicCqB.TryGetValue(i, out var value))
{
if (Convert.ToBoolean(obj))
{
if (!dictionary.ContainsKey(value))
{
dictionary[value] = DateTime.Now;
}
}
else
{
dictionary.Remove(value);
}
}
}
}
}
private void SetEsStop(Dictionary<string, DateTime> dictionary,List<AlarmData> list)
{
var listEs= GetDic(list, "", "estop_temporary_storage");
var bools = esStop.GetDb();
//全局的异常
cache.Set(CacheKeyManager.estop_temporary_storage, bools,timeOut);
for (int i = 0; i < Max; i++)
{
var obj = bools[i];
if (!listEs.TryGetValue(i, out var value)) continue;
if (Convert.ToBoolean(obj))
{
if (!dictionary.ContainsKey(value))
{
dictionary[value] = DateTime.Now;
}
}
else
{
dictionary.Remove(value);
}
}
}
public Dictionary<string, DateTime> GetList()
{
Dictionary<string, DateTime> dictionary = cache[CacheKeyManager.AramlList] as Dictionary<string, DateTime>
?? new Dictionary<string, DateTime>();
List<AlarmData> list = alarmDataService.GetList();
SetCH_alarm(dictionary,list);
SetCQ_alarm(dictionary,list);
SetEsStop(dictionary,list);
cache.Set(CacheKeyManager.AramlList, dictionary, TimeSpan.FromMinutes(10));
return dictionary;
}
}
2 weeks ago
2 weeks ago
}