LeakCheckViewModel.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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 LeakRateSCCount
  73. {
  74. get;
  75. set;
  76. }
  77. [IgnorePropertyChange]
  78. public string LeakCheckFlowScale
  79. {
  80. get;
  81. set;
  82. }
  83. [Subscription("IoMfc.MfcGas1.IsEnable")]
  84. public bool MfcGas1Enable
  85. {
  86. get;
  87. set;
  88. }
  89. [Subscription("IoMfc.MfcGas2.IsEnable")]
  90. public bool MfcGas2Enable
  91. {
  92. get;
  93. set;
  94. }
  95. [Subscription("IoMfc.MfcGas3.IsEnable")]
  96. public bool MfcGas3Enable
  97. {
  98. get;
  99. set;
  100. }
  101. [Subscription("IoMfc.MfcGas4.IsEnable")]
  102. public bool MfcGas4Enable
  103. {
  104. get;
  105. set;
  106. }
  107. [Subscription("IoMfc.MfcGas5.IsEnable")]
  108. public bool MfcGas5Enable
  109. {
  110. get;
  111. set;
  112. }
  113. private bool _enableGasLine1;
  114. public bool EnableGasLine1
  115. {
  116. get
  117. {
  118. return _enableGasLine1;
  119. }
  120. set
  121. {
  122. _enableGasLine1 = value;
  123. NotifyOfPropertyChange("EnableGasLine1");
  124. }
  125. }
  126. private bool _enableGasLine2;
  127. public bool EnableGasLine2
  128. {
  129. get
  130. {
  131. return _enableGasLine2;
  132. }
  133. set
  134. {
  135. _enableGasLine2 = value;
  136. NotifyOfPropertyChange("EnableGasLine2");
  137. }
  138. }
  139. private bool _enableGasLine3;
  140. public bool EnableGasLine3
  141. {
  142. get
  143. {
  144. return _enableGasLine3;
  145. }
  146. set
  147. {
  148. _enableGasLine3 = value;
  149. NotifyOfPropertyChange("EnableGasLine3");
  150. }
  151. }
  152. private bool _enableGasLine4;
  153. public bool EnableGasLine4
  154. {
  155. get
  156. {
  157. return _enableGasLine4;
  158. }
  159. set
  160. {
  161. _enableGasLine4 = value;
  162. NotifyOfPropertyChange("EnableGasLine4");
  163. }
  164. }
  165. private bool _enableGasLine5;
  166. public bool EnableGasLine5
  167. {
  168. get
  169. {
  170. return _enableGasLine5;
  171. }
  172. set
  173. {
  174. _enableGasLine5 = value;
  175. NotifyOfPropertyChange("EnableGasLine5");
  176. }
  177. }
  178. [Subscription(VirgoDevice.ProcessGauge)]
  179. public AITPressureMeterData ProcessGauge { get; set; }
  180. [Subscription(VirgoDevice.PressureGauge)]
  181. public AITPressureMeterData PressureGauge { get; set; }
  182. [Subscription(VirgoDevice.ForelineGauge)]
  183. public AITPressureMeterData ForelineGauge { get; set; }
  184. [Subscription("LeakCheckElapseTime")]
  185. public string LeakCheckElapseTime
  186. {
  187. get;
  188. set;
  189. }
  190. public List<LeakCheckResultItem> LeakCheckResultList
  191. {
  192. get;
  193. set;
  194. }
  195. [Subscription("IsAutoMode")]
  196. public bool IsAutoMode
  197. {
  198. get;
  199. set;
  200. }
  201. [Subscription(StateData.PMState)]
  202. public int PMStatus
  203. {
  204. get;
  205. set;
  206. }
  207. public string Status
  208. {
  209. get
  210. {
  211. return ((PMState)PMStatus).ToString();
  212. }
  213. }
  214. public string Pressure
  215. {
  216. get
  217. {
  218. return ProcessGauge == null ? "0" : ProcessGauge.FeedBack.ToString("F0") + ProcessGauge.Unit;
  219. }
  220. }
  221. public bool IsLeakCheck
  222. {
  223. get
  224. {
  225. return (PMState)PMStatus == PMState.LeakCheck;
  226. }
  227. }
  228. public bool IsManualMode
  229. {
  230. get
  231. {
  232. return !IsAutoMode;
  233. }
  234. }
  235. public bool IsEnableLeakCheck
  236. {
  237. get
  238. {
  239. return !IsAutoMode && (PMState)PMStatus == PMState.Idle;
  240. }
  241. }
  242. public LeakCheckResultItem CurrentLeakCheckResultItem
  243. {
  244. get;
  245. set;
  246. }
  247. F_TRIG _trigLeakCheckFinished = new F_TRIG();
  248. #endregion
  249. public LeakCheckViewModel()
  250. {
  251. LeakCheckModeSetPoint = LeakCheckMode.ChamberOnly.ToString();
  252. EnableGasLine1 = true;
  253. EnableGasLine2 = true;
  254. EnableGasLine3 = true;
  255. EnableGasLine4 = true;
  256. EnableGasLine5 = true;
  257. NotifyOfPropertyChange("EnableGasLine1");
  258. NotifyOfPropertyChange("EnableGasLine2");
  259. NotifyOfPropertyChange("EnableGasLine3");
  260. NotifyOfPropertyChange("EnableGasLine4");
  261. NotifyOfPropertyChange("EnableGasLine5");
  262. }
  263. protected override void OnInitialize()
  264. {
  265. base.OnInitialize();
  266. }
  267. protected override void OnActivate()
  268. {
  269. base.OnActivate();
  270. LeakCheckPumpDownTimeSetPoint = QueryDataClient.Instance.Service.GetConfig($"{SystemName}.Pump.LeakCheckPumpingTime").ToString();
  271. LeakCheckTimeSetPoint = QueryDataClient.Instance.Service.GetConfig($"{SystemName}.Pump.LeakCheckWaitTime").ToString();
  272. LeakRateUpperLimitSetPoint = ((float)(double)QueryDataClient.Instance.Service.GetConfig($"{SystemName}.Pump.LeakRate")).ToString();
  273. LeakRateSCCount = ((int)QueryDataClient.Instance.Service.GetConfig($"{SystemName}.Pump.LeakCheckSCCount")).ToString();
  274. }
  275. public void UpdateLeakCheckResult(string Module)
  276. {
  277. LeakCheckResultList = QueryDataClient.Instance.Service.GetHistoryLeakCheck(Module);
  278. InvokePropertyChanged("LeakCheckResultList");
  279. }
  280. protected override void InvokeBeforeUpdateProperty(Dictionary<string, object> data)
  281. {
  282. MenuPermission = ClientApp.Instance.GetPermission($"LeakCheck{SystemName}");
  283. if (!MfcGas1Enable) EnableGasLine1 = false;
  284. if (!MfcGas2Enable) EnableGasLine2 = false;
  285. if (!MfcGas3Enable) EnableGasLine3 = false;
  286. if (!MfcGas4Enable) EnableGasLine4 = false;
  287. if (!MfcGas5Enable) EnableGasLine5 = false;
  288. _trigLeakCheckFinished.CLK = IsLeakCheck;
  289. if (_trigLeakCheckFinished.Q)
  290. {
  291. Application.Current.Dispatcher.Invoke(new Action(() =>
  292. {
  293. UpdateLeakCheckResult(SystemName);
  294. }));
  295. }
  296. }
  297. protected override void InvokeAfterUpdateProperty(Dictionary<string, object> data)
  298. {
  299. if (CurrentLeakCheckResultItem == null)
  300. {
  301. UpdateLeakCheckResult(SystemName);
  302. ;
  303. }
  304. }
  305. public void LeakCheck()
  306. {
  307. if (MenuPermission != 3) return;
  308. if (!IsLeakCheck)
  309. {
  310. InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{SystemName}.Pump.LeakCheckPumpingTime", LeakCheckPumpDownTimeSetPoint.ToString());
  311. InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{SystemName}.Pump.LeakCheckWaitTime", LeakCheckTimeSetPoint.ToString());
  312. InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{SystemName}.Pump.LeakRate", LeakRateUpperLimitSetPoint.ToString());
  313. InvokeClient.Instance.Service.DoOperation("System.SetConfig", $"{SystemName}.Pump.LeakCheckSCCount", LeakRateSCCount.ToString());
  314. InvokeClient.Instance.Service.DoOperation($"{SystemName}.LeakCheck", new[]
  315. {
  316. LeakCheckPumpDownTimeSetPoint,
  317. LeakCheckTimeSetPoint,
  318. LeakCheckModeSetPoint,
  319. LeakRateUpperLimitSetPoint,
  320. EnableGasLine1.ToString(),
  321. EnableGasLine2.ToString(),
  322. EnableGasLine3.ToString(),
  323. EnableGasLine4.ToString(),
  324. EnableGasLine5.ToString(),
  325. });
  326. }
  327. }
  328. public void AbortLeakCheck()
  329. {
  330. if (MenuPermission != 3) return;
  331. if (MessageBox.Show("是否确认停止检漏?", "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  332. InvokeClient.Instance.Service.DoOperation($"{SystemName}.Abort");
  333. }
  334. public void DeleteLeakCheck()
  335. {
  336. if (MenuPermission != 3) return;
  337. if (CurrentLeakCheckResultItem == null)
  338. {
  339. MessageBox.Show("请先选择要删除的检漏记录", "JetPlasma", MessageBoxButton.OK);
  340. return;
  341. }
  342. if (MessageBox.Show("是否确认删除当前检漏记录?", "JetPlasma", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
  343. InvokeClient.Instance.Service.DoOperation($"{SystemName}.DeleteLeakCheck", CurrentLeakCheckResultItem.Id);
  344. CurrentLeakCheckResultItem = null;
  345. }
  346. }
  347. }