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

140 lines
4.9 KiB
C#
Raw Normal View History

2023-05-19 09:56:55 +08:00
using Aitex.Core.RT.DataCenter;
using Aitex.Core.RT.Device;
using Aitex.Core.RT.OperationCenter;
using Aitex.Core.RT.SCCore;
using Aitex.Core.Util;
using MECF.Framework.Common.DataCenter;
2023-05-18 19:07:16 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
2023-05-19 09:56:55 +08:00
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
2023-05-18 19:07:16 +08:00
{
public class MfcCalculation : BaseDevice,IDevice
2023-05-18 19:07:16 +08:00
{
2023-05-19 09:56:55 +08:00
List<MfcInputOutRow> InputOutList = new List<MfcInputOutRow>();
public double FeedBack { get; set; } = 0 ;
public double PN2_Vent { get; set; } = 0;
private string fileName;
private string ScConfigName;
/// <summary>
/// 气体流量系数
/// </summary>
private double FlowRatio { get; set; } = 1;
2023-05-19 09:56:55 +08:00
public MfcCalculation(string module, XmlElement node, string ioModule = "")
{
var attrModule = node.GetAttribute("module");
Module = string.IsNullOrEmpty(attrModule) ? module : attrModule;
Name = node.GetAttribute("id");
Display = node.GetAttribute("display");
ScConfigName = node.GetAttribute("scConfigName");
fileName = node.GetAttribute("fileName");
if (ScConfigName.Length>0)
FlowRatio = SC.GetValue<double>($"PM.{Module}.Efficiency.{ScConfigName}");
2023-05-19 09:56:55 +08:00
}
2023-05-19 09:56:55 +08:00
public bool Initialize()
{
DATA.Subscribe($"{Module}.Flow.{Name}.FeedBack", () => FeedBack);
if (fileName.Length > 0)
ReadXML($"Config\\MfcCalculation\\{fileName}");
2023-05-19 09:56:55 +08:00
return true;
}
2023-05-18 19:07:16 +08:00
public void ReadXML(string fileName)
{
try
{
XmlDocument xml = new XmlDocument();//初始化一个xml实例
xml.Load(fileName);
XmlElement root = xml.DocumentElement;
XmlNodeList nodelist = root.ChildNodes;
//遍历输出.
foreach (XmlNode node in nodelist)
{
2023-05-19 09:56:55 +08:00
MfcInputOutRow inputOutRow = new MfcInputOutRow();
2023-05-18 19:07:16 +08:00
var nodeBlocks = node.SelectNodes("Condition/Inputs/Input");
if (nodeBlocks != null)
{
foreach (var nodeBlock in nodeBlocks)
{
if (!(nodeBlock is XmlElement xmlBlock))
{
continue;
}
NameValue keyValue = new NameValue()
{
Name = xmlBlock.GetAttribute("Name"),
Value =Convert.ToDouble(xmlBlock.GetAttribute("Value")),
2023-05-18 19:07:16 +08:00
ControlName = xmlBlock.GetAttribute("ControlName")
};
inputOutRow.InputList.Add(keyValue);
}
}
nodeBlocks = node.SelectNodes("Condition/Outputs/Output");
if (nodeBlocks != null)
{
foreach (var nodeBlock in nodeBlocks)
{
if (!(nodeBlock is XmlElement xmlBlock))
{
continue;
}
NameValue keyValue = new NameValue()
{
Name = xmlBlock.GetAttribute("Name"),
Value = Convert.ToDouble(xmlBlock.GetAttribute("Value")),
2023-05-18 19:07:16 +08:00
ControlName = xmlBlock.GetAttribute("ControlName")
};
inputOutRow.OutputList.Add(keyValue);
2023-05-18 19:07:16 +08:00
}
}
InputOutList.Add(inputOutRow);
}
}
catch (Exception ex)
{
2023-05-19 09:56:55 +08:00
2023-05-18 19:07:16 +08:00
}
}
2023-05-19 09:56:55 +08:00
protected override void HandleMonitor()
{
2023-05-19 13:04:54 +08:00
double _feedBack = 0;
2023-05-19 09:56:55 +08:00
//循环检测气阀状态
if (InputOutList.Count>0)
{
foreach (var rowOutPut in InputOutList)
{
//PN2是特殊计算
if (Name .Contains( "PN2"))
_feedBack += rowOutPut.AccumulationPN2Run(Module);
else
_feedBack += rowOutPut.Accumulation(Module);
2023-05-19 09:56:55 +08:00
}
if (_feedBack < 0)
_feedBack = 0;
FeedBack = _feedBack * FlowRatio;//计算得到的结果*系数
2023-05-19 09:56:55 +08:00
}
2023-05-19 13:04:54 +08:00
2023-05-18 19:07:16 +08:00
}
public void Terminate()
{
}
public void Reset()
{
}
2023-05-18 19:07:16 +08:00
}
}