PMAux.cs 43 KB

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