IoMfc.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. using System;
  2. using System.Diagnostics;
  3. using System.Xml;
  4. using Aitex.Core.Common.DeviceData;
  5. using Aitex.Core.RT.DataCenter;
  6. using Aitex.Core.RT.Device;
  7. using Aitex.Core.RT.Event;
  8. using Aitex.Core.RT.IOCore;
  9. using Aitex.Core.RT.OperationCenter;
  10. using Aitex.Core.RT.SCCore;
  11. using Aitex.Core.RT.Tolerance;
  12. using Aitex.Core.Util;
  13. using MECF.Framework.Common.DBCore;
  14. using Venus_RT.Modules;
  15. using Aitex.Core.RT.Log;
  16. using static Venus_RT.Modules.PMs.PMGasVerificationRoutine;
  17. using Venus_Core;
  18. using MECF.Framework.Common.Equipment;
  19. namespace Venus_RT.Devices.IODevices
  20. {
  21. public enum MFCWriteMode
  22. {
  23. Flow,
  24. Percent
  25. }
  26. //will be upgrade later
  27. public class MfcBase1 : BaseDevice, IDevice
  28. {
  29. public virtual double SetPoint { get; set; }
  30. public virtual double FeedBack { get; set; }
  31. public virtual bool IsOutOfTolerance { get; }
  32. public virtual double Scale { set; get; }
  33. public virtual string DisplayName { set; get; }
  34. private float _percent10Calculate;
  35. private float _percent20Calculate;
  36. private float _percent30Calculate;
  37. private float _percent40Calculate;
  38. private float _percent50Calculate;
  39. private float _percent60Calculate;
  40. private float _percent70Calculate;
  41. private float _percent80Calculate;
  42. private float _percent90Calculate;
  43. private float _percent100Calculate;
  44. private float _verificationCalculate;
  45. private float _verificationSetpoint;
  46. private string _verificationResult = "";
  47. public MfcBase1()
  48. {
  49. }
  50. public virtual bool Initialize()
  51. {
  52. DATA.Subscribe($"{Module}.{Name}.VerificationResult", () => _verificationResult);
  53. DATA.Subscribe($"{Module}.{Name}.FeedBack", () => FeedBack);
  54. DATA.Subscribe($"{Module}.{Name}.SetPoint", () => SetPoint);
  55. return true;
  56. }
  57. public virtual void Monitor()
  58. {
  59. }
  60. public virtual void Reset()
  61. {
  62. }
  63. public virtual void Terminate()
  64. {
  65. }
  66. public virtual void Ramp(int time)
  67. {
  68. }
  69. public virtual void Ramp(double target, int time)
  70. {
  71. }
  72. public virtual void StopRamp()
  73. {
  74. }
  75. public virtual void SetVerificationResult(float setpoint, float calculateFlow, bool saveResult, double time, double deviation, bool result, int verifyMode)
  76. {
  77. if (verifyMode == 0)
  78. {
  79. MFCVerificationOnePointData data = new MFCVerificationOnePointData()
  80. {
  81. Module = Module,
  82. Name = Name,
  83. Setpoint = setpoint,
  84. Calculate = calculateFlow,
  85. };
  86. MFCVerificationDataRecorder.AddOnePointData(data);
  87. }
  88. //ten points
  89. var delta = Scale / 10;
  90. _verificationResult += $"{setpoint},{calculateFlow},{time},{deviation},{result};";
  91. if (delta - 0.1 < setpoint && delta + 0.1 > setpoint)
  92. {
  93. _percent10Calculate = calculateFlow;
  94. }
  95. else if (2 * delta - 0.1 < setpoint && 2 * delta + 0.1 > setpoint)
  96. {
  97. _percent20Calculate = calculateFlow;
  98. }
  99. else if (3 * delta - 0.1 < setpoint && 3 * delta + 0.1 > setpoint)
  100. {
  101. _percent30Calculate = calculateFlow;
  102. }
  103. else if (4 * delta - 0.1 < setpoint && 4 * delta + 0.1 > setpoint)
  104. {
  105. _percent40Calculate = calculateFlow;
  106. }
  107. else if (5 * delta - 0.1 < setpoint && 5 * delta + 0.1 > setpoint)
  108. {
  109. _percent50Calculate = calculateFlow;
  110. }
  111. else if (6 * delta - 0.1 < setpoint && 6 * delta + 0.1 > setpoint)
  112. {
  113. _percent60Calculate = calculateFlow;
  114. }
  115. else if (7 * delta - 0.1 < setpoint && 7 * delta + 0.1 > setpoint)
  116. {
  117. _percent70Calculate = calculateFlow;
  118. }
  119. else if (8 * delta - 0.1 < setpoint && 8 * delta + 0.1 > setpoint)
  120. {
  121. _percent80Calculate = calculateFlow;
  122. }
  123. else if (9 * delta - 0.1 < setpoint && 9 * delta + 0.1 > setpoint)
  124. {
  125. _percent90Calculate = calculateFlow;
  126. }
  127. else if (10 * delta - 0.1 < setpoint && 10 * delta + 0.1 > setpoint)
  128. {
  129. _percent100Calculate = calculateFlow;
  130. }
  131. else
  132. {
  133. _verificationCalculate = calculateFlow;
  134. _verificationSetpoint = setpoint;
  135. }
  136. if (saveResult)
  137. {
  138. SaveVerificationData(verifyMode);
  139. }
  140. }
  141. private void SaveVerificationData(int verifyMode)
  142. {
  143. var delta = (float)(Scale / 10);
  144. MFCVerificationData data = new MFCVerificationData()
  145. {
  146. Module = Module,
  147. Name = DisplayName,
  148. Percent10Setpoint = delta,
  149. Percent10Calculate = _percent10Calculate,
  150. Percent20Setpoint = delta * 2,
  151. Percent20Calculate = _percent20Calculate,
  152. Percent30Setpoint = delta * 3,
  153. Percent30Calculate = _percent30Calculate,
  154. Percent40Setpoint = delta * 4,
  155. Percent40Calculate = _percent40Calculate,
  156. Percent50Setpoint = delta * 5,
  157. Percent50Calculate = _percent50Calculate,
  158. Percent60Setpoint = delta * 6,
  159. Percent60Calculate = _percent60Calculate,
  160. Percent70Setpoint = delta * 7,
  161. Percent70Calculate = _percent70Calculate,
  162. Percent80Setpoint = delta * 8,
  163. Percent80Calculate = _percent80Calculate,
  164. Percent90Setpoint = delta * 9,
  165. Percent90Calculate = _percent90Calculate,
  166. Percent100Setpoint = delta * 10,
  167. Percent100Calculate = _percent100Calculate,
  168. Setpoint = _verificationSetpoint,
  169. Calculate = _verificationCalculate,
  170. };
  171. MFCVerificationDataRecorder.Add(data);
  172. if (verifyMode == 1)
  173. {
  174. MFCVerificationTenPointsData tenPointsdata = new MFCVerificationTenPointsData()
  175. {
  176. Module = Module,
  177. Name = Name,
  178. Percent10Setpoint = delta,
  179. Percent10Calculate = _percent10Calculate,
  180. Percent20Setpoint = delta * 2,
  181. Percent20Calculate = _percent20Calculate,
  182. Percent30Setpoint = delta * 3,
  183. Percent30Calculate = _percent30Calculate,
  184. Percent40Setpoint = delta * 4,
  185. Percent40Calculate = _percent40Calculate,
  186. Percent50Setpoint = delta * 5,
  187. Percent50Calculate = _percent50Calculate,
  188. Percent60Setpoint = delta * 6,
  189. Percent60Calculate = _percent60Calculate,
  190. Percent70Setpoint = delta * 7,
  191. Percent70Calculate = _percent70Calculate,
  192. Percent80Setpoint = delta * 8,
  193. Percent80Calculate = _percent80Calculate,
  194. Percent90Setpoint = delta * 9,
  195. Percent90Calculate = _percent90Calculate,
  196. Percent100Setpoint = delta * 10,
  197. Percent100Calculate = _percent100Calculate,
  198. };
  199. MFCVerificationDataRecorder.AddTenPointsData(tenPointsdata);
  200. }
  201. }
  202. public void ResetVerificationData()
  203. {
  204. _percent10Calculate = 0;
  205. _percent20Calculate = 0;
  206. _percent30Calculate = 0;
  207. _percent40Calculate = 0;
  208. _percent50Calculate = 0;
  209. _percent60Calculate = 0;
  210. _percent70Calculate = 0;
  211. _percent80Calculate = 0;
  212. _percent90Calculate = 0;
  213. _percent100Calculate = 0;
  214. _verificationCalculate = 0;
  215. _verificationSetpoint = 0;
  216. _verificationResult = "";
  217. }
  218. }
  219. public class IoMfc : MfcBase1
  220. {
  221. byte[] _buffer_1 = new byte[4];
  222. byte[] _buffer_2 = new byte[4];
  223. private MFCWriteMode _writeMode;
  224. private JetChamber m_JetChamber;
  225. public string Unit
  226. {
  227. get; set;
  228. }
  229. //[Subscription(AITMfcDataPropertyName.Scale)]
  230. public override double Scale
  231. {
  232. get
  233. {
  234. if (_scN2Scale == null || _scScaleFactor == null)
  235. return 0;
  236. return _scN2Scale.IntValue * _scScaleFactor.DoubleValue;
  237. }
  238. }
  239. //[Subscription(AITMfcDataPropertyName.SetPoint)]
  240. public override double SetPoint
  241. {
  242. get
  243. {
  244. if (_aoFlow != null)
  245. {
  246. byte[] high = BitConverter.GetBytes(_aoFlow.Buffer[_aoFlow.Index]);
  247. byte[] low = BitConverter.GetBytes(_aoFlow.Buffer[_aoFlow.Index + 1]);
  248. _buffer_1[0] = high[0];
  249. _buffer_1[1] = high[1];
  250. _buffer_1[2] = low[0];
  251. _buffer_1[3] = low[1];
  252. float flow = BitConverter.ToSingle(_buffer_1, 0);
  253. if (_writeMode == MFCWriteMode.Flow)
  254. {
  255. return flow * Scale / RtInstance.ANALOG_TRANS_RANGE;
  256. }
  257. else
  258. {
  259. return Math.Round(flow * Scale / 100, 2);
  260. }
  261. }
  262. return 0;
  263. }
  264. set
  265. {
  266. if (_aoFlow != null)
  267. {
  268. byte[] flow;
  269. if (_writeMode == MFCWriteMode.Flow)
  270. {
  271. flow = BitConverter.GetBytes((float)(value * RtInstance.ANALOG_TRANS_RANGE / Scale));
  272. }
  273. else
  274. {
  275. flow = BitConverter.GetBytes((float)(Math.Round(value / Scale * 100, 2)));
  276. }
  277. _aoFlow.Buffer[_aoFlow.Index] = BitConverter.ToInt16(flow, 0);
  278. _aoFlow.Buffer[_aoFlow.Index + 1] = BitConverter.ToInt16(flow, 2);
  279. }
  280. }
  281. }
  282. //[Subscription(AITMfcDataPropertyName.DefaultSetPoint)]
  283. public double DefaultSetPoint
  284. {
  285. get
  286. {
  287. if (_scDefaultSetPoint != null)
  288. return _scDefaultSetPoint.IntValue;
  289. return 0;
  290. }
  291. }
  292. //[Subscription(AITMfcDataPropertyName.FeedBack)]
  293. public override double FeedBack
  294. {
  295. get
  296. {
  297. if (_aiFlow != null)
  298. {
  299. byte[] high = BitConverter.GetBytes(_aiFlow.Buffer[_aiFlow.Index]);
  300. byte[] low = BitConverter.GetBytes(_aiFlow.Buffer[_aiFlow.Index + 1]);
  301. _buffer_2[0] = high[0];
  302. _buffer_2[1] = high[1];
  303. _buffer_2[2] = low[0];
  304. _buffer_2[3] = low[1];
  305. float flow = BitConverter.ToSingle(_buffer_2, 0);
  306. if (_writeMode == MFCWriteMode.Flow)
  307. {
  308. if (ModuleHelper.IsPm(Module) &&( m_JetChamber == JetChamber.VenusSE || m_JetChamber == JetChamber.VenusDE))
  309. return (_scRegulationFactor != null && _scRegulationFactor.IntValue > 0) ? flow
  310. : flow * Scale / RtInstance.ANALOG_TRANS_RANGE;
  311. else
  312. return (_scRegulationFactor != null && _scRegulationFactor.IntValue > 0) ? flow * Scale / RtInstance.ANALOG_TRANS_RANGE / _scRegulationFactor.IntValue
  313. : flow * Scale / RtInstance.ANALOG_TRANS_RANGE;
  314. }
  315. else
  316. {
  317. return flow * Scale / 100;
  318. }
  319. }
  320. return 0;
  321. }
  322. }
  323. //[Subscription(AITMfcDataPropertyName.IsOutOfTolerance)]
  324. public override bool IsOutOfTolerance
  325. {
  326. get
  327. {
  328. return _toleranceChecker.Result;
  329. }
  330. }
  331. //[Subscription(AITMfcDataPropertyName.IsEnableAlarm)]
  332. public bool EnableAlarm
  333. {
  334. get
  335. {
  336. if (_scEnableAlarm != null)
  337. return _scEnableAlarm.BoolValue;
  338. return false;
  339. }
  340. }
  341. //[Subscription(AITMfcDataPropertyName.AlarmRange)]
  342. public double AlarmRange
  343. {
  344. get
  345. {
  346. if (_scAlarmRange != null)
  347. return _scAlarmRange.IntValue;
  348. return 0;
  349. }
  350. }
  351. //[Subscription(AITMfcDataPropertyName.AlarmTime)]
  352. public double AlarmTime
  353. {
  354. get
  355. {
  356. if (_scAlarmTime != null)
  357. return _scAlarmTime.IntValue;
  358. return 0;
  359. }
  360. }
  361. //[Subscription(AITMfcDataPropertyName.PressureAlarm)]
  362. public bool PressureAlarm
  363. {
  364. get { return _diPressureAlarm != null ? _diPressureAlarm.Value : true; }
  365. }
  366. //[Subscription(AITMfcDataPropertyName.MfcAlarm)]
  367. public bool MfcAlarm
  368. {
  369. get
  370. {
  371. return _bMfcAlarm;
  372. }
  373. }
  374. //[Subscription(AITMfcDataPropertyName.IsEnable)]
  375. public bool Enable
  376. {
  377. get
  378. {
  379. if (_scEnable != null)
  380. return _scEnable.BoolValue;
  381. return false;
  382. }
  383. }
  384. //[Subscription(AITMfcDataPropertyName.IsOffline)]
  385. public bool IsOffline
  386. {
  387. get
  388. {
  389. if (_diOffline != null)
  390. return _diOffline.Value;
  391. return false;
  392. }
  393. }
  394. public override string DisplayName
  395. {
  396. get
  397. {
  398. if (_scGasName != null)
  399. return _scGasName.StringValue;
  400. return Display;
  401. }
  402. }
  403. private DeviceTimer rampTimer = new DeviceTimer();
  404. private double rampTarget;
  405. private double rampInitValue;
  406. private int rampTime;
  407. private bool _bMfcAlarm = false;
  408. private bool _bRamping = false;
  409. private ToleranceChecker _toleranceChecker = new ToleranceChecker();
  410. private AIAccessor _aiFlow;
  411. private AOAccessor _aoFlow;
  412. private AOAccessor _aoRange;
  413. private DIAccessor _diOffline;
  414. private DIAccessor _diPressureAlarm;
  415. private SCConfigItem _scGasName;
  416. private SCConfigItem _scEnable;
  417. private SCConfigItem _scN2Scale;
  418. private SCConfigItem _scScaleFactor;
  419. private SCConfigItem _scAlarmRange;
  420. private SCConfigItem _scEnableAlarm;
  421. private SCConfigItem _scAlarmTime;
  422. private SCConfigItem _scDefaultSetPoint;
  423. private SCConfigItem _scRegulationFactor;
  424. private R_TRIG _trigOffline = new R_TRIG();
  425. private R_TRIG _trigPressureAlarm = new R_TRIG();
  426. private string _uniqueName;
  427. private string GasFlowOutOfTolerance = "GasFlowOutOfTolerance";
  428. //private JetChamber jetChamber = JetChamber.None;
  429. public IoMfc(string module, XmlElement node, string ioModule = "")
  430. {
  431. Unit = node.GetAttribute("unit");
  432. base.Module = module;
  433. base.Name = node.GetAttribute("id");
  434. base.Display = node.GetAttribute("display");
  435. base.DeviceID = node.GetAttribute("schematicId");
  436. _aoRange = ParseAoNode("aoRange", node, ioModule);
  437. _diOffline = ParseDiNode("diOffline", node, ioModule);
  438. _aiFlow = ParseAiNode("aiFlow", node, ioModule);
  439. _aoFlow = ParseAoNode("aoFlow", node, ioModule);
  440. _diPressureAlarm = ParseDiNode("diPressureAlarm", node, ioModule);
  441. _scGasName = SC.GetConfigItem($"{Module}.{Name}.GasName");
  442. _scEnable = SC.GetConfigItem($"{Module}.{Name}.Enable");
  443. _scN2Scale = SC.GetConfigItem($"{Module}.{Name}.MfcN2Scale");
  444. _scScaleFactor = SC.GetConfigItem($"{Module}.{Name}.MfcScaleFactor");
  445. _scAlarmRange = SC.GetConfigItem($"{Module}.{Name}.MfcAlarmRange");
  446. _scEnableAlarm = SC.GetConfigItem($"{Module}.{Name}.MfcEnableAlarm");
  447. _scAlarmTime = SC.GetConfigItem($"{Module}.{Name}.MfcAlarmTime");
  448. _scDefaultSetPoint = SC.GetConfigItem($"{Module}.{Name}.DefaultSetPoint");
  449. _scRegulationFactor = SC.GetConfigItem($"{module}.{Name}.FlowRegulationFactor");
  450. _uniqueName = $"{Module}.{Name}";
  451. //if (module.Contains("PM"))
  452. //{
  453. // jetChamber = (JetChamber)SC.GetValue<int>($"{module}.ChamberType");
  454. //}
  455. //_writeMode = (MFCWriteMode)SC.GetValue<int>($"{module}.{Name}.MFCWriteMode");
  456. if(ModuleHelper.IsPm(module))
  457. m_JetChamber = (JetChamber)SC.GetValue<int>($"{module}.ChamberType");
  458. if (Name.Contains( "LLA"))
  459. {
  460. _writeMode = (MFCWriteMode)SC.GetValue<int>($"LLA.{Name}.MFCWriteMode");
  461. }
  462. else if (Name.Contains( "LLB"))
  463. {
  464. _writeMode = (MFCWriteMode)SC.GetValue<int>($"LLB.{Name}.MFCWriteMode");
  465. }
  466. else
  467. {
  468. _writeMode = (MFCWriteMode)SC.GetValue<int>($"{module}.{Name}.MFCWriteMode");
  469. }
  470. #if DEBUG
  471. //Debug.Assert(!string.IsNullOrWhiteSpace(_scGasName.StringValue));
  472. //Debug.Assert(null != _scN2Scale);
  473. //Debug.Assert(null != _aoFlow);
  474. //Debug.Assert(null != _aiFlow);
  475. #endif
  476. }
  477. public override bool Initialize()
  478. {
  479. EV.Subscribe(new EventItem("Event", GasFlowOutOfTolerance, "Gas Flow Out Of Tolerance", EventLevel.Alarm, EventType.HostNotification));
  480. DATA.Subscribe($"{Module}.{Name}", () =>
  481. {
  482. AITMfcData data = new AITMfcData
  483. {
  484. Type = "MFC",
  485. UniqueName = _uniqueName,
  486. DeviceName = Name,
  487. DeviceSchematicId = DeviceID,
  488. DisplayName = DisplayName,
  489. FeedBack = FeedBack,
  490. SetPoint = SetPoint,
  491. Scale = Scale,
  492. IsOffline = IsOffline,
  493. IsWarning = PressureAlarm
  494. };
  495. return data;
  496. }, SubscriptionAttribute.FLAG.IgnoreSaveDB);
  497. OP.Subscribe($"{Module}.{Name}.{AITMfcOperation.Ramp}", (name, args) =>
  498. {
  499. double target = (double)args[0];
  500. target = Math.Min(target, Scale);
  501. target = Math.Max(target, 0);
  502. Ramp(target, 0);
  503. LOG.Write(eEvent.EV_DEVICE_INFO, Module, $"Ramp to {target}{Unit}");
  504. return true;
  505. });
  506. DEVICE.Register($"{Module}.{Name}.{AITMfcOperation.Ramp}", (out string reason, int time, object[] param) =>
  507. {
  508. double target = Convert.ToDouble((string)param[0]);
  509. target = Math.Min(target, Scale);
  510. target = Math.Max(target, 0);
  511. Ramp(target, time);
  512. reason = $"{Display} ramp to {target}{Unit}";
  513. return true;
  514. });
  515. OP.Subscribe($"{Module}.{Name}.SetPoint", (cmd, args) =>
  516. {
  517. SetPoint = Convert.ToDouble(args[0]);
  518. return true;
  519. });
  520. //@AAA use recipe
  521. DEVICE.Register($"{Module}.{Name}", (out string reason, int time, object[] param) =>
  522. {
  523. double target = Convert.ToDouble((string)param[0]);
  524. target = Math.Min(target, Scale);
  525. target = Math.Max(target, 0);
  526. Ramp(target, time);
  527. reason = $"{Display} ramp to {target}{Unit}";
  528. return true;
  529. });
  530. return base.Initialize();
  531. }
  532. public override void Monitor()
  533. {
  534. if (Enable)
  535. {
  536. //Ramping();
  537. CheckTolerance();
  538. if (_aoRange != null)
  539. _aoRange.Value = (short)Scale;
  540. _trigOffline.CLK = IsOffline;
  541. if (_trigOffline.Q)
  542. {
  543. LOG.Write(eEvent.ERR_DEVICE_INFO, Module, string.Format("{0} is offline", DisplayName));
  544. _bMfcAlarm = true;
  545. }
  546. _trigPressureAlarm.CLK = PressureAlarm == false;
  547. if (_trigPressureAlarm.Q)
  548. LOG.Write(eEvent.ERR_DEVICE_INFO, Module, $"{Name}, {DisplayName} Pressure Alarm");
  549. if (PressureAlarm)
  550. {
  551. _trigPressureAlarm.RST = true;
  552. }
  553. }
  554. }
  555. public override void Reset()
  556. {
  557. _bMfcAlarm = false;
  558. _toleranceChecker.Reset(AlarmTime);
  559. _trigPressureAlarm.RST = true;
  560. _trigOffline.RST = true;
  561. }
  562. public override void Terminate()
  563. {
  564. _bRamping = false;
  565. Ramp(DefaultSetPoint, 0);
  566. }
  567. public override void Ramp(int time)
  568. {
  569. _bRamping = true;
  570. Ramp(DefaultSetPoint, time);
  571. }
  572. public override void Ramp(double target, int time)
  573. {
  574. _bRamping = true;
  575. target = Math.Max(0, target);
  576. target = Math.Min(Scale, target);
  577. rampInitValue = SetPoint; //ramp 初始值取当前设定值,而非实际读取值。零漂问题
  578. rampTime = time;
  579. rampTarget = target;
  580. rampTimer.Start(rampTime);
  581. }
  582. public override void StopRamp()
  583. {
  584. _bRamping = false;
  585. Ramp(SetPoint, 0);
  586. }
  587. private void Ramping()
  588. {
  589. if (_bRamping)
  590. {
  591. if (rampTimer.IsTimeout() || rampTime == 0)
  592. {
  593. SetPoint = rampTarget;
  594. _bRamping = false;
  595. }
  596. else
  597. {
  598. SetPoint = rampInitValue + (rampTarget - rampInitValue) * rampTimer.GetElapseTime() / rampTime;
  599. }
  600. }
  601. }
  602. private void CheckTolerance()
  603. {
  604. if (!EnableAlarm)
  605. return;
  606. // 流率检查
  607. _toleranceChecker.Monitor(FeedBack, SetPoint - Math.Abs(AlarmRange), SetPoint + Math.Abs(AlarmRange), AlarmTime);
  608. if (_toleranceChecker.Trig)
  609. {
  610. LOG.Write(eEvent.ERR_DEVICE_INFO, Module, Display + $"FeedBack {FeedBack} out of Range[{(int)(SetPoint - Math.Abs(AlarmRange))},{(int)(SetPoint + Math.Abs(AlarmRange))}] in {AlarmTime:0} seconds");
  611. EV.Notify(GasFlowOutOfTolerance);
  612. }
  613. }
  614. }
  615. }