136 lines
4.6 KiB
C#
136 lines
4.6 KiB
C#
using Aitex.Core.RT.DataCenter;
|
||
using Aitex.Core.RT.Device;
|
||
using Aitex.Core.RT.OperationCenter;
|
||
using Aitex.Core.RT.SCCore;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using System.Xml;
|
||
|
||
namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.MfcCalculation
|
||
{
|
||
public class MfcCalculation : BaseDevice, IDevice
|
||
{
|
||
|
||
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;
|
||
}
|
||
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)
|
||
{
|
||
MfcInputOutRow inputOutRow = new MfcInputOutRow();
|
||
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)
|
||
{
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
public void Reset()
|
||
{
|
||
|
||
}
|
||
|
||
public void Terminate()
|
||
{
|
||
|
||
}
|
||
|
||
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;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|