PMAux.cs 46 KB

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