IoMFC.cs 24 KB

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