PMAux.cs 43 KB

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