LeakCheckViewModel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.Linq;
  6. using System.Windows;
  7. using Aitex.Core.RT.Log;
  8. using Aitex.Core.UI.ControlDataContext;
  9. using Aitex.Core.Utilities;
  10. using Aitex.Sorter.Common;
  11. using VirgoUI.Client.Models.Sys;
  12. using MECF.Framework.Common.DataCenter;
  13. using OpenSEMI.ClientBase;
  14. using OpenSEMI.ClientBase.IO;
  15. using ExcelLibrary.SpreadSheet;
  16. using MECF.Framework.Common.OperationCenter;
  17. using Aitex.Core.Util;
  18. using VirgoCommon;
  19. using Aitex.Core.Common.DeviceData;
  20. using Aitex.Core.RT.SCCore;
  21. namespace VirgoUI.Client.Models.PMs
  22. {
  23. public class LeakCheckViewModel : ModuleUiViewModelBase, ISupportMultipleSystem
  24. {
  25. #region
  26. private int MenuPermission;
  27. private bool _isEnableGasLine;
  28. public bool IsEnableGasLine
  29. {
  30. get
  31. {
  32. return (LeakCheckModeSetPoint == "ChamberAndGasLine" || LeakCheckModeSetPoint == "ChamberAndGasLineAndFAC") && IsLeakCheckEnabled;
  33. }
  34. set
  35. {
  36. _isEnableGasLine = value;
  37. NotifyOfPropertyChange("IsEnableGasLine");
  38. }
  39. }
  40. public bool IsLeakCheckEnabled
  41. {
  42. get
  43. {
  44. return IsManualMode && !IsLeakCheck;
  45. }
  46. }
  47. [IgnorePropertyChange]
  48. public string LeakCheckModeSetPoint
  49. {
  50. get;
  51. set;
  52. }
  53. [IgnorePropertyChange]
  54. public string LeakCheckPumpDownTimeSetPoint
  55. {
  56. get;
  57. set;
  58. }
  59. [IgnorePropertyChange]
  60. public string LeakCheckTimeSetPoint
  61. {
  62. get;
  63. set;
  64. }
  65. [IgnorePropertyChange]
  66. public string LeakRateUpperLimitSetPoint
  67. {
  68. get;
  69. set;
  70. }
  71. [IgnorePropertyChange]
  72. public string LeakCheckFlowScale
  73. {
  74. get;
  75. set;
  76. }
  77. [Subscription("IoMfc.MfcGas1.IsEnable")]
  78. public bool MfcGas1Enable
  79. {
  80. get;
  81. set;
  82. }
  83. [Subscription("IoMfc.MfcGas2.IsEnable")]
  84. public bool MfcGas2Enable
  85. {
  86. get;
  87. set;
  88. }
  89. [Subscription("IoMfc.MfcGas3.IsEnable")]
  90. public bool MfcGas3Enable
  91. {
  92. get;
  93. set;
  94. }
  95. [Subscription("IoMfc.MfcGas4.IsEnable")]
  96. public bool MfcGas4Enable
  97. {
  98. get;
  99. set;
  100. }
  101. [Subscription("IoMfc.MfcGas5.IsEnable")]
  102. public bool MfcGas5Enable
  103. {
  104. get;
  105. set;
  106. }
  107. private bool _enableGasLine1;
  108. public bool EnableGasLine1
  109. {
  110. get
  111. {
  112. return _enableGasLine1;
  113. }
  114. set
  115. {
  116. _enableGasLine1 = value;
  117. NotifyOfPropertyChange("EnableGasLine1");
  118. }
  119. }
  120. private bool _enableGasLine2;
  121. public bool EnableGasLine2
  122. {
  123. get
  124. {
  125. return _enableGasLine2;
  126. }
  127. set
  128. {
  129. _enableGasLine2 = value;
  130. NotifyOfPropertyChange("EnableGasLine2");
  131. }
  132. }
  133. private bool _enableGasLine3;
  134. public bool EnableGasLine3
  135. {
  136. get
  137. {
  138. return _enableGasLine3;
  139. }
  140. set
  141. {
  142. _enableGasLine3 = value;
  143. NotifyOfPropertyChange("EnableGasLine3");
  144. }
  145. }
  146. private bool _enableGasLine4;
  147. public bool EnableGasLine4
  148. {
  149. get
  150. {
  151. return _enableGasLine4;
  152. }
  153. set
  154. {
  155. _enableGasLine4 = value;
  156. NotifyOfPropertyChange("EnableGasLine4");
  157. }
  158. }
  159. private bool _enableGasLine5;
  160. public bool EnableGasLine5
  161. {
  162. get
  163. {
  164. return _enableGasLine5;
  165. }
  166. set
  167. {
  168. _enableGasLine5 = value;
  169. NotifyOfPropertyChange("EnableGasLine5");
  170. }
  171. }
  172. [Subscription(VirgoDevice.ProcessGauge)]
  173. public AITPressureMeterData ProcessGauge { get; set; }
  174. [Subscription(VirgoDevice.PressureGauge)]
  175. public AITPressureMeterData PressureGauge { get; set; }
  176. [Subscription(VirgoDevice.ForelineGauge)]
  177. public AITPressureMeterData ForelineGauge { get; set; }
  178. [Subscription("LeakCheckElapseTime")]
  179. public string LeakCheckElapseTime
  180. {
  181. get;
  182. set;
  183. }
  184. public List<LeakCheckResultItem> LeakCheckResultList
  185. {
  186. get;
  187. set;
  188. }
  189. [Subscription("IsAutoMode")]
  190. public bool IsAutoMode
  191. {
  192. get;
  193. set;
  194. }
  195. [Subscription(StateData.PMState)]
  196. public int PMStatus
  197. {
  198. get;
  199. set;
  200. }
  201. public string Status
  202. {
  203. get
  204. {
  205. return ((PMState)PMStatus).ToString();
  206. }
  207. }
  208. public string Pressure
  209. {
  210. get
  211. {
  212. return ProcessGauge == null ? "0" : ProcessGauge.FeedBack.ToString("F0") + ProcessGauge.Unit;
  213. }
  214. }
  215. public bool IsLeakCheck
  216. {
  217. get
  218. {
  219. return (PMState)PMStatus == PMState.LeakCheck;
  220. }
  221. }
  222. public bool IsManualMode
  223. {
  224. get
  225. {
  226. return !IsAutoMode;
  227. }
  228. }
  229. public bool IsEnableLeakCheck
  230. {
  231. get
  232. {
  233. return !IsAutoMode && (PMState)PMStatus == PMState.Idle;
  234. }
  235. }
  236. public LeakCheckResultItem CurrentLeakCheckResultItem
  237. {
  238. get;
  239. set;
  240. }
  241. F_TRIG _trigLeakCheckFinished = new F_TRIG();
  242. #endregion
  243. public LeakCheckViewModel()
  244. {
  245. LeakCheckModeSetPoint = LeakCheckMode.ChamberOnly.ToString();
  246. EnableGasLine1 = true;
  247. EnableGasLine2 = true;
  248. EnableGasLine3 = true;
  249. EnableGasLine4 = true;
  250. EnableGasLine5 = true;
  251. NotifyOfPropertyChange("EnableGasLine1");
  252. NotifyOfPropertyChange("EnableGasLine2");
  253. NotifyOfPropertyChange("EnableGasLine3");
  254. NotifyOfPropertyChange("EnableGasLine4");
  255. NotifyOfPropertyChange("EnableGasLine5");
  256. }
  257. protected override void OnInitialize()
  258. {
  259. base.OnInitialize();
  260. }
  261. protected override void OnActivate()
  262. {
  263. base.OnActivate();
  264. LeakCheckPumpDownTimeSetPoint = QueryDataClient.Instance.Service.GetConfig($"{SystemName}.Pump.LeakCheckPumpingTime").ToString();
  265. LeakCheckTimeSetPoint = QueryDataClient.Instance.Service.GetConfig($"{SystemName}.Pump.LeakCheckWaitTime").ToString();
  266. LeakRateUpperLimitSetPoint = ((float)(double)QueryDataClient.Instance.Service.GetConfig($"{SystemName}.Pump.LeakRate")).ToString();
  267. }
  268. public void UpdateLeakCheckResult(string Module)
  269. {
  270. LeakCheckResultList = QueryDataClient.Instance.Service.GetHistoryLeakCheck(Module);
  271. InvokePropertyChanged("LeakCheckResultList");
  272. }
  273. protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  274. {
  275. MenuPermission = ClientApp.Instance.GetPermission($"LeakCheck{SystemName}");
  276. if (!MfcGas1Enable) EnableGasLine1 = false;
  277. if (!MfcGas2Enable) EnableGasLine2 = false;
  278. if (!MfcGas3Enable) EnableGasLine3 = false;
  279. if (!MfcGas4Enable) EnableGasLine4 = false;
  280. if (!MfcGas5Enable) EnableGasLine5 = false;
  281. _trigLeakCheckFinished.CLK = IsLeakCheck;
  282. if (_trigLeakCheckFinished.Q)
  283. {
  284. Application.Current.Dispatcher.Invoke(new Action(() =>
  285. {
  286. UpdateLeakCheckResult(SystemName);
  287. }));
  288. }
  289. }
  290. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  291. {
  292. if (CurrentLeakCheckResultItem == null)
  293. {
  294. UpdateLeakCheckResult(SystemName);
  295. ;
  296. }
  297. }
  298. public void LeakCheck()
  299. {
  300. if (MenuPermission != 3) return;
  301. if (!IsLeakCheck)
  302. {
  303. InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{SystemName}.Pump.LeakCheckPumpingTime", LeakCheckPumpDownTimeSetPoint.ToString());
  304. InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{SystemName}.Pump.LeakCheckWaitTime", LeakCheckTimeSetPoint.ToString());
  305. InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{SystemName}.Pump.LeakRate", LeakRateUpperLimitSetPoint.ToString());
  306. InvokeClient.Instance.Service.DoOperation($"{SystemName}.LeakCheck", new[]
  307. {
  308. LeakCheckPumpDownTimeSetPoint,
  309. LeakCheckTimeSetPoint,
  310. LeakCheckModeSetPoint,
  311. LeakRateUpperLimitSetPoint,
  312. EnableGasLine1.ToString(),
  313. EnableGasLine2.ToString(),
  314. EnableGasLine3.ToString(),
  315. EnableGasLine4.ToString(),
  316. EnableGasLine5.ToString(),
  317. });
  318. }
  319. }
  320. public void AbortLeakCheck()
  321. {
  322. if (MenuPermission != 3) return;
  323. if (MessageBox.Show("是否确认停止检漏?", "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  324. InvokeClient.Instance.Service.DoOperation($"{SystemName}.Abort");
  325. }
  326. public void DeleteLeakCheck()
  327. {
  328. if (MenuPermission != 3) return;
  329. if (CurrentLeakCheckResultItem == null)
  330. {
  331. MessageBox.Show("请先选择要删除的检漏记录", "JetPlasma", MessageBoxButton.OK);
  332. return;
  333. }
  334. if (MessageBox.Show("是否确认删除当前检漏记录?", "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  335. InvokeClient.Instance.Service.DoOperation($"{SystemName}.DeleteLeakCheck", CurrentLeakCheckResultItem.Id);
  336. CurrentLeakCheckResultItem = null;
  337. }
  338. }
  339. }