using Aitex.Core.RT.Device; using Aitex.Core.RT.SCCore; using MECF.Framework.Common.Equipment; using MECF.Framework.Common.RecipeCenter; using MECF.Framework.Common.ToolLayout; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PunkHPX8_RT.Devices.Reservoir { public class ReservoirCAPumpSpeedHelper { #region 内部变量 /// /// 时间 /// private DateTime _updateTime = DateTime.Now; /// /// 模块名称 /// private string _moduleName; /// /// CA流量总和 /// private double _caTotalFlow = 0; /// /// 设备对象 /// ReservoirDevice _device; #endregion /// /// 构造函数 /// /// public ReservoirCAPumpSpeedHelper(string moduleName, ReservoirDevice reservoirDevice) { _moduleName = moduleName; _device = reservoirDevice; } /// /// 监控 /// public void Monitor(ResRecipe resRecipe) { int cellFlowUpdatePeriod = SC.GetValue("Reservoir.CellFlowUpdatePeriod"); if (DateTime.Now.Subtract(_updateTime).TotalSeconds > cellFlowUpdatePeriod) { _updateTime = DateTime.Now; AdjustCAPumpSpeed(resRecipe); } } /// /// 调节阳极泵速 /// private void AdjustCAPumpSpeed(ResRecipe resRecipe) { if (_device.ReservoirData.CaPumpEnable) { double caPumpSpeed = _device.ReservoirData.CaPumpSpeed; double averageCAFlow = _device.ReservoirData.CaFlow; if (averageCAFlow == 0) { return; } double caPumpMaxSpeed = SC.GetValue("Reservoir.CAMaxPumpSpeed"); double caFlowDelta = resRecipe.CAFlowSetPoint - averageCAFlow; double newCAPumpSpeed = 330 * caFlowDelta + caPumpSpeed; if (newCAPumpSpeed <= 0 || newCAPumpSpeed > caPumpMaxSpeed) { return; } if (Math.Abs(newCAPumpSpeed - caPumpSpeed) >= 10) { _device.CAPumpSpeed(newCAPumpSpeed); } } } } }