PMAlarmCondition.cs 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Device.Unit;
  4. using Aitex.Core.RT.Event;
  5. using Aitex.Core.RT.IOCore;
  6. using Aitex.Core.RT.Log;
  7. using Aitex.Core.RT.OperationCenter;
  8. using Aitex.Core.RT.ParameterCenter;
  9. using Aitex.Core.RT.SCCore;
  10. using Aitex.Core.RT.Tolerance;
  11. using Aitex.Core.Util;
  12. using FurnaceRT.Equipments.PMs.RecipeExecutions;
  13. using FurnaceRT.Equipments.Systems;
  14. using MECF.Framework.Common.Equipment;
  15. using MECF.Framework.Common.Event;
  16. using MECF.Framework.Common.OperationCenter;
  17. using System;
  18. using System.Collections;
  19. using System.Collections.Generic;
  20. using System.Diagnostics;
  21. using System.Linq;
  22. using System.Xml;
  23. namespace FurnaceRT.Equipments.PMs
  24. {
  25. public partial class PMModule
  26. {
  27. private string _currentAlarmConditionFileName;
  28. private int _currentAlarmConditionIndex;
  29. private Dictionary<int, AlarmConditionTableParameter> _alarmConditionDic;
  30. private List<AlarmConditionChecker> _heaterChecker;
  31. private List<AlarmConditionChecker> _mfcChecker;
  32. private List<AlarmConditionChecker> _apcChecker;
  33. private List<AlarmConditionChecker> _auxChecker;
  34. private object _alarmConditionLocker = new object();
  35. private bool _isAlarmConditionHasRecipeCommand;//End,Reset,Hold,JumpStep,CallAlarmRecipe,CallAbortRecipe
  36. private Dictionary<string, string> _hardwareInterlockAlarmConditionDic;
  37. private Dictionary<string, string> _clnAlarmConditionDic;
  38. private AlarmEventItem _lastAlarmInAlarmCondition;
  39. private void SetAlarmConditionTableIndex(int index)
  40. {
  41. if (_alarmConditionDic == null)
  42. return;
  43. var ret = _alarmConditionDic.TryGetValue(index, out var currentParameter);
  44. if (!ret)
  45. return;
  46. _currentAlarmConditionIndex = index;
  47. SC.SetItemValueFromString("PM1.AlarmConditionIndex", index.ToString());
  48. //ResetAlarmCondition();
  49. for (int i = 0; i < _heaterChecker.Count; i++)
  50. {
  51. var checker = _heaterChecker[i];
  52. //checker.Parameter = checker.Parameter.Clone(currentParameter.HeaterParameterLst.Find(x => x.Name == checker.Heater.Display));
  53. checker.Parameter = currentParameter.HeaterParameterLst[i];
  54. //checker.ToleranceCheckerWarning.Reset(checker.Parameter.WarningTime);
  55. //checker.ToleranceCheckerAlarm.Reset(checker.Parameter.AlarmTime);
  56. }
  57. for (int i = 0; i < _mfcChecker.Count && i < currentParameter.MFCParameterLst.Count; i++)
  58. {
  59. var checker = _mfcChecker[i];
  60. checker.Parameter = currentParameter.MFCParameterLst[i];
  61. }
  62. for (int i = 0; i < _apcChecker.Count && i < currentParameter.APCParameterLst.Count; i++)
  63. {
  64. var checker = _apcChecker[i];
  65. checker.Parameter = currentParameter.APCParameterLst[i];
  66. }
  67. for (int i = 0; i < _auxChecker.Count && i < currentParameter.AUXParameterLst.Count; i++)
  68. {
  69. var checker = _auxChecker[i];
  70. checker.Parameter = currentParameter.AUXParameterLst[i];
  71. }
  72. }
  73. public void ResetAlarmCondition()
  74. {
  75. for (int i = 0; i < _heaterChecker.Count; i++)
  76. {
  77. var checker = _heaterChecker[i];
  78. checker.ToleranceCheckerWarning.RST = true;
  79. checker.ToleranceCheckerAlarm.RST = true;
  80. checker?.DelayTimer.Restart();
  81. }
  82. for (int i = 0; i < _mfcChecker.Count; i++)
  83. {
  84. var checker = _mfcChecker[i];
  85. checker.ToleranceCheckerWarning.RST = true;
  86. checker.ToleranceCheckerAlarm.RST = true;
  87. checker?.DelayTimer.Restart();
  88. }
  89. for (int i = 0; i < _apcChecker.Count; i++)
  90. {
  91. var checker = _apcChecker[i];
  92. checker.ToleranceCheckerWarning.RST = true;
  93. checker.ToleranceCheckerAlarm.RST = true;
  94. checker?.DelayTimer.Restart();
  95. }
  96. for (int i = 0; i < _auxChecker.Count; i++)
  97. {
  98. var checker = _auxChecker[i];
  99. checker.ToleranceCheckerWarning.RST = true;
  100. checker.ToleranceCheckerAlarm.RST = true;
  101. checker?.DelayTimer.Restart();
  102. }
  103. }
  104. private void InitAlarmConditionChecker()
  105. {
  106. InitHeaterChecker();
  107. InitMFCChecker();
  108. InitAPCChecker();
  109. InitAUXChecker();
  110. _hardwareInterlockAlarmConditionDic = new Dictionary<string, string>()
  111. {
  112. {"AlarmSignalOPBoxPS11Out1", "Air/N2-7 Pressure Too Low"},//deviceModel的名称和AlarmCondition ParameterFormat.xml的名称
  113. {"AlarmSignalGLBoxPG1CNT1Alarm", "N2-1 Pressure Too Low"},
  114. {"AlarmSignalGLBoxPG1CNT2Alarm", "N2-1 Pressure Too High"},
  115. {"AlarmSignalGLBoxPG2CNT1Alarm", "SiH2Cl2 Pressure Too Low"},
  116. {"AlarmSignalGLBoxPG2CNT2Alarm", "SiH2Cl2 Pressure Too High"},
  117. {"AlarmSignalGLBoxPG3CNT1Alarm", "NH3-1 Pressure To Low"},
  118. {"AlarmSignalGLBoxPG3CNT2Alarm", "NH3-1 Pressure Too High"},
  119. {"AlarmSignalGLBoxPG4CNT1Alarm", "NH3-2 Pressure Too Low"},
  120. {"AlarmSignalGLBoxPG4CNT2Alarm", "NH3-2 Pressure Too High"},
  121. {"AlarmSignalGLBoxPG5CNT1Alarm", "N2-2 Pressure Too Low"},
  122. {"AlarmSignalGLBoxPG5CNT2Alarm", "N2-2 Pressure Too High"},
  123. {"AlarmSignalGLBoxPG6CNT1Alarm", "20% F2/N2 Pressure Too Low"},
  124. {"AlarmSignalGLBoxPG6CNT2Alarm", "20% F2/N2 Pressure Too High"},
  125. {"AlarmSignalPG12OUT1", "N2-8-1 Pressure Too Low"},
  126. {"AlarmSignalPG12OUT2", "N2-8-1 Pressure Too High"},
  127. {"AlarmSignalPG13OUT1", "N2-8-2 Pressure Too Low"},
  128. {"AlarmSignalPS14OUT1", "O.PRS-PS14 Pressure Too High"},
  129. {"AlarmSignalPS14OUT2", "O.PRS-PS14 Pressure Too High"},
  130. {"AlarmSignalN2PurgeBOXPG16CNT1", "N2-6 Pressure Too Low"},
  131. {"AlarmSignalN2PurgeBOXPG70CNT2", "N2-70 Pressure Too Low"},
  132. {"AlarmSignalPS17ValueLowLimitAlarm", "Air/N2-1 Pressure Too Low"},
  133. {"AlarmSignalHeatingExhaust1stAlarmMS1", "Heater Exhaust Pressure Too Low"},
  134. {"AlarmSignalScavengeExhaust1stAlarmMS3", "Scavenge Exhaust Pressure Too Low"},
  135. {"AlarmSignalValveBoxExhaust1stAlarmMS4", "ValveBox Exhaust Pressure Too Low"},
  136. {"AlarmSignalGasBoxExhaust1stAlarmMS2", "GasBox Exhaust Pressure Too Low"},
  137. {"AlarmSignalLAExhaust1stAlarmMS7", "LA Exhaust Pressure Too Low"},
  138. {"AlarmSignalRHC1stAlarmMS8", "RHC Exhaust Pressure Too Low"},
  139. {"AlarmSignalLoadingAreaExhaust1stAlarmMS5", "Loading Area Exhaust Abnormal"},
  140. {"AlarmSignalFrontBodyExhaust1stAlarmMS6", "FrontBody Exhaust Pressure Too Low"},
  141. {"AlarmSignalMainFurnaceCellingTS306", "TEMP1 HTR Abnormal"},
  142. {"AlarmSignalT101TempStatus", "TEMP3 TR1 Abnormal"},
  143. {"AlarmSignalT102TempStatus", "TEMP4 TR2 Abnormal"},
  144. {"AlarmSignalT103TempStatus", "TEMP5 TR3 Abnormal"},
  145. {"AlarmSignalMagneticFluidLeak", "Magnetic Water Leak"},
  146. {"AlarmSignalCoolingWaterLeak", "Cooling Water Leak"},
  147. {"AlarmSignalFBFrontDoorSwitch", "Front Panel Abnormal"},
  148. {"AlarmSignalFilterBox1DoorSwitch", "Filter Box Cover Abnormal"},
  149. {"AlarmSignalLABacksideDoorSwitch", "Transfer Room Panel Abnormal"},
  150. {"AlarmSignalHeaterRoomSWS11S12", "Heater Room Panel Abnormal"},
  151. {"AlarmSignalGasBoxLowerDoorSW", "GasBox Lower Door Abnormal"},
  152. {"AlarmSignalGasBoxUpperDoorSW", "GasBox Upper Door Abnormal"},
  153. {"AlarmSignalRHCTS305", "RHC Abnormal Radiator"},
  154. {"AlarmSignalRHCFlowAlarmFL901", "RHC Flow Abnormal"},
  155. {"AlarmSignalCoolingWaterFlowAlarmOfFurnaceFL902", "Cooling Water Flow Of Furnace Abnormal"},
  156. {"AlarmSignalCoolingWaterFlowAlarmOfShuttleFL903", "Cooling Water Flow Of Shuttle Abnormal"},
  157. {"AlarmSignalCoolingWaterFlowAlarmOfBoatRotationFL904", "Cooling Water Flow Of BoatRotation Abnormal"},
  158. {"AlarmSignalCoolingWaterFlowAlarmOfFlangeFL905", "Cooling Water Flow Of Flange Abnormal"},
  159. {"AlarmSignalCoolingWaterFlowAlarmOfLoadingAreaFL906", "Cooling Water Flow Of Loading Area Abnormal"},
  160. {"AlarmSignalRFAlarm", "RF Alarm"},
  161. {"AlarmSignalAirFlowFL70", "RF N2 Flow Abnormal"},
  162. {"AlarmSignalAirFlowFL71", "RF N2 Flow Abnormal"},
  163. {"AlarmSignalFilterBox1Fan1Alarm", "Filter Box Fan Abnormal"},
  164. {"AlarmSignalFilterBox1Fan2Alarm", "Filter Box Fan Abnormal"},
  165. {"AlarmSignalHCLGasLeak1stAlarm", "SiH2CL2 Gas Leak"},
  166. {"AlarmSignalHCLGasLeak2ndAlarm", "SiH2CL2 Gas Leak"},
  167. {"AlarmSignalNH3GasLeak1stAlarm", "NH3 Gas Leak"},
  168. {"AlarmSignalNH3GasLeak2ndAlarm", "NH3 Gas Leak"},
  169. {"AlarmSignalF2GasLeak1stAlarm", "F2 Gas Leak"},
  170. {"AlarmSignalF2GasLeak2ndAlarm", "F2 Gas Leak"},
  171. {"AlarmSignalGasLeakFault", "Gas Leak Fault"},
  172. //{"AlarmSignalFurnaceMainCircuitBreakerStatusMonitor", "Heater Power Down"},
  173. {"AlarmSignalVaccumPumpWarning", "Vacuum Pump Warning"},
  174. {"AlarmSignalVaccumPumpAlarm", "Vacuum Pump Alarm"},
  175. {"AlarmSignalPS13HStatus", "O.PRS Too High"},
  176. {"AlarmSignalPS13LStatus", "CK.PRS Too Low"},
  177. {"AlarmSignalFFU1DataWriteError", "FFU Data Write Error"},
  178. {"AlarmSignalFFU2DataWriteError", "FFU Data Write Error"},
  179. {"AlarmSignalFFU3DataWriteError", "FFU Data Write Error"},
  180. {"AlarmSignalFFU4DataWriteError", "FFU Data Write Error"},
  181. {"AlarmSignalFFU5DataWriteError", "FFU Data Write Error"},
  182. {"AlarmSignalFFU6DataWriteError", "FFU Data Write Error"},
  183. {"AlarmSignalFFU7DataWriteError", "FFU Data Write Error"},
  184. {"AlarmSignalFFU8DataWriteError", "FFU Data Write Error"},
  185. {"AlarmSignalFFU9DataWriteError", "FFU Data Write Error"},
  186. {"AlarmSignalDG1Output1", "P.CNT Pressure NG"},
  187. {"AlarmSignalDG1Output2", "P.CNT Pressure NG"},
  188. {"AlarmSignalAV91_1RHCAirInOpened", "RHC.DMR Abnormal"},
  189. {"AlarmSignalAV91_2RHCAirInOpened", "RHC.DMR Abnormal"},
  190. {"AlarmSignalAV91_3RHCAirInOpened", "RHC.DMR Abnormal"},
  191. {"AlarmSignalAV91_4RHCAirInOpened", "RHC.DMR Abnormal"},
  192. {"AlarmSignalBlowerPower", "BlowerPower Overload"},
  193. {"AlarmSignalRFSetPowerReached", "RF Output Abnormal"},
  194. {"AlarmSignalN2FlowInFOUPAbnormal", "N2 Flow in FOUP Abnormal"},
  195. {"AlarmSignalCapHeaterAbnormal", "Cap Heater Abnormal"},
  196. {"AlarmSignalHeaterUOverTemp", "Tube Heater OverTemp"},
  197. {"AlarmSignalHeaterCUOverTemp", "Tube Heater OverTemp"},
  198. {"AlarmSignalHeaterCOverTemp", "Tube Heater OverTemp"},
  199. {"AlarmSignalHeaterCLOverTemp", "Tube Heater OverTemp"},
  200. {"AlarmSignalHeaterLOverTemp", "Tube Heater OverTemp"},
  201. {"InterlockAlarm", "Valve Interlock"},
  202. {"GasLine1AlarmSignalTempOutRange", "temp range alarm"},
  203. {"GasLine2AlarmSignalTempOutRange", "temp range alarm"},
  204. {"GasLine3AlarmSignalTempOutRange", "temp range alarm"},
  205. {"GasLine4AlarmSignalTempOutRange", "temp range alarm"},
  206. {"GasLine5AlarmSignalTempOutRange", "temp range alarm"},
  207. {"GasLine6AlarmSignalTempOutRange", "temp range alarm"},
  208. {"GasLine7AlarmSignalTempOutRange", "temp range alarm"},
  209. {"GasLine1AlarmSignalCLN", "CLN alarm"},
  210. {"GasLine2AlarmSignalCLN", "CLN alarm"},
  211. {"GasLine3AlarmSignalCLN", "CLN alarm"},
  212. {"GasLine4AlarmSignalCLN", "CLN alarm"},
  213. {"GasLine5AlarmSignalCLN", "CLN alarm"},
  214. {"GasLine6AlarmSignalCLN", "CLN alarm"},
  215. {"GasLine7AlarmSignalCLN", "CLN alarm"},
  216. };
  217. _clnAlarmConditionDic = new Dictionary<string, string>()
  218. {
  219. {"AlarmSignalOPBoxPS11Out1", "temp range warning"},//deviceModel的名称和AlarmCondition ParameterFormat.xml的名称
  220. {"AlarmSignalTempOutRange", "temp range alarm"},
  221. {"AlarmSignalGLBoxPG1CNT2Alarm", "CLN warning"},
  222. {"AlarmSignalCLN", "CLN alarm"},
  223. };
  224. if (!string.IsNullOrEmpty(SC.GetStringValue("PM1.AlarmCondition")))
  225. {
  226. InitAlarmCondition(SC.GetStringValue("PM1.AlarmCondition"));
  227. int.TryParse(SC.GetStringValue("PM1.AlarmConditionIndex"), out int index);
  228. SetAlarmConditionTableIndex(index);
  229. }
  230. }
  231. private void InitAUXChecker()
  232. {
  233. _auxChecker = new List<AlarmConditionChecker>();
  234. for (int index = 0; index < 512; index++)
  235. {
  236. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.{index}.AI"))
  237. continue;
  238. var checker = new AlarmConditionChecker()
  239. {
  240. AUXIOName = SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI"),
  241. AUXIndex = index,
  242. ToleranceCheckerWarning = new ToleranceChecker(),
  243. ToleranceCheckerAlarm = new ToleranceChecker(),
  244. Parameter = new AlarmConditionAIParameter(),
  245. DelayTimer = new Stopwatch(),
  246. };
  247. _auxChecker.Add(checker);
  248. }
  249. }
  250. private void InitAPCChecker()
  251. {
  252. _apcChecker = new List<AlarmConditionChecker>()
  253. {
  254. new AlarmConditionChecker()
  255. {
  256. APC = APC,
  257. ToleranceCheckerWarning = new ToleranceChecker(),
  258. ToleranceCheckerAlarm = new ToleranceChecker(),
  259. Parameter = new AlarmConditionAIParameter(),
  260. DelayTimer = new Stopwatch(),
  261. },
  262. new AlarmConditionChecker()
  263. {
  264. APC = APC,
  265. ToleranceCheckerWarning = new ToleranceChecker(),
  266. ToleranceCheckerAlarm = new ToleranceChecker(),
  267. Parameter = new AlarmConditionAIParameter(),
  268. DelayTimer = new Stopwatch(),
  269. },
  270. new AlarmConditionChecker()
  271. {
  272. APC = APC,
  273. ToleranceCheckerWarning = new ToleranceChecker(),
  274. ToleranceCheckerAlarm = new ToleranceChecker(),
  275. Parameter = new AlarmConditionAIParameter(),
  276. DelayTimer = new Stopwatch(),
  277. },
  278. };
  279. }
  280. private void InitMFCChecker()
  281. {
  282. _mfcChecker = new List<AlarmConditionChecker>()
  283. {
  284. new AlarmConditionChecker()
  285. {
  286. MFC = MFC1,
  287. ToleranceCheckerWarning = new ToleranceChecker(),
  288. ToleranceCheckerAlarm = new ToleranceChecker(),
  289. Parameter = new AlarmConditionAIParameter(),
  290. DelayTimer = new Stopwatch(),
  291. },
  292. new AlarmConditionChecker()
  293. {
  294. MFC = MFC2,
  295. ToleranceCheckerWarning = new ToleranceChecker(),
  296. ToleranceCheckerAlarm = new ToleranceChecker(),
  297. Parameter = new AlarmConditionAIParameter(),
  298. DelayTimer = new Stopwatch(),
  299. },
  300. new AlarmConditionChecker()
  301. {
  302. MFC = MFC3,
  303. ToleranceCheckerWarning = new ToleranceChecker(),
  304. ToleranceCheckerAlarm = new ToleranceChecker(),
  305. Parameter = new AlarmConditionAIParameter(),
  306. DelayTimer = new Stopwatch(),
  307. },
  308. new AlarmConditionChecker()
  309. {
  310. MFC = MFC4,
  311. ToleranceCheckerWarning = new ToleranceChecker(),
  312. ToleranceCheckerAlarm = new ToleranceChecker(),
  313. Parameter = new AlarmConditionAIParameter(),
  314. DelayTimer = new Stopwatch(),
  315. },
  316. new AlarmConditionChecker()
  317. {
  318. MFC = MFC5,
  319. ToleranceCheckerWarning = new ToleranceChecker(),
  320. ToleranceCheckerAlarm = new ToleranceChecker(),
  321. Parameter = new AlarmConditionAIParameter(),
  322. DelayTimer = new Stopwatch(),
  323. },
  324. new AlarmConditionChecker()
  325. {
  326. MFC = MFC6,
  327. ToleranceCheckerWarning = new ToleranceChecker(),
  328. ToleranceCheckerAlarm = new ToleranceChecker(),
  329. Parameter = new AlarmConditionAIParameter(),
  330. DelayTimer = new Stopwatch(),
  331. },
  332. new AlarmConditionChecker()
  333. {
  334. MFC = MFC7,
  335. ToleranceCheckerWarning = new ToleranceChecker(),
  336. ToleranceCheckerAlarm = new ToleranceChecker(),
  337. Parameter = new AlarmConditionAIParameter(),
  338. DelayTimer = new Stopwatch(),
  339. },
  340. new AlarmConditionChecker()
  341. {
  342. MFC = MFC8,
  343. ToleranceCheckerWarning = new ToleranceChecker(),
  344. ToleranceCheckerAlarm = new ToleranceChecker(),
  345. Parameter = new AlarmConditionAIParameter(),
  346. DelayTimer = new Stopwatch(),
  347. },
  348. new AlarmConditionChecker()
  349. {
  350. MFC = MFC9,
  351. ToleranceCheckerWarning = new ToleranceChecker(),
  352. ToleranceCheckerAlarm = new ToleranceChecker(),
  353. Parameter = new AlarmConditionAIParameter(),
  354. DelayTimer = new Stopwatch(),
  355. },
  356. new AlarmConditionChecker()
  357. {
  358. MFC = MFC10,
  359. ToleranceCheckerWarning = new ToleranceChecker(),
  360. ToleranceCheckerAlarm = new ToleranceChecker(),
  361. Parameter = new AlarmConditionAIParameter(),
  362. DelayTimer = new Stopwatch(),
  363. },
  364. new AlarmConditionChecker()
  365. {
  366. MFC = MFC11,
  367. ToleranceCheckerWarning = new ToleranceChecker(),
  368. ToleranceCheckerAlarm = new ToleranceChecker(),
  369. Parameter = new AlarmConditionAIParameter(),
  370. DelayTimer = new Stopwatch(),
  371. },
  372. new AlarmConditionChecker()
  373. {
  374. MFC = MFC12,
  375. ToleranceCheckerWarning = new ToleranceChecker(),
  376. ToleranceCheckerAlarm = new ToleranceChecker(),
  377. Parameter = new AlarmConditionAIParameter(),
  378. DelayTimer = new Stopwatch(),
  379. },
  380. };
  381. if (MFC13 != null)
  382. {
  383. _mfcChecker.Add(new AlarmConditionChecker()
  384. {
  385. MFC = MFC13,
  386. ToleranceCheckerWarning = new ToleranceChecker(),
  387. ToleranceCheckerAlarm = new ToleranceChecker(),
  388. Parameter = new AlarmConditionAIParameter(),
  389. DelayTimer = new Stopwatch(),
  390. });
  391. }
  392. if (MFC14 != null)
  393. {
  394. _mfcChecker.Add(new AlarmConditionChecker()
  395. {
  396. MFC = MFC14,
  397. ToleranceCheckerWarning = new ToleranceChecker(),
  398. ToleranceCheckerAlarm = new ToleranceChecker(),
  399. Parameter = new AlarmConditionAIParameter(),
  400. DelayTimer = new Stopwatch(),
  401. });
  402. }
  403. if (MFC15 != null)
  404. {
  405. _mfcChecker.Add(new AlarmConditionChecker()
  406. {
  407. MFC = MFC15,
  408. ToleranceCheckerWarning = new ToleranceChecker(),
  409. ToleranceCheckerAlarm = new ToleranceChecker(),
  410. Parameter = new AlarmConditionAIParameter(),
  411. DelayTimer = new Stopwatch(),
  412. });
  413. }
  414. if (MFC16 != null)
  415. {
  416. _mfcChecker.Add(new AlarmConditionChecker()
  417. {
  418. MFC = MFC16,
  419. ToleranceCheckerWarning = new ToleranceChecker(),
  420. ToleranceCheckerAlarm = new ToleranceChecker(),
  421. Parameter = new AlarmConditionAIParameter(),
  422. DelayTimer = new Stopwatch(),
  423. });
  424. }
  425. }
  426. private void InitHeaterChecker()
  427. {
  428. _heaterChecker = new List<AlarmConditionChecker>()
  429. {
  430. new AlarmConditionChecker()
  431. {
  432. Heater = HeaterU,
  433. ToleranceCheckerWarning = new ToleranceChecker(),
  434. ToleranceCheckerAlarm = new ToleranceChecker(),
  435. Parameter = new AlarmConditionAIParameter(),
  436. DelayTimer = new Stopwatch(),
  437. },
  438. new AlarmConditionChecker()
  439. {
  440. Heater = HeaterCU,
  441. ToleranceCheckerWarning = new ToleranceChecker(),
  442. ToleranceCheckerAlarm = new ToleranceChecker(),
  443. Parameter = new AlarmConditionAIParameter(),
  444. DelayTimer = new Stopwatch(),
  445. },
  446. new AlarmConditionChecker()
  447. {
  448. Heater = HeaterC,
  449. ToleranceCheckerWarning = new ToleranceChecker(),
  450. ToleranceCheckerAlarm = new ToleranceChecker(),
  451. Parameter = new AlarmConditionAIParameter(),
  452. DelayTimer = new Stopwatch(),
  453. },
  454. new AlarmConditionChecker()
  455. {
  456. Heater = HeaterCL,
  457. ToleranceCheckerWarning = new ToleranceChecker(),
  458. ToleranceCheckerAlarm = new ToleranceChecker(),
  459. Parameter = new AlarmConditionAIParameter(),
  460. DelayTimer = new Stopwatch(),
  461. },
  462. new AlarmConditionChecker()
  463. {
  464. Heater = HeaterL,
  465. ToleranceCheckerWarning = new ToleranceChecker(),
  466. ToleranceCheckerAlarm = new ToleranceChecker(),
  467. Parameter = new AlarmConditionAIParameter(),
  468. DelayTimer = new Stopwatch(),
  469. },
  470. };
  471. }
  472. public void InitAlarmCondition(string fileName)
  473. {
  474. if (string.IsNullOrEmpty(fileName))
  475. {
  476. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"Heater temperature correct file is empty");
  477. return;
  478. }
  479. _currentAlarmConditionFileName = fileName;
  480. //_currentAlarmConditionIndex = index;
  481. var content = ParameterFileManager.Instance.LoadParameter("Parameter\\AlarmCondition", fileName, false);
  482. if (string.IsNullOrEmpty(content))
  483. {
  484. //EV.PostWarningLog(ModuleName.PM1.ToString(), $"{fileNameAndPath} heater temperature correct file is empty");
  485. return;
  486. }
  487. var doc = new XmlDocument();
  488. doc.LoadXml(content);
  489. XmlNodeList nodeSteps = doc.SelectNodes($"Aitex/TableParameterData/Module[@Name='']/Step");
  490. if (nodeSteps == null)
  491. nodeSteps = doc.SelectNodes($"Aitex/TableParameterData/Step");
  492. if (nodeSteps == null)
  493. {
  494. EV.PostWarningLog(ModuleName.PM1.ToString(), $"Invalid alarm condition file {fileName}");
  495. return;
  496. }
  497. SC.SetItemValueFromString("PM1.AlarmCondition", fileName);
  498. _alarmConditionDic = new Dictionary<int, AlarmConditionTableParameter>();
  499. for (int i = 0; i < nodeSteps.Count; i++)
  500. {
  501. var step = nodeSteps[i];
  502. XmlElement stepNode = step as XmlElement;
  503. int tableIndex = i + 1;
  504. AlarmConditionTableParameter table = new AlarmConditionTableParameter();
  505. List<AlarmConditionDIParameter> valveInterlockParameterLst = null;
  506. List<AlarmConditionDIParameter> clnParameterLst = null;
  507. foreach (XmlAttribute att in stepNode.Attributes)
  508. {
  509. switch (att.Name)
  510. {
  511. case "StepNo":
  512. int.TryParse(att.Value, out int no);
  513. table.No = no;
  514. break;
  515. case "Name":
  516. table.Name = att.Value;
  517. break;
  518. case "TempHeater":
  519. table.HeaterParameterLst = InitAlarmConditionItem(att.Value);
  520. break;
  521. case "TempBoat":
  522. break;
  523. case "FlowDeviation":
  524. table.MFCParameterLst = InitAlarmConditionItem(att.Value);
  525. break;
  526. case "Press":
  527. table.APCParameterLst = InitAlarmConditionItem(att.Value);
  528. break;
  529. case "AUX":
  530. table.AUXParameterLst = InitAlarmConditionItem(att.Value);
  531. break;
  532. case "HWILK":
  533. table.InterlockParameterLst = InitAlarmConditionDIItem(att.Value);
  534. break;
  535. case "ValveILK":
  536. valveInterlockParameterLst = InitAlarmConditionDIItem(att.Value);
  537. break;
  538. case "TempController":
  539. break;
  540. case "APCController":
  541. break;
  542. case "TransferError":
  543. break;
  544. case "SerialLineDown":
  545. break;
  546. case "LanLineDown":
  547. break;
  548. case "DeviceNetLineDown":
  549. break;
  550. case "Sensor":
  551. break;
  552. case "CLNAlarmList":
  553. clnParameterLst = InitAlarmConditionDIItem(att.Value);
  554. break;
  555. }
  556. }
  557. if (table.InterlockParameterLst != null && valveInterlockParameterLst != null)
  558. table.InterlockParameterLst.AddRange(valveInterlockParameterLst);
  559. if (table.InterlockParameterLst != null && clnParameterLst != null)
  560. table.InterlockParameterLst.AddRange(clnParameterLst);
  561. if (!_alarmConditionDic.ContainsKey(table.No))
  562. _alarmConditionDic.Add(table.No, table);
  563. _alarmConditionDic[table.No] = table;
  564. }
  565. }
  566. public void MonitorAlarmCondition()
  567. {
  568. if (_alarmConditionDic == null)
  569. return;
  570. _isAlarmConditionHasRecipeCommand = false;
  571. MonitorHeaterAlarmCondition();
  572. MonitorMFCAlarmCondition();
  573. MonitorAUXAlarmCondition();
  574. MonitorAPCAlarmCondition();
  575. MonitorInterlockAlarmCondition();
  576. }
  577. private void MonitorInterlockAlarmCondition()
  578. {
  579. if (_triggeredAlarmList == null || _triggeredAlarmList.Count == 0)
  580. return;
  581. if (_hardwareInterlockAlarmConditionDic == null)
  582. return;
  583. if (_alarmConditionDic == null || !_alarmConditionDic.ContainsKey(_currentAlarmConditionIndex) || _alarmConditionDic[_currentAlarmConditionIndex].InterlockParameterLst == null)
  584. return;
  585. var newAlarm = _triggeredAlarmList[_triggeredAlarmList.Count - 1];
  586. var alarmConditionItemName = "";
  587. for (int i = _triggeredAlarmList.Count - 1; i >= 0; i--)
  588. {
  589. var alarm = _triggeredAlarmList[i];
  590. var interval = DateTime.Now - newAlarm.OccuringTime;
  591. if (interval.TotalMilliseconds > 1000)//老的alarm
  592. continue;
  593. var paras = newAlarm.EventEnum.Split('.');
  594. if (paras.Length < 2)
  595. continue;
  596. var ret = _hardwareInterlockAlarmConditionDic.TryGetValue(paras[1], out string name);
  597. if (ret)
  598. {
  599. newAlarm = alarm;
  600. alarmConditionItemName = name;
  601. var alarmConditionItem = _alarmConditionDic[_currentAlarmConditionIndex].InterlockParameterLst.FirstOrDefault(x => x.Name == alarmConditionItemName);
  602. if (alarmConditionItem == null)
  603. continue;
  604. if (alarmConditionItem.IsEnable)
  605. ProcessAlarmConditionErrorCommand(alarmConditionItem.Command);
  606. break;
  607. }
  608. }
  609. }
  610. private void MonitorAPCAlarmCondition()
  611. {
  612. for (int i = 0; i < _apcChecker.Count; i++)
  613. {
  614. var checker = _apcChecker[i];
  615. if (checker.Parameter.Unit == null)
  616. continue;
  617. var warningLow = checker.Parameter.WarningLow;
  618. var warningHigh = checker.Parameter.WarningHigh;
  619. var alarmLow = checker.Parameter.AlarmLow;
  620. var alarmHigh = checker.Parameter.AlarmHigh;
  621. var unit = checker.Parameter.Unit;
  622. if (checker.Parameter.Unit.ToLower().Contains("%"))
  623. {
  624. unit = "%";
  625. //angle
  626. if (checker.Parameter.Unit.ToLower() == "%d")
  627. {
  628. //do nothing
  629. }
  630. else
  631. {
  632. warningLow = (float)checker.APC.DeviceData.PositionSetPoint * warningLow;
  633. warningHigh = (float)checker.APC.DeviceData.PositionSetPoint * warningHigh;
  634. alarmLow = (float)checker.APC.DeviceData.PositionSetPoint * alarmLow;
  635. alarmHigh = (float)checker.APC.DeviceData.PositionSetPoint * alarmHigh;
  636. }
  637. if (checker.Parameter.IsWarningEnable && checker.Parameter.WarningTime > 0 && checker.DelayTimer.IsRunning && checker.DelayTimer.ElapsedMilliseconds >= checker.Parameter.WarningDelayDetectTimeS * 1000)
  638. checker.ToleranceCheckerWarning.Monitor(checker.APC.DeviceData.PositionFeedback,
  639. checker.APC.DeviceData.PositionSetPoint - warningLow, checker.APC.DeviceData.PositionSetPoint + warningHigh, checker.Parameter.WarningTime);
  640. if (checker.Parameter.IsAlarmEnable && checker.Parameter.AlarmTime > 0 && checker.DelayTimer.IsRunning && checker.DelayTimer.ElapsedMilliseconds >= checker.Parameter.AlarmDelayDetectTimeS * 1000)
  641. checker.ToleranceCheckerAlarm.Monitor(checker.APC.DeviceData.PositionFeedback,
  642. checker.APC.DeviceData.PositionSetPoint - alarmLow, checker.APC.DeviceData.PositionSetPoint + alarmHigh, checker.Parameter.AlarmTime);
  643. if (checker.ToleranceCheckerAlarm.Trig || checker.ToleranceCheckerWarning.Trig)
  644. {
  645. var range = "";
  646. var time = "";
  647. var command = checker.Parameter.AlarmCommand;
  648. if (checker.ToleranceCheckerAlarm.Trig)
  649. {
  650. range = $"({checker.APC.DeviceData.PositionSetPoint - alarmLow},{checker.APC.DeviceData.PositionSetPoint + alarmHigh})";
  651. time = $"{checker.Parameter.AlarmTime:F1}";
  652. checker.APC.APCAngleToleranceAlarm.Set($"APC angle out of range {range} {unit} in {time} seconds");
  653. command = checker.Parameter.AlarmCommand;
  654. }
  655. else if (checker.ToleranceCheckerWarning.Trig)
  656. {
  657. range = $"({checker.APC.DeviceData.PositionSetPoint - warningLow},{checker.APC.DeviceData.PositionSetPoint + warningHigh})";
  658. time = $"{checker.Parameter.WarningTime:F1}";
  659. checker.APC.APCAngleToleranceWarning.Set($"APC angle out of range {range} {unit} in {time} seconds");
  660. command = checker.Parameter.WarningCommand;
  661. }
  662. ProcessAlarmConditionErrorCommand(command);
  663. }
  664. }
  665. else
  666. {
  667. warningLow = (float)checker.APC.DeviceData.PressureSetPoint * warningLow;
  668. warningHigh = (float)checker.APC.DeviceData.PressureSetPoint * warningHigh;
  669. alarmLow = (float)checker.APC.DeviceData.PressureSetPoint * alarmLow;
  670. alarmHigh = (float)checker.APC.DeviceData.PressureSetPoint * alarmHigh;
  671. var alarmToleranceAlarm = checker.APC.APCPressure2ToleranceAlarm;
  672. var alarmToleranceWarning = checker.APC.APCPressure2ToleranceWarning;
  673. var pressureFeedback = checker.APC.DeviceData.Pressure2Feedback;
  674. if (i == 0)
  675. {
  676. alarmToleranceAlarm = checker.APC.APCPressure1ToleranceAlarm;
  677. alarmToleranceWarning = checker.APC.APCPressure1ToleranceWarning;
  678. pressureFeedback = checker.APC.DeviceData.Pressure1Feedback;
  679. }
  680. if (checker.Parameter.IsWarningEnable && checker.Parameter.WarningTime > 0)
  681. checker.ToleranceCheckerWarning.Monitor(pressureFeedback,
  682. checker.APC.DeviceData.PressureSetPoint - warningLow, checker.APC.DeviceData.PressureSetPoint + warningHigh, checker.Parameter.WarningTime);
  683. if (checker.Parameter.IsAlarmEnable && checker.Parameter.AlarmTime > 0)
  684. checker.ToleranceCheckerAlarm.Monitor(pressureFeedback,
  685. checker.APC.DeviceData.PressureSetPoint - alarmLow, checker.APC.DeviceData.PressureSetPoint + alarmHigh, checker.Parameter.AlarmTime);
  686. if (checker.ToleranceCheckerAlarm.Trig || checker.ToleranceCheckerWarning.Trig)
  687. {
  688. var range = "";
  689. var time = "";
  690. var command = checker.Parameter.AlarmCommand;
  691. if (checker.ToleranceCheckerAlarm.Trig)
  692. {
  693. range = $"({checker.APC.DeviceData.PressureSetPoint - alarmLow},{checker.APC.DeviceData.PressureSetPoint + alarmHigh})";
  694. time = $"{checker.Parameter.AlarmTime:F1}";
  695. alarmToleranceAlarm.Set($"APC Press{i + 1} out of range {range} {unit} in {time} seconds");
  696. command = checker.Parameter.AlarmCommand;
  697. }
  698. else if (checker.ToleranceCheckerWarning.Trig)
  699. {
  700. range = $"({checker.APC.DeviceData.PressureSetPoint - warningLow},{checker.APC.DeviceData.PressureSetPoint + warningHigh})";
  701. time = $"{checker.Parameter.WarningTime:F1}";
  702. alarmToleranceWarning.Set($"APC Press{i + 1} out of range {range} {unit} in {time} seconds");
  703. command = checker.Parameter.WarningCommand;
  704. }
  705. ProcessAlarmConditionErrorCommand(command);
  706. }
  707. }
  708. }
  709. }
  710. private void MonitorAUXAlarmCondition()
  711. {
  712. if (SC.ContainsItem("Minics.EnableMinics") && SC.GetValue<bool>("Minics.EnableMinics"))
  713. { return; }
  714. for (int i = 0; i < _auxChecker.Count; i++)
  715. {
  716. var checker = _auxChecker[i];
  717. if (checker.Parameter.Unit == null)
  718. continue;
  719. var warningLow = checker.Parameter.WarningLow;
  720. var warningHigh = checker.Parameter.WarningHigh;
  721. var alarmLow = checker.Parameter.AlarmLow;
  722. var alarmHigh = checker.Parameter.AlarmHigh;
  723. var unit = "";
  724. var setpoint = 0.0f;
  725. var feedback = 0.0f;
  726. var display = "";
  727. if (_auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  728. {
  729. foreach (var item in _auxDic[_currentAuxTable])
  730. {
  731. if (item == null || checker.AUXIOName != item.IOName)
  732. continue;
  733. setpoint = (float)item.SetPointConfig.DoubleValue;
  734. unit = item.Unit;
  735. display = item.DisplayNameConfig.StringValue;
  736. feedback = IO.AI[$"{Module}.{item.IOName}"] != null ? IO.AI[$"{Module}.{item.IOName}"].FloatValue : 0;
  737. break;
  738. }
  739. }
  740. if (checker.Parameter.Unit.ToLower() == "%sv")
  741. {
  742. warningLow = (float)setpoint * warningLow / 100.0f;
  743. warningHigh = (float)setpoint * warningHigh / 100.0f;
  744. alarmLow = (float)setpoint * alarmLow / 100.0f;
  745. alarmHigh = (float)setpoint * alarmHigh / 100.0f;
  746. }
  747. else if (checker.Parameter.Unit.ToLower() == "%fs")
  748. {
  749. //后续改为scale
  750. warningLow = (float)setpoint * warningLow / 100.0f;
  751. warningHigh = (float)setpoint * warningHigh / 100.0f;
  752. alarmLow = (float)setpoint * alarmLow / 100.0f;
  753. alarmHigh = (float)setpoint * alarmHigh / 100.0f;
  754. }
  755. if (checker.Parameter.IsWarningEnable && checker.Parameter.WarningTime > 0 && checker.DelayTimer.IsRunning && checker.DelayTimer.ElapsedMilliseconds >= checker.Parameter.WarningDelayDetectTimeS * 1000)
  756. checker.ToleranceCheckerWarning.Monitor(feedback,
  757. setpoint - warningLow, setpoint + warningHigh, checker.Parameter.WarningTime);
  758. if (checker.Parameter.IsAlarmEnable && checker.Parameter.AlarmTime > 0 && checker.DelayTimer.IsRunning && checker.DelayTimer.ElapsedMilliseconds >= checker.Parameter.AlarmDelayDetectTimeS * 1000)
  759. checker.ToleranceCheckerAlarm.Monitor(feedback,
  760. setpoint - alarmLow, setpoint + alarmHigh, checker.Parameter.AlarmTime);
  761. if (checker.ToleranceCheckerAlarm.Trig || checker.ToleranceCheckerWarning.Trig)
  762. {
  763. var range = "";
  764. var time = "";
  765. var ret = AUXAlarmDic.TryGetValue(checker.AUXIndex, out var AUXAlarm);
  766. if (ret)
  767. {
  768. var command = checker.Parameter.AlarmCommand;
  769. if (checker.ToleranceCheckerAlarm.Trig)
  770. {
  771. range = $"({(setpoint - alarmLow).ToString("f3")},{(setpoint + alarmHigh).ToString("f3")})";
  772. time = $"{checker.Parameter.AlarmTime:F1}";
  773. AUXAlarm.Item2.Set($"AUX {display} value out of range {range} {unit} in {time} seconds");
  774. command = checker.Parameter.AlarmCommand;
  775. }
  776. else if (checker.ToleranceCheckerWarning.Trig)
  777. {
  778. range = $"({(setpoint - warningLow).ToString("f3")},{(setpoint + warningHigh).ToString("f3")})";
  779. time = $"{checker.Parameter.WarningTime:F1}";
  780. AUXAlarm.Item1.Set($"AUX {display} value out of range {range} {unit} in {time} seconds");
  781. command = checker.Parameter.WarningCommand;
  782. }
  783. ProcessAlarmConditionErrorCommand(command);
  784. }
  785. }
  786. }
  787. }
  788. private void MonitorMFCAlarmCondition()
  789. {
  790. for (int i = 0; i < _mfcChecker.Count; i++)
  791. {
  792. var checker = _mfcChecker[i];
  793. if (checker.Parameter.Unit == null)
  794. continue;
  795. var warningLow = checker.Parameter.WarningLow;
  796. var warningHigh = checker.Parameter.WarningHigh;
  797. var alarmLow = checker.Parameter.AlarmLow;
  798. var alarmHigh = checker.Parameter.AlarmHigh;
  799. var unit = checker.MFC.Unit;
  800. if (checker.Parameter.Unit.ToLower() == "%sv")
  801. {
  802. warningLow = (float)checker.MFC.SetPoint * warningLow / 100.0f;
  803. warningHigh = (float)checker.MFC.SetPoint * warningHigh / 100.0f;
  804. alarmLow = (float)checker.MFC.SetPoint * alarmLow / 100.0f;
  805. alarmHigh = (float)checker.MFC.SetPoint * alarmHigh / 100.0f;
  806. }
  807. else if (checker.Parameter.Unit.ToLower() == "%fs")
  808. {
  809. warningLow = (float)checker.MFC.Scale * warningLow / 100.0f;
  810. warningHigh = (float)checker.MFC.Scale * warningHigh / 100.0f;
  811. alarmLow = (float)checker.MFC.Scale * alarmLow / 100.0f;
  812. alarmHigh = (float)checker.MFC.Scale * alarmHigh / 100.0f;
  813. }
  814. if (checker.Parameter.IsWarningEnable && checker.Parameter.WarningTime > 0 && checker.DelayTimer.IsRunning && checker.DelayTimer.ElapsedMilliseconds >= checker.Parameter.WarningDelayDetectTimeS * 1000)
  815. checker.ToleranceCheckerWarning.Monitor(checker.MFC.FeedBack,
  816. checker.MFC.SetPoint - warningLow, checker.MFC.SetPoint + warningHigh, checker.Parameter.WarningTime);
  817. if (checker.Parameter.IsAlarmEnable && checker.Parameter.AlarmTime > 0 && checker.DelayTimer.IsRunning && checker.DelayTimer.ElapsedMilliseconds >= checker.Parameter.AlarmDelayDetectTimeS * 1000)
  818. checker.ToleranceCheckerAlarm.Monitor(checker.MFC.FeedBack,
  819. checker.MFC.SetPoint - alarmLow, checker.MFC.SetPoint + alarmHigh, checker.Parameter.AlarmTime);
  820. if (checker.ToleranceCheckerAlarm.Trig || checker.ToleranceCheckerWarning.Trig)
  821. {
  822. var range = "";
  823. var time = "";
  824. var command = checker.Parameter.AlarmCommand;
  825. if (checker.ToleranceCheckerAlarm.Trig)
  826. {
  827. range = $"({(checker.MFC.SetPoint - alarmLow).ToString("f3")},{(checker.MFC.SetPoint + alarmHigh).ToString("f3")})";
  828. time = $"{checker.Parameter.AlarmTime:F1}";
  829. checker.MFC.AlarmToleranceAlarm.Set($"{Display} flow out of range {range} {unit} in {time} seconds");
  830. command = checker.Parameter.AlarmCommand;
  831. }
  832. else if (checker.ToleranceCheckerWarning.Trig)
  833. {
  834. range = $"({(checker.MFC.SetPoint - warningLow).ToString("f3")},{(checker.MFC.SetPoint + warningHigh).ToString("f3")})";
  835. time = $"{checker.Parameter.WarningTime:F1}";
  836. checker.MFC.AlarmToleranceWarning.Set($"{Display} flow out of range {range} {unit} in {time} seconds");
  837. command = checker.Parameter.WarningCommand;
  838. }
  839. ProcessAlarmConditionErrorCommand(command);
  840. }
  841. }
  842. }
  843. private void MonitorHeaterAlarmCondition()
  844. {
  845. for (int i = 0; i < _heaterChecker.Count; i++)
  846. {
  847. var checker = _heaterChecker[i];
  848. if (checker.Parameter.Unit == null)
  849. continue;
  850. if (checker.Parameter.IsWarningEnable && checker.Parameter.WarningTime > 0 && checker.DelayTimer.IsRunning && checker.DelayTimer.ElapsedMilliseconds >= checker.Parameter.WarningDelayDetectTimeS * 1000)
  851. checker.ToleranceCheckerWarning.Monitor(checker.Heater.TempFeedback,
  852. checker.Heater.TempSetPoint - checker.Parameter.WarningLow, checker.Heater.TempSetPoint + checker.Parameter.WarningHigh, checker.Parameter.WarningTime);
  853. if (checker.Parameter.IsAlarmEnable && checker.Parameter.AlarmTime > 0 && checker.DelayTimer.IsRunning && checker.DelayTimer.ElapsedMilliseconds >= checker.Parameter.AlarmDelayDetectTimeS * 1000)
  854. checker.ToleranceCheckerAlarm.Monitor(checker.Heater.TempFeedback,
  855. checker.Heater.TempSetPoint - checker.Parameter.AlarmLow, checker.Heater.TempSetPoint + checker.Parameter.AlarmHigh, checker.Parameter.AlarmTime);
  856. if (checker.ToleranceCheckerAlarm.Trig || checker.ToleranceCheckerWarning.Trig)
  857. {
  858. var range = "";
  859. var time = "";
  860. var command = checker.Parameter.AlarmCommand;
  861. if (checker.ToleranceCheckerAlarm.Trig)
  862. {
  863. range = $"({checker.Heater.TempSetPoint - checker.Parameter.AlarmLow},{checker.Heater.TempSetPoint + checker.Parameter.AlarmHigh})";
  864. time = $"{checker.Parameter.AlarmTime:F1}";
  865. checker.Heater.AlarmToleranceAlarm.Set($"{Display} temperature out of range {range} °C in {time} seconds");
  866. command = checker.Parameter.AlarmCommand;
  867. }
  868. else if (checker.ToleranceCheckerWarning.Trig)
  869. {
  870. range = $"({checker.Heater.TempSetPoint - checker.Parameter.WarningLow},{checker.Heater.TempSetPoint + checker.Parameter.WarningHigh})";
  871. time = $"{checker.Parameter.WarningTime:F1}";
  872. checker.Heater.AlarmToleranceWarning.Set($"{Display} temperature out of range {range} °C in {time} seconds");
  873. command = checker.Parameter.WarningCommand;
  874. }
  875. ProcessAlarmConditionErrorCommand(command);
  876. }
  877. }
  878. }
  879. private void ProcessAlarmConditionErrorCommand(string command)
  880. {
  881. var recipe = "";
  882. var recipeType = "";
  883. var recipeTable = "";
  884. switch (command)
  885. {
  886. case "Reset":
  887. if (_isAlarmConditionHasRecipeCommand)
  888. break;
  889. _isAlarmConditionHasRecipeCommand = true;
  890. recipe = SC.GetStringValue("System.Recipe.Reset Recipe");
  891. recipeType = "Reset";
  892. CheckToPostMessage((int)MSG.RunOtherRecipe, recipe, recipeType);
  893. LOG.Write($"Alarm condition: command={command} recipe={recipe}");
  894. break;
  895. case "End":
  896. if (_isAlarmConditionHasRecipeCommand)
  897. break;
  898. _isAlarmConditionHasRecipeCommand = true;
  899. if (IsProcessing)
  900. {
  901. //因为要跳到执行最后一步,所以stepNumber需要减一
  902. _processRoutine.JumpCurrentRecipeStep(RecipeRunningInfo.RecipeStepList.Count - 1, RecipeRunningInfo.RecipeStepList[RecipeRunningInfo.RecipeStepList.Count - 1].StepName);
  903. }
  904. else
  905. {
  906. if (!RecipeParser.Parse(SC.GetStringValue("PM1.ProcessRecipe"), Module, out var recipeHead, out var recipeSteps, out var reason, "Process"))
  907. {
  908. PreprocessStartFailedWarning.Set($"Load process recipe {SC.GetStringValue("PM1.ProcessRecipe")} failed, {reason}");
  909. return;
  910. }
  911. RecipeRunningInfo.MainRecipeName = SC.GetStringValue("PM1.ProcessRecipe");
  912. RecipeRunningInfo.Head = recipeHead;
  913. RecipeRunningInfo.RecipeStepList = recipeSteps;
  914. CheckToPostMessage((int)MSG.AlarmConditionJumpStep, RecipeRunningInfo.RecipeStepList.Count - 1);
  915. }
  916. LOG.Write($"Alarm condition: command={command} step name={RecipeRunningInfo.RecipeStepList[RecipeRunningInfo.RecipeStepList.Count - 1].StepName}");
  917. break;
  918. case "Hold":
  919. if (_isAlarmConditionHasRecipeCommand)
  920. break;
  921. _isAlarmConditionHasRecipeCommand = true;
  922. _processRoutine.PauseRecipe();
  923. LOG.Write($"Alarm condition: command={command}");
  924. break;
  925. case "Monitor":
  926. LOG.Write($"Alarm condition: command={command}");
  927. break;
  928. case "Buzzer":
  929. Singleton<EquipmentManager>.Instance.IsAlarmConditionBuzzerOn = true;
  930. LOG.Write($"Alarm condition: command={command}");
  931. break;
  932. default:
  933. if (_isAlarmConditionHasRecipeCommand)
  934. break;
  935. _isAlarmConditionHasRecipeCommand = true;
  936. if (command.StartsWith("JUMP"))
  937. {
  938. //Jump step
  939. //Jump 1:
  940. var stepName = command.Replace("JUMP ", "");
  941. if (IsProcessing)
  942. {
  943. var jumpStepNumber = RecipeRunningInfo.RecipeStepList.FindIndex(x => x.StepName == stepName);
  944. if (jumpStepNumber > 0)
  945. {
  946. _processRoutine.JumpCurrentRecipeStep(jumpStepNumber, stepName);
  947. }
  948. }
  949. else
  950. {
  951. if (!RecipeParser.Parse(SC.GetStringValue("PM1.ProcessRecipe"), Module, out var recipeHead, out var recipeSteps, out var reason, "Process"))
  952. {
  953. PreprocessStartFailedWarning.Set($"Load process recipe {SC.GetStringValue("PM1.ProcessRecipe")} failed, {reason}");
  954. return;
  955. }
  956. RecipeRunningInfo.MainRecipeName = SC.GetStringValue("PM1.ProcessRecipe");
  957. RecipeRunningInfo.Head = recipeHead;
  958. RecipeRunningInfo.RecipeStepList = recipeSteps;
  959. var jumpStepNumber = RecipeRunningInfo.RecipeStepList.FindIndex(x => x.StepName == stepName);
  960. if (jumpStepNumber > 0)
  961. {
  962. CheckToPostMessage((int)MSG.AlarmConditionJumpStep, jumpStepNumber);
  963. }
  964. }
  965. LOG.Write($"Alarm condition: command={command} step name={stepName}");
  966. }
  967. else if (command.StartsWith("CALL"))
  968. {
  969. //call Alarm recipe
  970. //Call 1:
  971. var paras = command.Split(':');
  972. if (paras.Length > 0)
  973. {
  974. recipe = RecipeRunningInfo.Head.AlarmRecipe;
  975. recipeType = "Alarm";
  976. recipeTable = paras[0].Replace("CALL", "").Replace(" ", "").Replace(":", "").Replace(":", "");
  977. CheckToPostMessage((int)MSG.RunOtherRecipe, recipe, recipeType, recipeTable);
  978. LOG.Write($"Alarm condition: command={command} recipe={recipe}");
  979. }
  980. }
  981. else if (command.StartsWith("ABORT"))
  982. {
  983. //call Abort recipe
  984. //Abort 1:
  985. var paras = command.Split(':');
  986. if (paras.Length > 0)
  987. {
  988. recipe = RecipeRunningInfo.Head.AbortRecipe;
  989. recipeType = "Abort";
  990. recipeTable = paras[0].Replace("ABORT", "").Replace(" ", "").Replace(":", "").Replace(":", "");
  991. CheckToPostMessage((int)MSG.RunOtherRecipe, recipe, recipeType, recipeTable);
  992. LOG.Write($"Alarm condition: command={command} recipe={recipe}");
  993. }
  994. }
  995. break;
  996. }
  997. }
  998. private List<AlarmConditionAIParameter> InitAlarmConditionItem(string content)
  999. {
  1000. List<AlarmConditionAIParameter> items = new List<AlarmConditionAIParameter>();
  1001. if (string.IsNullOrEmpty(content))
  1002. return items;
  1003. var zoneParas = content.Split('|');
  1004. foreach (var zonePara in zoneParas)
  1005. {
  1006. //U;Alert,True,0,0,℃,5,Monitor;Alarm,True,0,0,℃,6,Buzzer
  1007. //1;C1-N2-1;Alert,True,0,0,%fs,5,Buzzer;Alarm,True,0,0,%fs,6,Buzzer
  1008. //1;MS1;Alert,True,0,0,%fs,5,Monitor;Alarm,True,0,0,%fs,6,Monitor
  1009. AlarmConditionAIParameter item = new AlarmConditionAIParameter();
  1010. var array = zonePara.Split(';');
  1011. if (array.Length > 2)
  1012. {
  1013. item.Name = array[0];
  1014. var warningParas = array[array.Length - 2].Split(',');
  1015. var alarmParas = array[array.Length - 1].Split(',');
  1016. if (warningParas.Length > 6)
  1017. {
  1018. bool.TryParse(warningParas[1], out bool isEnable);
  1019. float.TryParse(warningParas[2], out float high);
  1020. float.TryParse(warningParas[3], out float low);
  1021. item.Unit = warningParas[4];
  1022. float.TryParse(warningParas[5], out float time);
  1023. item.WarningCommand = warningParas[6];
  1024. item.IsWarningEnable = isEnable;
  1025. item.WarningHigh = high;
  1026. item.WarningLow = low;
  1027. item.WarningTime = time;
  1028. }
  1029. if (warningParas.Length > 7)
  1030. {
  1031. float.TryParse(warningParas[7], out float time);
  1032. item.WarningDelayDetectTimeS = time;
  1033. }
  1034. if (alarmParas.Length > 6)
  1035. {
  1036. bool.TryParse(alarmParas[1], out bool isEnable);
  1037. float.TryParse(alarmParas[2], out float high);
  1038. float.TryParse(alarmParas[3], out float low);
  1039. item.Unit = alarmParas[4];
  1040. float.TryParse(alarmParas[5], out float time);
  1041. item.AlarmCommand = alarmParas[6];
  1042. item.IsAlarmEnable = isEnable;
  1043. item.AlarmHigh = high;
  1044. item.AlarmLow = low;
  1045. item.AlarmTime = time;
  1046. }
  1047. if (alarmParas.Length > 7)
  1048. {
  1049. float.TryParse(alarmParas[7], out float time);
  1050. item.AlarmDelayDetectTimeS = time;
  1051. }
  1052. }
  1053. items.Add(item);
  1054. }
  1055. return items;
  1056. }
  1057. private List<AlarmConditionDIParameter> InitAlarmConditionDIItem(string content)
  1058. {
  1059. List<AlarmConditionDIParameter> items = new List<AlarmConditionDIParameter>();
  1060. if (string.IsNullOrEmpty(content))
  1061. return items;
  1062. var zoneParas = content.Split('|');
  1063. foreach (var zonePara in zoneParas)
  1064. {
  1065. //1,Air/N2-7 Pressure Too Low,Alert,False,Buzzer|2,N2-1 Pressure Too Low,Alert,False,End
  1066. AlarmConditionDIParameter item = new AlarmConditionDIParameter();
  1067. var array = zonePara.Split(',');
  1068. if (array.Length > 4)
  1069. {
  1070. item.Name = array[1];
  1071. item.IsAlarm = array[2].ToLower() == "alarm";
  1072. bool.TryParse(array[3], out bool isEnable);
  1073. item.IsEnable = isEnable;
  1074. item.Command = array[4];
  1075. }
  1076. items.Add(item);
  1077. }
  1078. return items;
  1079. }
  1080. class AlarmConditionChecker
  1081. {
  1082. public FurnaceRT.Devices.IoHeater Heater { get; set; }
  1083. public FurnaceRT.Devices.IoAPC APC { get; set; }
  1084. public FurnaceRT.Equipments.PMs.Devices.IoMFC MFC { get; set; }
  1085. public string AUXIOName { get; set; }
  1086. public int AUXIndex { get; set; }
  1087. public ToleranceChecker ToleranceCheckerWarning { get; set; }
  1088. public ToleranceChecker ToleranceCheckerAlarm { get; set; }
  1089. public AlarmConditionAIParameter Parameter { get; set; }
  1090. public Stopwatch DelayTimer { get; set; }//N秒过后才检测
  1091. }
  1092. class AlarmConditionTableParameter
  1093. {
  1094. public int No { get; set; }
  1095. public string Name { get; set; }
  1096. public List<AlarmConditionAIParameter> HeaterParameterLst { get; set; }
  1097. public List<AlarmConditionAIParameter> MFCParameterLst { get; set; }
  1098. public List<AlarmConditionAIParameter> APCParameterLst { get; set; }
  1099. public List<AlarmConditionAIParameter> AUXParameterLst { get; set; }
  1100. public List<AlarmConditionDIParameter> InterlockParameterLst { get; set; }
  1101. }
  1102. class AlarmConditionAIParameter
  1103. {
  1104. //类似AI的
  1105. public string Name { get; set; }
  1106. public string Unit { get; set; }
  1107. public string DataPoll { get; set; }
  1108. public float WarningHigh { get; set; }
  1109. public float WarningLow { get; set; }
  1110. public float WarningTime { get; set; }
  1111. public string WarningCommand { get; set; }
  1112. public bool IsWarningEnable { get; set; }
  1113. public float AlarmHigh { get; set; }
  1114. public float AlarmLow { get; set; }
  1115. public float AlarmTime { get; set; }
  1116. public string AlarmCommand { get; set; }
  1117. public bool IsAlarmEnable { get; set; }
  1118. public float WarningDelayDetectTimeS { get; set; } = 0;//N秒过后才检测
  1119. public float AlarmDelayDetectTimeS { get; set; } = 0;//N秒过后才检测
  1120. public AlarmConditionAIParameter Clone(AlarmConditionAIParameter source)
  1121. {
  1122. AlarmConditionAIParameter clone = new AlarmConditionAIParameter();
  1123. clone.Name = source.Name;
  1124. clone.Unit = source.Unit;
  1125. clone.DataPoll = source.DataPoll;
  1126. clone.WarningHigh = source.WarningHigh;
  1127. clone.WarningLow = source.WarningLow;
  1128. clone.WarningTime = source.WarningTime;
  1129. clone.WarningCommand = source.WarningCommand;
  1130. clone.IsWarningEnable = source.IsWarningEnable;
  1131. clone.AlarmHigh = source.AlarmHigh;
  1132. clone.AlarmLow = source.AlarmLow;
  1133. clone.AlarmTime = source.AlarmTime;
  1134. clone.AlarmCommand = source.AlarmCommand;
  1135. clone.IsAlarmEnable = source.IsAlarmEnable;
  1136. return clone;
  1137. }
  1138. }
  1139. class AlarmConditionDIParameter
  1140. {
  1141. //类似DI的
  1142. public string Name { get; set; }
  1143. public string DataPoll { get; set; }
  1144. public bool IsAlarm { get; set; }
  1145. public bool IsEnable { get; set; }
  1146. public string Command { get; set; }
  1147. }
  1148. class AlarmConditionBoatParameter
  1149. {
  1150. //Boat load,unload温度判断
  1151. public string Name { get; set; }
  1152. public string DataPoll { get; set; }
  1153. public bool IsAlarm { get; set; }
  1154. public bool IsEnable { get; set; }
  1155. public float AlarmHighLimit { get; set; }
  1156. }
  1157. }
  1158. }