StationItem.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. using MeterVision.db;
  2. using MeterVision.Util;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace MeterVision.model
  10. {
  11. public class StationItem : INotifyPropertyChanged
  12. {
  13. public static List<KeyValuePair<int, string>> MeterTypeList =
  14. new List<KeyValuePair<int, string>>()
  15. {
  16. //new KeyValuePair<int, string>(0,"0 - 未知"),
  17. new KeyValuePair<int, string>(1, "1 - 数字+指针"),
  18. new KeyValuePair<int, string>(2, "2 - 全指针"),
  19. new KeyValuePair<int, string>(3, "3 - 全数字")
  20. };
  21. public static List<KeyValuePair<int, string>> FlowRateList =
  22. new List<KeyValuePair<int, string>>()
  23. {
  24. new KeyValuePair<int, string>(3, "DN15 - 3"),
  25. new KeyValuePair<int, string>(5, "DN20 - 5"),
  26. new KeyValuePair<int, string>(8, "DN25 - 8"),
  27. new KeyValuePair<int, string>(12, "DN32 - 12"),
  28. new KeyValuePair<int, string>(20, "DN40 - 20"),
  29. new KeyValuePair<int, string>(32, "DN50 - 32"),
  30. new KeyValuePair<int, string>(60, "DN65 - 60"),
  31. new KeyValuePair<int, string>(79, "DN80 - 79"),
  32. new KeyValuePair<int, string>(125, "DN100 - 125"),
  33. new KeyValuePair<int, string>(200, "DN125 - 200"),
  34. new KeyValuePair<int, string>(312, "DN150 - 312"),
  35. new KeyValuePair<int, string>(500, "DN200 - 500"),
  36. new KeyValuePair<int, string>(787, "DN250 - 787"),
  37. new KeyValuePair<int, string>(1250, "DN300 - 1250"),
  38. new KeyValuePair<int, string>(2000, "DN400 - 2000"),
  39. new KeyValuePair<int, string>(3125, "DN500 - 3125"),
  40. new KeyValuePair<int, string>(5000, "DN600 - 5000"),
  41. new KeyValuePair<int, string>(7875, "DN800 - 7875"),
  42. };
  43. public static List<double> UnitList = new List<double>
  44. {
  45. 1000,100,10,1,0.1,0.01,0.001,0.0001
  46. };
  47. public event PropertyChangedEventHandler PropertyChanged;
  48. protected virtual void OnPropertyChanged(string propertyName)
  49. {
  50. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  51. }
  52. private int _index;
  53. public int Index
  54. {
  55. get => _index;
  56. set
  57. {
  58. if (_index != value)
  59. {
  60. _index = value;
  61. OnPropertyChanged(nameof(Index));
  62. }
  63. }
  64. }
  65. public string Id { get; set; }
  66. public string StationId { get; set; }
  67. private string _stationName;
  68. public string StationName
  69. {
  70. get => _stationName;
  71. set
  72. {
  73. if(_stationName != value)
  74. {
  75. _stationName = value;
  76. OnPropertyChanged(nameof(StationName));
  77. }
  78. }
  79. }
  80. public string DeviceSn { get; set; }
  81. public string StandId { get; set; }
  82. private int _meterType;
  83. public int MeterType
  84. {
  85. get => _meterType;
  86. set
  87. {
  88. if (_meterType != value)
  89. {
  90. _meterType = value;
  91. OnPropertyChanged(nameof(MeterType));
  92. OnPropertyChanged(nameof(MeterTypeName));
  93. }
  94. }
  95. }
  96. public string MeterTypeName => Get_MeterTypeName();
  97. private double _brightVal;
  98. public double BrightVal
  99. {
  100. get => _brightVal;
  101. set
  102. {
  103. if(_brightVal != value)
  104. {
  105. _brightVal = value;
  106. OnPropertyChanged(nameof(BrightVal));
  107. }
  108. }
  109. }
  110. private int _flowRate;
  111. public int FlowRate
  112. {
  113. get => _flowRate;
  114. set
  115. {
  116. if(_flowRate != value)
  117. {
  118. _flowRate = value;
  119. OnPropertyChanged(nameof(FlowRate));
  120. }
  121. }
  122. }
  123. private string _dialRegion;
  124. public string DialRegion
  125. {
  126. get => _dialRegion;
  127. set
  128. {
  129. if(_dialRegion != value)
  130. {
  131. _dialRegion = value;
  132. OnPropertyChanged(nameof(DialRegion));
  133. }
  134. }
  135. }
  136. private int _numCount;
  137. public int NumCount
  138. {
  139. get => _numCount;
  140. set
  141. {
  142. if(_numCount != value)
  143. {
  144. _numCount = value;
  145. OnPropertyChanged(nameof(NumCount));
  146. OnPropertyChanged(nameof(NumCountName));
  147. }
  148. }
  149. }
  150. public string NumCountName
  151. {
  152. get
  153. {
  154. if(MeterType == 1 || MeterType == 3)
  155. {
  156. return NumCount + "";
  157. }
  158. return "";
  159. }
  160. }
  161. private int _indCount;
  162. public int IndCount
  163. {
  164. get => _indCount;
  165. set
  166. {
  167. if(_indCount != value)
  168. {
  169. _indCount = value;
  170. OnPropertyChanged(nameof(IndCount));
  171. OnPropertyChanged(nameof(IndCountName));
  172. }
  173. }
  174. }
  175. public string IndCountName
  176. {
  177. get
  178. {
  179. if(MeterType == 1 || MeterType == 2)
  180. {
  181. return IndCount + "";
  182. }
  183. return "";
  184. }
  185. }
  186. private string _numRegion;
  187. public string NumRegion
  188. {
  189. get => _numRegion;
  190. set
  191. {
  192. if(_numRegion != value)
  193. {
  194. _numRegion = value;
  195. OnPropertyChanged(nameof(NumRegion));
  196. OnPropertyChanged(nameof(NumRegionName));
  197. }
  198. }
  199. }
  200. public string NumRegionName
  201. {
  202. get
  203. {
  204. if(MeterType == 1 || MeterType == 3)
  205. {
  206. return NumRegion;
  207. }
  208. return "";
  209. }
  210. }
  211. private string _htReigon;
  212. public string HtRegion
  213. {
  214. get => _htReigon;
  215. set
  216. {
  217. if(_htReigon != value)
  218. {
  219. _htReigon = value;
  220. OnPropertyChanged(nameof(HtRegion));
  221. OnPropertyChanged(nameof(HtRegionName));
  222. }
  223. }
  224. }
  225. public string HtRegionName
  226. {
  227. get
  228. {
  229. if(MeterType == 2)
  230. {
  231. return HtRegion;
  232. }
  233. return "";
  234. }
  235. }
  236. private double _lastNumUnit;
  237. public double LastNumUnit
  238. {
  239. get => _lastNumUnit;
  240. set
  241. {
  242. if(_lastNumUnit != value)
  243. {
  244. _lastNumUnit = value;
  245. OnPropertyChanged(nameof(LastNumUnit));
  246. OnPropertyChanged(nameof(LastNumUnitName));
  247. }
  248. }
  249. }
  250. public string LastNumUnitName
  251. {
  252. get
  253. {
  254. if(MeterType == 1 || MeterType == 3)
  255. {
  256. return LastNumUnit + "";
  257. }
  258. return "";
  259. }
  260. }
  261. private double _lastIndUnit;
  262. public double LastIndUnit
  263. {
  264. get => _lastIndUnit;
  265. set
  266. {
  267. if(_lastIndUnit != value)
  268. {
  269. _lastIndUnit = value;
  270. OnPropertyChanged(nameof(LastIndUnit));
  271. OnPropertyChanged(nameof(LastIndUnitName));
  272. }
  273. }
  274. }
  275. public string LastIndUnitName
  276. {
  277. get
  278. {
  279. if(MeterType == 2)
  280. {
  281. return LastIndUnit + "";
  282. }
  283. return "";
  284. }
  285. }
  286. private double _lastValue;
  287. public double LastValue
  288. {
  289. get => _lastValue;
  290. set
  291. {
  292. if(_lastValue != value)
  293. {
  294. _lastValue = value;
  295. OnPropertyChanged(nameof(LastValue));
  296. }
  297. }
  298. }
  299. private string _lastTime;
  300. public string LastTime
  301. {
  302. //get => ThisApp.ConvertDateFormat(_lastTime);
  303. get => _lastTime;
  304. set
  305. {
  306. if(_lastTime != value)
  307. {
  308. _lastTime = value;
  309. OnPropertyChanged(nameof(LastTime));
  310. }
  311. }
  312. }
  313. public string LastTimeName => ThisApp.ConvertDateFormat(LastTime);
  314. private string _createTime;
  315. public string CreateTime
  316. {
  317. get => _createTime;
  318. set
  319. {
  320. if(_createTime != value)
  321. {
  322. _createTime = value;
  323. OnPropertyChanged(nameof(CreateTime));
  324. }
  325. }
  326. }
  327. public StationItem()
  328. {
  329. }
  330. public StationItem(TStation tStation)
  331. {
  332. ObjectHelper.CopyMatchingFields(tStation, this);
  333. }
  334. private string Get_MeterTypeName()
  335. {
  336. switch (MeterType)
  337. {
  338. case 1:
  339. return "数字+指针";
  340. case 2:
  341. return "全指针";
  342. case 3:
  343. return "全数字";
  344. case 4:
  345. return "LED表";
  346. case 5:
  347. return "压力表";
  348. default:
  349. return "非水表";
  350. }
  351. }
  352. }
  353. }