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 { public class HimAlarmManager:BaseManager { private HmiChAlarm hmiChAlarm = new HmiChAlarm(); private HmiCqAlarm hmiCq = new HmiCqAlarm(); EsStop esStop=new EsStop(); private void SetCH_alarm(Dictionary dictionary,List 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 dictionary,List 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 dictionary,List 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 GetList() { Dictionary dictionary = cache[CacheKeyManager.AramlList] as Dictionary ?? new Dictionary(); List list = alarmDataService.GetList(); SetCH_alarm(dictionary,list); SetCQ_alarm(dictionary,list); SetEsStop(dictionary,list); cache.Set(CacheKeyManager.AramlList, dictionary, TimeSpan.FromMinutes(10)); return dictionary; } } }