|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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<BoolAddEnum, string> boolAdds { get; set; } = new Dictionary<BoolAddEnum, string>();
- protected Dictionary<FloatAddEnum, string> floatAdds { get; set; } = new Dictionary<FloatAddEnum, string>();
- public ConcurrentDictionary<FeedbackData, object> Data { get; set; } = new ConcurrentDictionary<FeedbackData, object>();
-
- protected Dictionary<T, string> GetAdd<T>() where T : Enum
- {
- Dictionary<T, string> result = new Dictionary<T, string>();
- 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<AddAttribute>();
- if (attribute != null)
- {
- if (x.TryToEnum<T>(out T eu))
- {
- if (!result.ContainsKey(eu))
- {
- result.Add(eu, attribute.Add);
- }
- }
- }
- }
- });
- return result;
- }
-
- public AddData()
- {
- boolAdds = GetAdd<BoolAddEnum>();
- floatAdds = GetAdd<FloatAddEnum>();
- Enum.GetNames(typeof(FeedbackData)).ToList().ForEach(x => {
- if (x.TryToEnum(out FeedbackData fbd))
- {
- Data.TryAdd(fbd, 0);
- }
- });
- //AlarmHelper.GetInstance.AddNotify = (s) =>
- //{
- // App.Current.Dispatcher.Invoke(() =>
- // {
- // MessageNotify.GetInstance.ShowAlarmLog(s.Info);
- // });
- //};
- //AlarmHelper.GetInstance.Register<AlarmData>("50L反应釜");
- //AlarmHelper.GetInstance.Start();
- }
- }
- }
|