LightControllerConfig.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using Prism.Mvvm;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using TeamAAS_VP.Core.Lights;
  9. using TeamAAS_VP.Enums;
  10. namespace TeamAAS_VP.Models.Lights
  11. {
  12. public class LightControllerConfig: BindableBase
  13. {
  14. private int _Id;
  15. public int Id
  16. {
  17. get { return _Id; }
  18. set { SetProperty(ref _Id, value); }
  19. }
  20. private string _Name;
  21. public string Name
  22. {
  23. get { return _Name; }
  24. set { SetProperty(ref _Name, value); }
  25. }
  26. private int _ChannelCount;
  27. public int ChannelCount
  28. {
  29. get { return _ChannelCount; }
  30. set { SetProperty(ref _ChannelCount, value); }
  31. }
  32. private LightModel _LightModel;
  33. public LightModel LightModel
  34. {
  35. get { return _LightModel; }
  36. set { SetProperty(ref _LightModel, value);
  37. switch (value)
  38. {
  39. case LightModel.KCS_KDC_12V60W_4T:
  40. ChannelCount=4;
  41. TcpConfig = null;
  42. if (SerialPortConfig==null)
  43. {
  44. SerialPortConfig = new SerialPortConfig();
  45. }
  46. ChannelConfigs = new ObservableCollection<ChannelConfig>();
  47. for (int i = 0; i < ChannelCount; i++)
  48. {
  49. ChannelConfigs.Add(new ChannelConfig()
  50. {
  51. LocalIndex = i,
  52. GlobalIndex = i,
  53. Name = $"Channel {i + 1}",
  54. Description = $"Description for Channel {i + 1}",
  55. DefaultBrightness = 100
  56. });
  57. }
  58. break;
  59. default:
  60. ChannelConfigs = new ObservableCollection<ChannelConfig>();
  61. SerialPortConfig = null;
  62. TcpConfig = null;
  63. break;
  64. }
  65. }
  66. }
  67. private ObservableCollection<ChannelConfig> _ChannelConfigs;
  68. public ObservableCollection<ChannelConfig> ChannelConfigs
  69. {
  70. get { return _ChannelConfigs; }
  71. set { SetProperty(ref _ChannelConfigs, value); }
  72. }
  73. private TcpConfig _TcpConfig;
  74. public TcpConfig TcpConfig
  75. {
  76. get { return _TcpConfig; }
  77. set { SetProperty(ref _TcpConfig, value); }
  78. }
  79. private SerialPortConfig _SerialPortConfig;
  80. public SerialPortConfig SerialPortConfig
  81. {
  82. get { return _SerialPortConfig; }
  83. set { SetProperty(ref _SerialPortConfig, value); }
  84. }
  85. public LightControllerConfig()
  86. {
  87. ChannelConfigs = new ObservableCollection<ChannelConfig>();
  88. }
  89. public LightControllerConfig(int id, string name, LightModel model)
  90. {
  91. Id = id;
  92. Name = name;
  93. LightModel = model;
  94. switch (LightModel)
  95. {
  96. case LightModel.KCS_KDC_12V60W_4T:
  97. ChannelCount = 4;
  98. TcpConfig = null;
  99. SerialPortConfig = new SerialPortConfig();
  100. ChannelConfigs = new ObservableCollection<ChannelConfig>();
  101. for (int i = 0; i < ChannelCount; i++)
  102. {
  103. ChannelConfigs.Add(new ChannelConfig()
  104. {
  105. LocalIndex = i,
  106. GlobalIndex = i,
  107. Name = $"Channel {i + 1}",
  108. Description = $"Description for Channel {i + 1}",
  109. DefaultBrightness = 100
  110. });
  111. }
  112. break;
  113. default:
  114. ChannelConfigs = new ObservableCollection<ChannelConfig>();
  115. SerialPortConfig = null;
  116. TcpConfig = null;
  117. break;
  118. }
  119. }
  120. }
  121. }