Sic.Framework/MECF.Framework.RT.Equipment.../HardwareUnits/GasFlow/GasFlowManager.cs

98 lines
3.2 KiB
C#

using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.OperationCenter;
using Aitex.Core.Util;
using MECF.Framework.Common.Device.Bases;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using static System.Net.Mime.MediaTypeNames;
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow
{
public class GasFlowManager : Singleton<GasFlowManager>
{
ModuleGsaFlow123 PM1GsaFlow { get; set; }
public GasFlowManager()
{
}
public void Initialize()
{
//PM1GsaFlow = new ModuleGsaFlow123();
//ControlNameValue controlNameValue = new ControlNameValue();
//controlNameValue.Name = "1";
//controlNameValue.Value = 2;
//controlNameValue.ControlName = "123";
//RealtimeGasFlowTrueTableRow realtimeGasFlowTrueTableRow = new RealtimeGasFlowTrueTableRow();
//realtimeGasFlowTrueTableRow.InputList.Add(controlNameValue);
//realtimeGasFlowTrueTableRow.InputList.Add(controlNameValue);
//realtimeGasFlowTrueTableRow.OutputList.Add(controlNameValue);
//GasFlowUnit gasFlowUnit = new GasFlowUnit();
//gasFlowUnit.GasName = "SiH4";
//gasFlowUnit.GasFlowRatioName = "Test";
//gasFlowUnit.GasTrueTableRowList.Add(realtimeGasFlowTrueTableRow);
//gasFlowUnit.GasTrueTableRowList.Add(realtimeGasFlowTrueTableRow);
//gasFlowUnit.GasTrueTableRowList.Add(realtimeGasFlowTrueTableRow);
//PM1GsaFlow.GasFlowUnitList = new List<GasFlowUnit>
//{
// gasFlowUnit,
// gasFlowUnit
//};
//XmlSerializer xml = new XmlSerializer(typeof(ModuleGsaFlow123));
//System.IO.Stream stream = new System.IO.FileStream(" sutudents.xml", System.IO.FileMode.OpenOrCreate);
//xml.Serialize(stream, PM1GsaFlow);
ModuleGsaFlow m= DeserializeFromXml<ModuleGsaFlow>($"Config\\PM\\RealtimeGasFlow\\Test.xml");
PM1GsaFlow = CustomXmlSerializer.Deserialize<ModuleGsaFlow123>(new FileInfo($"Config\\PM\\RealtimeGasFlow\\Test.xml"));
PM1GsaFlow.SetModuleName("PM1");
DATA.Subscribe("GasFlowManagerTest", () => GasFlowManagerTest());
OP.Subscribe("GasFlowManager.QueryUpdate", (string cmd, object[] args) => QueryUpdate());
}
public T DeserializeFromXml<T>(string filePath)
{
try
{
if (!File.Exists(filePath))
throw new ArgumentNullException(filePath + " not Exists");
using (StreamReader reader = new StreamReader(filePath))
{
XmlSerializer xs = new XmlSerializer(typeof(T));
T ret = (T)xs.Deserialize(reader);
return ret;
}
}
catch (Exception ex)
{
return default(T);
}
}
public string GasFlowManagerTest()
{
return DateTime.Now.ToString("");
}
public bool QueryUpdate()
{
return true;
}
}
}