Beispiel #1
0
        public void loadXmlHsp(XmlNode xn)
        {
            XmlNodeList nodeList = xn.ChildNodes;   //创建xn的所有子节点的集合

            foreach (XmlNode childNode in nodeList) //遍历集合中所有的节点
            {
                XmlElement e       = (XmlElement)childNode;
                HSPData    hspData = new HSPData();
                string     name    = e.Name;
                hspData.name = e.GetAttribute("name");
                bool.TryParse(e.GetAttribute("used"), out hspData.used);
                hspData.address = e.GetAttribute("address");

                int.TryParse(e.GetAttribute("type"), out hspData.type);
                int.TryParse(e.GetAttribute("timebase"), out hspData.timeBase);
                int.TryParse(e.GetAttribute("preset"), out hspData.preset);
                bool.TryParse(e.GetAttribute("doubleword"), out hspData.doubleWord);
                int.TryParse(e.GetAttribute("signalfrequency"), out hspData.signalFrequency);
                int.TryParse(e.GetAttribute("outputmode"), out hspData.outputMode);
                hspData.pulsePort     = e.GetAttribute("pulseport");
                hspData.directionPort = e.GetAttribute("directionport");
                hspData.note          = e.GetAttribute("note");

                dataManage.hspList.Add(hspData);
            }
        }
Beispiel #2
0
        public void initData()
        {
            var list = UserControlBase.dataManage.deviceInfoElem.connector.moduleList;

            foreach (var elem in list)
            {
                if (elem.moduleID == "HSP_FUNC")
                {
                    var modulesList = UserControlBase.dataManage.modules.list;
                    foreach (var elemModule in modulesList)
                    {
                        if (elemModule.moduleID == elem.moduleID)
                        {
                            foreach (var innerElem in elemModule.connectModules.list)
                            {
                                xml.HSPData hspData = new HSPData();

                                DataRow drData;
                                drData                  = dtData.NewRow();
                                hspData.used            = false;
                                drData[columnUsedIndex] = hspData.used;

                                hspData.name               = innerElem.parameterName;
                                drData[columnVarIndex]     = hspData.name;
                                drData[columnAddressIndex] = hspData.address;

                                hspData.type = 0;
                                if (typeDescDic.ContainsKey(hspData.type))
                                {
                                    drData[columnTypeIndex] = typeDescDic[hspData.type];
                                }
                                else
                                {
                                    drData[columnTypeIndex] = "";
                                }

                                hspData.note            = "";
                                drData[columnNoteIndex] = hspData.note;  //注释

                                dtData.Rows.Add(drData);
                                UserControlBase.dataManage.hspList.Add(hspData);
                            }
                        }
                    }
                    this.dataGridView1.DataSource = dtData;
                }
            }
        }