PMN2Purge.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.RT.Device;
  3. using Aitex.Core.RT.Device.Unit;
  4. using Aitex.Core.RT.IOCore;
  5. using Aitex.Core.RT.Log;
  6. using Aitex.Core.RT.SCCore;
  7. using Aitex.Core.Util;
  8. using DocumentFormat.OpenXml.Packaging;
  9. using DocumentFormat.OpenXml.Spreadsheet;
  10. using FurnaceRT.Devices;
  11. using FurnaceRT.Equipments.PMs.Devices;
  12. using FurnaceRT.Extraction;
  13. using MECF.Framework.Common.CommonData.SorterDefines;
  14. using MECF.Framework.Common.Equipment;
  15. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.TDK;
  16. using System;
  17. using System.Collections.Generic;
  18. using System.Diagnostics;
  19. namespace FurnaceRT.Equipments.PMs
  20. {
  21. /// <summary>
  22. /// 分布类 定义N2Purge的执行逻辑
  23. /// </summary>
  24. public partial class PMModule
  25. {
  26. private R_TRIG _trigN2UpRD = new R_TRIG();
  27. private R_TRIG _trigN2DownRD = new R_TRIG();
  28. private R_TRIG _trigN2AirUpRD = new R_TRIG();
  29. private R_TRIG _trigN2AirDownRD = new R_TRIG();
  30. private R_TRIG _trigN2AirDownTwoRD = new R_TRIG();
  31. private R_TRIG _trigSelectN2PurgeModeD = new R_TRIG();
  32. private Dictionary<string, Tuple<R_TRIG, List<Tuple<IDevice, string>>>> _n2PurgeSequenceAction;
  33. private Dictionary<string, Func<bool>> _n2PurgeSequenceStatus;
  34. private Dictionary<string, R_TRIG> _rTrigDict;
  35. private N2PurgeModeEnum _N2PurgeMode = N2PurgeModeEnum.Auto;
  36. private double _n2PurgeData = 20;
  37. private double _n2ToAirData = 185000;
  38. private N2PurgeModeEnum _currentPhase;
  39. private double _manualPhase2StabilityTime = 0;
  40. private double _manualPhase4StabilityTime = 0;
  41. private bool _enableAbortN2purge = true;
  42. private int _phase1CycleCount = 0;
  43. private int _phase1CycleCountSC = 0;
  44. private bool _canSwitchToPhase2 = true;
  45. private Dictionary<string, Stopwatch> _allTimeDict = new Dictionary<string, Stopwatch>();
  46. private void InitN2PurgeData()
  47. {
  48. DATA.Subscribe($"{Module}.N2PurgeLimitData", () => GetN2PurgeLimitData());
  49. DATA.Subscribe($"{Module}.O2DensityData", () => ConcentrationO2.Value.ToString("f3"), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  50. DATA.Subscribe($"{Module}.CheckO2Location", () => GetCheckO2Location(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  51. DATA.Subscribe($"{Module}.O2SetCheckSetPoint", () => GetO2SetCheckSetPoint(), SubscriptionAttribute.FLAG.IgnoreSaveDB);
  52. DATA.Subscribe($"{Module}.N2PurgeMode", () => SC.ContainsItem("PM1.SelectN2PurgeMode") ? SC.GetStringValue("PM1.SelectN2PurgeMode") : "");
  53. var selectN2PurgeMode = SC.ContainsItem("PM1.SelectN2PurgeMode") ? SC.GetStringValue("PM1.SelectN2PurgeMode") : "";
  54. if (!string.IsNullOrEmpty(selectN2PurgeMode))
  55. {
  56. if (selectN2PurgeMode != _N2PurgeMode.ToString())
  57. {
  58. SetN2PurgeModeAction(selectN2PurgeMode);
  59. }
  60. }
  61. var currentPhase = SC.ContainsItem("PM1.SelectN2PurgeModePhase") ? SC.GetStringValue("PM1.SelectN2PurgeModePhase") : "";
  62. if (!string.IsNullOrEmpty(currentPhase))
  63. {
  64. var enumCurrentPhase = (N2PurgeModeEnum)Enum.Parse(typeof(N2PurgeModeEnum), currentPhase);
  65. _currentPhase = enumCurrentPhase;
  66. }
  67. }
  68. private void InitN2PurgeConfigData()
  69. {
  70. _n2PurgeData = SC.ContainsItem($"System.N2PurgeData") ? SC.GetValue<double>("System.N2PurgeData") : 20;
  71. _n2ToAirData = SC.ContainsItem($"System.N2PurgeData") ? SC.GetValue<double>("System.N2ToAirData") : 185000;
  72. _enableAbortN2purge = SC.ContainsItem($"PM1.N2Purge.EnableAbortN2purge") ? SC.GetValue<bool>("PM1.N2Purge.EnableAbortN2purge") : false;
  73. _manualPhase2StabilityTime = SC.ContainsItem($"PM1.N2Purge.Manual_phase2.StabilityTime") ? SC.GetValue<double>("PM1.N2Purge.Manual_phase2.StabilityTime") : 0;
  74. _manualPhase4StabilityTime = SC.ContainsItem($"PM1.N2Purge.Manual_phase4.StabilityTime") ? SC.GetValue<double>("PM1.N2Purge.Manual_phase4.StabilityTime") : 0;
  75. _phase1CycleCountSC = SC.ContainsItem($"PM1.N2Purge.Manual_phase1.CycleCount") ? SC.GetValue<int>("PM1.N2Purge.Manual_phase1.CycleCount") : 0;
  76. _n2PurgeSequenceAction = ExtractionMethods.GetN2PurgeSequenceAction();
  77. _n2PurgeSequenceStatus = new Dictionary<string, Func<bool>>()
  78. {
  79. {"N2PurgeAIRTo20PPM",()=> GetN2PurgeAIRTo20PPMStatus()},
  80. {"N2PurgeUnder20PPM",()=> GetN2PurgeUnder20PPMStatus()},
  81. {"AIR",()=> GetN2PurgeAIRStatus()},
  82. {"DoorOpen",()=> GetN2PurgeDoorOpenStatus()},
  83. {"Foup1",()=> GetN2PurgeFoup1Status()},
  84. {"Foup2",()=> GetN2PurgeFoup2Status()},
  85. {N2PurgeModeEnum.Manual_phase1.ToString(),()=> CheckN2PurgePhase1() },
  86. {N2PurgeModeEnum.Manual_phase2.ToString(),()=> CheckN2PurgePhase2()},
  87. {N2PurgeModeEnum.Manual_phase3.ToString(),()=> CheckN2PurgePhase3() },
  88. {N2PurgeModeEnum.Manual_phase4.ToString(),()=> CheckN2PurgePhase4() },
  89. {N2PurgeModeEnum.Manual_phase5.ToString(),()=> CheckN2PurgePhase5() },
  90. };
  91. _allTimeDict = new Dictionary<string, Stopwatch>()
  92. {
  93. {N2PurgeModeEnum.Manual_phase1.ToString(),new Stopwatch() },
  94. {N2PurgeModeEnum.Manual_phase2.ToString(),new Stopwatch()},
  95. {N2PurgeModeEnum.Manual_phase3.ToString(),new Stopwatch()},
  96. {N2PurgeModeEnum.Manual_phase4.ToString(),new Stopwatch() },
  97. {N2PurgeModeEnum.Manual_phase5.ToString(),new Stopwatch() }
  98. };
  99. _rTrigDict = new Dictionary<string, R_TRIG>();
  100. }
  101. private void MonitorN2Purge()
  102. {
  103. var selectN2PurgeMode = SC.ContainsItem("PM1.SelectN2PurgeMode") ? SC.GetStringValue("PM1.SelectN2PurgeMode") : "";
  104. if (string.IsNullOrEmpty(selectN2PurgeMode))
  105. {
  106. return;
  107. }
  108. SetN2PurgeModeAction(selectN2PurgeMode);
  109. }
  110. private double GetN2PurgeLimitData()
  111. {
  112. if (_N2PurgeMode == N2PurgeModeEnum.N2PurgeMode)
  113. {
  114. return _n2PurgeData;
  115. }
  116. if (_N2PurgeMode == N2PurgeModeEnum.ATMMode)
  117. {
  118. return _n2ToAirData;
  119. }
  120. return ConcentrationO2.Value;
  121. }
  122. private void SetN2PurgeModeAction(string selectN2PurgeMode)
  123. {
  124. _N2PurgeMode = (N2PurgeModeEnum)Enum.Parse(typeof(N2PurgeModeEnum), selectN2PurgeMode);
  125. if (_N2PurgeMode == N2PurgeModeEnum.N2PurgeMode)
  126. {
  127. if (_currentPhase == N2PurgeModeEnum.Manual_phase1)
  128. {
  129. if (CheckN2PurgePhase2() && _canSwitchToPhase2)
  130. {
  131. LOG.Info($" N2PurgeMode Trigger from Manual_phase1 to Manual_phase2,O2:{ConcentrationO2.Value}");
  132. SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase2.ToString());
  133. }
  134. }
  135. else if (_currentPhase == N2PurgeModeEnum.Manual_phase2)
  136. {
  137. if (!_allTimeDict[N2PurgeModeEnum.Manual_phase2.ToString()].IsRunning && _canSwitchToPhase2)
  138. {
  139. _allTimeDict[N2PurgeModeEnum.Manual_phase2.ToString()].Restart();
  140. }
  141. var second = _allTimeDict[N2PurgeModeEnum.Manual_phase2.ToString()].Elapsed.TotalSeconds;
  142. if (second >= _manualPhase2StabilityTime)
  143. {
  144. if (CheckN2PurgePhase1())
  145. {
  146. LOG.Info($"N2PurgeMode Trigger Manual_phase1 was triggered {second} seconds later,O2:{ConcentrationO2.Value}");
  147. N2PurgeFaileAlarm.Set();
  148. _allTimeDict[N2PurgeModeEnum.Manual_phase2.ToString()].Restart();
  149. _allTimeDict[N2PurgeModeEnum.Manual_phase2.ToString()].Stop();
  150. _canSwitchToPhase2 = false;
  151. SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase1.ToString());
  152. }
  153. if (CheckN2PurgePhase2())
  154. {
  155. LOG.Info($"N2PurgeMode Trigger Hold Manual_phase2 was triggered {second} seconds later,O2:{ConcentrationO2.Value}");
  156. _allTimeDict[N2PurgeModeEnum.Manual_phase2.ToString()].Restart();
  157. _allTimeDict[N2PurgeModeEnum.Manual_phase2.ToString()].Stop();
  158. _canSwitchToPhase2 = false;
  159. }
  160. }
  161. }
  162. else
  163. {
  164. if (CheckN2PurgePhase1())
  165. {
  166. LOG.Info($"N2PurgeMode Trigger Directly triggered Manual_phase1,O2:{ConcentrationO2.Value}");
  167. SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase1.ToString());
  168. }
  169. else if (CheckN2PurgePhase2())
  170. {
  171. LOG.Info($"N2PurgeMode Trigger Directly triggered Manual_phase2,O2:{ConcentrationO2.Value}");
  172. SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase2.ToString());
  173. }
  174. }
  175. }
  176. if (_N2PurgeMode == N2PurgeModeEnum.ATMMode)
  177. {
  178. if (_currentPhase == N2PurgeModeEnum.Manual_phase3)
  179. {
  180. var checkResult = CheckN2PurgePhase4();
  181. if (!_allTimeDict[N2PurgeModeEnum.Manual_phase4.ToString()].IsRunning)
  182. {
  183. _allTimeDict[N2PurgeModeEnum.Manual_phase4.ToString()].Restart();
  184. }
  185. var second = _allTimeDict[N2PurgeModeEnum.Manual_phase4.ToString()].Elapsed.TotalSeconds;
  186. if (second >= _manualPhase4StabilityTime && checkResult)
  187. {
  188. LOG.Info($"N2PurgeMode Trigger from Manual_phase3 to Manual_phase4 is triggered {second} seconds later,O2:{ConcentrationO2.Value}");
  189. SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase4.ToString());
  190. _allTimeDict[N2PurgeModeEnum.Manual_phase4.ToString()].Restart();
  191. _allTimeDict[N2PurgeModeEnum.Manual_phase4.ToString()].Stop();
  192. }
  193. }
  194. else if (_currentPhase == N2PurgeModeEnum.Manual_phase4)
  195. {
  196. if (CheckN2PurgePhase5())
  197. {
  198. LOG.Info($"N2PurgeMode Trigger from Manual_phase4 to Manual_phase5,O2:{ConcentrationO2.Value}");
  199. SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase5.ToString());
  200. }
  201. //if (CheckN2PurgePhase3( ))
  202. //{
  203. // LOG.Info($"N2PurgeMode Trigger from Manual_phase4 to Manual_phase3,O2:{o2Value}");
  204. // SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase3.ToString());
  205. //}
  206. }
  207. else if (_currentPhase == N2PurgeModeEnum.Manual_phase5)
  208. {
  209. if (CheckN2PurgePhase4())
  210. {
  211. LOG.Info($"N2PurgeMode Trigger from Manual_phase5 to Manual_phase4,O2:{ConcentrationO2.Value}");
  212. SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase4.ToString());
  213. }
  214. //if (CheckN2PurgePhase3( ))
  215. //{
  216. // LOG.Info($"N2PurgeMode Trigger from Manual_phase5 to Manual_phase3,O2:{o2Value}");
  217. // SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase3.ToString());
  218. //}
  219. }
  220. else
  221. {
  222. if (CheckN2PurgePhase3())
  223. {
  224. LOG.Info($"N2PurgeMode Trigger Directly triggered Manual_phase3,O2:{ConcentrationO2.Value}");
  225. SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase3.ToString());
  226. return;
  227. }
  228. if (CheckN2PurgePhase5())
  229. {
  230. LOG.Info($"N2PurgeMode Trigger Directly triggered Manual_phase5,O2:{ConcentrationO2.Value}");
  231. SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase5.ToString());
  232. return;
  233. }
  234. if (CheckN2PurgePhase4())
  235. {
  236. LOG.Info($"N2PurgeMode Trigger Directly triggered Manual_phase4,O2:{ConcentrationO2.Value}");
  237. SetN2PurgeValveData(N2PurgeModeEnum.Manual_phase4.ToString());
  238. return;
  239. }
  240. }
  241. }
  242. if (_N2PurgeMode == N2PurgeModeEnum.ManualMode || _N2PurgeMode == N2PurgeModeEnum.Auto)
  243. {
  244. _currentPhase = _N2PurgeMode;
  245. }
  246. //switch (_N2PurgeMode)
  247. //{
  248. // case N2PurgeModeEnum.Auto:
  249. // // 自动模式下的操作
  250. // break;
  251. // case N2PurgeModeEnum.ManualMode:
  252. // break;
  253. // case N2PurgeModeEnum.N2PurgeMode:
  254. // ProcessPhase(_trigN2UpRD, N2PurgeModeEnum.Manual_phase1.ToString());
  255. // ProcessPhase(_trigN2DownRD, N2PurgeModeEnum.Manual_phase2.ToString(), _manualPhase2NeedCheck, (int)(_manualPhase2StabilityTime * 1000));
  256. // break;
  257. // case N2PurgeModeEnum.ATMMode:
  258. // ProcessPhase(_trigN2AirDownRD, N2PurgeModeEnum.Manual_phase3.ToString());
  259. // ProcessPhase(_trigN2AirUpRD, N2PurgeModeEnum.Manual_phase4.ToString(), _manualPhase4NeedCheck, (int)(_manualPhase4StabilityTime * 1000));
  260. // ProcessPhase(_trigN2AirDownTwoRD, N2PurgeModeEnum.Manual_phase5.ToString());
  261. // break;
  262. //}
  263. }
  264. bool CheckConditionInTime(string modeKey, int millisecondsTimeout, Func<bool> condition)
  265. {
  266. var stopwatch = _allTimeDict[modeKey];
  267. if (!_allTimeDict[modeKey].IsRunning)
  268. {
  269. _allTimeDict[modeKey].Restart();
  270. }
  271. while (stopwatch.ElapsedMilliseconds < millisecondsTimeout)
  272. {
  273. if (!_allTimeDict[modeKey].IsRunning)
  274. {
  275. return true;
  276. }
  277. if (!condition())
  278. {
  279. _allTimeDict[modeKey].Stop();
  280. _allTimeDict[modeKey].Reset();
  281. return false;
  282. }
  283. }
  284. if (stopwatch.ElapsedMilliseconds > millisecondsTimeout)
  285. {
  286. _allTimeDict[modeKey].Stop();
  287. _allTimeDict[modeKey].Reset();
  288. }
  289. return true;
  290. }
  291. private void ProcessPhase(R_TRIG r_TRIG, string modeKey, bool needCheck = false, int time = 0)
  292. {
  293. r_TRIG.CLK = needCheck ? (CheckConditionInTime(modeKey, time, () => _n2PurgeSequenceStatus[modeKey].Invoke())) : _n2PurgeSequenceStatus[modeKey].Invoke();
  294. if (r_TRIG.Q)
  295. {
  296. LOG.Info($"N2PurgeMode Trigger {modeKey}!,O2:{ConcentrationO2.Value},time:{_allTimeDict[modeKey].ElapsedMilliseconds}");
  297. SetN2PurgeValveData(modeKey);
  298. _allTimeDict[modeKey].Stop();
  299. _allTimeDict[modeKey].Reset();
  300. }
  301. }
  302. public void RestAllN2PrugeRD()
  303. {
  304. _trigN2AirDownRD.RST = false;
  305. _trigN2AirUpRD.RST = false;
  306. _trigN2DownRD.RST = false;
  307. _trigN2UpRD.RST = false;
  308. foreach (var item in _allTimeDict)
  309. {
  310. item.Value.Stop();
  311. item.Value.Reset();
  312. }
  313. _canSwitchToPhase2 = true;
  314. }
  315. private void SetN2PurgeValveData(string mode, string msg = "")
  316. {
  317. var value = _n2PurgeSequenceAction[mode];
  318. _currentPhase = (N2PurgeModeEnum)Enum.Parse(typeof(N2PurgeModeEnum), mode);
  319. if (SC.ContainsItem("PM1.SelectN2PurgeModePhase"))
  320. {
  321. SC.SetItemValue("PM1.SelectN2PurgeModePhase", mode);
  322. }
  323. foreach (var operateItem in value.Item2)
  324. {
  325. if (operateItem.Item1 is IoMFC)
  326. {
  327. var ioMFc = (operateItem.Item1 as IoMFC);
  328. { ioMFc.SetMfcValue(out _, 0, new object[] { float.Parse(operateItem.Item2.ToString()) }); }
  329. }
  330. if (operateItem.Item1 is IoValve)
  331. {
  332. var ioValve = (operateItem.Item1 as IoValve);
  333. ioValve.TurnValve(bool.Parse(operateItem.Item2), out _);
  334. }
  335. if (operateItem.Item1 is IoTrigger)
  336. {
  337. var ioTrigger = (operateItem.Item1 as IoTrigger);
  338. ioTrigger.CheckAndSet(bool.Parse(operateItem.Item2), out _);
  339. }
  340. }
  341. }
  342. private bool SetN2PurgeMode(out string reason, int time, object[] param)
  343. {
  344. reason = string.Empty;
  345. var mode = param[0].ToString();
  346. _N2PurgeMode = (N2PurgeModeEnum)Enum.Parse(typeof(N2PurgeModeEnum), mode);
  347. if (SC.ContainsItem("PM1.SelectN2PurgeMode"))
  348. {
  349. SC.SetItemValue("PM1.SelectN2PurgeMode", mode);
  350. }
  351. RestAllN2PrugeRD();
  352. return true;
  353. }
  354. /// <summary>
  355. /// 获取当前O2检测位置的设定值
  356. /// </summary>
  357. /// <returns></returns>
  358. private string GetO2SetCheckSetPoint()
  359. {
  360. if (SensorO2DetectSideLA != null && SensorO2DetectSideLA.Value)
  361. {
  362. var key = "PM1.N2Purge.N2PurgeLAO2CheckSV";
  363. if (SC.ContainsItem(key))
  364. return SC.GetValue<double>(key).ToString("f3");
  365. }
  366. if ((SensorO2DetectSideFIMS1 != null && SensorO2DetectSideFIMS1.Value) || (SensorO2DetectSideFIMS2 != null && SensorO2DetectSideFIMS2.Value))
  367. {
  368. var key = "PM1.N2Purge.N2PurgeFOUPO2CheckSV";
  369. if (SC.ContainsItem(key))
  370. return SC.GetValue<double>(key).ToString("f3");
  371. }
  372. return "";
  373. }
  374. /// <summary>
  375. /// 获取当前O2检测位置
  376. /// </summary>
  377. /// <returns></returns>
  378. private string GetCheckO2Location()
  379. {
  380. if (SensorO2DetectSideLA != null && SensorO2DetectSideLA.Value)
  381. return SensorO2DetectSideLA.Display;
  382. if (SensorO2DetectSideFIMS1 != null && SensorO2DetectSideFIMS1.Value)
  383. return SensorO2DetectSideFIMS1.Display;
  384. if (SensorO2DetectSideFIMS2 != null && SensorO2DetectSideFIMS2.Value)
  385. return SensorO2DetectSideFIMS2.Display;
  386. return "";
  387. }
  388. /// <summary>
  389. /// 获取当前O2浓度
  390. /// </summary>
  391. /// <returns></returns>
  392. private bool CheckN2PurgePhase1()
  393. {
  394. return ((int)ConcentrationO2.Value >= _n2PurgeData) && GetLADoorOpenStatus();
  395. }
  396. private bool CheckN2PurgePhase2()
  397. {
  398. return ((int)ConcentrationO2.Value < _n2PurgeData) && GetLADoorOpenStatus();
  399. }
  400. private bool CheckN2PurgePhase3()
  401. {
  402. return ((int)ConcentrationO2.Value) < _n2ToAirData && GetLADoorOpenStatus();
  403. }
  404. private bool CheckN2PurgePhase5()
  405. {
  406. return ((int)ConcentrationO2.Value) >= _n2ToAirData && !GetLADoorOpenStatus();
  407. }
  408. private bool CheckN2PurgePhase4()
  409. {
  410. return (((int)ConcentrationO2.Value)) >= _n2ToAirData && GetLADoorOpenStatus();
  411. }
  412. private bool GetN2PurgeAIRTo20PPMStatus()
  413. {
  414. return ValveAV202.DOOpen.Value;
  415. }
  416. private bool GetN2PurgeUnder20PPMStatus(double value = 20)
  417. {
  418. return ConcentrationO2.Value < value;
  419. }
  420. private bool GetN2PurgeAIRStatus()
  421. {
  422. return ValveAV202.DOClose.Value && (AlarmSignalFilterBox1DoorSwitch != null ? !AlarmSignalFilterBox1DoorSwitch.Value : false);
  423. }
  424. private bool GetLADoorOpenStatus()
  425. {
  426. return (bool)(SensorLADoorSw1?.Value);
  427. }
  428. private bool GetN2PurgeDoorOpenStatus()
  429. {
  430. return ValveAV202.DOClose.Value && (AlarmSignalFilterBox1DoorSwitch != null ? !AlarmSignalFilterBox1DoorSwitch.Value : false);
  431. }
  432. private bool GetN2PurgeFoup1Status()
  433. {
  434. return GetN2PurgeAIRTo20PPMStatus() && GetN2PurgeUnder20PPMStatus() && FIMS1.IsFoupExist && FIMS1.CollisionAvoidanceUpDownStatus == DeviceStatus.Down;
  435. }
  436. private bool GetN2PurgeFoup2Status()
  437. {
  438. return GetN2PurgeAIRTo20PPMStatus() && GetN2PurgeUnder20PPMStatus() && FIMS2.IsFoupExist && FIMS2.CollisionAvoidanceUpDownStatus == DeviceStatus.Down; ;
  439. }
  440. public bool IsAbortN2purge()
  441. {
  442. if (!_enableAbortN2purge)
  443. {
  444. return false;
  445. }
  446. if (SensorSL02001gasboxdoorsw11.Value || SensorSL02001gasboxdoorsw12.Value || SensorSL02002gasboxdoorsw11.Value || SensorSL02002gasboxdoorsw12.Value || SensorSL05002LAdoorsw2.Value || SensorSL05004LAfurnacedoorsw.Value)
  447. {
  448. return true;
  449. }
  450. return false;
  451. }
  452. public void SetN2PurgeLAO2CheckFirstEnable(bool isEable)
  453. {
  454. if (TrigN2PurgeLAO2CheckFirstEnable != null && TrigN2PurgeLAO2CheckFirstEnable.Value != isEable)
  455. {
  456. TrigN2PurgeLAO2CheckFirstEnable.SetTrigger(isEable, out _);
  457. }
  458. }
  459. public void SetN2PurgeFIMS1O2CheckEnable(ModuleName fims, bool isEable)
  460. {
  461. if (fims == ModuleName.FIMS1 && TrigN2PurgeFIMS1O2CheckEnable != null && TrigN2PurgeFIMS1O2CheckEnable.Value != isEable)
  462. {
  463. TrigN2PurgeFIMS1O2CheckEnable.SetTrigger(isEable, out _);
  464. }
  465. if (fims == ModuleName.FIMS2 && TrigN2PurgeFIMS2O2CheckEnable != null && TrigN2PurgeFIMS2O2CheckEnable.Value != isEable)
  466. {
  467. TrigN2PurgeFIMS2O2CheckEnable.SetTrigger(isEable, out _);
  468. }
  469. }
  470. public void SetN2PurgeProcess(bool isEable)
  471. {
  472. if (TrigN2PurgeProcess != null && TrigN2PurgeProcess.Value != isEable)
  473. {
  474. TrigN2PurgeProcess.SetTrigger(isEable, out _);
  475. }
  476. }
  477. public void SetN2PurgeLAO2CheckSV(float value)
  478. {
  479. if (TrigN2PurgeLAO2CheckSV != null)
  480. TrigN2PurgeLAO2CheckSV?.SetAOTrigger(value, out _);
  481. }
  482. public void SetN2PurgeFOUPO2CheckSV(float value)
  483. {
  484. if (TrigN2PurgeFOUPO2CheckSV != null)
  485. TrigN2PurgeFOUPO2CheckSV?.SetAOTrigger(value, out _);
  486. }
  487. public void SetAVParameter(ModuleName fims, bool isEable)
  488. {
  489. if (fims == ModuleName.FIMS1)
  490. {
  491. var avValve58 = DEVICE.GetDevice<IoValve>($"{ModuleName.PM1}.ValveAV58");
  492. avValve58?.TurnValve(isEable, out _);
  493. }
  494. if (fims == ModuleName.FIMS2)
  495. {
  496. var avValve59 = DEVICE.GetDevice<IoValve>($"{ModuleName.PM1}.ValveAV59");
  497. avValve59?.TurnValve(isEable, out _);
  498. }
  499. }
  500. /// <summary>
  501. /// N2Purge相关时间参数,电气要求设定为秒,实际下发按照毫秒
  502. /// </summary>
  503. public void SetN2PurgeParameters()
  504. {
  505. if (SC.ContainsItem("PM1.N2Purge.TransferRoomArrivalWaitTime") && TrigN2PurgeLAO2CheckTime != null)
  506. {
  507. var time = (float)SC.GetValue<double>("PM1.N2Purge.TransferRoomArrivalWaitTime");
  508. TrigN2PurgeLAO2CheckTime.SetAOTrigger(time, out _);
  509. }
  510. if (SC.ContainsItem("PM1.N2Purge.TransferRoomStableWaitTime") && TrigN2PurgeLAO2OverTime != null)
  511. {
  512. var time = (float)SC.GetValue<double>("PM1.N2Purge.TransferRoomStableWaitTime");
  513. TrigN2PurgeLAO2OverTime.SetAOTrigger(time, out _);
  514. }
  515. if (SC.ContainsItem("PM1.N2Purge.FOUPOpenerArrivalWaitTime") && TrigN2PurgeFOUPO2CheckTime != null)
  516. {
  517. var time = (float)SC.GetValue<double>("PM1.N2Purge.FOUPOpenerArrivalWaitTime");
  518. TrigN2PurgeFOUPO2CheckTime.SetAOTrigger(time, out _);
  519. }
  520. if (SC.ContainsItem("PM1.N2Purge.FOUPOpenerStableWaitTime") && TrigN2PurgeFOUPO2OverTime != null)
  521. {
  522. var time = (float)SC.GetValue<double>("PM1.N2Purge.FOUPOpenerStableWaitTime");
  523. TrigN2PurgeFOUPO2OverTime.SetAOTrigger(time, out _);
  524. }
  525. if (SC.ContainsItem("PM1.N2Purge.O2DetectorTransferRoomToFOUPTime") && TrigN2PurgeExchangeLATOFOUPWaitTime != null)
  526. {
  527. var time = (float)SC.GetValue<double>("PM1.N2Purge.O2DetectorTransferRoomToFOUPTime");
  528. TrigN2PurgeExchangeLATOFOUPWaitTime.SetAOTrigger(time, out _);
  529. }
  530. if (SC.ContainsItem("PM1.N2Purge.O2DetectorFOUPToTransferRoomTime") && TrigN2PurgeExchangeFOUPTOLAWaitTime != null)
  531. {
  532. var time = (float)SC.GetValue<double>("PM1.N2Purge.O2DetectorFOUPToTransferRoomTime");
  533. TrigN2PurgeExchangeFOUPTOLAWaitTime.SetAOTrigger(time, out _);
  534. }
  535. if (SC.ContainsItem("PM1.N2Purge.O2DetectorFOUPToFOUPTime") && TrigN2PurgeExchangeFOUPTOFOUPWaitTime != null)
  536. {
  537. var time = (float)SC.GetValue<double>("PM1.N2Purge.O2DetectorFOUPToFOUPTime");
  538. TrigN2PurgeExchangeFOUPTOFOUPWaitTime.SetAOTrigger(time, out _);
  539. }
  540. SetN2PurgeLAO2CheckSV((float)SC.GetValue<double>("PM1.N2Purge.N2PurgeLAO2CheckSV"));
  541. SetN2PurgeFOUPO2CheckSV((float)SC.GetValue<double>("PM1.N2Purge.N2PurgeFOUPO2CheckSV"));
  542. }
  543. public void InitN2PurgeMode(string n2PurgeModeStr, bool isN2Purge)
  544. {
  545. if (SC.ContainsItem("PM1.RecipeRelevancyN2Purge") && SC.GetValue<bool>("PM1.RecipeRelevancyN2Purge") && SC.ContainsItem("PM1.SelectN2PurgeMode"))
  546. {
  547. if (!isN2Purge)
  548. {
  549. SC.SetItemValueFromString("PM1.SelectN2PurgeMode", N2PurgeModeEnum.ManualMode.ToString());
  550. }
  551. else
  552. {
  553. var setValue = GetN2PurgeModeEnumByStr(n2PurgeModeStr);
  554. SC.SetItemValueFromString("PM1.SelectN2PurgeMode", setValue);
  555. }
  556. RestAllN2PrugeRD();
  557. }
  558. }
  559. }
  560. }