PMAux.cs 40 KB

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