123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using Aitex.Core.RT.Device;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.SCCore;
- using CyberX8_RT.Devices.Metal;
- using MECF.Framework.Common.CommonData.Metal;
- using MECF.Framework.Common.CommonData.Reservoir;
- using MECF.Framework.Common.RecipeCenter;
- using MECF.Framework.Common.ToolLayout;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- namespace CyberX8_RT.Devices.Reservoir
- {
- public class ReservoirPumpSpeedHelper
- {
- #region 内部变量
- /// <summary>
- /// 时间
- /// </summary>
- private DateTime _updateTime=DateTime.Now;
- /// <summary>
- /// 模块名称
- /// </summary>
- private string _moduleName;
- /// <summary>
- /// AN流量总和
- /// </summary>
- private double _anTotalFlow = 0;
- /// <summary>
- /// CA流量总和
- /// </summary>
- private double _caTotalFlow = 0;
- /// <summary>
- /// 设备对象
- /// </summary>
- StandardHotReservoirDevice _device;
- #endregion
- /// <summary>
- /// 构造函数
- /// </summary>
- /// <param name="moduleName"></param>
- public ReservoirPumpSpeedHelper(string moduleName, StandardHotReservoirDevice reservoirDevice)
- {
- _moduleName = moduleName;
- _device = reservoirDevice;
- }
- /// <summary>
- /// 监控
- /// </summary>
- public void Monitor(ResRecipe resRecipe)
- {
- int cellFlowUpdatePeriod = SC.GetValue<int>("Reservoir.CellFlowUpdatePeriod");
- if(DateTime.Now.Subtract(_updateTime).TotalSeconds > cellFlowUpdatePeriod)
- {
- _updateTime = DateTime.Now;
- AdjustCAPumpSpeed(resRecipe);
- }
- }
-
- /// <summary>
- /// 调节阴极泵速
- /// </summary>
- private void AdjustCAPumpSpeed(ResRecipe resRecipe)
- {
- if (_device.ReservoirData.RegulatePumpSignalIn)
- {
- double caPumpSpeed = _device.ReservoirData.RegulatePumpSpeed;
- double averageCAFlow = GetAverageCAFlow();
- if (averageCAFlow == 0)
- {
- return;
- }
- double caPumpMaxSpeed = SC.GetValue<double>("Reservoir.MaxPumpSpeed");
- double caFlowDelta = resRecipe.CAFlowSetPoint - averageCAFlow;
- double newCAPumpSpeed = 330 * caFlowDelta + caPumpSpeed;
- if (newCAPumpSpeed <= 0 || newCAPumpSpeed > caPumpMaxSpeed)
- {
- return;
- }
- if (Math.Abs(newCAPumpSpeed - caPumpSpeed) >= 10)
- {
- _device.RegulatePumpSpeed(newCAPumpSpeed);
- }
- }
- }
- /// <summary>
- /// 获取平均阳极流量
- /// </summary>
- /// <returns></returns>
- private double GetAverageCAFlow()
- {
- int count = 0;
- _caTotalFlow = 0;
- ReservoirItem reservoirItem = ReservoirItemManager.Instance.GetReservoirItem(_moduleName);
- if (reservoirItem != null)
- {
- List<MetalItem> metalItems = reservoirItem.MetalCells;
- if (metalItems != null && metalItems.Count > 0)
- {
- foreach (MetalItem metalItem in metalItems)
- {
- StandardHotMetalDevice metalDevice = DEVICE.GetDevice<StandardHotMetalDevice>(metalItem.ModuleName);
- if (metalDevice != null&&metalDevice.IsAuto)
- {
- count++;
- _caTotalFlow += metalDevice.MetalDeviceData.CellFlow;
- }
- }
- }
- if (count != 0)
- {
- return _caTotalFlow / count;
- }
- }
- return 0;
- }
- }
- }
|