StationItem.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  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. OnPropertyChanged(nameof(LastUnitName));
  94. OnPropertyChanged(nameof(FeatureRegionName));
  95. OnPropertyChanged(nameof(CountName));
  96. }
  97. }
  98. }
  99. public string MeterTypeName => Get_MeterTypeName();
  100. private double _brightVal;
  101. public double BrightVal
  102. {
  103. get => _brightVal;
  104. set
  105. {
  106. if(_brightVal != value)
  107. {
  108. _brightVal = value;
  109. OnPropertyChanged(nameof(BrightVal));
  110. }
  111. }
  112. }
  113. private int _flowRate;
  114. public int FlowRate
  115. {
  116. get => _flowRate;
  117. set
  118. {
  119. if(_flowRate != value)
  120. {
  121. _flowRate = value;
  122. OnPropertyChanged(nameof(FlowRate));
  123. }
  124. }
  125. }
  126. private string _dialRegion;
  127. public string DialRegion
  128. {
  129. get => _dialRegion;
  130. set
  131. {
  132. if(_dialRegion != value)
  133. {
  134. _dialRegion = value;
  135. OnPropertyChanged(nameof(DialRegion));
  136. }
  137. }
  138. }
  139. private int _numCount;
  140. public int NumCount
  141. {
  142. get => _numCount;
  143. set
  144. {
  145. if(_numCount != value)
  146. {
  147. _numCount = value;
  148. OnPropertyChanged(nameof(NumCount));
  149. //OnPropertyChanged(nameof(NumCountName));
  150. OnPropertyChanged(nameof(CountName));
  151. }
  152. }
  153. }
  154. //public string NumCountName
  155. //{
  156. // get
  157. // {
  158. // if(MeterType == 1 || MeterType == 3)
  159. // {
  160. // return NumCount + "";
  161. // }
  162. // return "";
  163. // }
  164. //}
  165. private int _indCount;
  166. public int IndCount
  167. {
  168. get => _indCount;
  169. set
  170. {
  171. if(_indCount != value)
  172. {
  173. _indCount = value;
  174. OnPropertyChanged(nameof(IndCount));
  175. //OnPropertyChanged(nameof(IndCountName));
  176. OnPropertyChanged(nameof(CountName));
  177. }
  178. }
  179. }
  180. //public string IndCountName
  181. //{
  182. // get
  183. // {
  184. // if(MeterType == 1 || MeterType == 2)
  185. // {
  186. // return IndCount + "";
  187. // }
  188. // return "";
  189. // }
  190. //}
  191. public string CountName
  192. {
  193. get
  194. {
  195. if(MeterType == 1 )
  196. {
  197. return "数字: " + NumCount + " ;指针: " + IndCount;
  198. }
  199. else if(MeterType == 2)
  200. {
  201. return "指针: " + IndCount;
  202. }
  203. else if(MeterType == 3)
  204. {
  205. return "数字: " + NumCount;
  206. }
  207. else
  208. {
  209. return "";
  210. }
  211. }
  212. }
  213. private string _featureRegion;
  214. public string FeatureRegion
  215. {
  216. get => _featureRegion;
  217. set
  218. {
  219. if(_featureRegion != value)
  220. {
  221. _featureRegion = value;
  222. OnPropertyChanged(nameof(FeatureRegion));
  223. OnPropertyChanged(nameof(FeatureRegionName));
  224. }
  225. }
  226. }
  227. public string FeatureRegionName
  228. {
  229. get
  230. {
  231. if(MeterType == 1 || MeterType == 3 || MeterType == 2)
  232. {
  233. return FeatureRegion;
  234. }
  235. else
  236. {
  237. return "";
  238. }
  239. }
  240. }
  241. private double _lastUnit;
  242. public double LastUnit
  243. {
  244. get => _lastUnit;
  245. set
  246. {
  247. if(_lastUnit != value)
  248. {
  249. _lastUnit = value;
  250. OnPropertyChanged(nameof(LastUnit));
  251. OnPropertyChanged(nameof(LastUnitName));
  252. }
  253. }
  254. }
  255. public string LastUnitName
  256. {
  257. get
  258. {
  259. if (MeterType == 1 || MeterType == 3 || MeterType == 2)
  260. {
  261. return LastUnit + "";
  262. }
  263. else
  264. {
  265. return "";
  266. }
  267. }
  268. }
  269. private double _lastValue;
  270. public double LastValue
  271. {
  272. get => _lastValue;
  273. set
  274. {
  275. if(_lastValue != value)
  276. {
  277. _lastValue = value;
  278. OnPropertyChanged(nameof(LastValue));
  279. OnPropertyChanged(nameof(LastValueName));
  280. }
  281. }
  282. }
  283. public string LastValueName
  284. {
  285. get
  286. {
  287. if (string.IsNullOrEmpty(LastTime))
  288. {
  289. return "";
  290. }
  291. else
  292. {
  293. return LastValue + "";
  294. }
  295. }
  296. }
  297. private string _lastTime;
  298. public string LastTime
  299. {
  300. //get => ThisApp.ConvertDateFormat(_lastTime);
  301. get => _lastTime;
  302. set
  303. {
  304. if(_lastTime != value)
  305. {
  306. _lastTime = value;
  307. OnPropertyChanged(nameof(LastTime));
  308. OnPropertyChanged(nameof(LastTimeName));
  309. OnPropertyChanged(nameof(LastValueName));
  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. //return "非水表";
  351. }
  352. }
  353. }
  354. }