MFCVerificationViewModel.cs 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Aitex.Core.Common.DeviceData;
  7. using Aitex.Core.RT.Log;
  8. using Aitex.Core.Util;
  9. using MECF.Framework.Common.CommonData;
  10. using MECF.Framework.Common.DataCenter;
  11. using MECF.Framework.Common.OperationCenter;
  12. using OpenSEMI.ClientBase;
  13. using SciChart.Charting.Model.DataSeries;
  14. using SciChart.Charting.Visuals.Axes;
  15. using SciChart.Charting.Visuals.RenderableSeries;
  16. using SciChart.Data.Model;
  17. using System.Collections.ObjectModel;
  18. using System.ComponentModel;
  19. using MECF.Framework.UI.Client.ClientBase;
  20. using System.Windows;
  21. using System.Windows.Media;
  22. namespace MECF.Framework.UI.Client.CenterViews.Maitenances.MFCVerification
  23. {
  24. public class MFCVerificationDataListItem : NotifiableItem
  25. {
  26. private float _Setpoint;
  27. public float Setpoint
  28. {
  29. get
  30. {
  31. return _Setpoint;
  32. }
  33. set
  34. {
  35. _Setpoint = value;
  36. InvokePropertyChanged("Setpoint");
  37. }
  38. }
  39. private float _CalculateValue;
  40. public float CalculateValue
  41. {
  42. get
  43. {
  44. return _CalculateValue;
  45. }
  46. set
  47. {
  48. _CalculateValue = value;
  49. InvokePropertyChanged("CalculateValue");
  50. }
  51. }
  52. private float _ElapseTime;
  53. public float ElapseTime
  54. {
  55. get
  56. {
  57. return _ElapseTime;
  58. }
  59. set
  60. {
  61. _ElapseTime = value;
  62. InvokePropertyChanged("ElapseTime");
  63. }
  64. }
  65. private float _pressure;
  66. public float Pressure
  67. {
  68. get
  69. {
  70. return _pressure;
  71. }
  72. set
  73. {
  74. _pressure = value;
  75. InvokePropertyChanged("Pressure");
  76. }
  77. }
  78. }
  79. public class MFCVerificationErrorRateListItem : NotifiableItem
  80. {
  81. public float Setpoint { get; set; }
  82. public float CalculateValue { get; set; }
  83. public float ErrorRate { get; set; }
  84. }
  85. public class MFCVerificationData : NotifiableItem
  86. {
  87. public string Module { get; set; }
  88. public string Name { get; set; }
  89. public string Time { get; set; }
  90. public float Percent10Setpoint { get; set; }
  91. public float Percent10Calculate { get; set; }
  92. public float Percent20Setpoint { get; set; }
  93. public float Percent20Calculate { get; set; }
  94. public float Percent30Setpoint { get; set; }
  95. public float Percent30Calculate { get; set; }
  96. public float Percent40Setpoint { get; set; }
  97. public float Percent40Calculate { get; set; }
  98. public float Percent50Setpoint { get; set; }
  99. public float Percent50Calculate { get; set; }
  100. public float Percent60Setpoint { get; set; }
  101. public float Percent60Calculate { get; set; }
  102. public float Percent70Setpoint { get; set; }
  103. public float Percent70Calculate { get; set; }
  104. public float Percent80Setpoint { get; set; }
  105. public float Percent80Calculate { get; set; }
  106. public float Percent90Setpoint { get; set; }
  107. public float Percent90Calculate { get; set; }
  108. public float Percent100Setpoint { get; set; }
  109. public float Percent100Calculate { get; set; }
  110. public float Setpoint { get; set; }
  111. public float Calculate { get; set; }
  112. }
  113. public class MFCVerificationViewModel : ModuleUiViewModelBase, ISupportMultipleSystem
  114. {
  115. public MFCVerificationViewModel()
  116. {
  117. var now = DateTime.Today;
  118. SearchBeginTime = now;
  119. SearchEndTime = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59, 999);
  120. }
  121. #region MFCs
  122. #region MFCData
  123. private AITMfcData _mfc1DeviceData;
  124. [Subscription("MFC1.DeviceData")]
  125. public AITMfcData MFC1DeviceData
  126. {
  127. get
  128. {
  129. return _mfc1DeviceData;
  130. }
  131. set
  132. {
  133. if (_mfc1DeviceData == null || _mfc1DeviceData.Scale != value.Scale)
  134. {
  135. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  136. {
  137. int delta = (int)value.Scale / 10;
  138. if (MFC1VerificationPoints != null)
  139. MFC1VerificationPoints.Clear();
  140. else
  141. MFC1VerificationPoints = new ObservableCollection<int>();
  142. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  143. for (int i = 0; i < 10; i++)
  144. {
  145. MFC1VerificationPoints.Add(delta + delta * i);
  146. }
  147. }));
  148. }
  149. _mfc1DeviceData = value;
  150. }
  151. }
  152. private AITMfcData _mfc2DeviceData;
  153. [Subscription("MFC2.DeviceData")]
  154. public AITMfcData MFC2DeviceData
  155. {
  156. get
  157. {
  158. return _mfc2DeviceData;
  159. }
  160. set
  161. {
  162. if (_mfc2DeviceData == null || _mfc2DeviceData.Scale != value.Scale)
  163. {
  164. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  165. {
  166. int delta = (int)value.Scale / 10;
  167. if (MFC2VerificationPoints != null)
  168. MFC2VerificationPoints.Clear();
  169. else
  170. MFC2VerificationPoints = new ObservableCollection<int>();
  171. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  172. for (int i = 0; i < 10; i++)
  173. {
  174. MFC2VerificationPoints.Add(delta + delta * i);
  175. }
  176. }));
  177. }
  178. _mfc2DeviceData = value;
  179. }
  180. }
  181. private AITMfcData _mfc3DeviceData;
  182. [Subscription("MFC3.DeviceData")]
  183. public AITMfcData MFC3DeviceData
  184. {
  185. get
  186. {
  187. return _mfc3DeviceData;
  188. }
  189. set
  190. {
  191. if (_mfc3DeviceData == null || _mfc3DeviceData.Scale != value.Scale)
  192. {
  193. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  194. {
  195. int delta = (int)value.Scale / 10;
  196. if (MFC3VerificationPoints != null)
  197. MFC3VerificationPoints.Clear();
  198. else
  199. MFC3VerificationPoints = new ObservableCollection<int>();
  200. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  201. for (int i = 0; i < 10; i++)
  202. {
  203. MFC3VerificationPoints.Add(delta + delta * i);
  204. }
  205. }));
  206. }
  207. _mfc3DeviceData = value;
  208. }
  209. }
  210. private AITMfcData _mfc4DeviceData;
  211. [Subscription("MFC4.DeviceData")]
  212. public AITMfcData MFC4DeviceData
  213. {
  214. get
  215. {
  216. return _mfc4DeviceData;
  217. }
  218. set
  219. {
  220. if (_mfc4DeviceData == null || _mfc4DeviceData.Scale != value.Scale)
  221. {
  222. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  223. {
  224. int delta = (int)value.Scale / 10;
  225. if (MFC4VerificationPoints != null)
  226. MFC4VerificationPoints.Clear();
  227. else
  228. MFC4VerificationPoints = new ObservableCollection<int>();
  229. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  230. for (int i = 0; i < 10; i++)
  231. {
  232. MFC4VerificationPoints.Add(delta + delta * i);
  233. }
  234. }));
  235. }
  236. _mfc4DeviceData = value;
  237. }
  238. }
  239. private AITMfcData _mfc5DeviceData;
  240. [Subscription("MFC5.DeviceData")]
  241. public AITMfcData MFC5DeviceData
  242. {
  243. get
  244. {
  245. return _mfc5DeviceData;
  246. }
  247. set
  248. {
  249. if (_mfc5DeviceData == null || _mfc5DeviceData.Scale != value.Scale)
  250. {
  251. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  252. {
  253. int delta = (int)value.Scale / 10;
  254. if (MFC5VerificationPoints != null)
  255. MFC5VerificationPoints.Clear();
  256. else
  257. MFC5VerificationPoints = new ObservableCollection<int>();
  258. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  259. for (int i = 0; i < 10; i++)
  260. {
  261. MFC5VerificationPoints.Add(delta + delta * i);
  262. }
  263. }));
  264. }
  265. _mfc5DeviceData = value;
  266. }
  267. }
  268. private AITMfcData _mfc6DeviceData;
  269. [Subscription("MFC6.DeviceData")]
  270. public AITMfcData MFC6DeviceData
  271. {
  272. get
  273. {
  274. return _mfc6DeviceData;
  275. }
  276. set
  277. {
  278. if (_mfc6DeviceData == null || _mfc6DeviceData.Scale != value.Scale)
  279. {
  280. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  281. {
  282. int delta = (int)value.Scale / 10;
  283. if (MFC6VerificationPoints != null)
  284. MFC6VerificationPoints.Clear();
  285. else
  286. MFC6VerificationPoints = new ObservableCollection<int>();
  287. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  288. for (int i = 0; i < 10; i++)
  289. {
  290. MFC6VerificationPoints.Add(delta + delta * i);
  291. }
  292. }));
  293. }
  294. _mfc6DeviceData = value;
  295. }
  296. }
  297. private AITMfcData _mfc7DeviceData;
  298. [Subscription("MFC7.DeviceData")]
  299. public AITMfcData MFC7DeviceData
  300. {
  301. get
  302. {
  303. return _mfc7DeviceData;
  304. }
  305. set
  306. {
  307. if (_mfc7DeviceData == null || _mfc7DeviceData.Scale != value.Scale)
  308. {
  309. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  310. {
  311. int delta = (int)value.Scale / 10;
  312. if (MFC7VerificationPoints != null)
  313. MFC7VerificationPoints.Clear();
  314. else
  315. MFC7VerificationPoints = new ObservableCollection<int>();
  316. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  317. for (int i = 0; i < 10; i++)
  318. {
  319. MFC7VerificationPoints.Add(delta + delta * i);
  320. }
  321. }));
  322. }
  323. _mfc7DeviceData = value;
  324. }
  325. }
  326. private AITMfcData _mfc8DeviceData;
  327. [Subscription("MFC8.DeviceData")]
  328. public AITMfcData MFC8DeviceData
  329. {
  330. get
  331. {
  332. return _mfc8DeviceData;
  333. }
  334. set
  335. {
  336. if (_mfc8DeviceData == null || _mfc8DeviceData.Scale != value.Scale)
  337. {
  338. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  339. {
  340. int delta = (int)value.Scale / 10;
  341. if (MFC8VerificationPoints != null)
  342. MFC8VerificationPoints.Clear();
  343. else
  344. MFC8VerificationPoints = new ObservableCollection<int>();
  345. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  346. for (int i = 0; i < 10; i++)
  347. {
  348. MFC8VerificationPoints.Add(delta + delta * i);
  349. }
  350. }));
  351. }
  352. _mfc8DeviceData = value;
  353. }
  354. }
  355. private AITMfcData _mfc9DeviceData;
  356. [Subscription("MFC9.DeviceData")]
  357. public AITMfcData MFC9DeviceData
  358. {
  359. get
  360. {
  361. return _mfc9DeviceData;
  362. }
  363. set
  364. {
  365. if (_mfc9DeviceData == null || _mfc9DeviceData.Scale != value.Scale)
  366. {
  367. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  368. {
  369. int delta = (int)value.Scale / 10;
  370. if (MFC9VerificationPoints != null)
  371. MFC9VerificationPoints.Clear();
  372. else
  373. MFC9VerificationPoints = new ObservableCollection<int>();
  374. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  375. for (int i = 0; i < 10; i++)
  376. {
  377. MFC9VerificationPoints.Add(delta + delta * i);
  378. }
  379. }));
  380. }
  381. _mfc9DeviceData = value;
  382. }
  383. }
  384. private AITMfcData _mfc10DeviceData;
  385. [Subscription("MFC10.DeviceData")]
  386. public AITMfcData MFC10DeviceData
  387. {
  388. get
  389. {
  390. return _mfc10DeviceData;
  391. }
  392. set
  393. {
  394. if (_mfc10DeviceData == null || _mfc10DeviceData.Scale != value.Scale)
  395. {
  396. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  397. {
  398. int delta = (int)value.Scale / 10;
  399. if (MFC10VerificationPoints != null)
  400. MFC10VerificationPoints.Clear();
  401. else
  402. MFC10VerificationPoints = new ObservableCollection<int>();
  403. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  404. for (int i = 0; i < 10; i++)
  405. {
  406. MFC10VerificationPoints.Add(delta + delta * i);
  407. }
  408. }));
  409. }
  410. _mfc10DeviceData = value;
  411. }
  412. }
  413. private AITMfcData _mfc11DeviceData;
  414. [Subscription("MFC11.DeviceData")]
  415. public AITMfcData MFC11DeviceData
  416. {
  417. get
  418. {
  419. return _mfc11DeviceData;
  420. }
  421. set
  422. {
  423. if (_mfc11DeviceData == null || _mfc11DeviceData.Scale != value.Scale)
  424. {
  425. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  426. {
  427. int delta = (int)value.Scale / 10;
  428. if (MFC11VerificationPoints != null)
  429. MFC11VerificationPoints.Clear();
  430. else
  431. MFC11VerificationPoints = new ObservableCollection<int>();
  432. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  433. for (int i = 0; i < 10; i++)
  434. {
  435. MFC11VerificationPoints.Add(delta + delta * i);
  436. }
  437. }));
  438. }
  439. _mfc11DeviceData = value;
  440. }
  441. }
  442. private AITMfcData _mfc12DeviceData;
  443. [Subscription("MFC12.DeviceData")]
  444. public AITMfcData MFC12DeviceData
  445. {
  446. get
  447. {
  448. return _mfc12DeviceData;
  449. }
  450. set
  451. {
  452. if (_mfc12DeviceData == null || _mfc12DeviceData.Scale != value.Scale)
  453. {
  454. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  455. {
  456. int delta = (int)value.Scale / 10;
  457. if (MFC12VerificationPoints != null)
  458. MFC12VerificationPoints.Clear();
  459. else
  460. MFC12VerificationPoints = new ObservableCollection<int>();
  461. //ten points: 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% of range
  462. for (int i = 0; i < 10; i++)
  463. {
  464. MFC12VerificationPoints.Add(delta + delta * i);
  465. }
  466. }));
  467. }
  468. _mfc12DeviceData = value;
  469. }
  470. }
  471. #endregion
  472. #region MFCVerificationResult
  473. private string _MFC1VerificationResult;
  474. [Subscription("MfcGas1.VerificationResult")]
  475. public string MFC1VerificationResult
  476. {
  477. get
  478. {
  479. return _MFC1VerificationResult;
  480. }
  481. set
  482. {
  483. if (_MFC1VerificationResult != value)
  484. {
  485. var results = value.Split(';');
  486. if (results != null && results.Length > 0)
  487. {
  488. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  489. {
  490. MFC1VerificationData.Clear();
  491. foreach (var item in results)
  492. {
  493. var onePoint = item.Split(',');
  494. if (onePoint != null && onePoint.Length >= 2)
  495. {
  496. MFC1VerificationData.Add(new MFCVerificationDataListItem()
  497. {
  498. Setpoint = Convert.ToSingle(onePoint[0]),
  499. CalculateValue = Convert.ToSingle(onePoint[1]),
  500. });
  501. }
  502. }
  503. }));
  504. }
  505. }
  506. _MFC1VerificationResult = value;
  507. }
  508. }
  509. private string _MFC2VerificationResult;
  510. [Subscription("MfcGas2.VerificationResult")]
  511. public string MFC2VerificationResult
  512. {
  513. get
  514. {
  515. return _MFC2VerificationResult;
  516. }
  517. set
  518. {
  519. if (_MFC2VerificationResult != value)
  520. {
  521. var results = value.Split(';');
  522. if (results != null && results.Length > 0)
  523. {
  524. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  525. {
  526. MFC2VerificationData.Clear();
  527. foreach (var item in results)
  528. {
  529. var onePoint = item.Split(',');
  530. if (onePoint != null && onePoint.Length >= 2)
  531. {
  532. MFC2VerificationData.Add(new MFCVerificationDataListItem()
  533. {
  534. Setpoint = Convert.ToSingle(onePoint[0]),
  535. CalculateValue = Convert.ToSingle(onePoint[1]),
  536. });
  537. }
  538. }
  539. }));
  540. }
  541. }
  542. _MFC2VerificationResult = value;
  543. }
  544. }
  545. private string _MFC3VerificationResult;
  546. [Subscription("MfcGas3.VerificationResult")]
  547. public string MFC3VerificationResult
  548. {
  549. get
  550. {
  551. return _MFC3VerificationResult;
  552. }
  553. set
  554. {
  555. if (_MFC3VerificationResult != value)
  556. {
  557. var results = value.Split(';');
  558. if (results != null && results.Length > 0)
  559. {
  560. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  561. {
  562. MFC3VerificationData.Clear();
  563. foreach (var item in results)
  564. {
  565. var onePoint = item.Split(',');
  566. if (onePoint != null && onePoint.Length >= 2)
  567. {
  568. MFC3VerificationData.Add(new MFCVerificationDataListItem()
  569. {
  570. Setpoint = Convert.ToSingle(onePoint[0]),
  571. CalculateValue = Convert.ToSingle(onePoint[1]),
  572. });
  573. }
  574. }
  575. }));
  576. }
  577. }
  578. _MFC3VerificationResult = value;
  579. }
  580. }
  581. private string _MFC4VerificationResult;
  582. [Subscription("MfcGas4.VerificationResult")]
  583. public string MFC4VerificationResult
  584. {
  585. get
  586. {
  587. return _MFC4VerificationResult;
  588. }
  589. set
  590. {
  591. if (_MFC4VerificationResult != value)
  592. {
  593. var results = value.Split(';');
  594. if (results != null && results.Length > 0)
  595. {
  596. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  597. {
  598. MFC4VerificationData.Clear();
  599. foreach (var item in results)
  600. {
  601. var onePoint = item.Split(',');
  602. if (onePoint != null && onePoint.Length >= 2)
  603. {
  604. MFC4VerificationData.Add(new MFCVerificationDataListItem()
  605. {
  606. Setpoint = Convert.ToSingle(onePoint[0]),
  607. CalculateValue = Convert.ToSingle(onePoint[1]),
  608. });
  609. }
  610. }
  611. }));
  612. }
  613. }
  614. _MFC4VerificationResult = value;
  615. }
  616. }
  617. private string _MFC5VerificationResult;
  618. [Subscription("MfcGas5.VerificationResult")]
  619. public string MFC5VerificationResult
  620. {
  621. get
  622. {
  623. return _MFC5VerificationResult;
  624. }
  625. set
  626. {
  627. if (_MFC5VerificationResult != value)
  628. {
  629. var results = value.Split(';');
  630. if (results != null && results.Length > 0)
  631. {
  632. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  633. {
  634. MFC5VerificationData.Clear();
  635. foreach (var item in results)
  636. {
  637. var onePoint = item.Split(',');
  638. if (onePoint != null && onePoint.Length >= 2)
  639. {
  640. MFC5VerificationData.Add(new MFCVerificationDataListItem()
  641. {
  642. Setpoint = Convert.ToSingle(onePoint[0]),
  643. CalculateValue = Convert.ToSingle(onePoint[1]),
  644. });
  645. }
  646. }
  647. }));
  648. }
  649. }
  650. _MFC5VerificationResult = value;
  651. }
  652. }
  653. private string _MFC6VerificationResult;
  654. [Subscription("MfcGas6.VerificationResult")]
  655. public string MFC6VerificationResult
  656. {
  657. get
  658. {
  659. return _MFC6VerificationResult;
  660. }
  661. set
  662. {
  663. if (_MFC6VerificationResult != value)
  664. {
  665. var results = value.Split(';');
  666. if (results != null && results.Length > 0)
  667. {
  668. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  669. {
  670. MFC6VerificationData.Clear();
  671. foreach (var item in results)
  672. {
  673. var onePoint = item.Split(',');
  674. if (onePoint != null && onePoint.Length >= 2)
  675. {
  676. MFC6VerificationData.Add(new MFCVerificationDataListItem()
  677. {
  678. Setpoint = Convert.ToSingle(onePoint[0]),
  679. CalculateValue = Convert.ToSingle(onePoint[1]),
  680. });
  681. }
  682. }
  683. }));
  684. }
  685. }
  686. _MFC6VerificationResult = value;
  687. }
  688. }
  689. private string _MFC7VerificationResult;
  690. [Subscription("MfcGas7.VerificationResult")]
  691. public string MFC7VerificationResult
  692. {
  693. get
  694. {
  695. return _MFC7VerificationResult;
  696. }
  697. set
  698. {
  699. if (_MFC7VerificationResult != value)
  700. {
  701. var results = value.Split(';');
  702. if (results != null && results.Length > 0)
  703. {
  704. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  705. {
  706. MFC7VerificationData.Clear();
  707. foreach (var item in results)
  708. {
  709. var onePoint = item.Split(',');
  710. if (onePoint != null && onePoint.Length >= 2)
  711. {
  712. MFC7VerificationData.Add(new MFCVerificationDataListItem()
  713. {
  714. Setpoint = Convert.ToSingle(onePoint[0]),
  715. CalculateValue = Convert.ToSingle(onePoint[1]),
  716. });
  717. }
  718. }
  719. }));
  720. }
  721. }
  722. _MFC7VerificationResult = value;
  723. }
  724. }
  725. private string _MFC8VerificationResult;
  726. [Subscription("MfcGas8.VerificationResult")]
  727. public string MFC8VerificationResult
  728. {
  729. get
  730. {
  731. return _MFC8VerificationResult;
  732. }
  733. set
  734. {
  735. if (_MFC8VerificationResult != value)
  736. {
  737. var results = value.Split(';');
  738. if (results != null && results.Length > 0)
  739. {
  740. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  741. {
  742. MFC8VerificationData.Clear();
  743. foreach (var item in results)
  744. {
  745. var onePoint = item.Split(',');
  746. if (onePoint != null && onePoint.Length >= 2)
  747. {
  748. MFC8VerificationData.Add(new MFCVerificationDataListItem()
  749. {
  750. Setpoint = Convert.ToSingle(onePoint[0]),
  751. CalculateValue = Convert.ToSingle(onePoint[1]),
  752. });
  753. }
  754. }
  755. }));
  756. }
  757. }
  758. _MFC8VerificationResult = value;
  759. }
  760. }
  761. private string _MFC9VerificationResult;
  762. [Subscription("MfcGas9.VerificationResult")]
  763. public string MFC9VerificationResult
  764. {
  765. get
  766. {
  767. return _MFC9VerificationResult;
  768. }
  769. set
  770. {
  771. if (_MFC9VerificationResult != value)
  772. {
  773. var results = value.Split(';');
  774. if (results != null && results.Length > 0)
  775. {
  776. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  777. {
  778. MFC9VerificationData.Clear();
  779. foreach (var item in results)
  780. {
  781. var onePoint = item.Split(',');
  782. if (onePoint != null && onePoint.Length >= 2)
  783. {
  784. MFC9VerificationData.Add(new MFCVerificationDataListItem()
  785. {
  786. Setpoint = Convert.ToSingle(onePoint[0]),
  787. CalculateValue = Convert.ToSingle(onePoint[1]),
  788. });
  789. }
  790. }
  791. }));
  792. }
  793. }
  794. _MFC9VerificationResult = value;
  795. }
  796. }
  797. private string _MFC10VerificationResult;
  798. [Subscription("MfcGas10.VerificationResult")]
  799. public string MFC10VerificationResult
  800. {
  801. get
  802. {
  803. return _MFC10VerificationResult;
  804. }
  805. set
  806. {
  807. if (_MFC10VerificationResult != value)
  808. {
  809. var results = value.Split(';');
  810. if (results != null && results.Length > 0)
  811. {
  812. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  813. {
  814. MFC10VerificationData.Clear();
  815. foreach (var item in results)
  816. {
  817. var onePoint = item.Split(',');
  818. if (onePoint != null && onePoint.Length >= 2)
  819. {
  820. MFC10VerificationData.Add(new MFCVerificationDataListItem()
  821. {
  822. Setpoint = Convert.ToSingle(onePoint[0]),
  823. CalculateValue = Convert.ToSingle(onePoint[1]),
  824. });
  825. }
  826. }
  827. }));
  828. }
  829. }
  830. _MFC10VerificationResult = value;
  831. }
  832. }
  833. private string _MFC11VerificationResult;
  834. [Subscription("MfcGas11.VerificationResult")]
  835. public string MFC11VerificationResult
  836. {
  837. get
  838. {
  839. return _MFC11VerificationResult;
  840. }
  841. set
  842. {
  843. if (_MFC11VerificationResult != value)
  844. {
  845. var results = value.Split(';');
  846. if (results != null && results.Length > 0)
  847. {
  848. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  849. {
  850. MFC11VerificationData.Clear();
  851. foreach (var item in results)
  852. {
  853. var onePoint = item.Split(',');
  854. if (onePoint != null && onePoint.Length >= 2)
  855. {
  856. MFC11VerificationData.Add(new MFCVerificationDataListItem()
  857. {
  858. Setpoint = Convert.ToSingle(onePoint[0]),
  859. CalculateValue = Convert.ToSingle(onePoint[1]),
  860. });
  861. }
  862. }
  863. }));
  864. }
  865. }
  866. _MFC11VerificationResult = value;
  867. }
  868. }
  869. private string _MFC12VerificationResult;
  870. [Subscription("MfcGas12.VerificationResult")]
  871. public string MFC12VerificationResult
  872. {
  873. get
  874. {
  875. return _MFC12VerificationResult;
  876. }
  877. set
  878. {
  879. if (_MFC12VerificationResult != value)
  880. {
  881. var results = value.Split(';');
  882. if (results != null && results.Length > 0)
  883. {
  884. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  885. {
  886. MFC12VerificationData.Clear();
  887. foreach (var item in results)
  888. {
  889. var onePoint = item.Split(',');
  890. if (onePoint != null && onePoint.Length >= 2)
  891. {
  892. MFC12VerificationData.Add(new MFCVerificationDataListItem()
  893. {
  894. Setpoint = Convert.ToSingle(onePoint[0]),
  895. CalculateValue = Convert.ToSingle(onePoint[1]),
  896. });
  897. }
  898. }
  899. }));
  900. }
  901. }
  902. _MFC12VerificationResult = value;
  903. }
  904. }
  905. #endregion
  906. #endregion
  907. private string _pmStatus;
  908. [Subscription("Status")]
  909. public string PMStatus
  910. {
  911. get
  912. {
  913. return _pmStatus;
  914. }
  915. set
  916. {
  917. if (_pmStatus != value)
  918. Query();
  919. _pmStatus = value;
  920. }
  921. }
  922. [Subscription("IsOnline")]
  923. public bool IsOnline { get; set; }
  924. public string Setpoint { get; set; }
  925. public bool IsVerificationButtonEnable => PMStatus == "Idle" && !IsOnline;
  926. public bool IsPermission { get => this.Permission == 3; }
  927. public Visibility MFC1Visibility => !string.IsNullOrEmpty(MFC1VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  928. public Visibility MFC2Visibility => !string.IsNullOrEmpty(MFC2VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  929. public Visibility MFC3Visibility => !string.IsNullOrEmpty(MFC3VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  930. public Visibility MFC4Visibility => !string.IsNullOrEmpty(MFC4VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  931. public Visibility MFC5Visibility => !string.IsNullOrEmpty(MFC5VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  932. public Visibility MFC6Visibility => !string.IsNullOrEmpty(MFC6VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  933. public Visibility MFC7Visibility => !string.IsNullOrEmpty(MFC7VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  934. public Visibility MFC8Visibility => !string.IsNullOrEmpty(MFC8VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  935. public Visibility MFC9Visibility => !string.IsNullOrEmpty(MFC9VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  936. public Visibility MFC10Visibility => !string.IsNullOrEmpty(MFC10VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  937. public Visibility MFC11Visibility => !string.IsNullOrEmpty(MFC11VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  938. public Visibility MFC12Visibility => !string.IsNullOrEmpty(MFC12VerificationResult) ? Visibility.Visible : Visibility.Collapsed;
  939. public Visibility MFCQueryVisibility
  940. {
  941. get; set;
  942. }
  943. public ObservableCollection<IRenderableSeries> SelectedData { get; set; }
  944. private IRange _xValueRange;
  945. public IRange XValueRange
  946. {
  947. get { return _xValueRange; }
  948. set { _xValueRange = value; NotifyOfPropertyChange("XValueRange"); }
  949. }
  950. private IRange _yValueRange;
  951. public IRange YValueRange
  952. {
  953. get { return _yValueRange; }
  954. set { _yValueRange = value; NotifyOfPropertyChange("YValueRange"); }
  955. }
  956. public AutoRange ChartAutoRange
  957. {
  958. get { return EnableAutoZoom ? AutoRange.Always : AutoRange.Never; }
  959. }
  960. private bool _enableAutoZoom = true;
  961. public bool EnableAutoZoom
  962. {
  963. get { return _enableAutoZoom; }
  964. set
  965. {
  966. _enableAutoZoom = value;
  967. NotifyOfPropertyChange(nameof(EnableAutoZoom));
  968. NotifyOfPropertyChange(nameof(ChartAutoRange));
  969. }
  970. }
  971. private AutoRange _autoRangeX;
  972. public AutoRange AutoRangeX
  973. {
  974. get => _autoRangeX;
  975. set { _autoRangeX = value; NotifyOfPropertyChange(nameof(AutoRangeX)); }
  976. }
  977. private AutoRange _autoRangeY;
  978. public AutoRange AutoRangeY
  979. {
  980. get => _autoRangeY;
  981. set { _autoRangeY = value; NotifyOfPropertyChange(nameof(AutoRangeY)); }
  982. }
  983. public ObservableCollection<MFCVerificationDataListItem> MFC1VerificationData { get; set; }
  984. public ObservableCollection<MFCVerificationDataListItem> MFC2VerificationData { get; set; }
  985. public ObservableCollection<MFCVerificationDataListItem> MFC3VerificationData { get; set; }
  986. public ObservableCollection<MFCVerificationDataListItem> MFC4VerificationData { get; set; }
  987. public ObservableCollection<MFCVerificationDataListItem> MFC5VerificationData { get; set; }
  988. public ObservableCollection<MFCVerificationDataListItem> MFC6VerificationData { get; set; }
  989. public ObservableCollection<MFCVerificationDataListItem> MFC7VerificationData { get; set; }
  990. public ObservableCollection<MFCVerificationDataListItem> MFC8VerificationData { get; set; }
  991. public ObservableCollection<MFCVerificationDataListItem> MFC9VerificationData { get; set; }
  992. public ObservableCollection<MFCVerificationDataListItem> MFC10VerificationData { get; set; }
  993. public ObservableCollection<MFCVerificationDataListItem> MFC11VerificationData { get; set; }
  994. public ObservableCollection<MFCVerificationDataListItem> MFC12VerificationData { get; set; }
  995. public ObservableCollection<MFCVerificationErrorRateListItem> VerificationErrorRate { get; set; }
  996. public ObservableCollection<int> MFC1VerificationPoints { get; set; }
  997. public ObservableCollection<int> MFC2VerificationPoints { get; set; }
  998. public ObservableCollection<int> MFC3VerificationPoints { get; set; }
  999. public ObservableCollection<int> MFC4VerificationPoints { get; set; }
  1000. public ObservableCollection<int> MFC5VerificationPoints { get; set; }
  1001. public ObservableCollection<int> MFC6VerificationPoints { get; set; }
  1002. public ObservableCollection<int> MFC7VerificationPoints { get; set; }
  1003. public ObservableCollection<int> MFC8VerificationPoints { get; set; }
  1004. public ObservableCollection<int> MFC9VerificationPoints { get; set; }
  1005. public ObservableCollection<int> MFC10VerificationPoints { get; set; }
  1006. public ObservableCollection<int> MFC11VerificationPoints { get; set; }
  1007. public ObservableCollection<int> MFC12VerificationPoints { get; set; }
  1008. public ObservableCollection<MFCVerificationData> VerificationDataRecords { get; set; }//read form db
  1009. private MFCVerificationData selectedVerificationData;
  1010. public MFCVerificationData SelectedVerificationData
  1011. {
  1012. get { return this.selectedVerificationData; }
  1013. set
  1014. {
  1015. this.selectedVerificationData = value;
  1016. }
  1017. }
  1018. public DateTime SearchBeginTime { get; set; }
  1019. public DateTime SearchEndTime { get; set; }
  1020. private MFCVerificationView view;
  1021. protected override void OnInitialize()
  1022. {
  1023. MFC1VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1024. MFC2VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1025. MFC3VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1026. MFC4VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1027. MFC5VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1028. MFC6VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1029. MFC7VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1030. MFC8VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1031. MFC9VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1032. MFC10VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1033. MFC11VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1034. MFC12VerificationData = new ObservableCollection<MFCVerificationDataListItem>();
  1035. MFC1VerificationPoints = new ObservableCollection<int>();
  1036. MFC2VerificationPoints = new ObservableCollection<int>();
  1037. MFC3VerificationPoints = new ObservableCollection<int>();
  1038. MFC4VerificationPoints = new ObservableCollection<int>();
  1039. MFC5VerificationPoints = new ObservableCollection<int>();
  1040. MFC6VerificationPoints = new ObservableCollection<int>();
  1041. MFC7VerificationPoints = new ObservableCollection<int>();
  1042. MFC8VerificationPoints = new ObservableCollection<int>();
  1043. MFC9VerificationPoints = new ObservableCollection<int>();
  1044. MFC10VerificationPoints = new ObservableCollection<int>();
  1045. MFC11VerificationPoints = new ObservableCollection<int>();
  1046. MFC12VerificationPoints = new ObservableCollection<int>();
  1047. MFCQueryVisibility = Visibility.Collapsed;
  1048. base.OnInitialize();
  1049. YValueRange = new DoubleRange(0, 100);
  1050. SelectedData = new ObservableCollection<IRenderableSeries>();
  1051. AutoRangeX = AutoRange.Always;
  1052. AutoRangeY = AutoRange.Always;//(bool)QueryDataClient.Instance.Service.GetConfig("System.IsCycleMode");
  1053. }
  1054. protected override void OnActivate()
  1055. {
  1056. XValueRange = new DoubleRange(0, MFC1DeviceData != null ? MFC1DeviceData.Scale : 100);
  1057. base.OnActivate();
  1058. Query();
  1059. }
  1060. protected override void OnViewLoaded(object _view)
  1061. {
  1062. base.OnViewLoaded(_view);
  1063. this.view = (MFCVerificationView)_view;
  1064. this.view.wfTimeFrom.Value = this.SearchBeginTime;
  1065. this.view.wfTimeTo.Value = this.SearchEndTime;
  1066. Query();
  1067. }
  1068. protected override void OnDeactivate(bool close)
  1069. {
  1070. base.OnDeactivate(close);
  1071. }
  1072. public void StartVerification(object oj1, object oj2, object oj3)
  1073. {
  1074. string gasName = oj1.ToString();
  1075. float.TryParse(oj2.ToString(), out float flow);
  1076. int.TryParse(oj3.ToString(), out int flowCount);
  1077. InvokeClient.Instance.Service.DoOperation($"{SystemName}.MFCVerification", gasName, flow, flowCount);
  1078. }
  1079. public void AcceptAll(object o)
  1080. {
  1081. string gasName = o.ToString();
  1082. InvokeClient.Instance.Service.DoOperation($"{SystemName}.{gasName}.AcceptAllMFCVerification", gasName);
  1083. }
  1084. public void Back()
  1085. {
  1086. MFCQueryVisibility = Visibility.Collapsed;
  1087. NotifyOfPropertyChange("RFCalVisibility");
  1088. NotifyOfPropertyChange("MFCQueryVisibility");
  1089. }
  1090. public void SelectHistory()
  1091. {
  1092. if (SelectedVerificationData != null)
  1093. {
  1094. try
  1095. {
  1096. if (SelectedVerificationData.Name.Contains("Gas1"))
  1097. XValueRange = new DoubleRange(0, MFC1DeviceData.Scale);
  1098. else if (SelectedVerificationData.Name.Contains("Gas2"))
  1099. XValueRange = new DoubleRange(0, MFC2DeviceData.Scale);
  1100. else if (SelectedVerificationData.Name.Contains("Gas3"))
  1101. XValueRange = new DoubleRange(0, MFC3DeviceData.Scale);
  1102. else
  1103. XValueRange = new DoubleRange(0, MFC4DeviceData.Scale);
  1104. MFCQueryVisibility = Visibility.Visible;
  1105. NotifyOfPropertyChange("MFCQueryVisibility");
  1106. VerificationErrorRate = new ObservableCollection<MFCVerificationErrorRateListItem>();
  1107. MFCVerificationErrorRateListItem errorRate = new MFCVerificationErrorRateListItem()
  1108. {
  1109. Setpoint = SelectedVerificationData.Percent10Setpoint,
  1110. CalculateValue = SelectedVerificationData.Percent10Calculate,
  1111. ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent10Setpoint - SelectedVerificationData.Percent10Calculate) / SelectedVerificationData.Percent10Setpoint * 100, 3))
  1112. };
  1113. VerificationErrorRate.Add(errorRate);
  1114. errorRate = new MFCVerificationErrorRateListItem()
  1115. {
  1116. Setpoint = SelectedVerificationData.Percent20Setpoint,
  1117. CalculateValue = SelectedVerificationData.Percent20Calculate,
  1118. ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent20Setpoint - SelectedVerificationData.Percent20Calculate) / SelectedVerificationData.Percent20Setpoint * 100, 3))
  1119. };
  1120. VerificationErrorRate.Add(errorRate);
  1121. errorRate = new MFCVerificationErrorRateListItem()
  1122. {
  1123. Setpoint = SelectedVerificationData.Percent30Setpoint,
  1124. CalculateValue = SelectedVerificationData.Percent30Calculate,
  1125. ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent30Setpoint - SelectedVerificationData.Percent30Calculate) / SelectedVerificationData.Percent30Setpoint * 100, 3))
  1126. };
  1127. VerificationErrorRate.Add(errorRate);
  1128. errorRate = new MFCVerificationErrorRateListItem()
  1129. {
  1130. Setpoint = SelectedVerificationData.Percent40Setpoint,
  1131. CalculateValue = SelectedVerificationData.Percent40Calculate,
  1132. ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent40Setpoint - SelectedVerificationData.Percent40Calculate) / SelectedVerificationData.Percent40Setpoint * 100, 3))
  1133. };
  1134. VerificationErrorRate.Add(errorRate);
  1135. errorRate = new MFCVerificationErrorRateListItem()
  1136. {
  1137. Setpoint = SelectedVerificationData.Percent50Setpoint,
  1138. CalculateValue = SelectedVerificationData.Percent50Calculate,
  1139. ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent50Setpoint - SelectedVerificationData.Percent50Calculate) / SelectedVerificationData.Percent50Setpoint * 100, 3))
  1140. };
  1141. VerificationErrorRate.Add(errorRate);
  1142. errorRate = new MFCVerificationErrorRateListItem()
  1143. {
  1144. Setpoint = SelectedVerificationData.Percent60Setpoint,
  1145. CalculateValue = SelectedVerificationData.Percent60Calculate,
  1146. ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent60Setpoint - SelectedVerificationData.Percent60Calculate) / SelectedVerificationData.Percent60Setpoint * 100, 3))
  1147. };
  1148. VerificationErrorRate.Add(errorRate);
  1149. errorRate = new MFCVerificationErrorRateListItem()
  1150. {
  1151. Setpoint = SelectedVerificationData.Percent70Setpoint,
  1152. CalculateValue = SelectedVerificationData.Percent70Calculate,
  1153. ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent70Setpoint - SelectedVerificationData.Percent70Calculate) / SelectedVerificationData.Percent70Setpoint * 100, 3))
  1154. };
  1155. VerificationErrorRate.Add(errorRate);
  1156. errorRate = new MFCVerificationErrorRateListItem()
  1157. {
  1158. Setpoint = SelectedVerificationData.Percent80Setpoint,
  1159. CalculateValue = SelectedVerificationData.Percent80Calculate,
  1160. ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent80Setpoint - SelectedVerificationData.Percent80Calculate) / SelectedVerificationData.Percent80Setpoint * 100, 3))
  1161. };
  1162. VerificationErrorRate.Add(errorRate);
  1163. errorRate = new MFCVerificationErrorRateListItem()
  1164. {
  1165. Setpoint = SelectedVerificationData.Percent90Setpoint,
  1166. CalculateValue = SelectedVerificationData.Percent90Calculate,
  1167. ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent90Setpoint - SelectedVerificationData.Percent90Calculate) / SelectedVerificationData.Percent90Setpoint * 100, 3))
  1168. };
  1169. VerificationErrorRate.Add(errorRate);
  1170. errorRate = new MFCVerificationErrorRateListItem()
  1171. {
  1172. Setpoint = SelectedVerificationData.Percent100Setpoint,
  1173. CalculateValue = SelectedVerificationData.Percent100Calculate,
  1174. ErrorRate = Math.Abs((float)Math.Round((SelectedVerificationData.Percent100Setpoint - SelectedVerificationData.Percent100Calculate) / SelectedVerificationData.Percent100Setpoint * 100, 3))
  1175. };
  1176. VerificationErrorRate.Add(errorRate);//SelectedData
  1177. ChartDataLine line = new ChartDataLine("MFCCalibration");
  1178. VerificationErrorRate.ToList().ForEach(x => line.Append(x.Setpoint, x.ErrorRate));
  1179. //foreach(var item in VerificationErrorRate)
  1180. //{
  1181. // line.Append(item.Setpoint,item.ErrorRate);
  1182. //}
  1183. SelectedData.Clear();
  1184. SelectedData.Add(line);
  1185. }
  1186. catch (Exception ex)
  1187. {
  1188. LOG.Write(ex);
  1189. }
  1190. }
  1191. }
  1192. /// <summary>
  1193. /// 查询
  1194. /// </summary>
  1195. public void Query()
  1196. {
  1197. if (view == null || view.wfTimeFrom == null || view.wfTimeFrom == null)
  1198. return;
  1199. try
  1200. {
  1201. this.SearchBeginTime = (System.DateTime)this.view.wfTimeFrom.Value;
  1202. this.SearchEndTime = (System.DateTime)this.view.wfTimeTo.Value;
  1203. if (SearchBeginTime > SearchEndTime)
  1204. {
  1205. MessageBox.Show("Time range invalid, start time should be early than end time");
  1206. return;
  1207. }
  1208. string sql = string.Format(
  1209. "SELECT * FROM \"mfc_verification_data\" where \"operate_time\" >= '{0}' and \"operate_time\" <= '{1}' and \"module\" = '{2}' order by \"operate_time\" ASC;",
  1210. SearchBeginTime.ToString("yyyyMMdd HHmmss"), SearchEndTime.ToString("yyyyMMdd HHmmss"), SystemName);
  1211. var result = QueryDataClient.Instance.Service.QueryData(sql);
  1212. Application.Current.Dispatcher.BeginInvoke(new Action(() =>
  1213. {
  1214. VerificationDataRecords = new ObservableCollection<MFCVerificationData>();
  1215. for (int i = 0; i < result.Rows.Count; i++)
  1216. {
  1217. MFCVerificationData data = new MFCVerificationData()
  1218. {
  1219. Module = result.Rows[i]["module"].ToString(),
  1220. Name = result.Rows[i]["name"].ToString(),
  1221. Time = ((DateTime)result.Rows[i]["operate_time"]).ToString("yyyy/MM/dd HH:mm:ss.fff"),
  1222. Percent10Setpoint = float.Parse(result.Rows[i]["percent10_setpoint"].ToString()),
  1223. Percent10Calculate = float.Parse(result.Rows[i]["percent10_calculate"].ToString()),
  1224. Percent20Setpoint = float.Parse(result.Rows[i]["percent20_setpoint"].ToString()),
  1225. Percent20Calculate = float.Parse(result.Rows[i]["percent20_calculate"].ToString()),
  1226. Percent30Setpoint = float.Parse(result.Rows[i]["percent30_setpoint"].ToString()),
  1227. Percent30Calculate = float.Parse(result.Rows[i]["percent30_calculate"].ToString()),
  1228. Percent40Setpoint = float.Parse(result.Rows[i]["percent40_setpoint"].ToString()),
  1229. Percent40Calculate = float.Parse(result.Rows[i]["percent40_calculate"].ToString()),
  1230. Percent50Setpoint = float.Parse(result.Rows[i]["percent50_setpoint"].ToString()),
  1231. Percent50Calculate = float.Parse(result.Rows[i]["percent50_calculate"].ToString()),
  1232. Percent60Setpoint = float.Parse(result.Rows[i]["percent60_setpoint"].ToString()),
  1233. Percent60Calculate = float.Parse(result.Rows[i]["percent60_calculate"].ToString()),
  1234. Percent70Setpoint = float.Parse(result.Rows[i]["percent70_setpoint"].ToString()),
  1235. Percent70Calculate = float.Parse(result.Rows[i]["percent70_calculate"].ToString()),
  1236. Percent80Setpoint = float.Parse(result.Rows[i]["percent80_setpoint"].ToString()),
  1237. Percent80Calculate = float.Parse(result.Rows[i]["percent80_calculate"].ToString()),
  1238. Percent90Setpoint = float.Parse(result.Rows[i]["percent90_setpoint"].ToString()),
  1239. Percent90Calculate = float.Parse(result.Rows[i]["percent90_calculate"].ToString()),
  1240. Percent100Setpoint = float.Parse(result.Rows[i]["percent100_setpoint"].ToString()),
  1241. Percent100Calculate = float.Parse(result.Rows[i]["percent100_calculate"].ToString()),
  1242. Setpoint = float.Parse(result.Rows[i]["setpoint"].ToString()),
  1243. Calculate = float.Parse(result.Rows[i]["calculate"].ToString()),
  1244. };
  1245. VerificationDataRecords.Add(data);
  1246. }
  1247. NotifyOfPropertyChange("VerificationDataRecords");
  1248. }));
  1249. }
  1250. catch (Exception ex)
  1251. {
  1252. LOG.Write(ex);
  1253. }
  1254. }
  1255. public void SetAsCurrent(object o)
  1256. {
  1257. int.TryParse(o.ToString(), out int selectIndex);
  1258. if (selectIndex < 0 || selectIndex >= VerificationDataRecords.Count)
  1259. {
  1260. MessageBox.Show("Please select a row to set.", "Calibration", MessageBoxButton.OK, MessageBoxImage.Warning);
  1261. return;
  1262. }
  1263. InvokeClient.Instance.Service.DoOperation($"{SystemName}.{VerificationDataRecords[selectIndex].Name}.UpdateCalibrationInfo",
  1264. VerificationDataRecords[selectIndex].Percent10Calculate,
  1265. VerificationDataRecords[selectIndex].Percent20Calculate,
  1266. VerificationDataRecords[selectIndex].Percent30Calculate,
  1267. VerificationDataRecords[selectIndex].Percent40Calculate,
  1268. VerificationDataRecords[selectIndex].Percent50Calculate,
  1269. VerificationDataRecords[selectIndex].Percent60Calculate,
  1270. VerificationDataRecords[selectIndex].Percent70Calculate,
  1271. VerificationDataRecords[selectIndex].Percent80Calculate,
  1272. VerificationDataRecords[selectIndex].Percent90Calculate,
  1273. VerificationDataRecords[selectIndex].Percent100Calculate);
  1274. }
  1275. public void Abort()
  1276. {
  1277. InvokeClient.Instance.Service.DoOperation($"{SystemName}.Abort");
  1278. }
  1279. }
  1280. public class ChartDataLine : FastLineRenderableSeries, INotifyPropertyChanged
  1281. {
  1282. #region PropertyChanged
  1283. public event PropertyChangedEventHandler PropertyChanged;
  1284. public void InvokePropertyChanged(string propertyName)
  1285. {
  1286. PropertyChangedEventArgs eventArgs = new PropertyChangedEventArgs(propertyName);
  1287. PropertyChangedEventHandler changed = PropertyChanged;
  1288. if (changed != null)
  1289. {
  1290. changed(this, eventArgs);
  1291. }
  1292. }
  1293. public void InvokePropertyChanged()
  1294. {
  1295. Type t = this.GetType();
  1296. var ps = t.GetProperties();
  1297. foreach (var p in ps)
  1298. {
  1299. InvokePropertyChanged(p.Name);
  1300. }
  1301. }
  1302. #endregion
  1303. public string UniqueId { get; set; }
  1304. public List<Tuple<double, double>> Points
  1305. {
  1306. get
  1307. {
  1308. lock (_lockData)
  1309. {
  1310. return _queueRawData.ToList();
  1311. }
  1312. }
  1313. }
  1314. public string DataSource { get; set; }
  1315. public string DataName { get; set; }
  1316. public string DisplayName
  1317. {
  1318. get
  1319. {
  1320. return DataSeries.SeriesName;
  1321. }
  1322. set
  1323. {
  1324. DataSeries.SeriesName = value;
  1325. }
  1326. }
  1327. public double LineThickness
  1328. {
  1329. get
  1330. {
  1331. return StrokeThickness;
  1332. }
  1333. set
  1334. {
  1335. var i = Convert.ToInt32(value);
  1336. if (i < 1) i = 1;
  1337. if (i > 100) i = 100;
  1338. StrokeThickness = i;
  1339. InvokePropertyChanged("LineThickness");
  1340. }
  1341. }
  1342. private double _dataFactor = 1.0;
  1343. public double DataFactor
  1344. {
  1345. get => _dataFactor;
  1346. set
  1347. {
  1348. if (Math.Abs(_dataFactor - value) > 0.001)
  1349. {
  1350. _dataFactor = value;
  1351. InvokePropertyChanged(nameof(DataFactor));
  1352. UpdateChartSeriesValue();
  1353. }
  1354. }
  1355. }
  1356. private double _dataOffset = 0;
  1357. public double DataOffset
  1358. {
  1359. get => _dataOffset;
  1360. set
  1361. {
  1362. if (Math.Abs(_dataOffset - value) > 0.001)
  1363. {
  1364. _dataOffset = value;
  1365. InvokePropertyChanged(nameof(DataFactor));
  1366. UpdateChartSeriesValue();
  1367. }
  1368. }
  1369. }
  1370. private int _capacity = 10000;
  1371. public int Capacity
  1372. {
  1373. get { return _capacity; }
  1374. set
  1375. {
  1376. _capacity = value;
  1377. DataSeries.FifoCapacity = value;
  1378. }
  1379. }
  1380. private object _lockData = new object();
  1381. private FixSizeQueue<Tuple<double, double>> _queueRawData;
  1382. public ChartDataLine(string dataName)
  1383. : this(dataName, dataName, Colors.Blue)
  1384. {
  1385. }
  1386. public ChartDataLine(string dataName, string displayName, Color seriesColor)
  1387. {
  1388. UniqueId = Guid.NewGuid().ToString();
  1389. _queueRawData = new FixSizeQueue<Tuple<double, double>>(_capacity);
  1390. XAxisId = "DefaultAxisId";
  1391. YAxisId = "DefaultAxisId";
  1392. DataSeries = new XyDataSeries<double, double>(_capacity);
  1393. DisplayName = displayName;
  1394. DataName = dataName;
  1395. Stroke = seriesColor;
  1396. IsVisible = true;
  1397. DataOffset = 0;
  1398. LineThickness = 1;
  1399. DataFactor = 1;
  1400. }
  1401. public void Append(double dt, double value)
  1402. {
  1403. lock (_lockData)
  1404. {
  1405. _queueRawData.Enqueue(Tuple.Create(dt, value));
  1406. (DataSeries as XyDataSeries<double, double>)?.Append(dt, value * _dataFactor + _dataOffset);
  1407. }
  1408. }
  1409. public void UpdateChartSeriesValue()
  1410. {
  1411. lock (_lockData)
  1412. {
  1413. using (DataSeries.SuspendUpdates())
  1414. {
  1415. XyDataSeries<double, double> s = DataSeries as XyDataSeries<double, double>;
  1416. for (int i = 0; i < s.Count; i++)
  1417. {
  1418. s.Update(i, _queueRawData.ElementAt(i).Item2 * _dataFactor + _dataOffset);
  1419. }
  1420. }
  1421. }
  1422. }
  1423. public void ClearData()
  1424. {
  1425. lock (_lockData)
  1426. {
  1427. _queueRawData.Clear();
  1428. (DataSeries as XyDataSeries<double, double>)?.Clear();
  1429. }
  1430. }
  1431. }
  1432. }