PMAux.cs 32 KB

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