PMAux.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  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.OperationCenter;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.Diagnostics;
  19. using System.Linq;
  20. namespace FurnaceRT.Equipments.PMs
  21. {
  22. public partial class PMModule
  23. {
  24. private Dictionary<int, List<AITAuxData>> _auxDic;
  25. private int _currentAuxTable = 1;
  26. private bool _isF2ClnOn;
  27. private bool _isHFClnOn;
  28. private bool _isDEPOOn;
  29. private bool _isHTR1Enable;
  30. private bool _isHTR2Enable;
  31. private bool _isHTR3Enable;
  32. private bool _isCEXHOn;
  33. private string _toolType;
  34. private Dictionary<string, float> _auxScaleDic;
  35. private Stopwatch _initTimer = new Stopwatch();
  36. private List<string> _auxNames = new List<string>();
  37. public bool IsHTR1Enable
  38. {
  39. get
  40. {
  41. return _isHTR1Enable;
  42. }
  43. set
  44. {
  45. _isHTR1Enable = value;
  46. SC.SetItemValue($"PM1.IsHTR1Enable", value);
  47. TrigHTR1SWON?.SetTrigger(value, out _);
  48. //_HTR1Group.ForEach(x => x.SetEnable(value));
  49. }
  50. }
  51. public bool IsHTR2Enable
  52. {
  53. get
  54. {
  55. return _isHTR2Enable;
  56. }
  57. set
  58. {
  59. _isHTR2Enable = value;
  60. SC.SetItemValue($"PM1.IsHTR2Enable", value);
  61. TrigHTR2SWON?.SetTrigger(value, out _);
  62. _HTR2Group.ForEach(x => x.SetEnable(value));
  63. }
  64. }
  65. public bool IsHTR3Enable
  66. {
  67. get
  68. {
  69. return _isHTR3Enable;
  70. }
  71. set
  72. {
  73. _isHTR3Enable = value;
  74. SC.SetItemValue($"PM1.IsHTR3Enable", value);
  75. TrigHTR3SWON?.SetTrigger(value, out _);
  76. TrigForlineHeaterOn.SetTrigger(value, out _);
  77. }
  78. }
  79. public bool IsF2ClnOn
  80. {
  81. get
  82. {
  83. return _isF2ClnOn;
  84. }
  85. set
  86. {
  87. _isF2ClnOn = value;
  88. SC.SetItemValue($"PM1.IsF2ClnOn", value);
  89. TrigF2CleanSwitchB?.SetTrigger(value, out _);
  90. }
  91. }
  92. public bool IsHFClnOn
  93. {
  94. get
  95. {
  96. return _isHFClnOn;
  97. }
  98. set
  99. {
  100. _isHFClnOn = value;
  101. SC.SetItemValue($"PM1.IsHFClnOn", value);
  102. TrigHFCleanSwitchB?.SetTrigger(value, out _);
  103. }
  104. }
  105. public bool IsDEPOOn
  106. {
  107. get
  108. {
  109. return _isDEPOOn;
  110. }
  111. set
  112. {
  113. _isDEPOOn = value;
  114. SC.SetItemValue($"PM1.IsDEPOOn", value);
  115. TrigDEPOSW?.SetTrigger(value, out _);
  116. }
  117. }
  118. public bool IsCREFOn
  119. {
  120. get
  121. {
  122. return _isCREFOn;
  123. }
  124. set
  125. {
  126. _isCREFOn = value;
  127. TrigCREFON?.SetTrigger(value, out _);
  128. }
  129. }
  130. private bool _isCREFOn;
  131. public bool IsSIREFOn
  132. {
  133. get
  134. {
  135. return _isSIREFOn;
  136. }
  137. set
  138. {
  139. _isSIREFOn = value;
  140. TrigSIREFON?.SetTrigger(value, out _);
  141. }
  142. }
  143. private bool _isSIREFOn;
  144. private void InitAUX()
  145. {
  146. GetAuxNames();
  147. IsHFClnOn = SC.GetValue<bool>($"PM1.IsHFClnOn");
  148. IsF2ClnOn = SC.GetValue<bool>($"PM1.IsF2ClnOn");
  149. _toolType = (string)SC.GetStringValue("System.SetUp.ToolType");
  150. _auxDic = new Dictionary<int, List<AITAuxData>>();
  151. for (int table = 1; table < 5; table++)
  152. {
  153. List<AITAuxData> auxs = new List<AITAuxData>();
  154. for (int index = 1; index < 256; index++)
  155. {
  156. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.Set"))
  157. continue;
  158. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningLowLimit"))
  159. continue;
  160. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningHighLimit"))
  161. continue;
  162. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmLowLimit"))
  163. continue;
  164. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmHighLimit"))
  165. continue;
  166. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.{index}.Display"))
  167. continue;
  168. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.{index}.AI"))
  169. continue;
  170. if (!SC.ContainsItem($"PM1.RecipeEditParameter.AUX.{index}.Unit"))
  171. continue;
  172. AITAuxData aux = new AITAuxData()
  173. {
  174. DisplayName = SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Display"),
  175. DisplayNameConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.{index}.Display"),
  176. IOName = SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI"),
  177. AO = IO.AO[$"{Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO")}"],
  178. AISV = IO.AI[$"{Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI").Replace("PV", "SV")}"],
  179. AOAlarmHigher = IO.AO[$"{Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO").Replace("SV", "AlarmHigher")}"],
  180. AOAlarmLower = IO.AO[$"{Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO").Replace("SV", "AlarmLower")}"],
  181. Unit = SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Unit"),
  182. UnitConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.{index}.Unit"),
  183. SetPoint = (float)SC.GetValue<double>($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.Set"),
  184. SetPointConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.Set"),
  185. WarningLowLimit = (float)SC.GetValue<double>($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningLowLimit"),
  186. WarningLowLimitConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningLowLimit"),
  187. WarningHighLimit = (float)SC.GetValue<double>($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningHighLimit"),
  188. WarningHighLimitConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.WarningHighLimit"),
  189. AlarmLowLimit = (float)SC.GetValue<double>($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmLowLimit"),
  190. AlarmLowLimitConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmLowLimit"),
  191. AlarmHighLimit = (float)SC.GetValue<double>($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmHighLimit"),
  192. AlarmHighLimitConfig = SC.GetConfigItem($"PM1.RecipeEditParameter.AUX.Table{table}.{index}.AlarmHighLimit"),
  193. WarningLowLimitTrig = new R_TRIG(),
  194. WarningHighLimitTrig = new R_TRIG(),
  195. AlarmLowLimitTrig = new R_TRIG(),
  196. AlarmHighLimitTrig = new R_TRIG(),
  197. Index = index,
  198. WarningLowLimitEvent = SubscribeAlarm(new AlarmEventItem()
  199. {
  200. EventEnum = $"{Name}.WarningLowLimit.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI")}",
  201. Description = $"{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Display")} Low Limit",
  202. Solution = "No information available. Press[Clear] to delete alarm message.",
  203. Explaination = "No information available.",
  204. AutoRecovery = false,
  205. Level = EventLevel.Warning,
  206. Action = EventAction.Clear,
  207. Category = "TubeAlarm",
  208. }, () => { ResetAUXTrig(); return true; }),
  209. WarningHighLimitEvent = SubscribeAlarm(new AlarmEventItem()
  210. {
  211. EventEnum = $"{Name}.WarningHighLimit.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI")}",
  212. Description = $"{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Display")} High Limit",
  213. Solution = "No information available. Press[Clear] to delete alarm message.",
  214. Explaination = "No information available.",
  215. AutoRecovery = false,
  216. Level = EventLevel.Warning,
  217. Action = EventAction.Clear,
  218. Category = "TubeAlarm",
  219. }, () => { ResetAUXTrig(); return true; }),
  220. AlarmLowLimitEvent = SubscribeAlarm(new AlarmEventItem()
  221. {
  222. EventEnum = $"{Name}.AlarmLowLimit.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI")}",
  223. Description = $"{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Display")} Low Limit",
  224. Solution = "No information available. Press[Clear] to delete alarm message.",
  225. Explaination = "No information available.",
  226. AutoRecovery = false,
  227. Level = EventLevel.Alarm,
  228. Action = EventAction.Clear,
  229. Category = "TubeAlarm",
  230. }, () => { ResetAUXTrig(); return true; }),
  231. AlarmHighLimitEvent = SubscribeAlarm(new AlarmEventItem()
  232. {
  233. EventEnum = $"{Name}.AlarmHighLimit.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI")}",
  234. Description = $"{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.Display")} High Limit",
  235. Solution = "No information available. Press[Clear] to delete alarm message.",
  236. Explaination = "No information available.",
  237. AutoRecovery = false,
  238. Level = EventLevel.Alarm,
  239. Action = EventAction.Clear,
  240. Category = "TubeAlarm",
  241. }, () => { ResetAUXTrig(); return true; }),
  242. };
  243. if (SC.GetStringValue("System.SetUp.ToolType") == "ELK")
  244. {
  245. if (aux.DisplayName.Length > 5)
  246. aux.Module = aux.DisplayName.Substring(0, 5).Replace("Unit", "GasLine");
  247. aux.IOName = $"{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AI")}";
  248. aux.AO = IO.AO[$"{aux.Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO")}"];
  249. aux.AISV = null;
  250. aux.AOAlarmHigher = IO.AO[$"{aux.Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO").Replace("SV", "AlarmHigherPoint")}"];
  251. aux.AOAlarmLower = IO.AO[$"{aux.Module}.{SC.GetStringValue($"PM1.RecipeEditParameter.AUX.{index}.AO").Replace("SV", "AlarmLowerPoint")}"];
  252. }
  253. else
  254. {
  255. //需求: aux只需要gasline heater,Foline heater的alarm 不需要报警(序号68之后都是Foline heater)
  256. if (index >= 68)
  257. {
  258. aux.WarningLowLimitEvent = new AlarmEventItem();
  259. aux.WarningHighLimitEvent = new AlarmEventItem();
  260. aux.AlarmLowLimitEvent = new AlarmEventItem();
  261. aux.AlarmHighLimitEvent = new AlarmEventItem();
  262. }
  263. }
  264. auxs.Add(aux);
  265. }
  266. if (auxs.Any())
  267. _auxDic.Add(table, auxs);
  268. }
  269. _auxScaleDic = new Dictionary<string, float>()
  270. {
  271. { "AI_ForelineHeater1TempPV", 1},
  272. { "AI_ForelineHeater2TempPV", 1},
  273. { "AI_ForelineHeater3TempPV", 1},
  274. { "AI_ForelineHeater4TempPV", 1},
  275. { "AI_ForelineHeater5TempPV", 1},
  276. { "AI_ForelineHeater6TempPV", 1},
  277. { "AI_ForelineHeater7TempPV", 1},
  278. { "AI_ForelineHeater8TempPV", 1},
  279. { "AI_ForelineHeater9TempPV", 1},
  280. { "AI_ForelineHeater10TempPV", 1},
  281. { "AI_ForelineHeater11TempPV", 1},
  282. { "AI_ForelineHeater12TempPV", 1},
  283. { "AI_CapHeaterTempPV", 1},
  284. { "AI_APCExternalHeaterTempPV", 1},
  285. { "AI_APCRingHeaterTempPV", 1},
  286. { "AI_GaslineHeater1PV", 1},
  287. { "AI_GaslineHeater2PV", 1},
  288. { "AI_GaslineHeater3PV", 1},
  289. { "AI_GaslineHeater4PV", 1},
  290. { "AI_GaslineHeater5PV", 1},
  291. { "AI_GaslineHeater6PV", 1},
  292. { "AI_GaslineHeater7PV", 1},
  293. { "AI_GaslineHeater8PV", 1},
  294. { "AI_GaslineHeater9PV", 1},
  295. { "AI_GaslineHeater10PV", 1},
  296. { "AI_GaslineHeater11PV", 1},
  297. { "AI_GaslineHeater12PV", 1},
  298. { "AI_GaslineHeater13PV", 1},
  299. { "AI_GaslineHeater14PV", 1},
  300. { "AI_GaslineHeater15PV", 1},
  301. { "AI_GaslineHeater16PV", 1},
  302. { "AI_GaslineHeater17PV", 1},
  303. { "AI_GaslineHeater18PV", 1},
  304. { "AI_GaslineHeater19PV", 1},
  305. { "AI_GaslineHeater20PV", 1},
  306. { "AI_GaslineHeater21PV", 1},
  307. { "AI_GaslineHeater22PV", 1},
  308. { "AI_GaslineHeater23PV", 1},
  309. { "AI_GaslineHeater24PV", 1},
  310. { "AI_GaslineHeater25PV", 1},
  311. { "AI_GaslineHeater26PV", 1},
  312. { "AI_GaslineHeater27PV", 1},
  313. { "AI_GaslineHeater28PV", 1},
  314. { "AI_GaslineHeater29PV", 1},
  315. { "AI_GaslineHeater30PV", 1},
  316. { "AI_GaslineHeater31PV", 1},
  317. { "AI_GaslineHeater32PV", 1},
  318. { "AI_GaslineHeater33PV", 1},
  319. { "AI_GaslineHeater34PV", 1},
  320. { "AI_GaslineHeater35PV", 1},
  321. { "AI_GaslineHeater36PV", 1},
  322. { "AI_GaslineHeater37PV", 1},
  323. { "AI_GaslineHeater38PV", 1},
  324. { "AI_GaslineHeater39PV", 1},
  325. { "AI_GaslineHeater40PV", 1},
  326. { "AI_GaslineHeater44PV", 1},
  327. { "AI_GaslineHeater45PV", 1},
  328. { "AI_GaslineHeater49PV", 1},
  329. { "AI_GaslineHeater50PV", 1},
  330. { "AI_GaslineHeater51PV", 1},
  331. { "AI_GaslineHeater52PV", 1},
  332. { "AI_GaslineHeater53PV", 1},
  333. { "AI_GaslineHeater54PV", 1},
  334. { "AI_GaslineHeater55PV", 1},
  335. { "AI_GaslineHeater56PV", 1},
  336. { "AI_GaslineHeater57PV", 1},
  337. { "AI_GaslineHeater58PV", 1},
  338. { "AI_GaslineHeater59PV", 1},
  339. { "AI_GaslineHeater60PV", 1},
  340. { "AI_GaslineHeater61PV", 1},
  341. { "AI_GaslineHeater62PV", 1},
  342. { "AI_GaslineHeater63PV", 1},
  343. { "AI_GaslineHeater64PV", 1},
  344. };
  345. DATA.Subscribe($"{Module}.CurrentAuxData", () => GetCurrentAuxData());
  346. _initTimer.Start();
  347. }
  348. private void GetAuxNames()
  349. {
  350. for (int i = 52; i < 63; i++)
  351. {
  352. _auxNames.Add($"Gasline heater{i} PV");
  353. }
  354. }
  355. private void ResetAUXTrig()
  356. {
  357. if (_auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  358. {
  359. foreach (var item in _auxDic[_currentAuxTable])
  360. {
  361. if (item == null)
  362. continue;
  363. item.WarningLowLimitTrig.RST = true;
  364. item.WarningHighLimitTrig.RST = true;
  365. item.AlarmLowLimitTrig.RST = true;
  366. item.AlarmHighLimitTrig.RST = true;
  367. }
  368. }
  369. }
  370. private List<AITAuxData> GetCurrentAuxData()
  371. {
  372. var datas = new List<AITAuxData>();
  373. if (_auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  374. {
  375. foreach (var item in _auxDic[_currentAuxTable])
  376. {
  377. if (item == null)
  378. continue;
  379. var data = new AITAuxData();
  380. data.AlarmHighLimit = item.AlarmHighLimit;
  381. data.AlarmLowLimit = item.AlarmLowLimit;
  382. data.WarningLowLimit = item.WarningLowLimit;
  383. data.WarningHighLimit = item.WarningHighLimit;
  384. data.SetPoint = item.AISV != null ? item.AISV.FloatValue : item.SetPoint;
  385. data.DisplayName = item.DisplayName;
  386. data.IOName = item.IOName;
  387. data.Unit = item.Unit;
  388. data.Feedback = item.Feedback;
  389. data.Index = item.Index;
  390. datas.Add(data);
  391. }
  392. }
  393. return datas;
  394. }
  395. private void MonitorFfu()
  396. {
  397. _isCEXHOn = _fFUs != null && !_fFUs.Any(x => !x.IsEnable);
  398. }
  399. private void MonitorAux()
  400. {
  401. if (_initTimer.IsRunning && _initTimer.ElapsedMilliseconds < 3000)
  402. {
  403. _initTimer.Stop();
  404. return;
  405. }
  406. if (IsHTR1Enable != SC.GetValue<bool>("PM1.IsHTR1Enable"))
  407. IsHTR1Enable = SC.GetValue<bool>("PM1.IsHTR1Enable");
  408. if (IsHTR2Enable != SC.GetValue<bool>("PM1.IsHTR2Enable"))
  409. IsHTR2Enable = SC.GetValue<bool>("PM1.IsHTR2Enable");
  410. if (IsHTR3Enable != SC.GetValue<bool>("PM1.IsHTR3Enable"))
  411. IsHTR3Enable = SC.GetValue<bool>("PM1.IsHTR3Enable");
  412. if (IsHTR1Enable && IsHTR2Enable && IsF2ClnOn)
  413. {
  414. if (_currentAuxTable != 2)
  415. {
  416. _currentAuxTable = 2;
  417. LOG.Write($"AUC table switch to {_currentAuxTable}");
  418. }
  419. }
  420. else if (IsHTR1Enable && IsHTR2Enable && IsHFClnOn)
  421. {
  422. if (_currentAuxTable != 3)
  423. {
  424. _currentAuxTable = 3;
  425. LOG.Write($"AUC table switch to {_currentAuxTable}");
  426. }
  427. }
  428. else if (IsHTR1Enable)
  429. {
  430. if (_currentAuxTable != 1)
  431. {
  432. _currentAuxTable = 1;
  433. LOG.Write($"AUC table switch to {_currentAuxTable}");
  434. }
  435. }
  436. if (IsHTR1Enable && IsHTR2Enable && IsF2ClnOn)
  437. {
  438. if (TrigGasLineHeaterMemoryChange != null && TrigGasLineHeaterMemoryChange.AOValue != 2)
  439. TrigGasLineHeaterMemoryChange.SetAOTrigger(2, out _);
  440. }
  441. else if (IsHTR1Enable)
  442. {
  443. if (TrigGasLineHeaterMemoryChange != null && TrigGasLineHeaterMemoryChange.AOValue != 1)
  444. TrigGasLineHeaterMemoryChange.SetAOTrigger(1, out _);
  445. }
  446. else
  447. {
  448. if (TrigGasLineHeaterMemoryChange != null && TrigGasLineHeaterMemoryChange.AOValue != 0)
  449. TrigGasLineHeaterMemoryChange.SetAOTrigger(0, out _);
  450. }
  451. if (_auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  452. {
  453. if (IsProcessing)
  454. {
  455. foreach (var item in _auxDic[_currentAuxTable])
  456. {
  457. if (item == null)
  458. continue;
  459. item.AlarmHighLimit = (float)item.AlarmHighLimitConfig.DoubleValue;
  460. item.AlarmLowLimit = (float)item.AlarmLowLimitConfig.DoubleValue;
  461. item.WarningHighLimit = (float)item.WarningHighLimitConfig.DoubleValue;
  462. item.WarningLowLimit = (float)item.WarningLowLimitConfig.DoubleValue;
  463. //item.SetPoint = (float)item.SetPointConfig.DoubleValue;
  464. item.Unit = item.UnitConfig.StringValue;
  465. item.DisplayName = item.DisplayNameConfig.StringValue;
  466. if (SC.GetStringValue("System.SetUp.ToolType") == "ELK")
  467. {
  468. item.Feedback = IO.AI[$"{item.Module}.{item.IOName}"] != null ? IO.AI[$"{item.Module}.{item.IOName}"].FloatValue : 0;
  469. item.SetPoint = item.AO != null ? item.AO.FloatValue : 0;
  470. }
  471. else
  472. {
  473. item.Feedback = IO.AI[$"{Module}.{item.IOName}"] != null ? IO.AI[$"{Module}.{item.IOName}"].FloatValue : 0;
  474. }
  475. if (item.AO != null && Math.Abs(item.AO.FloatValue - item.SetPoint) > 0.0001 && item.SetPoint > 0 && item.IOName.Contains("ForelineHeater"))//只有ForelineHeater需要写,GasLine heater之类不写
  476. {
  477. item.AO.FloatValue = item.SetPoint;//process 过程中,不写ao
  478. }
  479. if (item.AOAlarmHigher != null && Math.Abs(item.AOAlarmHigher.FloatValue - item.AlarmHighLimit) > 0.0001)
  480. {
  481. item.AOAlarmHigher.FloatValue = item.AlarmHighLimit;//process 过程中,不写ao
  482. }
  483. if (item.AOAlarmLower != null && Math.Abs(item.AOAlarmLower.FloatValue - item.AlarmLowLimit) > 0.0001)
  484. {
  485. item.AOAlarmLower.FloatValue = item.AlarmLowLimit;//process 过程中,不写ao
  486. }
  487. }
  488. }
  489. else
  490. {
  491. foreach (var item in _auxDic[_currentAuxTable])
  492. {
  493. if (item == null)
  494. continue;
  495. item.WarningHighLimit = (float)item.WarningHighLimitConfig.DoubleValue;
  496. item.WarningLowLimit = (float)item.WarningLowLimitConfig.DoubleValue;
  497. item.SetPoint = (float)item.SetPointConfig.DoubleValue;
  498. item.Unit = item.UnitConfig.StringValue;
  499. item.DisplayName = item.DisplayNameConfig.StringValue;
  500. item.AlarmHighLimit = (float)item.AlarmHighLimitConfig.DoubleValue;
  501. item.AlarmLowLimit = (float)item.AlarmLowLimitConfig.DoubleValue;
  502. if (SC.GetStringValue("System.SetUp.ToolType") == "ELK")
  503. {
  504. item.Feedback = IO.AI[$"{item.Module}.{item.IOName}"] != null ? IO.AI[$"{item.Module}.{item.IOName}"].FloatValue : 0;
  505. item.SetPoint = item.AO != null ? item.AO.FloatValue : 0;
  506. }
  507. else
  508. {
  509. item.Feedback = IO.AI[$"{Module}.{item.IOName}"] != null ? IO.AI[$"{Module}.{item.IOName}"].FloatValue : 0;
  510. }
  511. //item.Feedback = IO.AI[$"{Module}.{item.IOName}"] != null ? IO.AI[$"{Module}.{item.IOName}"].FloatValue : 0;
  512. if (item.AO != null && Math.Abs(item.AO.FloatValue - (float)item.SetPointConfig.DoubleValue) > 0.0001 && item.SetPoint > 0 && item.IOName.Contains("ForelineHeater"))//只有ForelineHeater需要写,GasLine heater之类不写
  513. {
  514. item.AO.FloatValue = (float)item.SetPointConfig.DoubleValue;
  515. }
  516. if (item.AOAlarmHigher != null && Math.Abs(item.AOAlarmHigher.FloatValue - item.AlarmHighLimit) > 0.0001)
  517. {
  518. item.AOAlarmHigher.FloatValue = item.AlarmHighLimit;
  519. }
  520. if (item.AOAlarmLower != null && Math.Abs(item.AOAlarmLower.FloatValue - item.AlarmLowLimit) > 0.0001)
  521. {
  522. item.AOAlarmLower.FloatValue = item.AlarmLowLimit;
  523. }
  524. if (item.Feedback > item.SetPoint + item.AlarmHighLimit)
  525. {
  526. //注释AUX报警
  527. //item.AlarmHighLimitTrig.CLK = true;
  528. //if (item.AlarmHighLimitTrig.Q)
  529. //{
  530. // var reason = $"{item.DisplayName} feedback={item.Feedback}, alarm high limit is {item.SetPoint + item.AlarmHighLimit}";
  531. // item.AlarmHighLimitEvent.Set(reason);
  532. //}
  533. }
  534. else if (item.Feedback < item.SetPoint - item.AlarmLowLimit)
  535. {
  536. //注释AUX报警
  537. //item.AlarmLowLimitTrig.CLK = true;
  538. //if (item.AlarmLowLimitTrig.Q)
  539. //{
  540. // var reason = $"{item.DisplayName} feedback={item.Feedback}, alarm low limit is {item.SetPoint - item.AlarmLowLimit}";
  541. // item.AlarmLowLimitEvent.Set(reason);
  542. //}
  543. }
  544. else if (item.Feedback > item.SetPoint + item.WarningHighLimit)
  545. {
  546. //注释AUX报警
  547. //item.WarningHighLimitTrig.CLK = true;
  548. //if (item.WarningHighLimitTrig.Q)
  549. //{
  550. // var reason = $"{item.DisplayName} feedback={item.Feedback}, warning high limit is {item.SetPoint + item.WarningHighLimit}";
  551. // item.AlarmHighLimitEvent.Set(reason);
  552. //}
  553. }
  554. else if (item.Feedback < item.SetPoint - item.WarningLowLimit)
  555. {
  556. //注释AUX报警
  557. //item.WarningLowLimitTrig.CLK = true;
  558. //if (item.WarningLowLimitTrig.Q)
  559. //{
  560. // var reason = $"{item.DisplayName} feedback={item.Feedback}, warning low limit is {item.SetPoint - item.WarningLowLimit}";
  561. // item.AlarmLowLimitEvent.Set(reason);
  562. //}
  563. }
  564. }
  565. }
  566. }
  567. }
  568. private void SetAUXParameters(object[] param)
  569. {
  570. if (param != null && param.Length > 0 &&
  571. _auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  572. {
  573. var array = param[0].ToString().Split(';');
  574. if (array != null && array.Length > 0)
  575. {
  576. for (int i = 0; i < array.Length; i++)
  577. {
  578. var auxItems = array[i].Split(',');
  579. if (auxItems == null || auxItems.Length < 6)
  580. continue;
  581. int.TryParse(auxItems[0], out int index);
  582. float.TryParse(auxItems[1], out float set);
  583. bool.TryParse(auxItems[2], out bool isCheck);
  584. float.TryParse(auxItems[3], out float checkHigh);
  585. float.TryParse(auxItems[4], out float checkLow);
  586. var checkUnit = auxItems[5];
  587. var aux = _auxDic[_currentAuxTable].SingleOrDefault(x => x.Index == index);
  588. if (aux != null)
  589. {
  590. if (checkUnit.ToLower() == "%sv")
  591. {
  592. checkHigh = set * checkHigh;
  593. checkLow = set * checkLow;
  594. }
  595. else if (checkUnit.ToLower() == "%fs")
  596. {
  597. checkHigh = (_auxScaleDic.ContainsKey(aux.IOName) ? _auxScaleDic[aux.IOName] : 1) * checkHigh;
  598. checkLow = (_auxScaleDic.ContainsKey(aux.IOName) ? _auxScaleDic[aux.IOName] : 1) * checkLow;
  599. }
  600. if (set > 0)
  601. aux.SetPoint = set;
  602. aux.IsWait = isCheck;
  603. aux.WaitHigh = checkHigh;
  604. aux.WaitLow = checkLow;
  605. }
  606. }
  607. }
  608. }
  609. }
  610. public bool CheckAUXWaitCondition(out string reason)
  611. {
  612. reason = "";
  613. bool allFinish = true;
  614. if (_auxDic != null && _auxDic.ContainsKey(_currentAuxTable))
  615. {
  616. foreach (var item in _auxDic[_currentAuxTable])
  617. {
  618. if (item == null)
  619. continue;
  620. if (!item.IsWait || item.WaitHigh == 0 || item.WaitLow == 0)
  621. continue;
  622. if (item.Feedback < item.SetPoint - item.WaitLow || item.Feedback > item.SetPoint + item.WaitHigh)
  623. {
  624. allFinish = false;
  625. reason += $"{item.DisplayName} feedback={item.Feedback}, limit is ({item.SetPoint - item.WaitLow}, {item.SetPoint + item.WaitHigh}) \n";
  626. }
  627. }
  628. }
  629. return allFinish;
  630. }
  631. private bool SetF2ClnEnable(object[] param)
  632. {
  633. if (param != null && param.Length > 0)
  634. {
  635. bool.TryParse(param[0].ToString(), out bool isEnable);
  636. IsF2ClnOn = isEnable;
  637. }
  638. return true;
  639. }
  640. private bool SetHFClnEnable(object[] param)
  641. {
  642. if (param != null && param.Length > 0)
  643. {
  644. bool.TryParse(param[0].ToString(), out bool isEnable);
  645. IsHFClnOn = isEnable;
  646. }
  647. return true;
  648. }
  649. private bool SetDEPOEnable(object[] param)
  650. {
  651. if (param != null && param.Length > 0)
  652. {
  653. bool.TryParse(param[0].ToString(), out bool isEnable);
  654. IsDEPOOn = isEnable;
  655. }
  656. return true;
  657. }
  658. private bool SetCREFEnable(object[] param)
  659. {
  660. if (param != null && param.Length > 0)
  661. {
  662. bool.TryParse(param[0].ToString(), out bool isEnable);
  663. IsCREFOn = isEnable;
  664. }
  665. return true;
  666. }
  667. private bool SetSIREFEnable(object[] param)
  668. {
  669. if (param != null && param.Length > 0)
  670. {
  671. bool.TryParse(param[0].ToString(), out bool isEnable);
  672. IsSIREFOn = isEnable;
  673. }
  674. return true;
  675. }
  676. }
  677. }