PMAux.cs 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  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.Minics;
  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 string _currentTableName ="";
  28. private bool _isF2ClnOn;
  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 (IsHTR1Enable && IsF2ClnOn)
  431. {
  432. var config2Name = SC.ContainsItem("Minics.Config2") ? SC.GetStringValue("Minics.Config2") : "";
  433. if (_currentTableName != config2Name)
  434. {
  435. Singleton<MinicsManager>.Instance.SelectMinicsConfig(config2Name);
  436. _currentTableName = config2Name;
  437. LOG.Write($"minics table switch to config2 {config2Name}");
  438. }
  439. }
  440. else if (IsHTR1Enable && IsHTR2Enable && IsHFClnOn)
  441. {
  442. var config3Name = SC.ContainsItem("Minics.Config3") ? SC.GetStringValue("Minics.Config3") : "";
  443. if (_currentTableName != config3Name)
  444. {
  445. Singleton<MinicsManager>.Instance.SelectMinicsConfig(config3Name);
  446. _currentTableName = config3Name;
  447. LOG.Write($"minics table switch to config3 {config3Name}");
  448. }
  449. }
  450. else if (IsHTR1Enable)
  451. {
  452. var config1Name = SC.ContainsItem("Minics.Config1") ? SC.GetStringValue("Minics.Config1") : "";
  453. if (_currentTableName != config1Name)
  454. {
  455. Singleton<MinicsManager>.Instance.SelectMinicsConfig(config1Name);
  456. _currentTableName = config1Name;
  457. LOG.Write($"minics table switch to config1 {config1Name}");
  458. }
  459. }
  460. return;
  461. }
  462. #region old
  463. if (_initTimer.IsRunning && _initTimer.ElapsedMilliseconds < 3000)
  464. {
  465. _initTimer.Stop();
  466. return;
  467. }
  468. if (IsHTR1Enable != SC.GetValue<bool>("PM1.IsHTR1Enable"))
  469. IsHTR1Enable = SC.GetValue<bool>("PM1.IsHTR1Enable");
  470. if (IsHTR2Enable != SC.GetValue<bool>("PM1.IsHTR2Enable"))
  471. IsHTR2Enable = SC.GetValue<bool>("PM1.IsHTR2Enable");
  472. if (IsHTR3Enable != SC.GetValue<bool>("PM1.IsHTR3Enable"))
  473. IsHTR3Enable = SC.GetValue<bool>("PM1.IsHTR3Enable");
  474. if (IsHTR1Enable && IsHTR2Enable && IsF2ClnOn)
  475. {
  476. if (_currentAuxTable != 2)
  477. {
  478. _currentAuxTable = 2;
  479. LOG.Write($"AUC table switch to {_currentAuxTable}");
  480. }
  481. }
  482. else if (IsHTR1Enable && IsHTR2Enable && IsHFClnOn)
  483. {
  484. if (_currentAuxTable != 3)
  485. {
  486. _currentAuxTable = 3;
  487. LOG.Write($"AUC table switch to {_currentAuxTable}");
  488. }
  489. }
  490. else if (IsHTR1Enable)
  491. {
  492. if (_currentAuxTable != 1)
  493. {
  494. _currentAuxTable = 1;
  495. LOG.Write($"AUC table switch to {_currentAuxTable}");
  496. }
  497. }
  498. if (TrigGasLine1PowerOn != null && IsHTR1Enable != TrigGasLine1PowerOn.Value)
  499. {
  500. TrigGasLine1PowerOn?.SetTrigger(IsHTR1Enable, out _);
  501. }
  502. if (TrigGasLine2PowerOn != null && IsHTR1Enable != TrigGasLine2PowerOn.Value)
  503. {
  504. TrigGasLine2PowerOn?.SetTrigger(IsHTR1Enable, out _);
  505. }
  506. if (TrigGasLine3PowerOn != null && IsHTR1Enable != TrigGasLine3PowerOn.Value)
  507. {
  508. TrigGasLine3PowerOn?.SetTrigger(IsHTR1Enable, out _);
  509. }
  510. if (TrigGasLine4PowerOn != null)
  511. {
  512. if (IsF2ClnOn || IsHTR2Enable)
  513. {
  514. TrigGasLine4PowerOn?.SetTrigger(true, out _);
  515. }
  516. else
  517. {
  518. TrigGasLine4PowerOn?.SetTrigger(false, out _);
  519. }
  520. }
  521. if (TrigGasLine6PowerOn != null)
  522. {
  523. if (IsF2ClnOn || IsHTR2Enable)
  524. {
  525. TrigGasLine6PowerOn?.SetTrigger(true, out _);
  526. }
  527. else
  528. {
  529. TrigGasLine6PowerOn?.SetTrigger(false, out _);
  530. }
  531. }
  532. if (TrigGasLine7PowerOn != null)
  533. {
  534. if (IsF2ClnOn || IsHTR2Enable)
  535. {
  536. TrigGasLine7PowerOn?.SetTrigger(true, out _);
  537. }
  538. else
  539. {
  540. TrigGasLine7PowerOn?.SetTrigger(false, out _);
  541. }
  542. }
  543. if (IsHTR1Enable || IsHTR2Enable || IsHTR3Enable)
  544. {
  545. if (IsHTR1Enable && IsF2ClnOn)
  546. {
  547. if (TrigGasLine1RecipeChange != null && TrigGasLine1RecipeChange.AOValue != 2)
  548. TrigGasLine1RecipeChange.SetAOTrigger(2, out _);
  549. if (TrigGasLine2RecipeChange != null && TrigGasLine2RecipeChange.AOValue != 2)
  550. TrigGasLine2RecipeChange.SetAOTrigger(2, out _);
  551. if (TrigGasLine3RecipeChange != null && TrigGasLine3RecipeChange.AOValue != 2)
  552. TrigGasLine3RecipeChange.SetAOTrigger(2, out _);
  553. if (TrigGasLine4RecipeChange != null && TrigGasLine4RecipeChange.AOValue != 2)
  554. TrigGasLine4RecipeChange.SetAOTrigger(2, out _);
  555. if (TrigGasLine6RecipeChange != null && TrigGasLine6RecipeChange.AOValue != 2)
  556. TrigGasLine6RecipeChange.SetAOTrigger(2, out _);
  557. if (TrigGasLine7RecipeChange != null && TrigGasLine7RecipeChange.AOValue != 2)
  558. TrigGasLine7RecipeChange.SetAOTrigger(2, out _);
  559. }
  560. else
  561. {
  562. if (TrigGasLine1RecipeChange != null && TrigGasLine1RecipeChange.AOValue != 1)
  563. {
  564. TrigGasLine1RecipeChange?.SetAOTrigger(1, out _);
  565. }
  566. if (TrigGasLine2RecipeChange != null && TrigGasLine2RecipeChange.AOValue != 1)
  567. {
  568. TrigGasLine2RecipeChange?.SetAOTrigger(1, out _);
  569. }
  570. if (TrigGasLine3RecipeChange != null && TrigGasLine3RecipeChange.AOValue != 1)
  571. {
  572. TrigGasLine3RecipeChange?.SetAOTrigger(1, out _);
  573. }
  574. if (TrigGasLine4RecipeChange != null && TrigGasLine4RecipeChange.AOValue != 1)
  575. {
  576. TrigGasLine4RecipeChange?.SetAOTrigger(1, out _);
  577. }
  578. if (TrigGasLine6RecipeChange != null && TrigGasLine6RecipeChange.AOValue != 1)
  579. {
  580. TrigGasLine6RecipeChange?.SetAOTrigger(1, out _);
  581. }
  582. if (TrigGasLine7RecipeChange != null && TrigGasLine7RecipeChange.AOValue != 1)
  583. {
  584. TrigGasLine7RecipeChange?.SetAOTrigger(1, out _);
  585. }
  586. }
  587. }
  588. else
  589. {
  590. if (TrigGasLine1RecipeChange != null && TrigGasLine1RecipeChange.AOValue != 0)
  591. TrigGasLine1RecipeChange.SetAOTrigger(0, out _);
  592. if (TrigGasLine2RecipeChange != null && TrigGasLine2RecipeChange.AOValue != 0)
  593. TrigGasLine2RecipeChange.SetAOTrigger(0, out _);
  594. if (TrigGasLine3RecipeChange != null && TrigGasLine3RecipeChange.AOValue != 0)
  595. TrigGasLine3RecipeChange.SetAOTrigger(0, out _);
  596. if (TrigGasLine4RecipeChange != null && TrigGasLine4RecipeChange.AOValue != 0)
  597. TrigGasLine4RecipeChange.SetAOTrigger(0, out _);
  598. if (TrigGasLine6RecipeChange != null && TrigGasLine6RecipeChange.AOValue != 0)
  599. TrigGasLine6RecipeChange.SetAOTrigger(0, out _);
  600. if (TrigGasLine7RecipeChange != null && TrigGasLine7RecipeChange.AOValue != 0)
  601. TrigGasLine7RecipeChange.SetAOTrigger(0, out _);
  602. }
  603. if (IsHTR1Enable && IsHTR2Enable && IsF2ClnOn)
  604. {
  605. if (TrigGasLineHeaterMemoryChange != null && TrigGasLineHeaterMemoryChange.AOValue != 2)
  606. TrigGasLineHeaterMemoryChange.SetAOTrigger(2, out _);
  607. }
  608. else if (IsHTR1Enable || IsHTR2Enable)
  609. {
  610. if (IsHTR1Enable)
  611. {
  612. if (TrigGasLineHeaterMemoryChange != null && TrigGasLineHeaterMemoryChange.AOValue != 1)
  613. {
  614. TrigGasLineHeaterMemoryChange.SetAOTrigger(1, out _);
  615. }
  616. }
  617. else
  618. {
  619. if (TrigGasLineHeaterMemoryChange != null && TrigGasLineHeaterMemoryChange.AOValue != 0)
  620. {
  621. TrigGasLineHeaterMemoryChange.SetAOTrigger(0, out _);
  622. }
  623. }
  624. }
  625. else
  626. {
  627. if (TrigGasLineHeaterMemoryChange != null && TrigGasLineHeaterMemoryChange.AOValue != 0)
  628. TrigGasLineHeaterMemoryChange.SetAOTrigger(0, out _);
  629. }
  630. if (_auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  631. {
  632. if (IsProcessing)
  633. {
  634. foreach (var item in _auxDic[_currentAuxTable])
  635. {
  636. if (item == null)
  637. continue;
  638. item.AlarmHighLimit = (float)item.AlarmHighLimitConfig.DoubleValue;
  639. item.AlarmLowLimit = (float)item.AlarmLowLimitConfig.DoubleValue;
  640. item.WarningHighLimit = (float)item.WarningHighLimitConfig.DoubleValue;
  641. item.WarningLowLimit = (float)item.WarningLowLimitConfig.DoubleValue;
  642. //item.SetPoint = (float)item.SetPointConfig.DoubleValue;
  643. item.Unit = item.UnitConfig.StringValue;
  644. item.DisplayName = item.DisplayNameConfig.StringValue;
  645. if (SC.GetStringValue("System.SetUp.ToolType") == "ELK" && item.Index <= 96)
  646. {
  647. item.Feedback = IO.AI[$"{item.Module}.{item.IOName}"] != null ? IO.AI[$"{item.Module}.{item.IOName}"].FloatValue : 0;
  648. item.SetPoint = item.AO != null ? item.AO.FloatValue : 0;
  649. }
  650. else
  651. {
  652. item.Feedback = IO.AI[$"{Module}.{item.IOName}"] != null ? IO.AI[$"{Module}.{item.IOName}"].FloatValue : 0;
  653. }
  654. 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之类不写
  655. {
  656. item.AO.FloatValue = item.SetPoint;//process 过程中,不写ao
  657. }
  658. if (item.AOAlarmHigher != null && Math.Abs(item.AOAlarmHigher.FloatValue - item.AlarmHighLimit) > 0.0001)
  659. {
  660. item.AOAlarmHigher.FloatValue = item.AlarmHighLimit;//process 过程中,不写ao
  661. }
  662. if (item.AOAlarmLower != null && Math.Abs(item.AOAlarmLower.FloatValue - item.AlarmLowLimit) > 0.0001)
  663. {
  664. item.AOAlarmLower.FloatValue = item.AlarmLowLimit;//process 过程中,不写ao
  665. }
  666. }
  667. }
  668. else
  669. {
  670. foreach (var item in _auxDic[_currentAuxTable])
  671. {
  672. if (item == null)
  673. continue;
  674. item.WarningHighLimit = (float)item.WarningHighLimitConfig.DoubleValue;
  675. item.WarningLowLimit = (float)item.WarningLowLimitConfig.DoubleValue;
  676. item.SetPoint = (float)item.SetPointConfig.DoubleValue;
  677. item.Unit = item.UnitConfig.StringValue;
  678. item.DisplayName = item.DisplayNameConfig.StringValue;
  679. item.AlarmHighLimit = (float)item.AlarmHighLimitConfig.DoubleValue;
  680. item.AlarmLowLimit = (float)item.AlarmLowLimitConfig.DoubleValue;
  681. if (SC.GetStringValue("System.SetUp.ToolType") == "ELK" && item.Index <= 96)
  682. {
  683. item.Feedback = IO.AI[$"{item.Module}.{item.IOName}"] != null ? IO.AI[$"{item.Module}.{item.IOName}"].FloatValue : 0;
  684. item.SetPoint = item.AO != null ? item.AO.FloatValue : 0;
  685. }
  686. else
  687. {
  688. item.Feedback = IO.AI[$"{Module}.{item.IOName}"] != null ? IO.AI[$"{Module}.{item.IOName}"].FloatValue : 0;
  689. }
  690. //item.Feedback = IO.AI[$"{Module}.{item.IOName}"] != null ? IO.AI[$"{Module}.{item.IOName}"].FloatValue : 0;
  691. 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需要设置
  692. {
  693. item.AO.FloatValue = (float)item.SetPointConfig.DoubleValue;
  694. }
  695. if (item.AOAlarmHigher != null && Math.Abs(item.AOAlarmHigher.FloatValue - item.AlarmHighLimit) > 0.0001)
  696. {
  697. item.AOAlarmHigher.FloatValue = item.AlarmHighLimit;
  698. }
  699. if (item.AOAlarmLower != null && Math.Abs(item.AOAlarmLower.FloatValue - item.AlarmLowLimit) > 0.0001)
  700. {
  701. item.AOAlarmLower.FloatValue = item.AlarmLowLimit;
  702. }
  703. if (item.Feedback > item.SetPoint + item.AlarmHighLimit)
  704. {
  705. //注释AUX报警
  706. //item.AlarmHighLimitTrig.CLK = true;
  707. //if (item.AlarmHighLimitTrig.Q)
  708. //{
  709. // var reason = $"{item.DisplayName} feedback={item.Feedback}, alarm high limit is {item.SetPoint + item.AlarmHighLimit}";
  710. // item.AlarmHighLimitEvent.Set(reason);
  711. //}
  712. }
  713. else if (item.Feedback < item.SetPoint - item.AlarmLowLimit)
  714. {
  715. //注释AUX报警
  716. //item.AlarmLowLimitTrig.CLK = true;
  717. //if (item.AlarmLowLimitTrig.Q)
  718. //{
  719. // var reason = $"{item.DisplayName} feedback={item.Feedback}, alarm low limit is {item.SetPoint - item.AlarmLowLimit}";
  720. // item.AlarmLowLimitEvent.Set(reason);
  721. //}
  722. }
  723. else if (item.Feedback > item.SetPoint + item.WarningHighLimit)
  724. {
  725. //注释AUX报警
  726. //item.WarningHighLimitTrig.CLK = true;
  727. //if (item.WarningHighLimitTrig.Q)
  728. //{
  729. // var reason = $"{item.DisplayName} feedback={item.Feedback}, warning high limit is {item.SetPoint + item.WarningHighLimit}";
  730. // item.AlarmHighLimitEvent.Set(reason);
  731. //}
  732. }
  733. else if (item.Feedback < item.SetPoint - item.WarningLowLimit)
  734. {
  735. //注释AUX报警
  736. //item.WarningLowLimitTrig.CLK = true;
  737. //if (item.WarningLowLimitTrig.Q)
  738. //{
  739. // var reason = $"{item.DisplayName} feedback={item.Feedback}, warning low limit is {item.SetPoint - item.WarningLowLimit}";
  740. // item.AlarmLowLimitEvent.Set(reason);
  741. //}
  742. }
  743. }
  744. }
  745. }
  746. #endregion
  747. }
  748. private void SetAUXParameters(object[] param)
  749. {
  750. if (SC.ContainsItem("Minics.EnableMinics") && SC.GetValue<bool>("Minics.EnableMinics"))
  751. return;
  752. if (param != null && param.Length > 0 &&
  753. _auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  754. {
  755. var array = param[0].ToString().Split(';');
  756. if (array != null && array.Length > 0)
  757. {
  758. for (int i = 0; i < array.Length; i++)
  759. {
  760. var auxItems = array[i].Split(',');
  761. if (auxItems == null || auxItems.Length < 6)
  762. continue;
  763. int.TryParse(auxItems[0], out int index);
  764. float.TryParse(auxItems[1], out float set);
  765. bool.TryParse(auxItems[2], out bool isCheck);
  766. float.TryParse(auxItems[3], out float checkHigh);
  767. float.TryParse(auxItems[4], out float checkLow);
  768. var checkUnit = auxItems[5];
  769. var aux = _auxDic[_currentAuxTable].SingleOrDefault(x => x.Index == index);
  770. if (aux != null)
  771. {
  772. if (checkUnit.ToLower() == "%sv")
  773. {
  774. checkHigh = set * checkHigh;
  775. checkLow = set * checkLow;
  776. }
  777. else if (checkUnit.ToLower() == "%fs")
  778. {
  779. checkHigh = (_auxScaleDic.ContainsKey(aux.IOName) ? _auxScaleDic[aux.IOName] : 1) * checkHigh;
  780. checkLow = (_auxScaleDic.ContainsKey(aux.IOName) ? _auxScaleDic[aux.IOName] : 1) * checkLow;
  781. }
  782. if (set > 0)
  783. aux.SetPoint = set;
  784. aux.IsWait = isCheck;
  785. aux.WaitHigh = checkHigh;
  786. aux.WaitLow = checkLow;
  787. }
  788. }
  789. }
  790. }
  791. }
  792. public bool CheckAUXWaitCondition(out string reason)
  793. {
  794. reason = "";
  795. bool allFinish = true;
  796. if (_auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  797. {
  798. foreach (var item in _auxDic[_currentAuxTable])
  799. {
  800. if (item == null)
  801. continue;
  802. if (!item.IsWait || item.WaitHigh == 0 || item.WaitLow == 0)
  803. continue;
  804. if (item.Feedback < item.SetPoint - item.WaitLow || item.Feedback > item.SetPoint + item.WaitHigh)
  805. {
  806. allFinish = false;
  807. reason += $"{item.DisplayName} feedback={item.Feedback}, limit is ({item.SetPoint - item.WaitLow}, {item.SetPoint + item.WaitHigh}) \n";
  808. }
  809. }
  810. }
  811. return allFinish;
  812. }
  813. private bool SetF2ClnEnable(object[] param)
  814. {
  815. if (param != null && param.Length > 0)
  816. {
  817. bool.TryParse(param[0].ToString(), out bool isEnable);
  818. IsF2ClnOn = isEnable;
  819. }
  820. return true;
  821. }
  822. private bool SetHFClnEnable(object[] param)
  823. {
  824. if (param != null && param.Length > 0)
  825. {
  826. bool.TryParse(param[0].ToString(), out bool isEnable);
  827. IsHFClnOn = isEnable;
  828. }
  829. return true;
  830. }
  831. private bool SetDEPOEnable(object[] param)
  832. {
  833. if (param != null && param.Length > 0)
  834. {
  835. bool.TryParse(param[0].ToString(), out bool isEnable);
  836. IsDEPOOn = isEnable;
  837. }
  838. return true;
  839. }
  840. private bool SetCREFEnable(object[] param)
  841. {
  842. if (param != null && param.Length > 0)
  843. {
  844. bool.TryParse(param[0].ToString(), out bool isEnable);
  845. IsCREFOn = isEnable;
  846. }
  847. return true;
  848. }
  849. private bool SetSIREFEnable(object[] param)
  850. {
  851. if (param != null && param.Length > 0)
  852. {
  853. bool.TryParse(param[0].ToString(), out bool isEnable);
  854. IsSIREFOn = isEnable;
  855. }
  856. return true;
  857. }
  858. }
  859. }