终端一体化运控平台
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

78 wiersze
3.5 KiB

  1. using FryPot_DosingSystem.Attributes;
  2. using BPA.Helper;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.Linq;
  7. using System.Reflection;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace FryPot_DosingSystem.Model
  11. {
  12. internal class FryPotInfoManage:NotifyBase
  13. {
  14. public static FryPotInfoManage GetInstance => _instance ?? (_instance = new FryPotInfoManage());
  15. private static FryPotInfoManage _instance;
  16. public int id { get; set; }
  17. public ObservableCollection<VariableMonitorModel> variableInfos { get; set; } = new ObservableCollection<VariableMonitorModel>();
  18. public FryPotInfoManage()
  19. {
  20. if (variableInfos.Count > 0)
  21. {
  22. variableInfos.Clear();
  23. }
  24. PropertyInfo[] pros = FryPotMonitorManage.GetInstance.fryOne.GetType().GetProperties();
  25. foreach (var item in pros)
  26. {
  27. var monitor = item.GetCustomAttribute<VariableAttribute>();
  28. if (monitor != null)
  29. {
  30. variableInfos.Add(new VariableMonitorModel { Id = id + 1, VarName = monitor.VarName, PLCAddress = monitor.PLCAddress, Notes = monitor.Notes, ModbusTcpAddress = monitor.ModbusTcpAddress });
  31. id++;
  32. }
  33. }
  34. PropertyInfo[] pros2 = FryPotMonitorManage.GetInstance.fryTwo.GetType().GetProperties();
  35. foreach (var item in pros2)
  36. {
  37. var monitor = item.GetCustomAttribute<VariableAttribute>();
  38. if (monitor != null)
  39. {
  40. variableInfos.Add(new VariableMonitorModel { Id = id + 1, VarName = monitor.VarName, PLCAddress = monitor.PLCAddress, Notes = monitor.Notes, ModbusTcpAddress = monitor.ModbusTcpAddress });
  41. id++;
  42. }
  43. }
  44. PropertyInfo[] pros3 = FryPotMonitorManage.GetInstance.fryThree.GetType().GetProperties();
  45. foreach (var item in pros3)
  46. {
  47. var monitor = item.GetCustomAttribute<VariableAttribute>();
  48. if (monitor != null)
  49. {
  50. variableInfos.Add(new VariableMonitorModel { Id = id + 1, VarName = monitor.VarName, PLCAddress = monitor.PLCAddress, Notes = monitor.Notes, ModbusTcpAddress = monitor.ModbusTcpAddress });
  51. id++;
  52. }
  53. }
  54. PropertyInfo[] pros4 = FryPotMonitorManage.GetInstance.fryFour.GetType().GetProperties();
  55. foreach (var item in pros4)
  56. {
  57. var monitor = item.GetCustomAttribute<VariableAttribute>();
  58. if (monitor != null)
  59. {
  60. variableInfos.Add(new VariableMonitorModel { Id = id + 1, VarName = monitor.VarName, PLCAddress = monitor.PLCAddress, Notes = monitor.Notes, ModbusTcpAddress = monitor.ModbusTcpAddress });
  61. id++;
  62. }
  63. }
  64. PropertyInfo[] pros5 = FryPotMonitorManage.GetInstance.fryFive.GetType().GetProperties();
  65. foreach (var item in pros5)
  66. {
  67. var monitor = item.GetCustomAttribute<VariableAttribute>();
  68. if (monitor != null)
  69. {
  70. variableInfos.Add(new VariableMonitorModel { Id = id + 1, VarName = monitor.VarName, PLCAddress = monitor.PLCAddress, Notes = monitor.Notes, ModbusTcpAddress = monitor.ModbusTcpAddress });
  71. id++;
  72. }
  73. }
  74. }
  75. }
  76. }