示例#1
0
        /// <summary>
        /// The get decode type from file.
        /// </summary>
        /// <returns>
        /// The <see>
        ///       <cref>Dictionary</cref>
        ///     </see> .
        /// </returns>
        public Dictionary <string, SpecialNode> GetDecodeTypeFromFile()
        {
            if (0 == this.DecodeInfos.Count)
            {
                string xmlPath = this.GetPath();
                var    curXml  = new XmlDocument();
                try
                {
                    curXml.Load(xmlPath);
                    XmlNodeList typeNodeList = curXml.SelectNodes(@"/Document/Protocols/Protocol");

                    if (typeNodeList == null)
                    {
                        return(null);
                    }

                    foreach (XmlNode curNode in typeNodeList)
                    {
                        XmlAttributeCollection attributes = curNode.Attributes;
                        if (attributes != null)
                        {
                            XmlAttribute typePort = attributes["Port"];
                            string       port     = typePort.Value;

                            XmlAttribute decodeDll = attributes["DecodeDll"];
                            string       strDll    = decodeDll.Value;

                            XmlAttribute id    = attributes["ID"];
                            string       strId = id.Value;
                            int          nId   = int.Parse(strId);

                            var curSpeNode = new SpecialNode {
                                DecodePort = port, DecodePdu = nId, DecodeDll = strDll
                            };

                            if (!this.SecondDecodeDll.ContainsKey(port))
                            {
                                this.SecondDecodeDll.Add(port, curSpeNode);
                            }
                        }
                    }

                    return(this.SecondDecodeDll);
                }
                catch (Exception)
                {
                    Log.Error("Cannot find secondNodeDecode");
                }
            }

            return(null);
        }
示例#2
0
        /// <summary>
        /// The get node info from file.
        /// </summary>
        /// <param name="typeNodeList">
        /// The type node list.
        /// </param>
        protected void GetNodeInfoFromFile(XmlNodeList typeNodeList)
        {
            if (typeNodeList == null)
            {
                return;
            }

            foreach (XmlNode curNode in typeNodeList)
            {
                XmlAttributeCollection attributes = curNode.Attributes;
                if (attributes != null)
                {
                    XmlAttribute typeNameAttr = attributes["Name"];
                    string       strTypeName  = typeNameAttr.Value;
                    int          MsgId        = Convert.ToInt32(strTypeName, 16);
                    strTypeName = Convert.ToString(MsgId);

                    XmlAttribute typePort = attributes["Port"];
                    string       port     = typePort.Value;

                    XmlAttribute id    = attributes["ID"];
                    string       strId = id.Value;
                    int          nId   = int.Parse(strId);

                    XmlAttribute decodeDll = attributes["DecodeDll"];
                    string       strDll    = decodeDll.Value;

                    var curSpeNode = new SpecialNode {
                        DecodePort = port, DecodePdu = nId, DecodeName = strTypeName, DecodeDll = strDll
                    };

                    if (!this.DecodeInfos.ContainsKey(strTypeName))
                    {
                        IList <SpecialNode> list = new List <SpecialNode>();
                        list.Add(curSpeNode);
                        this.DecodeInfos.Add(strTypeName, list);
                    }
                    else
                    {
                        var list = this.DecodeInfos[strTypeName];
                        list.Add(curSpeNode);
                    }
                }
            }
        }