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 ReservoirANPumpSpeedHelper
{
#region 内部变量
///
/// 时间
///
private DateTime _updateTime = DateTime.Now;
///
/// 模块名称
///
private string _moduleName;
///
/// CA流量总和
///
private double _caTotalFlow = 0;
///
/// 设备对象
///
DMReservoirDevice _device;
#endregion
///
/// 构造函数
///
///
public ReservoirANPumpSpeedHelper(string moduleName, DMReservoirDevice 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;
AdjustAnPumpSpeed(resRecipe);
}
}
///
/// 调节阳极泵速
///
private void AdjustAnPumpSpeed(ResRecipe resRecipe)
{
if (_device.ReservoirData.AnPumpEnable)
{
double anPumpSpeed = _device.ReservoirData.AnPumpSpeed;
double averageANFlow = _device.ReservoirData.AnFlow;
if (averageANFlow == 0)
{
return;
}
double anPumpMaxSpeed = SC.GetValue("Reservoir.ANMaxPumpSpeed");
double anFlowDelta = resRecipe.ANFlowSetPoint - averageANFlow;
double newANPumpSpeed = 1.8 * anFlowDelta + anPumpSpeed;
if (newANPumpSpeed <= 0||newANPumpSpeed>=anPumpMaxSpeed)
{
return;
}
if (Math.Abs(newANPumpSpeed - anPumpSpeed) >= 0.01)
{
_device.AnPumpSpeed(newANPumpSpeed);
}
}
}
}
}