终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

57 lines
2.1 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace BPASmartClient.Academy._50L
  8. {
  9. public class AddData
  10. {
  11. protected Dictionary<BoolAddEnum, string> boolAdds { get; set; } = new Dictionary<BoolAddEnum, string>();
  12. protected Dictionary<FloatAddEnum, string> floatAdds { get; set; } = new Dictionary<FloatAddEnum, string>();
  13. public ConcurrentDictionary<FeedbackData, object> Data { get; set; } = new ConcurrentDictionary<FeedbackData, object>();
  14. protected Dictionary<T, string> GetAdd<T>() where T : Enum
  15. {
  16. Dictionary<T, string> result = new Dictionary<T, string>();
  17. Type type = typeof(T);
  18. Enum.GetNames(typeof(T)).ToList().ForEach(x =>
  19. {
  20. MemberInfo[] memberInfo = type.GetMember(x);
  21. if (memberInfo != null && memberInfo.Length > 0)
  22. {
  23. var attribute = memberInfo[0].GetCustomAttribute<AddAttribute>();
  24. if (attribute != null)
  25. {
  26. if (x.TryToEnum<T>(out T eu))
  27. {
  28. if (!result.ContainsKey(eu))
  29. {
  30. result.Add(eu, attribute.Add);
  31. }
  32. }
  33. }
  34. }
  35. });
  36. return result;
  37. }
  38. public AddData()
  39. {
  40. boolAdds = GetAdd<BoolAddEnum>();
  41. floatAdds = GetAdd<FloatAddEnum>();
  42. Enum.GetNames(typeof(FeedbackData)).ToList().ForEach(x => {
  43. if (x.TryToEnum(out FeedbackData fbd))
  44. {
  45. Data.TryAdd(fbd, 0);
  46. }
  47. });
  48. AlarmHelper.GetInstance.AddNotify = (s) => { MessageNotify.GetInstance.ShowAlarmLog(s.Info); };
  49. AlarmHelper.GetInstance.Register<AlarmData>("50L反应釜");
  50. AlarmHelper.GetInstance.Start();
  51. }
  52. }
  53. }