CalibrationDataModel.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. using SWRIS.Dtos;
  2. using SWRIS.Enums;
  3. using SWRIS.Extensions;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.ComponentModel;
  7. using System.IO.Ports;
  8. using System.Linq;
  9. namespace SWRIS.Models
  10. {
  11. public class CalibrationDataModel : INotifyPropertyChanged
  12. {
  13. private int moduleType;
  14. private TcpDataModel tcp;
  15. private SerialDataModel serial;
  16. private ObservableCollection<LimitDataModel> limits;
  17. public int ModuleType
  18. {
  19. get => moduleType;
  20. set
  21. {
  22. moduleType = value;
  23. OnPropertyChanged(nameof(ModuleType));
  24. }
  25. }
  26. public TcpDataModel Tcp
  27. {
  28. get => tcp;
  29. set
  30. {
  31. tcp = value;
  32. OnPropertyChanged(nameof(Tcp));
  33. }
  34. }
  35. public SerialDataModel Serial
  36. {
  37. get => serial;
  38. set
  39. {
  40. serial = value;
  41. OnPropertyChanged(nameof(Serial));
  42. }
  43. }
  44. public ObservableCollection<LimitDataModel> Limits
  45. {
  46. get => limits;
  47. set
  48. {
  49. limits = value;
  50. OnPropertyChanged(nameof(Limits));
  51. }
  52. }
  53. public List<KeyAndValueDto> ModuleTypes => TypeExtension.ToKeyAndDescriptionList(typeof(ModuleType));
  54. public event PropertyChangedEventHandler PropertyChanged;
  55. protected internal virtual void OnPropertyChanged(string propertyName)
  56. {
  57. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  58. }
  59. }
  60. public class TcpDataModel : INotifyPropertyChanged
  61. {
  62. private string ipAddress;
  63. private int port;
  64. private byte station;
  65. public string IpAddress
  66. {
  67. get => ipAddress;
  68. set
  69. {
  70. ipAddress = value;
  71. OnPropertyChanged(nameof(IpAddress));
  72. }
  73. }
  74. public int Port
  75. {
  76. get => port;
  77. set
  78. {
  79. port = value;
  80. OnPropertyChanged(nameof(Port));
  81. }
  82. }
  83. public byte Station
  84. {
  85. get => station;
  86. set
  87. {
  88. station = value;
  89. OnPropertyChanged(nameof(Station));
  90. }
  91. }
  92. public event PropertyChangedEventHandler PropertyChanged;
  93. protected internal virtual void OnPropertyChanged(string propertyName)
  94. {
  95. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  96. }
  97. }
  98. public class SerialDataModel : INotifyPropertyChanged
  99. {
  100. private string portName;
  101. private int baudRate;
  102. private int dataBits;
  103. private string parity;
  104. private int stopBits;
  105. private byte station;
  106. public string PortName
  107. {
  108. get => portName;
  109. set
  110. {
  111. portName = value;
  112. OnPropertyChanged(nameof(PortName));
  113. }
  114. }
  115. public int BaudRate
  116. {
  117. get => baudRate;
  118. set
  119. {
  120. baudRate = value;
  121. OnPropertyChanged(nameof(BaudRate));
  122. }
  123. }
  124. public int DataBits
  125. {
  126. get => dataBits;
  127. set
  128. {
  129. dataBits = value;
  130. OnPropertyChanged(nameof(DataBits));
  131. }
  132. }
  133. public string Parity
  134. {
  135. get => parity;
  136. set
  137. {
  138. parity = value;
  139. OnPropertyChanged(nameof(Parity));
  140. }
  141. }
  142. public int StopBits
  143. {
  144. get => stopBits;
  145. set
  146. {
  147. stopBits = value;
  148. OnPropertyChanged(nameof(StopBits));
  149. }
  150. }
  151. public byte Station
  152. {
  153. get => station;
  154. set
  155. {
  156. station = value;
  157. OnPropertyChanged(nameof(Station));
  158. }
  159. }
  160. public List<string> SerialNames => SerialPort.GetPortNames().ToList();
  161. public event PropertyChangedEventHandler PropertyChanged;
  162. protected internal virtual void OnPropertyChanged(string propertyName)
  163. {
  164. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  165. }
  166. }
  167. public class LimitDataModel : INotifyPropertyChanged
  168. {
  169. private string name;
  170. private string address;
  171. private double position;
  172. private bool isReverse;
  173. private bool isEnable;
  174. private List<RopeDataModel> relatedRopes;
  175. public string Name
  176. {
  177. get => name;
  178. set
  179. {
  180. name = value;
  181. OnPropertyChanged(nameof(Name));
  182. }
  183. }
  184. public string Address
  185. {
  186. get => address;
  187. set
  188. {
  189. address = value;
  190. OnPropertyChanged(nameof(Address));
  191. }
  192. }
  193. public double Position
  194. {
  195. get => position;
  196. set
  197. {
  198. position = value;
  199. OnPropertyChanged(nameof(Position));
  200. }
  201. }
  202. public bool IsReverse
  203. {
  204. get => isReverse;
  205. set
  206. {
  207. isReverse = value;
  208. OnPropertyChanged(nameof(IsReverse));
  209. }
  210. }
  211. public bool IsEnable
  212. {
  213. get => isEnable;
  214. set
  215. {
  216. isEnable = value;
  217. OnPropertyChanged(nameof(IsEnable));
  218. }
  219. }
  220. public List<RopeDataModel> RelatedRopes
  221. {
  222. get => relatedRopes;
  223. set
  224. {
  225. relatedRopes = value;
  226. OnPropertyChanged(nameof(RelatedRopes));
  227. }
  228. }
  229. public event PropertyChangedEventHandler PropertyChanged;
  230. protected internal virtual void OnPropertyChanged(string propertyName)
  231. {
  232. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  233. }
  234. }
  235. public class RopeDataModel : INotifyPropertyChanged
  236. {
  237. private int ropeNumber;
  238. private string ropeName;
  239. private bool isSelected;
  240. public int RopeNumber
  241. {
  242. get => ropeNumber;
  243. set
  244. {
  245. ropeNumber = value;
  246. OnPropertyChanged(nameof(RopeNumber));
  247. }
  248. }
  249. public string RopeName
  250. {
  251. get => ropeName;
  252. set
  253. {
  254. ropeName = value;
  255. OnPropertyChanged(nameof(RopeName));
  256. }
  257. }
  258. public bool IsSelected
  259. {
  260. get => isSelected;
  261. set
  262. {
  263. isSelected = value;
  264. OnPropertyChanged(nameof(IsSelected));
  265. }
  266. }
  267. public event PropertyChangedEventHandler PropertyChanged;
  268. protected internal virtual void OnPropertyChanged(string propertyName)
  269. {
  270. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  271. }
  272. }
  273. }