IoMFC.cs 23 KB

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