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 NameList = new List() { "Ar", "H2", "C2H4", "SiH4", "HCL", "N2", "TCS", "TMA" }; private DateTime start; private DateTime end; public ObservableCollection 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 ObservableCollection(); 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) { string str = JsonConvert.SerializeObject(FactorDataFlow()); return str; } } private ObservableCollection FactorDataFlow() { for (int i = 0; i < NameList.Count; i++) { DataFlowList[i].Name = NameList[i]; DataFlowList[i].RunFeedBack = Convert.ToDouble(DATA.Poll($"{Module}.Flow.{NameList[i]}_Run.FeedBack")); DataFlowList[i].VentFeedBack = Convert.ToDouble(DATA.Poll($"{Module}.Flow.{NameList[i]}_Vent.FeedBack")); } return DataFlowList; } private bool Query(object[] objects) { string flowName = objects[0].ToString(); start =Convert.ToDateTime(objects[1]); end = Convert.ToDateTime(objects[2]); QueryRunVent(flowName + "_Run"); QueryRunVent(flowName + "_Vent"); return true; } private void QueryRunVent(string flowName) { List doubles = MfcSqlHelp.Query(Module, "Flow", flowName, start, end); foreach (var item in DataFlowList) { if (flowName.Contains(item.Name)) { double volume = 0; for (int i = 0; i < doubles.Count; i++) { volume += doubles[i]; } item.RunVolume = volume; } } } } }