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

73 lines
2.1 KiB
C#
Raw Normal View History

2023-07-11 17:46:32 +08:00
using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.OperationCenter;
using Aitex.Core.Util;
2023-07-12 17:48:06 +08:00
using MECF.Framework.Common.Device.Bases;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
2023-07-11 17:46:32 +08:00
using System;
using System.Collections.Generic;
2023-07-12 17:48:06 +08:00
using System.IO;
2023-07-11 17:46:32 +08:00
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
2023-07-12 17:48:06 +08:00
using System.Xml.Serialization;
using static System.Net.Mime.MediaTypeNames;
2023-07-11 17:46:32 +08:00
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow
{
public class GasFlowManager : Singleton<GasFlowManager>
{
ModuleGsaFlow PM1GsaFlow { get; set; }
2023-07-11 17:46:32 +08:00
public GasFlowManager()
{
2023-07-12 17:48:06 +08:00
2023-07-11 17:46:32 +08:00
}
public void Initialize()
{
PM1GsaFlow = CustomXmlSerializer.Deserialize<ModuleGsaFlow>(new FileInfo($"Config\\PM\\PM1\\RealtimeGasFlow.xml"));
DATA.Subscribe($"\"PM1\".GasFlowManagerTest", () => PM1GsaFlow.GasFlowUnitLise);
2023-07-12 17:48:06 +08:00
2023-07-11 17:46:32 +08:00
OP.Subscribe("GasFlowManager.QueryUpdate", (string cmd, object[] args) => QueryUpdate());
}
2023-07-12 17:48:06 +08:00
private void IniPM(string pmName)
{
ModuleGsaFlow moduleGsaFlow = CustomXmlSerializer.Deserialize<ModuleGsaFlow>(new FileInfo($"Config\\PM\\{pmName}\\RealtimeGasFlow.xml"));
DATA.Subscribe($"{pmName}.GasFlowManagerTest", () => moduleGsaFlow.GasFlowUnitLise);
}
2023-07-12 17:48:06 +08:00
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);
}
}
2023-07-11 17:46:32 +08:00
public string GasFlowManagerTest()
{
return DateTime.Now.ToString("");
}
public bool QueryUpdate()
{
return true;
}
}
}