PMAux.cs 43 KB

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