StationItem.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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 static List<int> NumList = new List<int>
  48. {
  49. 0,1,2,3,4,5,6,7,8,9,10
  50. };
  51. public event PropertyChangedEventHandler PropertyChanged;
  52. protected virtual void OnPropertyChanged(string propertyName)
  53. {
  54. PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
  55. }
  56. private int _index;
  57. public int Index
  58. {
  59. get => _index;
  60. set
  61. {
  62. if (_index != value)
  63. {
  64. _index = value;
  65. OnPropertyChanged(nameof(Index));
  66. }
  67. }
  68. }
  69. public string Id { get; set; }
  70. public string StationId { get; set; }
  71. public string StationIdColor
  72. {
  73. get
  74. {
  75. if(MarkCount > 0)
  76. {
  77. return "#FF6347";
  78. }
  79. return "black";
  80. }
  81. }
  82. private string _stationName;
  83. public string StationName
  84. {
  85. get => _stationName;
  86. set
  87. {
  88. if(_stationName != value)
  89. {
  90. _stationName = value;
  91. OnPropertyChanged(nameof(StationName));
  92. }
  93. }
  94. }
  95. public string DeviceSn { get; set; }
  96. public string StandId { get; set; }
  97. private int _meterType;
  98. public int MeterType
  99. {
  100. get => _meterType;
  101. set
  102. {
  103. if (_meterType != value)
  104. {
  105. _meterType = value;
  106. OnPropertyChanged(nameof(MeterType));
  107. OnPropertyChanged(nameof(MeterTypeName));
  108. OnPropertyChanged(nameof(LastUnitName));
  109. OnPropertyChanged(nameof(FeatureRegionName));
  110. OnPropertyChanged(nameof(CountName));
  111. }
  112. }
  113. }
  114. public string MeterTypeName => Get_MeterTypeName();
  115. private double _brightVal;
  116. public double BrightVal
  117. {
  118. get => _brightVal;
  119. set
  120. {
  121. if(_brightVal != value)
  122. {
  123. _brightVal = value;
  124. OnPropertyChanged(nameof(BrightVal));
  125. }
  126. }
  127. }
  128. private int _flowRate;
  129. public int FlowRate
  130. {
  131. get => _flowRate;
  132. set
  133. {
  134. if(_flowRate != value)
  135. {
  136. _flowRate = value;
  137. OnPropertyChanged(nameof(FlowRate));
  138. }
  139. }
  140. }
  141. private string _dialRegion;
  142. public string DialRegion
  143. {
  144. get => _dialRegion;
  145. set
  146. {
  147. if(_dialRegion != value)
  148. {
  149. _dialRegion = value;
  150. OnPropertyChanged(nameof(DialRegion));
  151. }
  152. }
  153. }
  154. private int _numCount;
  155. public int NumCount
  156. {
  157. get => _numCount;
  158. set
  159. {
  160. if(_numCount != value)
  161. {
  162. _numCount = value;
  163. OnPropertyChanged(nameof(NumCount));
  164. //OnPropertyChanged(nameof(NumCountName));
  165. OnPropertyChanged(nameof(CountName));
  166. }
  167. }
  168. }
  169. //public string NumCountName
  170. //{
  171. // get
  172. // {
  173. // if(MeterType == 1 || MeterType == 3)
  174. // {
  175. // return NumCount + "";
  176. // }
  177. // return "";
  178. // }
  179. //}
  180. private int _indCount;
  181. public int IndCount
  182. {
  183. get => _indCount;
  184. set
  185. {
  186. if(_indCount != value)
  187. {
  188. _indCount = value;
  189. OnPropertyChanged(nameof(IndCount));
  190. //OnPropertyChanged(nameof(IndCountName));
  191. OnPropertyChanged(nameof(CountName));
  192. }
  193. }
  194. }
  195. //public string IndCountName
  196. //{
  197. // get
  198. // {
  199. // if(MeterType == 1 || MeterType == 2)
  200. // {
  201. // return IndCount + "";
  202. // }
  203. // return "";
  204. // }
  205. //}
  206. public string CountName
  207. {
  208. get
  209. {
  210. if(MeterType == 1 )
  211. {
  212. return "数字: " + NumCount + " ;指针: " + IndCount;
  213. }
  214. else if(MeterType == 2)
  215. {
  216. return "指针: " + IndCount;
  217. }
  218. else if(MeterType == 3)
  219. {
  220. return "数字: " + NumCount;
  221. }
  222. else
  223. {
  224. return "";
  225. }
  226. }
  227. }
  228. private string _featureRegion;
  229. public string FeatureRegion
  230. {
  231. get => _featureRegion;
  232. set
  233. {
  234. if(_featureRegion != value)
  235. {
  236. _featureRegion = value;
  237. OnPropertyChanged(nameof(FeatureRegion));
  238. OnPropertyChanged(nameof(FeatureRegionName));
  239. }
  240. }
  241. }
  242. public string FeatureRegionName
  243. {
  244. get
  245. {
  246. if(MeterType == 1 || MeterType == 3 || MeterType == 2)
  247. {
  248. return FeatureRegion;
  249. }
  250. else
  251. {
  252. return "";
  253. }
  254. }
  255. }
  256. private double _lastUnit;
  257. public double LastUnit
  258. {
  259. get => _lastUnit;
  260. set
  261. {
  262. if(_lastUnit != value)
  263. {
  264. _lastUnit = value;
  265. OnPropertyChanged(nameof(LastUnit));
  266. OnPropertyChanged(nameof(LastUnitName));
  267. }
  268. }
  269. }
  270. public string LastUnitName
  271. {
  272. get
  273. {
  274. if (MeterType == 1 || MeterType == 3 || MeterType == 2)
  275. {
  276. return LastUnit + "";
  277. }
  278. else
  279. {
  280. return "";
  281. }
  282. }
  283. }
  284. private double _lastValue;
  285. public double LastValue
  286. {
  287. get => _lastValue;
  288. set
  289. {
  290. if(_lastValue != value)
  291. {
  292. _lastValue = value;
  293. OnPropertyChanged(nameof(LastValue));
  294. OnPropertyChanged(nameof(LastValueName));
  295. }
  296. }
  297. }
  298. public string LastValueName
  299. {
  300. get
  301. {
  302. if (string.IsNullOrEmpty(LastTime))
  303. {
  304. return "";
  305. }
  306. else
  307. {
  308. return LastValue + "";
  309. }
  310. }
  311. }
  312. private string _lastTime;
  313. public string LastTime
  314. {
  315. //get => ThisApp.ConvertDateFormat(_lastTime);
  316. get => _lastTime;
  317. set
  318. {
  319. if(_lastTime != value)
  320. {
  321. _lastTime = value;
  322. OnPropertyChanged(nameof(LastTime));
  323. OnPropertyChanged(nameof(LastTimeName));
  324. OnPropertyChanged(nameof(LastValueName));
  325. }
  326. }
  327. }
  328. public string LastTimeName => ThisApp.ConvertDateFormat(LastTime);
  329. private string _createTime;
  330. public string CreateTime
  331. {
  332. get => _createTime;
  333. set
  334. {
  335. if(_createTime != value)
  336. {
  337. _createTime = value;
  338. OnPropertyChanged(nameof(CreateTime));
  339. }
  340. }
  341. }
  342. private int _markCount;
  343. public int MarkCount
  344. {
  345. get => _markCount;
  346. set
  347. {
  348. if(_markCount != value)
  349. {
  350. _markCount = value;
  351. OnPropertyChanged(nameof(MarkCount));
  352. OnPropertyChanged(nameof(MarkCountName));
  353. OnPropertyChanged(nameof(StationIdColor));
  354. }
  355. }
  356. }
  357. public string MarkCountName
  358. {
  359. get
  360. {
  361. if(MarkCount > 0)
  362. {
  363. return MarkCount + "";
  364. }
  365. return "";
  366. }
  367. }
  368. public StationItem()
  369. {
  370. }
  371. public StationItem(TStation tStation)
  372. {
  373. ObjectHelper.CopyMatchingFields(tStation, this);
  374. }
  375. private string Get_MeterTypeName()
  376. {
  377. switch (MeterType)
  378. {
  379. case 1:
  380. return "数字+指针";
  381. case 2:
  382. return "全指针";
  383. case 3:
  384. return "全数字";
  385. case 4:
  386. return "LED表";
  387. case 5:
  388. return "压力表";
  389. default:
  390. return "";
  391. //return "非水表";
  392. }
  393. }
  394. }
  395. }