PMAux.cs 45 KB

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