LeakCheckViewModel.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Input;
  7. using Aitex.Core.Common.DeviceData;
  8. using Aitex.Core.UI.MVVM;
  9. using Aitex.Core.Util;
  10. using Aitex.Core.Utilities;
  11. using Aitex.Triton160.Common;
  12. using Aitex.Triton160.UI.Wcf;
  13. namespace Aitex.Triton160.UI.ViewModel
  14. {
  15. class LeakCheckViewModel : UIViewModelBase
  16. {
  17. public ICommand LeakCheckCommand
  18. {
  19. get;
  20. private set;
  21. }
  22. public ICommand AbortCommand
  23. {
  24. get;
  25. private set;
  26. }
  27. public ICommand DeleteCommand
  28. {
  29. get;
  30. private set;
  31. }
  32. public List<LeakCheckResultItem> LeakCheckResultList
  33. {
  34. get;
  35. set;
  36. }
  37. #region StateData
  38. [Subscription(StateData.IsAutoMode, SystemStateModule)]
  39. public bool IsAutoMode
  40. {
  41. get;
  42. set;
  43. }
  44. [Subscription(TritonDevice.PressureMeterChamber, SystemDeviceModule)]
  45. public AITPressureMeterData ChamberPressure
  46. {
  47. get;
  48. set;
  49. }
  50. [Subscription(StateData.PMState, SystemStateModule)]
  51. public int PMStatus
  52. {
  53. get;
  54. set;
  55. }
  56. [Subscription(StateData.LeakCheckElapseTime, SystemStateModule)]
  57. public string LeakCheckElapseTime
  58. {
  59. get;
  60. set;
  61. }
  62. #endregion
  63. #region logic display
  64. public bool IsManualMode
  65. {
  66. get
  67. {
  68. return !IsAutoMode;
  69. }
  70. }
  71. public bool IsEnableLeakCheck
  72. {
  73. get
  74. {
  75. return !IsAutoMode && (PMState)PMStatus == PMState.Idle;
  76. }
  77. }
  78. [IgnorePropertyChange]
  79. public string LeakCheckModeSetPoint
  80. {
  81. get; set;
  82. }
  83. public bool IsEnableGasLine
  84. {
  85. get
  86. {
  87. return LeakCheckModeSetPoint == "ChamberAndGasLine";
  88. }
  89. }
  90. [IgnorePropertyChange]
  91. public string LeakCheckPumpDownTimeSetPoint
  92. {
  93. get;
  94. set;
  95. }
  96. [IgnorePropertyChange]
  97. public string LeakCheckTimeSetPoint
  98. {
  99. get;
  100. set;
  101. }
  102. [IgnorePropertyChange]
  103. public bool EnableGasLine1
  104. {
  105. get;
  106. set;
  107. }
  108. [IgnorePropertyChange]
  109. public bool EnableGasLine2
  110. {
  111. get;
  112. set;
  113. }
  114. [IgnorePropertyChange]
  115. public bool EnableGasLine3
  116. {
  117. get;
  118. set;
  119. }
  120. [IgnorePropertyChange]
  121. public bool EnableGasLine4
  122. {
  123. get;
  124. set;
  125. }
  126. [IgnorePropertyChange]
  127. public bool EnableGasLine5
  128. {
  129. get;
  130. set;
  131. }
  132. public bool IsLeakCheck
  133. {
  134. get
  135. {
  136. return (PMState)PMStatus == PMState.LeakCheck;
  137. }
  138. }
  139. public string Status
  140. {
  141. get
  142. {
  143. return ((PMState) PMStatus).ToString();
  144. }
  145. }
  146. public string Pressure
  147. {
  148. get
  149. {
  150. return ChamberPressure==null ? "0" : ChamberPressure.FeedBack.ToString("F0") + ChamberPressure.Unit;
  151. }
  152. }
  153. [IgnorePropertyChange]
  154. public LeakCheckResultItem CurrentLeakCheckResultItem
  155. {
  156. get; set;
  157. }
  158. F_TRIG _trigLeakCheckFinished = new F_TRIG();
  159. #endregion
  160. public LeakCheckViewModel()
  161. : base("LeakCheckViewModel")
  162. {
  163. LeakCheckCommand = new DelegateCommand<object>(LeakCheck);
  164. AbortCommand = new DelegateCommand<object>(AbortLeakCheck);
  165. DeleteCommand = new DelegateCommand<object>(DeleteLeakCheck);
  166. LeakCheckModeSetPoint = LeakCheckMode.ChamberOnly.ToString();
  167. LeakCheckPumpDownTimeSetPoint = "3";
  168. LeakCheckTimeSetPoint = "3";
  169. EnableGasLine1 = true;
  170. EnableGasLine2 = true;
  171. EnableGasLine3 = true;
  172. EnableGasLine4 = true;
  173. EnableGasLine5 = true;
  174. InvokePropertyChanged("LeakCheckModeSetPoint");
  175. InvokePropertyChanged("LeakCheckPumpDownTimeSetPoint");
  176. InvokePropertyChanged("LeakCheckTimeSetPoint");
  177. InvokePropertyChanged("EnableGasLine1");
  178. InvokePropertyChanged("EnableGasLine2");
  179. InvokePropertyChanged("EnableGasLine3");
  180. InvokePropertyChanged("EnableGasLine4");
  181. InvokePropertyChanged("EnableGasLine5");
  182. }
  183. public void UpdateLeakCheckResult()
  184. {
  185. LeakCheckResultList = Triton160UiSystem.Instance.WCF.Query.GetHistoryLeakCheck();
  186. InvokePropertyChanged("LeakCheckResultList");
  187. }
  188. protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  189. {
  190. _trigLeakCheckFinished.CLK = IsLeakCheck;
  191. if (_trigLeakCheckFinished.Q)
  192. {
  193. Application.Current.Dispatcher.Invoke(new Action(() =>
  194. {
  195. UpdateLeakCheckResult();
  196. }));
  197. }
  198. }
  199. private void LeakCheck(object param)
  200. {
  201. WcfClient.Instance.InvokeService_DoOperation(
  202. TritonOperation.LeakCheck.ToString(), new[]
  203. {
  204. LeakCheckPumpDownTimeSetPoint,
  205. LeakCheckTimeSetPoint,
  206. LeakCheckModeSetPoint,
  207. EnableGasLine1.ToString(),
  208. EnableGasLine2.ToString(),
  209. EnableGasLine3.ToString(),
  210. EnableGasLine4.ToString(),
  211. EnableGasLine5.ToString(),
  212. });
  213. }
  214. private void AbortLeakCheck(object param)
  215. {
  216. if (MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.LeakCheckViewModel_AbortLeakCheck_DoYouWantToStopCurrentLeakCheckRunning, "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  217. WcfClient.Instance.InvokeService_DoOperation(TritonOperation.Abort.ToString());
  218. }
  219. private void DeleteLeakCheck(object param)
  220. {
  221. if (CurrentLeakCheckResultItem == null)
  222. {
  223. MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.LeakCheckViewModel_DeleteLeakCheck_DidNotSelectLeakCheckResult, "JetPlasma", MessageBoxButton.OK);
  224. return;
  225. }
  226. if (MessageBox.Show(Aitex.Triton160.UI.Properties.Resources.LeakCheckViewModel_DeleteLeakCheck_DoYouWantToDeleteCurrentLeakCheckResult, "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  227. WcfClient.Instance.InvokeService_DoOperation(TritonOperation.DeleteLeakCheck.ToString(), CurrentLeakCheckResultItem.Id);
  228. UpdateLeakCheckResult();
  229. }
  230. }
  231. }