IoMfc4.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  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.RT.Tolerance;
  10. using Aitex.Core.Util;
  11. using Aitex.Core.Utilities;
  12. using MECF.Framework.Common.Event;
  13. using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MFCs;
  14. using System;
  15. using System.Collections.Generic;
  16. using System.Linq;
  17. using System.Text;
  18. using System.Threading.Tasks;
  19. using System.Xml;
  20. namespace Aitex.Core.RT.Device.Unit
  21. {
  22. public class IoMfc4 : BaseDevice, IDevice, IMfc
  23. {
  24. public string Unit
  25. {
  26. get; set;
  27. }
  28. public double Scale
  29. {
  30. get
  31. {
  32. if (_scN2Scale == null || _scScaleFactor == null)
  33. return 0;
  34. return _scN2Scale.DoubleValue * _scScaleFactor.DoubleValue;
  35. }
  36. }
  37. private double _setpoint;
  38. public double SetPoint
  39. {
  40. get
  41. {
  42. return _setpoint;
  43. }
  44. set
  45. {
  46. _setpoint = value;
  47. if (_aoFlow != null)
  48. {
  49. //var setpoint = Scale != 0 ? (float)(value * _maxScale / Scale) : value;
  50. if (_isFloatAioType)
  51. _aoFlow.FloatValue = (float)Converter.Logic2Phy(value, 0, Scale, _phyScaleMin, _phyScale);
  52. else
  53. _aoFlow.Value = (short)Converter.Logic2Phy(value, 0, Scale, _phyScaleMin, _phyScale);
  54. }
  55. }
  56. }
  57. public double DefaultSetPoint
  58. {
  59. get
  60. {
  61. if (_scDefaultSetPoint != null)
  62. return _scDefaultSetPoint.DoubleValue;
  63. return 0;
  64. }
  65. }
  66. public double FeedBack
  67. {
  68. get
  69. {
  70. if (_aiFlow != null)
  71. {
  72. //double aiValue = _isFloatAioType ? _aiFlow.FloatValue : _aiFlow.Value;
  73. var phy = _aiFlow == null ? 0 : (_isFloatAioType ? _aiFlow.FloatValue : _aiFlow.Value);
  74. return Converter.Phy2Logic(phy, 0, Scale, _phyScaleMin, _phyScale);
  75. //return _maxScale != 0 ? aiValue * Scale / _maxScale : aiValue;
  76. }
  77. return 0;
  78. }
  79. }
  80. public bool EnableAlarm
  81. {
  82. get
  83. {
  84. if (_scEnableAlarm != null)
  85. return _scEnableAlarm.BoolValue;
  86. return false;
  87. }
  88. }
  89. public bool IsStable
  90. {
  91. get
  92. {
  93. if (!_stableDelayTimer.IsIdle() && _stableDelayTimer.GetElapseTime() >= _stableDelayTime * 1000)
  94. {
  95. if (!_stableJudgmentTimer.IsIdle())
  96. {
  97. if (FeedBack < SetPoint * (100 - _stableMinValue) / 100 ||
  98. FeedBack > SetPoint * (100 + _stableMaxValue) / 100)
  99. {
  100. _stableJudgmentTimer.Start(0);
  101. }
  102. if (_stableJudgmentTimer.GetElapseTime() >= _stableJudgmentTime * 1000)
  103. {
  104. return true;
  105. }
  106. }
  107. else
  108. {
  109. _stableJudgmentTimer.Start(0);
  110. }
  111. }
  112. return false;
  113. }
  114. }
  115. private AITMfcData DeviceData
  116. {
  117. get
  118. {
  119. AITMfcData data = new AITMfcData()
  120. {
  121. UniqueName = $"{Module}.{Name}",
  122. Type = "MFC",
  123. Module = Module,
  124. DeviceName = Name,
  125. DeviceSchematicId = DeviceID,
  126. DisplayName = DisplayName,
  127. FeedBack = FeedBack < 0 ? 0 : FeedBack,
  128. SetPoint = _rampTarget,
  129. Ramping = _ramping,
  130. AlarmWatchTable = AlarmWatchTable,
  131. Scale = Scale,
  132. //IsWarning = !AlarmToleranceWarning.IsAcknowledged,
  133. //IsError = !AlarmToleranceAlarm.IsAcknowledged,
  134. Unit = Unit,
  135. };
  136. return data;
  137. }
  138. }
  139. public string DisplayName
  140. {
  141. get
  142. {
  143. if (_scGasName != null)
  144. return _scGasName.StringValue;
  145. return Display;
  146. }
  147. }
  148. public string AlarmWatchTable
  149. {
  150. get;
  151. set;
  152. }
  153. private DeviceTimer _rampTimer = new DeviceTimer();
  154. private double _rampTarget;
  155. private double _rampInitValue;
  156. private int _rampTime;
  157. private float _ramping;
  158. private double _phyScaleMin;
  159. private double _phyScale;
  160. private ToleranceChecker _toleranceCheckerWarning = new ToleranceChecker();
  161. private ToleranceChecker _toleranceCheckerAlarm = new ToleranceChecker();
  162. private AIAccessor _aiFlow;
  163. private AOAccessor _aoFlow;
  164. private DOAccessor _doOpen;
  165. private DOAccessor _doClose;
  166. private bool _isMFCInstalled;
  167. private int _mfcIndex;
  168. public bool IsMFCInstalled
  169. {
  170. get { return _isMFCInstalled; }
  171. }
  172. public int MFCIndex
  173. {
  174. get { return _mfcIndex; }
  175. }
  176. protected SCConfigItem _scGasName;
  177. protected SCConfigItem _scEnable;
  178. private SCConfigItem _scN2Scale;
  179. private SCConfigItem _scScaleFactor;
  180. private SCConfigItem _scEnableAlarm;
  181. private SCConfigItem _scDefaultSetPoint;
  182. private SCConfigItem _scRegulationFactor;
  183. //tolerance check
  184. private float _alarmJudgmentRange;
  185. private float _warningJudgmentRange;
  186. private float _alarmJudgmentTime;
  187. private float _warningJudgmentTime;
  188. private float _toleranceJudgmentDelayTime;
  189. private DeviceTimer _toleranceJudgmentDelayTimer = new DeviceTimer();
  190. //stable check
  191. private DeviceTimer _stableDelayTimer = new DeviceTimer();
  192. private float _stableDelayTime;
  193. private DeviceTimer _stableJudgmentTimer = new DeviceTimer();
  194. private float _stableJudgmentTime;
  195. private float _stableMinValue;
  196. private float _stableMaxValue;
  197. private int _toleranceAlarmEventId;
  198. private int _toleranceWarningEventId;
  199. public AlarmEventItem AlarmToleranceWarning { get; set; }
  200. public AlarmEventItem AlarmToleranceAlarm { get; set; }
  201. private bool _isFloatAioType = false;
  202. public IoMfc4(string module, XmlElement node, string ioModule = "")
  203. {
  204. Unit = node.GetAttribute("unit");
  205. base.Module = string.IsNullOrEmpty(node.GetAttribute("module")) ? module : node.GetAttribute("module");
  206. base.Name = node.GetAttribute("id");
  207. base.Display = node.GetAttribute("display");
  208. base.DeviceID = node.GetAttribute("schematicId");
  209. int.TryParse(node.GetAttribute("MFCIndex"), out _mfcIndex);
  210. int.TryParse(node.GetAttribute("toleranceAlarmEventId"), out _toleranceAlarmEventId);
  211. int.TryParse(node.GetAttribute("toleranceWarningEventId"), out _toleranceWarningEventId);
  212. _aiFlow = ParseAiNode("aiFlow", node, ioModule);
  213. _aoFlow = ParseAoNode("aoFlow", node, ioModule);
  214. _doOpen = ParseDoNode("doOpen", node, ioModule);
  215. _doClose = ParseDoNode("doClose", node, ioModule);
  216. _isFloatAioType = !string.IsNullOrEmpty(node.GetAttribute("aioType")) && (node.GetAttribute("aioType") == "float");
  217. string scBasePath = node.GetAttribute("scBasePath");
  218. if (string.IsNullOrEmpty(scBasePath))
  219. scBasePath = $"{Module}.{Name}";
  220. else
  221. {
  222. scBasePath = scBasePath.Replace("{module}", Module);
  223. }
  224. _scGasName = SC.GetConfigItem($"{scBasePath}.{Name}.GasName");
  225. _scEnable = SC.GetConfigItem($"{scBasePath}.{Name}.Enable");
  226. _isMFCInstalled = SC.GetConfigItem($"{scBasePath}.{Display}.IsMFCInstalled").BoolValue;
  227. _scN2Scale = ParseScNode("scN2Scale", node, ioModule, $"{scBasePath}.{Name}.N2Scale");
  228. _scScaleFactor = ParseScNode("scScaleFactor", node, ioModule, $"{scBasePath}.{Name}.ScaleFactor");
  229. _scEnableAlarm = ParseScNode("scEnableAlarm", node, ioModule, $"{scBasePath}.{Name}.EnableAlarm");
  230. _scDefaultSetPoint = ParseScNode("scDefaultSetPoint", node, ioModule, $"{scBasePath}.{Name}.DefaultSetPoint");
  231. _scRegulationFactor = ParseScNode("scFlowRegulationFactor", node, ioModule, $"{scBasePath}.{Name}.RegulationFactor");
  232. if (SC.ContainsItem($"{scBasePath}.{Name}.FlowUnit"))
  233. Unit = SC.GetStringValue($"{scBasePath}.{Name}.FlowUnit");
  234. }
  235. public bool Initialize()
  236. {
  237. DATA.Subscribe($"{Module}.{Name}.DeviceData", () => DeviceData);
  238. DATA.Subscribe($"{Module}.{Name}.Feedback", () => FeedBack);
  239. DATA.Subscribe($"{Module}.{Name}.SetPoint", () => SetPoint);
  240. DATA.Subscribe($"{Module}.{Name}.ForceOpen", () => _doOpen.Value);
  241. DATA.Subscribe($"{Module}.{Name}.ForceClose", () => _doClose.Value);
  242. OP.Subscribe($"{Module}.{Name}.Ramp", (out string reason, int time, object[] param) =>
  243. {
  244. double target = Convert.ToDouble(param[0].ToString());
  245. if (target < 0 || target > Scale)
  246. {
  247. reason = $"set {Display} value {target} out of range [0, {Scale}] {Unit}";
  248. return false;
  249. }
  250. Ramp(target, time);
  251. if (time > 0)
  252. {
  253. reason = $"{Display} ramp to {target} {Unit} in {time} seconds";
  254. }
  255. else
  256. {
  257. reason = $"{Display} ramp to {target} {Unit}";
  258. }
  259. return true;
  260. });
  261. OP.Subscribe($"{Module}.{Name}.SetMfcFlow", SetMfcFlow);
  262. OP.Subscribe($"{Module}.{Name}.SetParameters", SetParameters);
  263. OP.Subscribe($"{Module}.{Name}.SetMfcValue", SetMfcValue);
  264. _phyScale = SC.GetValue<double>($"{Module}.MFC.{Name}.PhyScale");
  265. _phyScaleMin = SC.GetValue<double>($"{Module}.MFC.{Name}.PhyScaleMin");
  266. return true;
  267. }
  268. public void Monitor()
  269. {
  270. //ProcessSensorStatus();
  271. MonitorRamping();
  272. MonitorTolerance();
  273. }
  274. //private void ProcessSensorStatus()
  275. //{
  276. // BitArray SensorStatus = new BitArray(new int[] { _aiStatus.Value });
  277. // _isErrorStatus = SensorStatus[15];
  278. //}
  279. public void SetStableParameters(string tableId)
  280. {
  281. if (SC.ContainsItem($"{Module}.RecipeEditParameter.FlowStabilizeTable.Table{tableId}.DelayTime"))
  282. {
  283. var scPath = $"{Module}.RecipeEditParameter.FlowStabilizeTable.Table{tableId}";
  284. _stableDelayTime = (float)SC.GetValue<double>($"{scPath}.DelayTime");
  285. _stableJudgmentTime = (float)SC.GetValue<double>($"{scPath}.JudgmentTime");
  286. _stableMinValue = (float)SC.GetValue<double>($"{scPath}.MinValue");
  287. _stableMaxValue = (float)SC.GetValue<double>($"{scPath}.MaxValue");
  288. _stableDelayTimer.Start(0);
  289. _stableJudgmentTimer.Stop();
  290. }
  291. }
  292. public bool ResetWarningChecker()
  293. {
  294. _toleranceCheckerWarning.Reset(_warningJudgmentTime);
  295. return true;
  296. }
  297. public bool ResetAlarmChecker()
  298. {
  299. _toleranceCheckerAlarm.Reset(_alarmJudgmentTime);
  300. return true;
  301. }
  302. public void Reset()
  303. {
  304. _toleranceCheckerWarning.Reset(_warningJudgmentTime);
  305. _toleranceCheckerAlarm.Reset(_alarmJudgmentTime);
  306. AlarmToleranceWarning.Reset();
  307. AlarmToleranceAlarm.Reset();
  308. }
  309. public void Terminate()
  310. {
  311. Ramp(DefaultSetPoint, 0);
  312. }
  313. private bool SetParameters(out string reason, int time, object[] param)
  314. {
  315. reason = string.Empty;
  316. var paras = param[0].ToString().Split(';');//flow;rampTime;alarmTable
  317. float setpoint = 0.0f;
  318. if (paras[0].ToString() == "Continue")
  319. {
  320. EV.PostInfoLog(Module, $"Set {DisplayName} flow to Continue");
  321. return true;
  322. }
  323. else if (paras[0].ToString() == "ForceOpen")
  324. {
  325. _doOpen.SetValue(true, out reason);
  326. }
  327. else if (paras[0].ToString() == "ForceClose")
  328. {
  329. _doClose.SetValue(true, out reason);
  330. }
  331. else
  332. {
  333. if (System.Text.RegularExpressions.Regex.Match(paras[0].ToString(), @"[a-zA-Z]").Success)
  334. {
  335. var table = paras[0].ToString().Split(':')[0];
  336. if (SC.ContainsItem($"{Module}.RecipeEditParameter.FlowSetting.{Name}.{table}"))
  337. setpoint = (float)SC.GetValue<double>($"{Module}.RecipeEditParameter.FlowSetting.{Name}.{table}");
  338. }
  339. else
  340. {
  341. float.TryParse(paras[0].ToString(), out setpoint);
  342. }
  343. }
  344. if (paras.Length > 1)
  345. float.TryParse(paras[1].ToString(), out _ramping);
  346. if (paras.Length > 2)
  347. {
  348. var alarmWatchTable = paras[2].ToString();
  349. AlarmWatchTable = alarmWatchTable;
  350. if (SC.ContainsItem($"{Module}.RecipeEditParameter.AlarmWatchTable.FlowAlarmWatch.Table{alarmWatchTable}.DelayTime"))
  351. {
  352. var scPath = $"{Module}.RecipeEditParameter.AlarmWatchTable.FlowAlarmWatch.Table{alarmWatchTable}";
  353. _toleranceJudgmentDelayTime = (float)SC.GetValue<double>($"{scPath}.DelayTime");
  354. _alarmJudgmentRange = (float)SC.GetValue<double>($"{scPath}.AlarmJudgment");
  355. _warningJudgmentRange = (float)SC.GetValue<double>($"{scPath}.WarningJudgment");
  356. _alarmJudgmentTime = (float)SC.GetValue<double>($"{scPath}.AlarmJudgmentTime");
  357. _warningJudgmentTime = (float)SC.GetValue<double>($"{scPath}.WarningJudgmentTime");
  358. _toleranceJudgmentDelayTimer.Start(0);
  359. }
  360. else
  361. {
  362. _toleranceJudgmentDelayTime = 0;
  363. _alarmJudgmentRange = 0;
  364. _warningJudgmentRange = 0;
  365. _alarmJudgmentTime = 0;
  366. _warningJudgmentTime = 0;
  367. _toleranceJudgmentDelayTimer.Stop();
  368. }
  369. ResetWarningChecker();
  370. ResetAlarmChecker();
  371. }
  372. //_rampTime = _ramping != 0 ? (int)(Math.Abs(setpoint - FeedBack) / _ramping) * 1000 : 0;
  373. _rampTime = (int)(_ramping * 1000);
  374. return Ramp(setpoint, _rampTime, out reason);
  375. }
  376. private bool SetMfcFlow(out string reason, int time, object[] param)
  377. {
  378. float setpoint = 0.0f;
  379. var paras = param[0].ToString().Split(';');
  380. if (System.Text.RegularExpressions.Regex.Match(paras[0].ToString(), @"[a-zA-Z]").Success)
  381. {
  382. var table = paras[0].ToString().Split(':')[0];
  383. if (SC.ContainsItem($"{Module}.RecipeEditParameter.FlowSetting.{Name}.{table}"))
  384. setpoint = (float)SC.GetValue<double>($"{Module}.RecipeEditParameter.FlowSetting.{Name}.{table}");
  385. }
  386. else
  387. {
  388. float.TryParse(param[0].ToString(), out setpoint);
  389. }
  390. if (paras.Length == 1)
  391. {
  392. Ramp(setpoint, 0, out reason);
  393. }
  394. else
  395. {
  396. Ramp(setpoint, (int)Convert.ToSingle(paras[1]), out reason);
  397. }
  398. return true;
  399. }
  400. private bool SetMfcValue(out string reason, int time, object[] param)
  401. {
  402. reason = string.Empty;
  403. float setpoint = 0.0f;
  404. var paras = param[0].ToString().Split(';'); // setpoint;ramping;alarmWatchTable
  405. if (paras[0].ToString() == "ForceOpen")
  406. {
  407. _doOpen.SetValue(true, out reason);
  408. _doClose.SetValue(false, out reason);
  409. }
  410. else if (paras[0].ToString() == "ForceClose")
  411. {
  412. _doClose.SetValue(true, out reason);
  413. _doOpen.SetValue(false, out reason);
  414. }
  415. else
  416. {
  417. if (System.Text.RegularExpressions.Regex.Match(paras[0].ToString(), @"[a-zA-Z]").Success)
  418. {
  419. var table = paras[0].ToString().Split(':')[0];
  420. if (SC.ContainsItem($"{Module}.RecipeEditParameter.FlowSetting.{Name}.{table}"))
  421. setpoint = (float)SC.GetValue<double>($"{Module}.RecipeEditParameter.FlowSetting.{Name}.{table}");
  422. }
  423. else
  424. {
  425. float.TryParse(paras[0].ToString(), out setpoint);
  426. }
  427. _doOpen.SetValue(false, out reason);
  428. _doClose.SetValue(false, out reason);
  429. }
  430. if (paras.Length > 1)
  431. float.TryParse(paras[1].ToString(), out _ramping);
  432. if (paras.Length > 2)
  433. {
  434. AlarmWatchTable = paras[2].ToString();
  435. if (SC.ContainsItem($"{Module}.RecipeEditParameter.AlarmWatchTable.FlowAlarmWatch.Table{AlarmWatchTable}.DelayTime"))
  436. {
  437. var scPath = $"{Module}.RecipeEditParameter.AlarmWatchTable.FlowAlarmWatch.Table{AlarmWatchTable}";
  438. _toleranceJudgmentDelayTime = (float)SC.GetValue<double>($"{scPath}.DelayTime");
  439. _alarmJudgmentRange = (float)SC.GetValue<double>($"{scPath}.AlarmJudgment");
  440. _warningJudgmentRange = (float)SC.GetValue<double>($"{scPath}.WarningJudgment");
  441. _alarmJudgmentTime = (float)SC.GetValue<double>($"{scPath}.AlarmJudgmentTime");
  442. _warningJudgmentTime = (float)SC.GetValue<double>($"{scPath}.WarningJudgmentTime");
  443. }
  444. else
  445. {
  446. _toleranceJudgmentDelayTime = 0;
  447. _alarmJudgmentRange = 0;
  448. _warningJudgmentRange = 0;
  449. _alarmJudgmentTime = 0;
  450. _warningJudgmentTime = 0;
  451. }
  452. }
  453. //_rampTime = _ramping != 0 ? (int)(Math.Abs(setpoint - FeedBack) / _ramping * 1000) : 0;
  454. _rampTime = (int)(_ramping * 1000);
  455. Ramp(setpoint, _rampTime, out reason);
  456. return true;
  457. }
  458. public bool Ramp(double flowSetPoint, int time, out string reason)
  459. {
  460. if (HasAlarm)
  461. {
  462. reason = $"{DisplayName} in error status, can not flow";
  463. return false;
  464. }
  465. if (flowSetPoint < 0 || flowSetPoint > Scale)
  466. {
  467. reason = $"{DisplayName} range is [0, {Scale}], can not flow {flowSetPoint}";
  468. return false;
  469. }
  470. if (time > 0)
  471. {
  472. EV.PostInfoLog(Module, $"Set {DisplayName} flow to {flowSetPoint} {Unit} in {time / 1000:F0} seconds");
  473. }
  474. else
  475. {
  476. EV.PostInfoLog(Module, $"Set {DisplayName} flow to {flowSetPoint} {Unit}");
  477. }
  478. Ramp(flowSetPoint, time);
  479. reason = string.Empty;
  480. return true;
  481. }
  482. public void Ramp(int time)
  483. {
  484. Ramp(DefaultSetPoint, time);
  485. }
  486. public void Ramp(double target, int time)
  487. {
  488. target = Math.Max(0, target);
  489. target = Math.Min(Scale, target);
  490. _rampInitValue = FeedBack; //ramp 初始值取当前设定值,而非实际读取值.零漂问题
  491. _rampTime = time;
  492. _rampTarget = target;
  493. _rampTimer.Start(time);
  494. }
  495. public void StopRamp()
  496. {
  497. Ramp(SetPoint, 0);
  498. }
  499. private void MonitorRamping()
  500. {
  501. if (!_rampTimer.IsIdle())
  502. {
  503. if (_rampTimer.IsTimeout() || _rampTime == 0)
  504. {
  505. _rampTimer.Stop();
  506. SetPoint = _rampTarget;
  507. }
  508. else
  509. {
  510. SetPoint = _rampInitValue + (_rampTarget - _rampInitValue) * _rampTimer.GetElapseTime() / _rampTime;
  511. }
  512. }
  513. }
  514. public bool SetOpen(bool isOpen, out string reason)
  515. {
  516. reason = string.Empty;
  517. if (_doOpen != null)
  518. {
  519. if (!_doOpen.SetValue(isOpen, out reason))
  520. {
  521. LOG.Write(reason);
  522. return false;
  523. }
  524. }
  525. if (_doClose != null)
  526. {
  527. if (!_doClose.SetValue(!isOpen, out reason))
  528. {
  529. LOG.Write(reason);
  530. return false;
  531. }
  532. }
  533. return true;
  534. }
  535. private void MonitorTolerance()
  536. {
  537. if (!EnableAlarm || SetPoint < 0.01 ||
  538. _toleranceJudgmentDelayTimer.IsIdle() ||
  539. _toleranceJudgmentDelayTimer.GetElapseTime() < _toleranceJudgmentDelayTime * 1000)
  540. {
  541. _toleranceCheckerWarning.RST = true;
  542. _toleranceCheckerAlarm.RST = true;
  543. return;
  544. }
  545. if (_warningJudgmentRange != 0 && _warningJudgmentTime > 0)
  546. {
  547. _toleranceCheckerWarning.Monitor(FeedBack, (SetPoint - Math.Abs(_warningJudgmentRange)), (SetPoint + Math.Abs(_warningJudgmentRange)), _warningJudgmentTime);
  548. if (_toleranceCheckerWarning.Trig)
  549. {
  550. //AlarmToleranceWarning.Description = $"{Display} flow out of range {_warningJudgmentRange} {Unit} in {_warningJudgmentTime:F0} seconds";
  551. AlarmToleranceWarning.Set($"{Display} flow out of range {_warningJudgmentRange} {Unit} in {_warningJudgmentTime:F0} seconds");
  552. }
  553. }
  554. if (_alarmJudgmentRange != 0 && _alarmJudgmentTime > 0)
  555. {
  556. _toleranceCheckerAlarm.Monitor(FeedBack, (SetPoint - Math.Abs(_alarmJudgmentRange)), (SetPoint + Math.Abs(_alarmJudgmentRange)), _alarmJudgmentTime);
  557. if (_toleranceCheckerAlarm.Trig)
  558. {
  559. //AlarmToleranceAlarm.Description = $"{Display} flow out of range {_alarmJudgmentRange} {Unit} in {_alarmJudgmentTime:F0} seconds";
  560. AlarmToleranceAlarm.Set($"{Display} flow out of range {_alarmJudgmentRange} {Unit} in {_alarmJudgmentTime:F0} seconds");
  561. }
  562. }
  563. }
  564. }
  565. }