using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace BPASmartClient.Academy._50L { public class AddData { protected Dictionary boolAdds { get; set; } = new Dictionary(); protected Dictionary floatAdds { get; set; } = new Dictionary(); public ConcurrentDictionary Data { get; set; } = new ConcurrentDictionary(); protected Dictionary GetAdd() where T : Enum { Dictionary result = new Dictionary(); Type type = typeof(T); Enum.GetNames(typeof(T)).ToList().ForEach(x => { MemberInfo[] memberInfo = type.GetMember(x); if (memberInfo != null && memberInfo.Length > 0) { var attribute = memberInfo[0].GetCustomAttribute(); if (attribute != null) { if (x.TryToEnum(out T eu)) { if (!result.ContainsKey(eu)) { result.Add(eu, attribute.Add); } } } } }); return result; } public AddData() { boolAdds = GetAdd(); floatAdds = GetAdd(); Enum.GetNames(typeof(FeedbackData)).ToList().ForEach(x => { if (x.TryToEnum(out FeedbackData fbd)) { Data.TryAdd(fbd, 0); } }); AlarmHelper.GetInstance.AddNotify = (s) => { MessageNotify.GetInstance.ShowAlarmLog(s.Info); }; AlarmHelper.GetInstance.Register("50L反应釜"); AlarmHelper.GetInstance.Start(); } } }