IoMFC.cs 23 KB

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