Sic.Framework-Nanjing-Baishi/MECF.Framework.RT.Equipment.../HardwareUnits/MfcCalculation/MfcManager.cs

140 lines
4.9 KiB
C#

using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.Device;
using Aitex.Core.RT.OperationCenter;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
{
public class MfcManager : BaseDevice, IDevice
{
public List<string> NameList = new List<string>()
{
"Ar",
"H2",
"C2H4",
"SiH4",
"HCL",
"PN2",
"TCS",
"TMA"
};
private DateTime start;
private DateTime end;
public List<DataFlow> DataFlowList;
private readonly object locker = new object();
//public static double H2 { get; private set; }
//public static double ArFlow { get; private set; }
public static double HCL_Run { get; private set; }
public static double TMA_Run { get; private set; }
public static double TCS_Run { get; private set; }
public static double PN2_Run { get; private set; }
//public static double HCL_Vent { get; private set; }
//public static double TMA_Vent { get; private set; }
//public static double TCS_Vent { get; private set; }
//public static double PN2_Vent { get; private set; }
public MfcManager(string module, XmlElement node, string ioModule = "")
{
var attrModule = node.GetAttribute("module");
base.Module = string.IsNullOrEmpty(attrModule) ? module : attrModule;
base.Name = node.GetAttribute("id");
base.Display = node.GetAttribute("display");
base.DeviceID = node.GetAttribute("schematicId");
}
public bool Initialize()
{
DataFlowList = new List<DataFlow>();
foreach (var item in NameList)
{
DataFlowList.Add(new DataFlow()
{
Name = item,
//RunFeedBack = Convert.ToDouble(DATA.Poll($"{Module}.Flow.{item}_Run.FeedBack")),
//VentFeedBack = Convert.ToDouble(DATA.Poll($"{Module}.Flow.{item}_Vent.FeedBack")),
});
}
DATA.Subscribe($"{Module}.MfcManager.DataFlow", () => GetDataFlowJsonString());
OP.Subscribe($"{Module}.FlowName.Query", (string cmd, object[] args) => Query(args));
return true;
}
protected override void HandleMonitor()
{
//H2 = Convert.ToDouble(DATA.Poll($"{Module}.H2_Join.FeedBack"));
//ArFlow = Convert.ToDouble(DATA.Poll($"{Module}.ArFlow_Join.FeedBack"));
HCL_Run = Convert.ToDouble(DATA.Poll($"{Module}.Flow.HCL_Run.FeedBack"));
TMA_Run = Convert.ToDouble(DATA.Poll($"{Module}.Flow.TMA_Run.FeedBack"));
TCS_Run = Convert.ToDouble(DATA.Poll($"{Module}.Flow.TCS_Run.FeedBack"));
PN2_Run = Convert.ToDouble(DATA.Poll($"{Module}.Flow.PN2_Run.FeedBack"));
//HCL_Vent = Convert.ToDouble(DATA.Poll($"{Module}.HCL_Vent.FeedBack"));
//TMA_Vent = Convert.ToDouble(DATA.Poll($"{Module}.TMA_Vent.FeedBack"));
//TCS_Vent = Convert.ToDouble(DATA.Poll($"{Module}.TCS_Vent.FeedBack"));
//PN2_Vent = Convert.ToDouble(DATA.Poll($"{Module}.PN2_Vent.FeedBack"));
}
public void Terminate()
{
}
public void Reset()
{
}
private string GetDataFlowJsonString()
{
lock (locker)
{
return JsonConvert.SerializeObject(DataFlowList);
}
}
private bool Query(object[] objects)
{
string flowName = objects[0].ToString();
start =Convert.ToDateTime(objects[1]);
end = Convert.ToDateTime(objects[2]);
QueryRunVentVolume(flowName + "_Run");
QueryRunVentVolume(flowName + "_Vent");
return true;
}
private void QueryRunVentVolume(string flowName)
{
List<double> valueList = MfcSqlHelp.Query(Module, "Flow", flowName, start, end);
if (valueList.Count == 0)
return;
foreach (var item in DataFlowList)
{
if (flowName.Contains(item.Name))
{
double allValue = 0;
for (int i = 0; i < valueList.Count; i++)
{
allValue += valueList[i];
}
if (flowName.Contains("Run"))
item.RunVolume = allValue * 1.66667 * Math.Pow(10, -7);
else
item.VentVolume = allValue * 1.66667 * Math.Pow(10, -7);
}
}
}
}
}