ReservoirANPumpSpeedHelper.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 ReservoirANPumpSpeedHelper
  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. DMReservoirDevice _device;
  32. #endregion
  33. /// <summary>
  34. /// 构造函数
  35. /// </summary>
  36. /// <param name="moduleName"></param>
  37. public ReservoirANPumpSpeedHelper(string moduleName, DMReservoirDevice 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. AdjustAnPumpSpeed(resRecipe);
  52. }
  53. }
  54. /// <summary>
  55. /// 调节阳极泵速
  56. /// </summary>
  57. private void AdjustAnPumpSpeed(ResRecipe resRecipe)
  58. {
  59. if (_device.ReservoirData.AnPumpEnable)
  60. {
  61. double anPumpSpeed = _device.ReservoirData.AnPumpSpeed;
  62. double averageANFlow = _device.ReservoirData.AnFlow;
  63. if (averageANFlow == 0)
  64. {
  65. return;
  66. }
  67. double anPumpMaxSpeed = SC.GetValue<double>("Reservoir.ANMaxPumpSpeed");
  68. double anFlowDelta = resRecipe.ANFlowSetPoint - averageANFlow;
  69. double newANPumpSpeed = 1.8 * anFlowDelta + anPumpSpeed;
  70. if (newANPumpSpeed <= 0||newANPumpSpeed>=anPumpMaxSpeed)
  71. {
  72. return;
  73. }
  74. if (Math.Abs(newANPumpSpeed - anPumpSpeed) >= 0.01)
  75. {
  76. _device.AnPumpSpeed(newANPumpSpeed);
  77. }
  78. }
  79. }
  80. }
  81. }