80 lines
2.8 KiB
C#
80 lines
2.8 KiB
C#
|
using Aitex.Core.RT.Device;
|
|||
|
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.ValueMfc
|
|||
|
{
|
|||
|
public class ValueMfcState : BaseDevice
|
|||
|
{
|
|||
|
List<ValueMfcInputOutRow> InputOutList = new List<ValueMfcInputOutRow>();
|
|||
|
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)
|
|||
|
{
|
|||
|
ValueMfcInputOutRow inputOutRow = new ValueMfcInputOutRow();
|
|||
|
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)
|
|||
|
{
|
|||
|
|
|||
|
throw;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
protected override void HandleMonitor()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|