public class BaseParameters
{
private const string XPathConfiguration = "/p:configuration";
private const string XPathParameters = "/p:configuration/p:Parameters";
private const string XPathData = "/p:configuration/p:Data";
private const string XPathController = "/p:configuration/p:Parameters/p:Controller";
private const string XPathAxes = "/p:configuration/p:Parameters/p:Axes";
private const string XPathTasks = "/p:configuration/p:Parameters/p:Tasks";
private const string XPathSubAxis = "p:Axis";
private const string XPathSubAxis_Format = "p:Axis[@number='{0}']";
private const string XPathAxis = "/p:configuration/p:Parameters/p:Axes/p:Axis";
private const string XPathSubTask = "p:Task";
private const string XPathSubTask_Format = "p:Task[@number='{0}']";
private const string XPathTask = "/p:configuration/p:Parameters/p:Tasks/p:Task";
private const string XPathSubP = "p:P";
private const string XPathSubP_Format = "p:P[@n='{0}']";
private NamedConstantCollection<TaskParameterCategory, TaskId> tasks = new NamedConstantCollection<TaskParameterCategory, TaskId>(new TaskParameterCategory[0]);
private SystemParameterCategory system;
private NamedMaskableConstantCollection<AxisParameterCategory, string, AxisMask> axes;
public static BaseParameters Defaults => Global.DefaultParameters;
public INamedConstantCollection<TaskParameterCategory, TaskId> Tasks => tasks;
public SystemParameterCategory System => system;
public INamedMaskedConstantCollection<AxisParameterCategory, string, AxisMask> Axes => axes;
internal NamedMaskableConstantCollection<AxisParameterCategory, string, AxisMask> MaskableAxes => axes;
internal BaseParameters()
{
}
internal virtual void SaveToFile(string fileName)
{
SaveToFile(fileName, null);
}
internal void SaveToFile(string fileName, XmlNode data)
{
fileName = Path.GetFullPath(fileName);
XmlDocument xmlDocument = new XmlDocument();
StringReader stringReader = new StringReader(InfoResources.parameters);
XmlReader xmlReader = new XmlTextReader(stringReader);
try
{
xmlDocument.LoadXml(InfoResources.parameters);
}
finally
{
stringReader.Close();
}
XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(xmlReader.NameTable);
xmlNamespaceManager.AddNamespace("p", "http://www.aerotech.com/xsd/Controller/Parameters/2009/");
SaveToFile(fileName, xmlDocument, xmlNamespaceManager, data);
}
internal void SaveToFile(string fileName, XmlDocument xdoc, XmlNamespaceManager nsMan, XmlNode data)
{
fileName = Path.GetFullPath(fileName);
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(InfoResources.parameters);
XmlNode xmlNode = xdoc.SelectSingleNode("/p:configuration/p:Parameters/p:Controller", nsMan);
XmlNode xmlNode2 = xdoc.SelectSingleNode("/p:configuration/p:Parameters/p:Axes", nsMan);
XmlNode xmlNode3 = xdoc.SelectSingleNode("/p:configuration/p:Parameters/p:Tasks", nsMan);
Dictionary<string, XmlNode> dictionary = new Dictionary<string, XmlNode>();
foreach (XmlNode item in xmlNode.SelectNodes("p:P", nsMan))
{
string value = item.Attributes["n"].Value;
dictionary[value] = item;
}
Dictionary<int, Dictionary<str
A3200 运动控制系统的核心参数管理类BaseParameters
最新推荐文章于 2025-06-06 22:39:47 发布