Пример #1
0
        public void LoadTaxonomyDatabase()
        {
            XmlDocument db = new XmlDocument();

            db.Load(@"c:\temp\MetrologyNET_Taxonomy_v2.xml"); //the path should be updated in the final version

            //////////////////////////////

            XmlNodeList ptNodesList = db.GetElementsByTagName("mtc:ProcessType");

            foreach (XmlNode xmlNode in ptNodesList)
            {
                ProcessType tempPt   = new ProcessType(); // Model object to be filled by XML node
                String      tempName = xmlNode.Attributes["name"].Value;
                //Console.WriteLine(tempName);
                if (tempName.StartsWith("Source"))     // taxonomy contains: <mtc:ProcessType name="D0AD73A4-E43E-4B9A-9C41-9A54281C18BC">, change or delete it
                {
                    tempPt.Action   = "Source";
                    tempPt.Taxonomy = tempName.Substring(7);
                }
                else if (tempName.StartsWith("Measure"))
                {
                    tempPt.Action   = "Measure";
                    tempPt.Taxonomy = tempName.Substring(8);
                }

                XmlNodeList childNodeList = xmlNode.ChildNodes;
                foreach (XmlNode childNode in childNodeList)
                {
                    if (childNode.Name.Equals("mtc:Parameter"))
                    {
                        bool isOptional = false;
                        XmlAttributeCollection attributes = childNode.Attributes;
                        foreach (XmlAttribute xmlAttribute in attributes)
                        {
                            if (xmlAttribute.Name.Equals("optional") && xmlAttribute.Value.Equals("true")) // if there exist an optional attribute and its value is true...
                            {
                                isOptional = true;
                            }
                        }

                        if (isOptional == true) // optional parameter
                        {
                            tempPt.OptionalParameters.Add(new MeasurementParameter(childNode.Attributes["name"].Value));
                        }
                        else if (isOptional == false)
                        {
                            tempPt.RequiredParameters.Add(new MeasurementParameter(childNode.Attributes["name"].Value));
                        }
                    }
                }

                ProcessTypes.Add(tempPt);
            }
        }
Пример #2
0
 public void Add(string processName, string process, int processNum, int portNum)
 {
     if (!ProcessTypes.ContainsKey(processName))
     {
         ProcessTypes.Add(processName, new ProcessType(processName, processNum, portNum));
     }
     else
     {
         ProcessTypes[processName].Add(processNum, portNum);
     }
 }