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;
|
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
|
|
|
|
{
|
2023-05-19 09:56:55 +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>();
|
|
|
|
|
|
|
|
|
|
private string FileName;
|
|
|
|
|
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");
|
|
|
|
|
FileName= node.GetAttribute("fileName");
|
|
|
|
|
|
|
|
|
|
if (FileName.Length>0)
|
|
|
|
|
ReadXML($"Config\\MfcCalculation\\{FileName}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Initialize()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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 = xmlBlock.GetAttribute("Value"),
|
|
|
|
|
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 = xmlBlock.GetAttribute("Value"),
|
|
|
|
|
ControlName = xmlBlock.GetAttribute("ControlName")
|
|
|
|
|
};
|
|
|
|
|
inputOutRow.OutList.Add(keyValue);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Terminate()
|
2023-05-18 19:07:16 +08:00
|
|
|
|
{
|
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()
|
|
|
|
|
{
|
|
|
|
|
//循环检测气阀状态
|
|
|
|
|
if (InputOutList.Count>0)
|
|
|
|
|
{
|
|
|
|
|
//每次循环row这是一行,表格配置的数据集合
|
|
|
|
|
foreach (var row in InputOutList)
|
|
|
|
|
{
|
|
|
|
|
//一行内单元格的输入输出配置
|
|
|
|
|
foreach (var rowInputs in row.InputList)
|
|
|
|
|
{
|
|
|
|
|
//Input配置的单元格
|
|
|
|
|
var name = rowInputs.Name;
|
|
|
|
|
var value= rowInputs.Value;
|
|
|
|
|
var controlName = rowInputs.ControlName;
|
|
|
|
|
}
|
|
|
|
|
foreach (var rowOutputs in row.OutList)
|
|
|
|
|
{
|
|
|
|
|
//Output配置的单元格
|
|
|
|
|
var name =rowOutputs.Name;
|
|
|
|
|
var value= rowOutputs.Value;
|
|
|
|
|
var controlName = rowOutputs.ControlName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-18 19:07:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|