Sic.Framework-Nanjing-Baishi/MECF.Framework.RT.Equipment.../HardwareUnits/GasFlow/PMGsaFlow.cs

149 lines
4.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.OperationCenter;
using Aitex.Core.Util;
using MECF.Framework.Common.Aitex.Core.Common.DeviceData;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow
{
[XmlType(typeName: "PMGsaFlow")]
public class PMAllGsa
{
/// <summary>
/// PM腔体中气体
/// </summary>
[XmlElement("GasFlowUnit")]
public List<GasFlowUnit> GasFlowUnitList { get; set; }
public string ModuleName { get; set; }
public List<string> GasNameList { get; set; }
public List<GasFlowSum> GasFlowSumList { get; set; }
private DateTime start;
private DateTime end;
public void Initialize(string moduleName)
{
IniGasUnit(moduleName);
DATA.Subscribe($"{ModuleName}.PMGasNameList", () => GasNameList);
DATA.Subscribe($"{ModuleName}.PMGasFlowSumList", () => GasFlowSumList);
OP.Subscribe($"{ModuleName}.GasFlowSum.Query", (string cmd, object[] args) => Query(args));
OP.Subscribe($"{ModuleName}.GasFlowSum.QueryAll", (string cmd, object[] args) => QueryAll(args));
var _thread = new PeriodicJob(1000, OnTimer, $"{moduleName}.ModuleGsaFlow", true);
}
private bool OnTimer()
{
foreach (var Unit in GasFlowUnitList)
{
Unit.GetGasFlowFeedBack();
}
return true;
}
/// <summary>
/// 初始化单个气体和界面气体统计对象
/// </summary>
/// <param name="moduleName"></param>
private void IniGasUnit(string moduleName)
{
ModuleName = moduleName;
GasFlowSumList = new();
GasNameList = new() { "All" };//添加总的查询选项
//单中气体初始化
foreach (var unit in GasFlowUnitList)
{
unit.Initialize(moduleName);
string gasName = unit.GasName.Split('_')[0];//气体格式定位为H2_Run H2_Vent,所以根据下划线来拆分
if (!GasNameList.Contains(gasName))
GasNameList.Add(gasName);
}
for (int i = 1; i < GasNameList.Count; i++)//第一个是All选项不参与对象生成
{
GasFlowSumList.Add(new GasFlowSum() { Name = GasNameList[i] });
}
}
/// <summary>
/// 单种气体体积使用查询
/// </summary>
/// <param name="objects"></param>
/// <returns></returns>
private bool Query(object[] objects)
{
Task.Run(() =>
{
string flowName = objects[0].ToString();
start = Convert.ToDateTime(objects[1]);
end = Convert.ToDateTime(objects[2]);
QueryRunVentVolume(flowName + "_Run");
QueryRunVentVolume(flowName + "_Vent");
});
return true;
}
/// <summary>
/// 所有气体使用体积查询
/// </summary>
/// <param name="objects"></param>
/// <returns></returns>
private bool QueryAll(object[] objects)
{
Task.Run(() =>
{
start = Convert.ToDateTime(objects[0]);
end = Convert.ToDateTime(objects[1]);
foreach (var item in GasFlowSumList)
{
QueryRunVentVolume(item.Name + "_Run");
QueryRunVentVolume(item.Name + "_Vent");
}
});
return true;
}
private void QueryRunVentVolume(string flowName)
{
Task.Run(() =>
{
double values = GasFlowSqlHelp.Query(ModuleName, "GasRealTimeFlow." + flowName, start, end);
foreach (var item in GasFlowSumList)
{
if (flowName.Contains(item.Name))
{
if (flowName.Contains("Run"))
item.RunVolume = values * 1.66667 * Math.Pow(10, -7);
else
item.VentVolume = values * 1.66667 * Math.Pow(10, -7);
return;
}
}
});
}
}
}