终端一体化运控平台
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

AddData.cs 2.2 KiB

1 ay önce
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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) =>
  49. //{
  50. // App.Current.Dispatcher.Invoke(() =>
  51. // {
  52. // MessageNotify.GetInstance.ShowAlarmLog(s.Info);
  53. // });
  54. //};
  55. //AlarmHelper.GetInstance.Register<AlarmData>("50L反应釜");
  56. //AlarmHelper.GetInstance.Start();
  57. }
  58. }
  59. }