示例#1
0
        /// <summary>
        /// get all need monitor address
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, List <monitorAddress> > GetMtAddrList()
        {
            var infoNode = Xml_Tool.xdoc.Root.Element("InfoConfig");
            var dic      = new Dictionary <string, List <monitorAddress> >();

            foreach (var lineElement in infoNode.Elements("line"))
            {
                var opcList = lineElement.Descendants("opcitem").ToList();

                List <monitorAddress> maList = new List <monitorAddress>();

                foreach (var item in opcList)
                {
                    Dictionary <string, string> para = new Dictionary <string, string>();
                    para.Add("line", item.Parent.Parent.Parent.Attribute("name").Value);
                    para.Add("station", item.Parent.Parent.Attribute("name").Value);
                    para.Add("type", item.Parent.Name.LocalName);
                    foreach (var at in item.Attributes())
                    {
                        para.Add(at.Name.LocalName, at.Value);
                    }
                    monitorAddress ma = new monitorAddress(item.Attribute("addr").Value, para);
                    maList.Add(ma);
                }
                dic.Add(lineElement.Attribute("name").Value, maList);
            }
            return(dic);
        }
示例#2
0
        /// <summary>
        /// plc data changed
        /// </summary>
        /// <param name="ma"></param>
        /// <param name="objValue"></param>
        private void OnSiemensPLCDataChanged(monitorAddress ma, object objValue)
        {
            string itemValue = objValue.ToString().Replace("\0", "");

            ThreadPool.QueueUserWorkItem(new WaitCallback(DealSiemensPLCEvent),
                                         new SiemensPLCParameter(ma, itemValue));
        }
示例#3
0
        public static List <monitorAddress> GetMtAddressList(string line, string attributeName)
        {
            XmlNode               lineNode        = ClsCommon.InfoRootNode.SelectSingleNode("line[@name='" + line + "']");
            XmlNodeList           controlNodeList = lineNode.SelectNodes("station");
            List <monitorAddress> maList          = new List <monitorAddress>();

            foreach (XmlNode item in controlNodeList)
            {
                XmlNodeList contol = item.SelectNodes(attributeName);
                foreach (XmlNode itemO in contol)
                {
                    XmlElement xe = (XmlElement)itemO;
                    Dictionary <string, string> para = new Dictionary <string, string>();
                    para.Add("type", xe.Attributes["type"].Value);
                    para.Add("address", xe.Attributes["addr"].Value);
                    para.Add("stationName", item.Attributes["name"].Value);
                    para.Add("lineName", item.ParentNode.Attributes["name"].Value);
                    monitorAddress ma = new monitorAddress(xe.Attributes["addr"].Value, para);
                    maList.Add(ma);
                }
            }
            return(maList);
        }
示例#4
0
 public SiemensPLCParameter(monitorAddress ma_, string itemValue_)   // 带参数的构造函数
 {
     ma        = ma_;
     itemValue = itemValue_;
 }