PMAux.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. using Aitex.Core.Common.DeviceData;
  2. using Aitex.Core.RT.DataCenter;
  3. using Aitex.Core.RT.Device;
  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.SCCore;
  9. using Aitex.Core.Util;
  10. using Aitex.Core.Utilities;
  11. using FurnaceRT.Devices;
  12. using MECF.Framework.Common.DataCenter;
  13. using MECF.Framework.Common.Event;
  14. using MECF.Framework.Common.OperationCenter;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.Diagnostics;
  19. using System.Linq;
  20. namespace FurnaceRT.Equipments.PMs
  21. {
  22. public partial class PMModule
  23. {
  24. private Dictionary<int, List<AITAuxData>> _auxDic;
  25. private int _currentAuxTable = 1;
  26. private bool _isF2ClnOn;
  27. private bool _isHFClnOn;
  28. private bool _isDEPOOn;
  29. private bool _isHTR1Enable;
  30. private bool _isHTR2Enable;
  31. private bool _isHTR3Enable;
  32. private bool _isCEXHOn;
  33. private string _toolType;
  34. private Dictionary<string, float> _auxScaleDic;
  35. private Stopwatch _initTimer = new Stopwatch();
  36. private List<string> _auxNames = new List<string>();
  37. public bool IsHTR1Enable
  38. {
  39. get
  40. {
  41. return _isHTR1Enable;
  42. }
  43. set
  44. {
  45. _isHTR1Enable = value;
  46. SC.SetItemValue($"PM1.IsHTR1Enable", value);
  47. TrigHTR1SWON?.SetTrigger(value, out _);
  48. //_HTR1Group.ForEach(x => x.SetEnable(value));
  49. }
  50. }
  51. public bool IsHTR2Enable
  52. {
  53. get
  54. {
  55. return _isHTR2Enable;
  56. }
  57. set
  58. {
  59. _isHTR2Enable = value;
  60. SC.SetItemValue($"PM1.IsHTR2Enable", value);
  61. TrigHTR2SWON?.SetTrigger(value, out _);
  62. _HTR2Group.ForEach(x => x.SetEnable(value));
  63. }
  64. }
  65. public bool IsHTR3Enable
  66. {
  67. get
  68. {
  69. return _isHTR3Enable;
  70. }
  71. set
  72. {
  73. _isHTR3Enable = value;
  74. SC.SetItemValue($"PM1.IsHTR3Enable", value);
  75. TrigHTR3SWON?.SetTrigger(value, out _);
  76. TrigForlineHeaterOn.SetTrigger(value, out _);
  77. }
  78. }
  79. public bool IsF2ClnOn
  80. {
  81. get
  82. {
  83. return _isF2ClnOn;
  84. }
  85. set
  86. {
  87. _isF2ClnOn = value;
  88. SC.SetItemValue($"PM1.IsF2ClnOn", value);
  89. TrigF2CleanSwitchB?.SetTrigger(value, out _);
  90. }
  91. }
  92. public bool IsHFClnOn
  93. {
  94. get
  95. {
  96. return _isHFClnOn;
  97. }
  98. set
  99. {
  100. _isHFClnOn = value;
  101. SC.SetItemValue($"PM1.IsHFClnOn", value);
  102. TrigHFCleanSwitchB?.SetTrigger(value, out _);
  103. }
  104. }
  105. public bool IsDEPOOn
  106. {
  107. get
  108. {
  109. return _isDEPOOn;
  110. }
  111. set
  112. {
  113. _isDEPOOn = value;
  114. SC.SetItemValue($"PM1.IsDEPOOn", value);
  115. TrigDEPOSW?.SetTrigger(value, out _);
  116. }
  117. }
  118. public bool IsCREFOn
  119. {
  120. get
  121. {
  122. return _isCREFOn;
  123. }
  124. set
  125. {
  126. _isCREFOn = value;
  127. TrigCREFON?.SetTrigger(value, out _);
  128. }
  129. }
  130. private bool _isCREFOn;
  131. public bool IsSIREFOn
  132. {
  133. get
  134. {
  135. return _isSIREFOn;
  136. }
  137. set
  138. {
  139. _isSIREFOn = value;
  140. TrigSIREFON?.SetTrigger(value, out _);
  141. }
  142. }
  143. private bool _isSIREFOn;
  144. private void InitAUX()
  145. {
  146. GetAuxNames();
  147. IsHFClnOn = SC.GetValue<bool>($"PM1.IsHFClnOn");
  148. IsF2ClnOn = SC.GetValue<bool>($"PM1.IsF2ClnOn");
  149. _toolType = (string)SC.GetStringValue("System.SetUp.ToolType");
  150. _auxDic = new Dictionary<int, List<AITAuxData>>();
  151. for (int table = 1; table < 5; table++)
  152. {
  153. List<AITAuxData> auxs = new List<AITAuxData>();
  154. for (int index = 1; index < 256; index++)
  155. {
  156. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.Set"))
  157. continue;
  158. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningLowLimit"))
  159. continue;
  160. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningHighLimit"))
  161. continue;
  162. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmLowLimit"))
  163. continue;
  164. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmHighLimit"))
  165. continue;
  166. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.{index}.Display"))
  167. continue;
  168. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.{index}.AI"))
  169. continue;
  170. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.{index}.Unit"))
  171. continue;
  172. AITAuxData aux = new AITAuxData()
  173. {
  174. DisplayName = SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Display"),
  175. DisplayNameConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.{index}.Display"),
  176. IOName = SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI"),
  177. AO = IO.AO[$"{Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO")}"],
  178. AISV = IO.AI[$"{Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI").Replace("PV", "SV")}"],
  179. AOAlarmHigher = IO.AO[$"{Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO").Replace("SV", "AlarmHigher")}"],
  180. AOAlarmLower = IO.AO[$"{Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO").Replace("SV", "AlarmLower")}"],
  181. Unit = SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Unit"),
  182. UnitConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.{index}.Unit"),
  183. SetPoint = (float)SC.GetValue<double>($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.Set"),
  184. SetPointConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.Set"),
  185. WarningLowLimit = (float)SC.GetValue<double>($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningLowLimit"),
  186. WarningLowLimitConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningLowLimit"),
  187. WarningHighLimit = (float)SC.GetValue<double>($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningHighLimit"),
  188. WarningHighLimitConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningHighLimit"),
  189. AlarmLowLimit = (float)SC.GetValue<double>($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmLowLimit"),
  190. AlarmLowLimitConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmLowLimit"),
  191. AlarmHighLimit = (float)SC.GetValue<double>($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmHighLimit"),
  192. AlarmHighLimitConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmHighLimit"),
  193. WarningLowLimitTrig = new R_TRIG(),
  194. WarningHighLimitTrig = new R_TRIG(),
  195. AlarmLowLimitTrig = new R_TRIG(),
  196. AlarmHighLimitTrig = new R_TRIG(),
  197. Index = index,
  198. WarningLowLimitEvent = SubscribeAlarm(new AlarmEventItem()
  199. {
  200. EventEnum = $"{Name}.WarningLowLimit.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI")}",
  201. Description = $"{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Display")} Low Limit",
  202. Solution = "No information available. Press[Clear] to delete alarm message.",
  203. Explaination = "No information available.",
  204. AutoRecovery = false,
  205. Level = EventLevel.Warning,
  206. Action = EventAction.Clear,
  207. Category = "TubeAlarm",
  208. }, () => { ResetAUXTrig(); return true; }),
  209. WarningHighLimitEvent = SubscribeAlarm(new AlarmEventItem()
  210. {
  211. EventEnum = $"{Name}.WarningHighLimit.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI")}",
  212. Description = $"{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Display")} High Limit",
  213. Solution = "No information available. Press[Clear] to delete alarm message.",
  214. Explaination = "No information available.",
  215. AutoRecovery = false,
  216. Level = EventLevel.Warning,
  217. Action = EventAction.Clear,
  218. Category = "TubeAlarm",
  219. }, () => { ResetAUXTrig(); return true; }),
  220. AlarmLowLimitEvent = SubscribeAlarm(new AlarmEventItem()
  221. {
  222. EventEnum = $"{Name}.AlarmLowLimit.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI")}",
  223. Description = $"{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Display")} Low Limit",
  224. Solution = "No information available. Press[Clear] to delete alarm message.",
  225. Explaination = "No information available.",
  226. AutoRecovery = false,
  227. Level = EventLevel.Alarm,
  228. Action = EventAction.Clear,
  229. Category = "TubeAlarm",
  230. }, () => { ResetAUXTrig(); return true; }),
  231. AlarmHighLimitEvent = SubscribeAlarm(new AlarmEventItem()
  232. {
  233. EventEnum = $"{Name}.AlarmHighLimit.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI")}",
  234. Description = $"{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Display")} High Limit",
  235. Solution = "No information available. Press[Clear] to delete alarm message.",
  236. Explaination = "No information available.",
  237. AutoRecovery = false,
  238. Level = EventLevel.Alarm,
  239. Action = EventAction.Clear,
  240. Category = "TubeAlarm",
  241. }, () => { ResetAUXTrig(); return true; }),
  242. };
  243. if (SC.ContainsItem($"PM1.RecipeEditParameter.AUX.{index}.IsInstalled") && SC.GetValue<bool>($"PM1.RecipeEditParameter.AUX.{index}.IsInstalled") == false)
  244. {
  245. aux.IsInstalled = false;
  246. }
  247. else
  248. {
  249. aux.IsInstalled = true;
  250. }
  251. if (SC.GetStringValue("System.SetUp.ToolType") == "ELK")
  252. {
  253. if (index <= 96)
  254. {
  255. if (aux.DisplayName.Length > 5)
  256. aux.Module = aux.DisplayName.Substring(0, 5).Replace("Unit", "GasLine");
  257. aux.IOName = $"{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI")}";
  258. aux.AO = IO.AO[$"{aux.Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO")}"];
  259. aux.AISV = null;
  260. aux.AOAlarmHigher = IO.AO[$"{aux.Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO").Replace("SV", "AlarmHigherPoint")}"];
  261. aux.AOAlarmLower = IO.AO[$"{aux.Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO").Replace("SV", "AlarmLowerPoint")}"];
  262. }
  263. }
  264. else
  265. {
  266. //需求: aux只需要gasline heater,Foline heater的alarm 不需要报警(序号68之后都是Foline heater)
  267. if (index >= 68)
  268. {
  269. aux.WarningLowLimitEvent = new AlarmEventItem();
  270. aux.WarningHighLimitEvent = new AlarmEventItem();
  271. aux.AlarmLowLimitEvent = new AlarmEventItem();
  272. aux.AlarmHighLimitEvent = new AlarmEventItem();
  273. }
  274. }
  275. auxs.Add(aux);
  276. }
  277. if (auxs.Any())
  278. _auxDic.Add(table, auxs);
  279. }
  280. _auxScaleDic = new Dictionary<string, float>()
  281. {
  282. { "AI_ForelineHeater1TempPV", 1},
  283. { "AI_ForelineHeater2TempPV", 1},
  284. { "AI_ForelineHeater3TempPV", 1},
  285. { "AI_ForelineHeater4TempPV", 1},
  286. { "AI_ForelineHeater5TempPV", 1},
  287. { "AI_ForelineHeater6TempPV", 1},
  288. { "AI_ForelineHeater7TempPV", 1},
  289. { "AI_ForelineHeater8TempPV", 1},
  290. { "AI_ForelineHeater9TempPV", 1},
  291. { "AI_ForelineHeater10TempPV", 1},
  292. { "AI_ForelineHeater11TempPV", 1},
  293. { "AI_ForelineHeater12TempPV", 1},
  294. { "AI_CapHeaterTempPV", 1},
  295. { "AI_APCExternalHeaterTempPV", 1},
  296. { "AI_APCRingHeaterTempPV", 1},
  297. { "AI_GaslineHeater1PV", 1},
  298. { "AI_GaslineHeater2PV", 1},
  299. { "AI_GaslineHeater3PV", 1},
  300. { "AI_GaslineHeater4PV", 1},
  301. { "AI_GaslineHeater5PV", 1},
  302. { "AI_GaslineHeater6PV", 1},
  303. { "AI_GaslineHeater7PV", 1},
  304. { "AI_GaslineHeater8PV", 1},
  305. { "AI_GaslineHeater9PV", 1},
  306. { "AI_GaslineHeater10PV", 1},
  307. { "AI_GaslineHeater11PV", 1},
  308. { "AI_GaslineHeater12PV", 1},
  309. { "AI_GaslineHeater13PV", 1},
  310. { "AI_GaslineHeater14PV", 1},
  311. { "AI_GaslineHeater15PV", 1},
  312. { "AI_GaslineHeater16PV", 1},
  313. { "AI_GaslineHeater17PV", 1},
  314. { "AI_GaslineHeater18PV", 1},
  315. { "AI_GaslineHeater19PV", 1},
  316. { "AI_GaslineHeater20PV", 1},
  317. { "AI_GaslineHeater21PV", 1},
  318. { "AI_GaslineHeater22PV", 1},
  319. { "AI_GaslineHeater23PV", 1},
  320. { "AI_GaslineHeater24PV", 1},
  321. { "AI_GaslineHeater25PV", 1},
  322. { "AI_GaslineHeater26PV", 1},
  323. { "AI_GaslineHeater27PV", 1},
  324. { "AI_GaslineHeater28PV", 1},
  325. { "AI_GaslineHeater29PV", 1},
  326. { "AI_GaslineHeater30PV", 1},
  327. { "AI_GaslineHeater31PV", 1},
  328. { "AI_GaslineHeater32PV", 1},
  329. { "AI_GaslineHeater33PV", 1},
  330. { "AI_GaslineHeater34PV", 1},
  331. { "AI_GaslineHeater35PV", 1},
  332. { "AI_GaslineHeater36PV", 1},
  333. { "AI_GaslineHeater37PV", 1},
  334. { "AI_GaslineHeater38PV", 1},
  335. { "AI_GaslineHeater39PV", 1},
  336. { "AI_GaslineHeater40PV", 1},
  337. { "AI_GaslineHeater44PV", 1},
  338. { "AI_GaslineHeater45PV", 1},
  339. { "AI_GaslineHeater49PV", 1},
  340. { "AI_GaslineHeater50PV", 1},
  341. { "AI_GaslineHeater51PV", 1},
  342. { "AI_GaslineHeater52PV", 1},
  343. { "AI_GaslineHeater53PV", 1},
  344. { "AI_GaslineHeater54PV", 1},
  345. { "AI_GaslineHeater55PV", 1},
  346. { "AI_GaslineHeater56PV", 1},
  347. { "AI_GaslineHeater57PV", 1},
  348. { "AI_GaslineHeater58PV", 1},
  349. { "AI_GaslineHeater59PV", 1},
  350. { "AI_GaslineHeater60PV", 1},
  351. { "AI_GaslineHeater61PV", 1},
  352. { "AI_GaslineHeater62PV", 1},
  353. { "AI_GaslineHeater63PV", 1},
  354. { "AI_GaslineHeater64PV", 1},
  355. };
  356. DATA.Subscribe($"{Module}.CurrentAuxData", () => GetCurrentAuxData());
  357. _initTimer.Start();
  358. }
  359. private void GetAuxNames()
  360. {
  361. for (int i = 52; i < 63; i++)
  362. {
  363. _auxNames.Add($"Gasline heater{i} PV");
  364. }
  365. }
  366. private void ResetAUXTrig()
  367. {
  368. if (_auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  369. {
  370. foreach (var item in _auxDic[_currentAuxTable])
  371. {
  372. if (item == null)
  373. continue;
  374. item.WarningLowLimitTrig.RST = true;
  375. item.WarningHighLimitTrig.RST = true;
  376. item.AlarmLowLimitTrig.RST = true;
  377. item.AlarmHighLimitTrig.RST = true;
  378. }
  379. }
  380. }
  381. private List<AITAuxData> GetCurrentAuxData()
  382. {
  383. var datas = new List<AITAuxData>();
  384. if (_auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  385. {
  386. foreach (var item in _auxDic[_currentAuxTable])
  387. {
  388. if (item == null)
  389. continue;
  390. var data = new AITAuxData();
  391. data.AlarmHighLimit = item.AlarmHighLimit;
  392. data.AlarmLowLimit = item.AlarmLowLimit;
  393. data.WarningLowLimit = item.WarningLowLimit;
  394. data.WarningHighLimit = item.WarningHighLimit;
  395. data.SetPoint = item.AISV != null ? item.AISV.FloatValue : item.SetPoint;
  396. data.DisplayName = item.DisplayName;
  397. data.IOName = item.IOName;
  398. data.Unit = item.Unit;
  399. data.Feedback = item.Feedback;
  400. data.Index = item.Index;
  401. data.IsInstalled = item.IsInstalled;
  402. datas.Add(data);
  403. }
  404. }
  405. return datas;
  406. }
  407. private void MonitorFfu()
  408. {
  409. _isCEXHOn = _fFUs != null && !_fFUs.Any(x => !x.IsEnable);
  410. }
  411. private void MonitorAux()
  412. {
  413. if (_initTimer.IsRunning && _initTimer.ElapsedMilliseconds < 3000)
  414. {
  415. _initTimer.Stop();
  416. return;
  417. }
  418. if (IsHTR1Enable != SC.GetValue<bool>("PM1.IsHTR1Enable"))
  419. IsHTR1Enable = SC.GetValue<bool>("PM1.IsHTR1Enable");
  420. if (IsHTR2Enable != SC.GetValue<bool>("PM1.IsHTR2Enable"))
  421. IsHTR2Enable = SC.GetValue<bool>("PM1.IsHTR2Enable");
  422. if (IsHTR3Enable != SC.GetValue<bool>("PM1.IsHTR3Enable"))
  423. IsHTR3Enable = SC.GetValue<bool>("PM1.IsHTR3Enable");
  424. if (IsHTR1Enable && IsHTR2Enable && IsF2ClnOn)
  425. {
  426. if (_currentAuxTable != 2)
  427. {
  428. _currentAuxTable = 2;
  429. LOG.Write($"AUC table switch to {_currentAuxTable}");
  430. }
  431. }
  432. else if (IsHTR1Enable && IsHTR2Enable && IsHFClnOn)
  433. {
  434. if (_currentAuxTable != 3)
  435. {
  436. _currentAuxTable = 3;
  437. LOG.Write($"AUC table switch to {_currentAuxTable}");
  438. }
  439. }
  440. else if (IsHTR1Enable)
  441. {
  442. if (_currentAuxTable != 1)
  443. {
  444. _currentAuxTable = 1;
  445. LOG.Write($"AUC table switch to {_currentAuxTable}");
  446. }
  447. }
  448. if (TrigGasLine1PowerOn != null && IsHTR1Enable != TrigGasLine1PowerOn.Value)
  449. {
  450. TrigGasLine1PowerOn?.SetTrigger(IsHTR1Enable, out _);
  451. }
  452. if (TrigGasLine2PowerOn != null && IsHTR1Enable != TrigGasLine2PowerOn.Value)
  453. {
  454. TrigGasLine2PowerOn?.SetTrigger(IsHTR1Enable, out _);
  455. }
  456. if (TrigGasLine3PowerOn != null && IsHTR1Enable != TrigGasLine3PowerOn.Value)
  457. {
  458. TrigGasLine3PowerOn?.SetTrigger(IsHTR1Enable, out _);
  459. }
  460. if (TrigGasLine4PowerOn != null)
  461. {
  462. if (IsF2ClnOn || IsHTR2Enable)
  463. {
  464. TrigGasLine4PowerOn?.SetTrigger(true, out _);
  465. }
  466. else
  467. {
  468. TrigGasLine4PowerOn?.SetTrigger(false, out _);
  469. }
  470. }
  471. if (TrigGasLine6PowerOn != null)
  472. {
  473. if (IsF2ClnOn || IsHTR2Enable)
  474. {
  475. TrigGasLine6PowerOn?.SetTrigger(true, out _);
  476. }
  477. else
  478. {
  479. TrigGasLine6PowerOn?.SetTrigger(false, out _);
  480. }
  481. }
  482. if (TrigGasLine7PowerOn != null)
  483. {
  484. if (IsF2ClnOn || IsHTR2Enable)
  485. {
  486. TrigGasLine7PowerOn?.SetTrigger(true, out _);
  487. }
  488. else
  489. {
  490. TrigGasLine7PowerOn?.SetTrigger(false, out _);
  491. }
  492. }
  493. if (IsHTR1Enable || IsHTR2Enable || IsHTR3Enable)
  494. {
  495. if (IsHTR1Enable && IsF2ClnOn)
  496. {
  497. if (TrigGasLine1RecipeChange != null && TrigGasLine1RecipeChange.AOValue != 2)
  498. TrigGasLine1RecipeChange.SetAOTrigger(2, out _);
  499. if (TrigGasLine2RecipeChange != null && TrigGasLine2RecipeChange.AOValue != 2)
  500. TrigGasLine2RecipeChange.SetAOTrigger(2, out _);
  501. if (TrigGasLine3RecipeChange != null && TrigGasLine3RecipeChange.AOValue != 2)
  502. TrigGasLine3RecipeChange.SetAOTrigger(2, out _);
  503. if (TrigGasLine4RecipeChange != null && TrigGasLine4RecipeChange.AOValue != 2)
  504. TrigGasLine4RecipeChange.SetAOTrigger(2, out _);
  505. if (TrigGasLine6RecipeChange != null && TrigGasLine6RecipeChange.AOValue != 2)
  506. TrigGasLine6RecipeChange.SetAOTrigger(2, out _);
  507. if (TrigGasLine7RecipeChange != null && TrigGasLine7RecipeChange.AOValue != 2)
  508. TrigGasLine7RecipeChange.SetAOTrigger(2, out _);
  509. }
  510. else
  511. {
  512. if (TrigGasLine1RecipeChange != null && TrigGasLine1RecipeChange.AOValue != 1)
  513. {
  514. TrigGasLine1RecipeChange?.SetAOTrigger(1, out _);
  515. }
  516. if (TrigGasLine2RecipeChange != null && TrigGasLine2RecipeChange.AOValue != 1)
  517. {
  518. TrigGasLine2RecipeChange?.SetAOTrigger(1, out _);
  519. }
  520. if (TrigGasLine3RecipeChange != null && TrigGasLine3RecipeChange.AOValue != 1)
  521. {
  522. TrigGasLine3RecipeChange?.SetAOTrigger(1, out _);
  523. }
  524. if (TrigGasLine4RecipeChange != null && TrigGasLine4RecipeChange.AOValue != 1)
  525. {
  526. TrigGasLine4RecipeChange?.SetAOTrigger(1, out _);
  527. }
  528. if (TrigGasLine6RecipeChange != null && TrigGasLine6RecipeChange.AOValue != 1)
  529. {
  530. TrigGasLine6RecipeChange?.SetAOTrigger(1, out _);
  531. }
  532. if (TrigGasLine7RecipeChange != null && TrigGasLine7RecipeChange.AOValue != 1)
  533. {
  534. TrigGasLine7RecipeChange?.SetAOTrigger(1, out _);
  535. }
  536. }
  537. }
  538. else
  539. {
  540. if (TrigGasLine1RecipeChange != null && TrigGasLine1RecipeChange.AOValue != 0)
  541. TrigGasLine1RecipeChange.SetAOTrigger(0, out _);
  542. if (TrigGasLine2RecipeChange != null && TrigGasLine2RecipeChange.AOValue != 0)
  543. TrigGasLine2RecipeChange.SetAOTrigger(0, out _);
  544. if (TrigGasLine3RecipeChange != null && TrigGasLine3RecipeChange.AOValue != 0)
  545. TrigGasLine3RecipeChange.SetAOTrigger(0, out _);
  546. if (TrigGasLine4RecipeChange != null && TrigGasLine4RecipeChange.AOValue != 0)
  547. TrigGasLine4RecipeChange.SetAOTrigger(0, out _);
  548. if (TrigGasLine6RecipeChange != null && TrigGasLine6RecipeChange.AOValue != 0)
  549. TrigGasLine6RecipeChange.SetAOTrigger(0, out _);
  550. if (TrigGasLine7RecipeChange != null && TrigGasLine7RecipeChange.AOValue != 0)
  551. TrigGasLine7RecipeChange.SetAOTrigger(0, out _);
  552. }
  553. if (IsHTR1Enable && IsHTR2Enable && IsF2ClnOn)
  554. {
  555. if (TrigGasLineHeaterMemoryChange != null && TrigGasLineHeaterMemoryChange.AOValue != 2)
  556. TrigGasLineHeaterMemoryChange.SetAOTrigger(2, out _);
  557. }
  558. else if (IsHTR1Enable || IsHTR2Enable)
  559. {
  560. if (IsHTR1Enable)
  561. {
  562. if (TrigGasLineHeaterMemoryChange != null && TrigGasLineHeaterMemoryChange.AOValue != 1)
  563. {
  564. TrigGasLineHeaterMemoryChange.SetAOTrigger(1, out _);
  565. }
  566. }
  567. else
  568. {
  569. if (TrigGasLineHeaterMemoryChange != null && TrigGasLineHeaterMemoryChange.AOValue != 0)
  570. {
  571. TrigGasLineHeaterMemoryChange.SetAOTrigger(0, out _);
  572. }
  573. }
  574. }
  575. else
  576. {
  577. if (TrigGasLineHeaterMemoryChange != null && TrigGasLineHeaterMemoryChange.AOValue != 0)
  578. TrigGasLineHeaterMemoryChange.SetAOTrigger(0, out _);
  579. }
  580. if (_auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  581. {
  582. if (IsProcessing)
  583. {
  584. foreach (var item in _auxDic[_currentAuxTable])
  585. {
  586. if (item == null)
  587. continue;
  588. item.AlarmHighLimit = (float)item.AlarmHighLimitConfig.DoubleValue;
  589. item.AlarmLowLimit = (float)item.AlarmLowLimitConfig.DoubleValue;
  590. item.WarningHighLimit = (float)item.WarningHighLimitConfig.DoubleValue;
  591. item.WarningLowLimit = (float)item.WarningLowLimitConfig.DoubleValue;
  592. //item.SetPoint = (float)item.SetPointConfig.DoubleValue;
  593. item.Unit = item.UnitConfig.StringValue;
  594. item.DisplayName = item.DisplayNameConfig.StringValue;
  595. if (SC.GetStringValue("System.SetUp.ToolType") == "ELK" && item.Index <= 96)
  596. {
  597. item.Feedback = IO.AI[$"{item.Module}.{item.IOName}"] != null ? IO.AI[$"{item.Module}.{item.IOName}"].FloatValue : 0;
  598. item.SetPoint = item.AO != null ? item.AO.FloatValue : 0;
  599. }
  600. else
  601. {
  602. item.Feedback = IO.AI[$"{Module}.{item.IOName}"] != null ? IO.AI[$"{Module}.{item.IOName}"].FloatValue : 0;
  603. }
  604. if (item.AO != null && Math.Abs(item.AO.FloatValue - item.SetPoint) > 0.0001 && item.SetPoint > 0 && (item.IOName.Contains("ForelineHeater") || item.IOName.Contains("SiSource") || item.IOName.Contains("CSource")))//只有ForelineHeater需要写,GasLine heater之类不写
  605. {
  606. item.AO.FloatValue = item.SetPoint;//process 过程中,不写ao
  607. }
  608. if (item.AOAlarmHigher != null && Math.Abs(item.AOAlarmHigher.FloatValue - item.AlarmHighLimit) > 0.0001)
  609. {
  610. item.AOAlarmHigher.FloatValue = item.AlarmHighLimit;//process 过程中,不写ao
  611. }
  612. if (item.AOAlarmLower != null && Math.Abs(item.AOAlarmLower.FloatValue - item.AlarmLowLimit) > 0.0001)
  613. {
  614. item.AOAlarmLower.FloatValue = item.AlarmLowLimit;//process 过程中,不写ao
  615. }
  616. }
  617. }
  618. else
  619. {
  620. foreach (var item in _auxDic[_currentAuxTable])
  621. {
  622. if (item == null)
  623. continue;
  624. item.WarningHighLimit = (float)item.WarningHighLimitConfig.DoubleValue;
  625. item.WarningLowLimit = (float)item.WarningLowLimitConfig.DoubleValue;
  626. item.SetPoint = (float)item.SetPointConfig.DoubleValue;
  627. item.Unit = item.UnitConfig.StringValue;
  628. item.DisplayName = item.DisplayNameConfig.StringValue;
  629. item.AlarmHighLimit = (float)item.AlarmHighLimitConfig.DoubleValue;
  630. item.AlarmLowLimit = (float)item.AlarmLowLimitConfig.DoubleValue;
  631. if (SC.GetStringValue("System.SetUp.ToolType") == "ELK" && item.Index <= 96)
  632. {
  633. item.Feedback = IO.AI[$"{item.Module}.{item.IOName}"] != null ? IO.AI[$"{item.Module}.{item.IOName}"].FloatValue : 0;
  634. item.SetPoint = item.AO != null ? item.AO.FloatValue : 0;
  635. }
  636. else
  637. {
  638. item.Feedback = IO.AI[$"{Module}.{item.IOName}"] != null ? IO.AI[$"{Module}.{item.IOName}"].FloatValue : 0;
  639. }
  640. //item.Feedback = IO.AI[$"{Module}.{item.IOName}"] != null ? IO.AI[$"{Module}.{item.IOName}"].FloatValue : 0;
  641. if (item.AO != null && Math.Abs(item.AO.FloatValue - (float)item.SetPointConfig.DoubleValue) > 0.0001 && item.SetPoint > 0 && (item.IOName.Contains("ForelineHeater") || item.IOName.Contains("SiSource") || item.IOName.Contains("CSource")))//只有ForelineHeater需要写,GasLine heater之类不写 ELK除了GasLine需要设置
  642. {
  643. item.AO.FloatValue = (float)item.SetPointConfig.DoubleValue;
  644. }
  645. if (item.AOAlarmHigher != null && Math.Abs(item.AOAlarmHigher.FloatValue - item.AlarmHighLimit) > 0.0001)
  646. {
  647. item.AOAlarmHigher.FloatValue = item.AlarmHighLimit;
  648. }
  649. if (item.AOAlarmLower != null && Math.Abs(item.AOAlarmLower.FloatValue - item.AlarmLowLimit) > 0.0001)
  650. {
  651. item.AOAlarmLower.FloatValue = item.AlarmLowLimit;
  652. }
  653. if (item.Feedback > item.SetPoint + item.AlarmHighLimit)
  654. {
  655. //注释AUX报警
  656. //item.AlarmHighLimitTrig.CLK = true;
  657. //if (item.AlarmHighLimitTrig.Q)
  658. //{
  659. // var reason = $"{item.DisplayName} feedback={item.Feedback}, alarm high limit is {item.SetPoint + item.AlarmHighLimit}";
  660. // item.AlarmHighLimitEvent.Set(reason);
  661. //}
  662. }
  663. else if (item.Feedback < item.SetPoint - item.AlarmLowLimit)
  664. {
  665. //注释AUX报警
  666. //item.AlarmLowLimitTrig.CLK = true;
  667. //if (item.AlarmLowLimitTrig.Q)
  668. //{
  669. // var reason = $"{item.DisplayName} feedback={item.Feedback}, alarm low limit is {item.SetPoint - item.AlarmLowLimit}";
  670. // item.AlarmLowLimitEvent.Set(reason);
  671. //}
  672. }
  673. else if (item.Feedback > item.SetPoint + item.WarningHighLimit)
  674. {
  675. //注释AUX报警
  676. //item.WarningHighLimitTrig.CLK = true;
  677. //if (item.WarningHighLimitTrig.Q)
  678. //{
  679. // var reason = $"{item.DisplayName} feedback={item.Feedback}, warning high limit is {item.SetPoint + item.WarningHighLimit}";
  680. // item.AlarmHighLimitEvent.Set(reason);
  681. //}
  682. }
  683. else if (item.Feedback < item.SetPoint - item.WarningLowLimit)
  684. {
  685. //注释AUX报警
  686. //item.WarningLowLimitTrig.CLK = true;
  687. //if (item.WarningLowLimitTrig.Q)
  688. //{
  689. // var reason = $"{item.DisplayName} feedback={item.Feedback}, warning low limit is {item.SetPoint - item.WarningLowLimit}";
  690. // item.AlarmLowLimitEvent.Set(reason);
  691. //}
  692. }
  693. }
  694. }
  695. }
  696. }
  697. private void SetAUXParameters(object[] param)
  698. {
  699. if (param != null && param.Length > 0 &&
  700. _auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  701. {
  702. var array = param[0].ToString().Split(';');
  703. if (array != null && array.Length > 0)
  704. {
  705. for (int i = 0; i < array.Length; i++)
  706. {
  707. var auxItems = array[i].Split(',');
  708. if (auxItems == null || auxItems.Length < 6)
  709. continue;
  710. int.TryParse(auxItems[0], out int index);
  711. float.TryParse(auxItems[1], out float set);
  712. bool.TryParse(auxItems[2], out bool isCheck);
  713. float.TryParse(auxItems[3], out float checkHigh);
  714. float.TryParse(auxItems[4], out float checkLow);
  715. var checkUnit = auxItems[5];
  716. var aux = _auxDic[_currentAuxTable].SingleOrDefault(x => x.Index == index);
  717. if (aux != null)
  718. {
  719. if (checkUnit.ToLower() == "%sv")
  720. {
  721. checkHigh = set * checkHigh;
  722. checkLow = set * checkLow;
  723. }
  724. else if (checkUnit.ToLower() == "%fs")
  725. {
  726. checkHigh = (_auxScaleDic.ContainsKey(aux.IOName) ? _auxScaleDic[aux.IOName] : 1) * checkHigh;
  727. checkLow = (_auxScaleDic.ContainsKey(aux.IOName) ? _auxScaleDic[aux.IOName] : 1) * checkLow;
  728. }
  729. if (set > 0)
  730. aux.SetPoint = set;
  731. aux.IsWait = isCheck;
  732. aux.WaitHigh = checkHigh;
  733. aux.WaitLow = checkLow;
  734. }
  735. }
  736. }
  737. }
  738. }
  739. public bool CheckAUXWaitCondition(out string reason)
  740. {
  741. reason = "";
  742. bool allFinish = true;
  743. if (_auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  744. {
  745. foreach (var item in _auxDic[_currentAuxTable])
  746. {
  747. if (item == null)
  748. continue;
  749. if (!item.IsWait || item.WaitHigh == 0 || item.WaitLow == 0)
  750. continue;
  751. if (item.Feedback < item.SetPoint - item.WaitLow || item.Feedback > item.SetPoint + item.WaitHigh)
  752. {
  753. allFinish = false;
  754. reason += $"{item.DisplayName} feedback={item.Feedback}, limit is ({item.SetPoint - item.WaitLow}, {item.SetPoint + item.WaitHigh}) \n";
  755. }
  756. }
  757. }
  758. return allFinish;
  759. }
  760. private bool SetF2ClnEnable(object[] param)
  761. {
  762. if (param != null && param.Length > 0)
  763. {
  764. bool.TryParse(param[0].ToString(), out bool isEnable);
  765. IsF2ClnOn = isEnable;
  766. }
  767. return true;
  768. }
  769. private bool SetHFClnEnable(object[] param)
  770. {
  771. if (param != null && param.Length > 0)
  772. {
  773. bool.TryParse(param[0].ToString(), out bool isEnable);
  774. IsHFClnOn = isEnable;
  775. }
  776. return true;
  777. }
  778. private bool SetDEPOEnable(object[] param)
  779. {
  780. if (param != null && param.Length > 0)
  781. {
  782. bool.TryParse(param[0].ToString(), out bool isEnable);
  783. IsDEPOOn = isEnable;
  784. }
  785. return true;
  786. }
  787. private bool SetCREFEnable(object[] param)
  788. {
  789. if (param != null && param.Length > 0)
  790. {
  791. bool.TryParse(param[0].ToString(), out bool isEnable);
  792. IsCREFOn = isEnable;
  793. }
  794. return true;
  795. }
  796. private bool SetSIREFEnable(object[] param)
  797. {
  798. if (param != null && param.Length > 0)
  799. {
  800. bool.TryParse(param[0].ToString(), out bool isEnable);
  801. IsSIREFOn = isEnable;
  802. }
  803. return true;
  804. }
  805. }
  806. }