ReservoirCAPumpSpeedHelper.cs 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using Aitex.Core.RT.Device;
  2. using Aitex.Core.RT.SCCore;
  3. using MECF.Framework.Common.Equipment;
  4. using MECF.Framework.Common.RecipeCenter;
  5. using MECF.Framework.Common.ToolLayout;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. namespace PunkHPX8_RT.Devices.Reservoir
  12. {
  13. public class ReservoirCAPumpSpeedHelper
  14. {
  15. #region 内部变量
  16. /// <summary>
  17. /// 时间
  18. /// </summary>
  19. private DateTime _updateTime = DateTime.Now;
  20. /// <summary>
  21. /// 模块名称
  22. /// </summary>
  23. private string _moduleName;
  24. /// <summary>
  25. /// CA流量总和
  26. /// </summary>
  27. private double _caTotalFlow = 0;
  28. /// <summary>
  29. /// 设备对象
  30. /// </summary>
  31. ReservoirDevice _device;
  32. #endregion
  33. /// <summary>
  34. /// 构造函数
  35. /// </summary>
  36. /// <param name="moduleName"></param>
  37. public ReservoirCAPumpSpeedHelper(string moduleName, ReservoirDevice reservoirDevice)
  38. {
  39. _moduleName = moduleName;
  40. _device = reservoirDevice;
  41. }
  42. /// <summary>
  43. /// 监控
  44. /// </summary>
  45. public void Monitor(ResRecipe resRecipe)
  46. {
  47. int cellFlowUpdatePeriod = SC.GetValue<int>("Reservoir.CellFlowUpdatePeriod");
  48. if (DateTime.Now.Subtract(_updateTime).TotalSeconds > cellFlowUpdatePeriod)
  49. {
  50. _updateTime = DateTime.Now;
  51. AdjustCAPumpSpeed(resRecipe);
  52. }
  53. }
  54. /// <summary>
  55. /// 调节阳极泵速
  56. /// </summary>
  57. private void AdjustCAPumpSpeed(ResRecipe resRecipe)
  58. {
  59. if (_device.ReservoirData.CaPumpEnable)
  60. {
  61. double caPumpSpeed = _device.ReservoirData.CaPumpSpeed;
  62. double averageCAFlow = _device.ReservoirData.CaFlow;
  63. if (averageCAFlow == 0)
  64. {
  65. return;
  66. }
  67. double caPumpMaxSpeed = SC.GetValue<double>("Reservoir.CAMaxPumpSpeed");
  68. double caFlowDelta = resRecipe.CAFlowSetPoint - averageCAFlow;
  69. double newCAPumpSpeed = 330 * caFlowDelta + caPumpSpeed;
  70. if (newCAPumpSpeed <= 0 || newCAPumpSpeed > caPumpMaxSpeed)
  71. {
  72. return;
  73. }
  74. if (Math.Abs(newCAPumpSpeed - caPumpSpeed) >= 10)
  75. {
  76. _device.CAPumpSpeed(newCAPumpSpeed);
  77. }
  78. }
  79. }
  80. }
  81. }