Beispiel #1
3
 private void RecurBrowse(OPCBrowser oPcBrowser)
 {
     //展开分支
     oPcBrowser.ShowBranches();
     //展开叶子
     oPcBrowser.ShowLeafs(true);
     foreach (object turn in oPcBrowser)
     {
         ListBox1.Items.Add(turn.ToString());
     }
 }
Beispiel #2
0
        private void browseBranch(Branch Parent)
        {
            _OPCBrowser.ShowBranches();

            if (_OPCBrowser.Count > 0)
            {
                for (int i = 1; i <= _OPCBrowser.Count; i++)
                {
                    _OPCBrowser.MoveDown(_OPCBrowser.Item(i));

                    //string BranchName = _OPCBrowser.CurrentPosition;

                    //while(BranchName.Contains("."))
                    //{
                    //    BranchName = BranchName.Substring(_OPCBrowser.CurrentPosition.IndexOf(".") + 1);
                    //}

                    Branch b = new Branch(Name: _OPCBrowser.CurrentPosition, Server: this._OPCServer, Parent: Parent);

                    browseBranch(b);
                    browseLeaf(b);

                    _OPCBrowser.MoveUp();
                    _OPCBrowser.ShowBranches();
                }
            }
        }
Beispiel #3
0
        static void Browser()
        {
            OPCBrowser        browser = _opcServer.CreateBrowser();
            OPCNamespaceTypes type    = (OPCNamespaceTypes)(browser.Organization);

            PrintInfo("browser Type", type.ToString());

            browser.ShowBranches();

            for (int i = 1; i <= browser.Count; i++)
            {
                Console.WriteLine(browser.Item(i));

                browser.MoveDown(browser.Item(i));
                browser.ShowBranches();

                for (int j = 1; j <= browser.Count; j++)
                {
                    Console.WriteLine(string.Format("   {0}", browser.Item(j)));


                    browser.MoveDown(browser.Item(j));
                    browser.ShowLeafs();

                    for (int k = 1; k <= browser.Count; k++)
                    {
                        Console.WriteLine(string.Format("      {0}   ItemID = {1}", browser.Item(k), browser.GetItemID(browser.Item(k))));
                    }
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// OPCBrowser遍历组下一层节点,并构建Tree节点
        /// </summary>
        /// <param name="nodeId"></param>
        public List <OpcNode> ShowBranches(string nodeId = "")
        {
            if (nodeId.IsNullOrEmpty())
            {
                //返回根节点,需要顺序执行下列3个函数。
                oPCBrowser.MoveTo(oPCBrowser.CurrentPosition.Split('.'));
                oPCBrowser.ShowLeafs(true);
                oPCBrowser.MoveToRoot();
            }
            else
            {
                oPCBrowser.MoveTo(nodeId.Split('.'));
            }

            oPCBrowser.ShowBranches();
            List <OpcNode> listNode = Task.Run(() =>
            {
                List <OpcNode> list = new List <OpcNode>();
                foreach (object branch in oPCBrowser)
                {
                    string key          = "ClassIcon";
                    bool isExpand       = false;
                    string branchNodeId = "";
                    //拼接nodeId
                    if (nodeId.IsNullOrEmpty())
                    {
                        branchNodeId = branch.ToString();
                    }
                    else
                    {
                        branchNodeId = nodeId + "." + branch.ToString();
                    }
                    oPCBrowser.MoveDown(branch.ToString());
                    oPCBrowser.ShowBranches();
                    if (oPCBrowser.Count > 0)
                    {
                        isExpand = true;
                    }
                    var child = new OpcNode(branch.ToString(), branchNodeId, key, isExpand);
                    list.Add(child);
                    oPCBrowser.MoveUp();
                }
                return(list);
            }
                                               ).Result;

            oPCBrowser.MoveToRoot();
            return(listNode);
        }
Beispiel #5
0
        public TKepwareServer(string address, string name)
        {
            try
            {
                server.Connect(name, address);
            }
            catch (Exception error)
            {
                Exception err =
                    new Exception(
                        $"无法连接到KEPServer[{name}({address})],[{error.Message}]");
                err.Data.Add("ErrCode", 900103);
                err.Data.Add("ErrText", err.Message);
                throw err;
            }

            this.address = address;
            this.name    = name;

            OPCBrowser browser = server.CreateBrowser();

            browser.ShowBranches();
            browser.ShowLeafs(true);

            foreach (object tag in browser)
            {
                devices.Add(
                    address,
                    name,
                    tag.ToString());
            }
        }
Beispiel #6
0
        /// <summary>
        /// 获取对应的分支点
        /// </summary>
        /// <param name="filter">点名字</param>
        public List <OpcData> RecurBrowse(string[] filter)
        {
            OPCBrowser     opcBrowser = _opcSerialInfo.OpcServer.CreateBrowser();
            List <OpcData> datas      = new List <OpcData>();

            //展开分支
            opcBrowser.ShowBranches();
            //展开叶子
            opcBrowser.ShowLeafs(true);

            foreach (object turn in opcBrowser)
            {
                foreach (var r in filter)
                {
                    if (turn.ToString().ToUpper().Contains(r.ToUpper()))
                    {
                        OpcData data = new OpcData
                        {
                            OpcName  = turn.ToString(),
                            OpcValue = "null",
                            OpcTime  = DateTime.Now.ToString()
                        };
                        datas.Add(data);
                    }
                }
            }
            return(datas);
        }
Beispiel #7
0
        private void RecurBrowse(OPCBrowser opcBrowser, string[] filter)
        {
            //展开分支
            opcBrowser.ShowBranches();
            //展开叶子
            opcBrowser.ShowLeafs(true);

            foreach (object turn in opcBrowser)
            {
                foreach (var r in filter)
                {
                    if (turn.ToString().ToUpper().Contains(r.ToUpper()))
                    {
                        OpcData data = new OpcData
                        {
                            OpcName  = turn.ToString(),
                            OpcValue = "null",
                            OpcTime  = DateTime.Now.ToString()
                        };
                        Log.Info($"绑定的数据{data.OpcName}");
                        _bindingData.Add(data);
                    }
                }
            }
        }
Beispiel #8
0
        public List <string> ConnRemoteAndGetRecurBrowse(
            string remoteServerIP,
            string remoteServerName)
        {
            List <string> rlt = new List <string>();

            string connRlt = ConnectRemoteServer(remoteServerIP, remoteServerName);

            if (connRlt != "")
            {
                return(rlt);
            }

            OPCBrowser browser = server.CreateBrowser();

            // 展开分支
            browser.ShowBranches();
            // 展开叶子
            browser.ShowLeafs(true);
            foreach (object turn in browser)
            {
                string strTurn = turn.ToString();
                if (!(strTurn.Contains("._Statistics._") ||
                      strTurn.Contains("_System._") ||
                      strTurn.Contains("_DataLogger._")))
                {
                    rlt.Add(strTurn);
                }
            }

            return(rlt);
        }
Beispiel #9
0
        /// <summary>
        /// 列出OPC服务器中所有组
        /// </summary>
        /// <param name="oPCBrowser"></param>
        private void RecurBrowseGroups(OPCBrowser oPCBrowser)
        {
            //string branch;
            //oPCBrowser.ShowBranches();
            //oPCBrowser.ShowLeafs(true);
            //foreach (object turn in oPCBrowser)
            // {                  Console.WriteLine("服务端浏览——————:" + turn.ToString());             }
            // Console.WriteLine("请需要浏览的分支:");
            // branch = Console.ReadLine();
            // oPCBrowser.MoveDown("Channel_0_User_Defined");
            // oPCBrowser.ShowBranches();
            // oPCBrowser.ShowLeafs(true);
            // foreach (object turn in oPCBrowser)
            // {
            //     Console.WriteLine("服务端:" + turn.ToString());
            // }

            //展开分支
            oPCBrowser.ShowBranches();
            foreach (object turn in oPCBrowser)
            {
                if (!turn.ToString().Substring(0, 1).Equals("_"))
                {
                    listBoxGroups.Items.Add(turn.ToString());
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Рекурсивно обходит содержимое OPC-сервера.
        /// </summary>
        /// <param name="aBrowser">Браузер OPC-сервера.</param>
        /// <param name="aPrefix">Префикс для построения дерева.</param>
        private static void ShowOpcTagsRecurcive(OPCBrowser aBrowser, string aPrefix = "")
        {
            var isError = false;
            try {
                aBrowser.ShowBranches();
            }
            catch (Exception ex) {
                Console.WriteLine("Ошибка при отображении ветки.");
                isError = true;
            }

            if (!isError) {
                foreach (var item in aBrowser) {
                    Console.WriteLine(aPrefix + "Ветвь: " + item);
                    aBrowser.MoveDown(item.ToString());
                    ShowOpcTagsRecurcive(aBrowser, aPrefix + "-");
                    aBrowser.MoveUp();
                }
            }

            isError = false;
            try {
                aBrowser.ShowLeafs();
            }
            catch (Exception ex) {
                Console.WriteLine("Ошибка при отображении листа.");
                isError = true;
            }

            if (!isError) {
                foreach (var item in aBrowser) {
                    Console.WriteLine(aPrefix + "Лист:" + item);
                }
            }
        }
Beispiel #11
0
        private bool LoadDataToTree(OPCBrowser oPCBrowser, TreeNodeCollection treeNodeCollection, string root)
        {
            oPCBrowser.Organization.ToString();

            oPCBrowser.ShowBranches();

            bool isLeaf = true;

            foreach (object turn in opcBrowser)
            {
                TreeNode node = null;
                node = treeNodeCollection.Add(turn.ToString());
                opcBrowser.MoveDown(turn.ToString());
                if (LoadDataToTree(oPCBrowser, node.Nodes, root + "\\" + turn.ToString()))
                {
                    //if (turn.ToString().Equals("PV"))
                    //{


                    //textBoxResult.Text +=root+"\\"+turn.ToString() + "\r\n";
                    File.AppendAllText(path, root + "\\" + turn.ToString() + "\r\n", Encoding.UTF8);

                    // }
                }
                oPCBrowser.MoveUp();
                isLeaf = false;
            }
            return(isLeaf);
        }
Beispiel #12
0
        /// <summary>
        /// OPCBrowser遍历组下所有点,并构建Tree节点
        /// </summary>
        /// <param name="nodes"></param>
        public void ShowBranchesByTree(TreeNodeCollection nodes)
        {
            TreeNode treeNode;

            oPCBrowser.ShowBranches();
            foreach (object branch in oPCBrowser)
            {
                if (branch.ToString().Equals("_Hints") || branch.ToString().Equals("_System"))//排除这两项
                {
                }
                else
                {
                    treeNode = nodes.Add(branch.ToString());
                    oPCBrowser.MoveDown(branch.ToString());
                    ShowBranchesByTree(treeNode.Nodes);
                    oPCBrowser.MoveUp();
                }
            }
        }
        /// <summary>
        /// 展开OPC服务器的节点
        /// </summary>
        /// <param name="opcServer">OPC服务器</param>
        /// <returns>返回展开后的节点数据</returns>

        public OPCBrowser RecurBrowse(OPCServer opcServer)
        {
            OPCBrowser opcBrowser = opcServer.CreateBrowser();

            //展开分支
            opcBrowser.ShowBranches();
            //展开叶子
            opcBrowser.ShowLeafs(true);
            return(opcBrowser);
        }
Beispiel #14
0
        private void LoadDataToTreeFlat(OPCBrowser oPCBrowser, TreeNodeCollection treeNodeCollection, string root)
        {
            oPCBrowser.Organization.ToString();

            oPCBrowser.ShowBranches();
            opcBrowser.ShowLeafs(true);
            foreach (object turn in opcBrowser)
            {
                File.AppendAllText(path, root + "\\" + turn.ToString() + "\r\n", Encoding.UTF8);
            }
        }
Beispiel #15
0
 /// <summary>
 /// OPC分支展开
 /// </summary>
 /// <param name="oPCBrowser"></param>
 public void RecurBrowse(OPCBrowser oPCBrowser)
 {
     //展开分支
     oPCBrowser.ShowBranches();
     //展开叶子
     oPCBrowser.ShowLeafs(true);
     foreach (object turn in oPCBrowser)
     {
         Console.WriteLine(turn.ToString());
     }
 }
Beispiel #16
0
 /// <summary>
 /// 列出OPC服务器中所有节点
 /// </summary>
 /// <param name="oPCBrowser"></param>
 private void RecurBrowse(OPCBrowser oPCBrowser)
 {
     //展开分支
     oPCBrowser.ShowBranches();
     //展开叶子
     oPCBrowser.ShowLeafs(true);
     foreach (object turn in oPCBrowser)
     {
         listBox1.Items.Add(turn.ToString());
     }
 }
Beispiel #17
0
        /// <summary>
        /// 列出opc服务器中所有节点
        /// </summary>
        /// <param name="TransactionID"></param>
        /// <param name="NumItems"></param>
        /// <param name="ClientHandles"></param>
        /// <param name="Errors"></param>
        private void RecurBrowse(OPCBrowser oPCBrowser)
        {
            //写入接到treeview

            LoadDataToTree(oPCBrowser, treeView1.Nodes[0].Nodes);
            oPCBrowser.ShowBranches();
            oPCBrowser.ShowLeafs(true);
            foreach (object turn in oPCBrowser)
            {
                listBox1.Items.Add(turn.ToString());
            }
        }
Beispiel #18
0
 /// <summary>
 /// 列出OPC服务器中所有节点
 /// </summary>
 /// <param name="oPCBrowser"></param>
 private void RecurBrowse(OPCBrowser oPCBrowser)
 {
     //展开分支
     oPCBrowser.ShowBranches();
     //展开叶子
     oPCBrowser.ShowLeafs(true);
     foreach (object turn in oPCBrowser)
     {
         //OPCItemDic2.Add(turn.ToString(), );
         OPCItemNames.Add(turn.ToString());
     }
 }
Beispiel #19
0
 /// <summary>
 /// 获取listview中相应的值
 /// </summary>
 /// <param name="opcbrowser"></param>
 public List <string> RecurBrowse(OPCBrowser opcbrowser)
 {
     //  OPCBrowser opcbrowser = ServerConnect.KepServer.CreateBrowser();
     opcbrowser.ShowBranches();
     opcbrowser.ShowLeafs(true);
     list = new List <string>();
     foreach (object turn in opcbrowser)
     {
         list.Add(turn.ToString());
         //lv = new ListViewItem(turn.ToString());
         //listView1.Items.Add(lv);
     }
     return(list);
 }
Beispiel #20
0
        public List <string> RecurBrowse(OPCBrowser opcBrowser)
        {
            List <string> opcNodeNameList = new List <string>();

            //展开分支
            opcBrowser.ShowBranches();
            //展开叶子
            opcBrowser.ShowLeafs(true);
            foreach (object item in opcBrowser)
            {
                opcNodeNameList.Add(item.ToString());
            }
            return(opcNodeNameList);
        }
        /// <summary>
        /// 显示节点树 不包含叶子节点
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public TagTreeNode GetTree(TagTreeNode node)
        {
            TagTreeNode subNode = null;

            opcBrowser.ShowBranches();

            foreach (var branch in opcBrowser)
            {
                if (node == null)
                {
                    node = new TagTreeNode(opcServer.ServerName);
                }
                //Console.WriteLine(branch);
                subNode = node.AddNode(branch.ToString());
                try
                {
                    opcBrowser.MoveDown(branch.ToString());
                    GetTree(subNode);
                    opcBrowser.MoveUp();
                }
                catch { }
            }
            return(node);
        }
Beispiel #22
0
        /// <summary>
        /// 展开OPC服务器的节点
        /// </summary>
        /// <param name="opcServer">OPC服务器</param>
        /// <returns>返回展开后的节点数据</returns>
        public List <string> RecurBrowse()
        {
            OPCBrowser opcBrowser = opcServer.CreateBrowser();

            //展开分支
            opcBrowser.ShowBranches();
            //展开叶子
            opcBrowser.ShowLeafs(true);
            List <string> browserNames = new List <string>();

            for (int i = 1; i <= opcBrowser.Count; i++)
            {
                browserNames.Add(opcBrowser.Item(i));
            }
            return(browserNames);
        }
Beispiel #23
0
        /// <summary>
        /// 列出OPC服务器中所有节点
        /// </summary>
        /// <param name="oPCBrowser"></param>
        public OPCBrowser RecurBrowse()
        {
            OPCBrowser oPCBrowser = KepServer.CreateBrowser();

            //展开分支
            oPCBrowser.ShowBranches();


            //展开叶子
            oPCBrowser.ShowLeafs(true);
            // foreach (object turn in oPCBrowser)
            // {
            //  lsbGroups.Items.Add(turn.ToString());
            // }
            return(oPCBrowser);
        }
Beispiel #24
0
        //获取PLC对象中所有的Item
        public string ItemList()
        {
            browser = myOpcServer.CreateBrowser();
            browser.ShowBranches();
            browser.ShowLeafs(true);
            string i = "";

            foreach (var item in browser)
            {
                if (item.ToString().Contains(str))
                {
                    i += item.ToString() + "|";
                }
            }
            return(i);
        }
Beispiel #25
0
 private void btnGetGrps_Click(object sender, EventArgs e)
 {
     //实例化Tag浏览器
     myOPCBrowser = myServer.CreateBrowser();
     //展开分组
     myOPCBrowser.ShowBranches();
     //展开标签
     myOPCBrowser.ShowLeafs(true);
     //将所有分支和叶子节点显示到ListBox
     lstItems.Items.Clear();
     foreach (object turn in myOPCBrowser)
     {
         lstItems.Items.Add(turn.ToString());
     }
     //开启定位标签按钮
     btnSetItem.Enabled = true;
 }
Beispiel #26
0
            public void GetItemsNames(string RemoteServerName, string RemoteServerIp, string pass, string pattern, string patternRe)
            {
                try
                {
                    _kepServer.Connect(RemoteServerName, RemoteServerIp);
                    OPCBrowser browser = _kepServer.CreateBrowser();
                    //browser.Filter = "[\u4e00-\u9fa5]+.PLC.[\u4e00-\u9fa5]+[A|B|C]";
                    browser.ShowBranches();
                    browser.ShowLeafs(true);

                    dicItems.Clear();

                    //string pattern = @"[\u4e00-\u9fa5]+\d+\-" + pass + @".PLC.[\u4e00-\u9fa5]+[A-Z]+\d+";//匹配 设备001.PLC.配置参数A1

                    //string patternRe = @".PLC.[\u4e00-\u9fa5]+[A-Z]+\d+";

                    //string pattern = "[A-Z|a-z]+.PLC." + @"[AI|BI]+\d";
                    //string patternRe = @".PLC.[AI|BI]+\d";

                    foreach (object item in browser)
                    {
                        if (Regex.IsMatch(item.ToString(), pattern, RegexOptions.IgnoreCase))
                        {
                            ItemsNames.Add(item.ToString());
                            Regex          rgx   = new Regex(patternRe);//获取GroupName(组名)
                            string         key   = rgx.Replace(item.ToString(), " ");
                            IList <string> items = new List <string>
                            {
                                item.ToString()
                            };
                            if (!dicItems.ContainsKey(key))
                            {
                                dicItems.Add(key, items);
                            }
                            else
                            {
                                dicItems[key].Add(item.ToString());
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(typeof(OpcClient), ex.Message);
                }
            }
Beispiel #27
0
 /// <summary>
 /// 将数据获取到treeview
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void LoadDataToTree(OPCBrowser oPCBrowser, TreeNodeCollection treeNodeCollection)
 {
     oPCBrowser.Organization.ToString();
     oPCBrowser.ShowBranches();
     foreach (object turn in oPCBrowser)
     {
         TreeNode node = treeNodeCollection.Add(turn.ToString());
         treeView1.SelectedNode = node;
         oPCBrowser.MoveDown(turn.ToString());
         LoadDataToTree(oPCBrowser, node.Nodes);
         oPCBrowser.MoveUp();
     }
     oPCBrowser.ShowLeafs(false);
     foreach (object turn in oPCBrowser)
     {
         treeView1.SelectedNode.Nodes.Add(turn.ToString());
     }
 }
Beispiel #28
0
 private bool CreateGroup()
 {
     try {
         opcGroups = opcServer.OPCGroups;
         opcGroup  = opcGroups.Add(base.deviceName);
         SetGroupProperty();
         OPCItems kepItems = opcGroup.OPCItems;
         opcGroup.DataChange += KepGroup_DataChange;
         OPCBrowser oPCBrowser = opcServer.CreateBrowser();
         //展开分支
         oPCBrowser.ShowBranches();
         //展开叶子
         oPCBrowser.ShowLeafs(true);
         foreach (object turn in oPCBrowser)
         {
             ///客户端句柄
             int      itmHandleClient = 1;
             string[] strTem;
             string   str;
             string   Tem;
             Tem    = turn.ToString().Split('.')[turn.ToString().Split('.').Length - 1];
             strTem = Tem.ToString().Split('_');
             if (strTem.Length >= 2)
             {
                 str = strTem[strTem.Length - 2];
                 if (str == deviceName)
                 {
                     OPCItem kepItem = kepItems.AddItem(turn.ToString(), itmHandleClient);
                     itmHandleClient += 1;
                     // OPCItem Item = (OPCItem)turn;
                 }
             }
         }
         // myEnumBuilder.CreateType();
         opcGroup.AsyncWriteComplete += new DIOPCGroupEvent_AsyncWriteCompleteEventHandler(KepGroup_AsyncWriteComplete);
     }
     catch (Exception err) {
         return(false);
     }
     return(true);
 }
Beispiel #29
0
        public List <string> GetBranch(string position)
        {
            List <string> branchs = new List <string>();

            string[] desName = position.ToString().Split('.');
            Browser.MoveTo(desName);
            Browser.ShowBranches();
            IEnumerator enumerator = Browser.GetEnumerator();

            //树
            while (enumerator.MoveNext())
            {
                if (enumerator.Current != null)
                {
                    branchs.Add(enumerator.Current.ToString());
                }
            }

            Browser.MoveToRoot();
            return(branchs);
        }
Beispiel #30
0
        /// <summary>
        /// Рекурсивно обходит содержимое OPC-сервера.
        /// </summary>
        /// <param name="aBrowser">Браузер OPC-сервера.</param>
        /// <param name="aPrefix">Префикс для построения дерева.</param>
        private static void ShowOpcTagsRecurcive(OPCBrowser aBrowser, string aPrefix = "")
        {
            var isError = false;

            try {
                aBrowser.ShowBranches();
            }
            catch (Exception ex) {
                Console.WriteLine("Ошибка при отображении ветки.");
                isError = true;
            }

            if (!isError)
            {
                foreach (var item in aBrowser)
                {
                    Console.WriteLine(aPrefix + "Ветвь: " + item);
                    aBrowser.MoveDown(item.ToString());
                    ShowOpcTagsRecurcive(aBrowser, aPrefix + "-");
                    aBrowser.MoveUp();
                }
            }

            isError = false;
            try {
                aBrowser.ShowLeafs();
            }
            catch (Exception ex) {
                Console.WriteLine("Ошибка при отображении листа.");
                isError = true;
            }

            if (!isError)
            {
                foreach (var item in aBrowser)
                {
                    Console.WriteLine(aPrefix + "Лист:" + item);
                }
            }
        }
Beispiel #31
0
 /// <summary>
 /// 遍历该分支节点下所有的叶节点
 /// </summary>
 /// <param name="node"></param>
 /// <param name="oPCBrowser"></param>
 private void ListLeaf(ref TreeNode node, OPCBrowser oPCBrowser)
 {
     if (null == node)
     {
         oPCBrowser.MoveToRoot();
         node = ItemTreeNode.Nodes.Add("Root");
     }
     else
     {//剔除无意义的Root根节点
         List <string> BranchesList = new List <string>();
         BranchesList.AddRange(node.FullPath.Split('\\'));
         BranchesList.RemoveAt(0);
         Array Branches = BranchesList.ToArray();
         oPCBrowser.MoveTo(ref Branches);
     }
     oPCBrowser.ShowLeafs(false);//false不展开子集叶,true展开所有子集叶
     foreach (object item in oPCBrowser)
     {
         node.Nodes.Add(item.ToString());
     }
     oPCBrowser.ShowBranches();
 }
Beispiel #32
0
        private void lsbGroups_SelectedIndexChanged(object sender, EventArgs e)
        {
            OPCBrowser oPCBrowser = KepServer.CreateBrowser();

            //lsbGroups.SelectedItem.ToString())
            //展开分支
            //oPCBrowser.Filter = lsbGroups.SelectedItem.ToString();
            oPCBrowser.ShowBranches();

            //KepGroups = KepServer.OPCGroups;
            //string str = KepGroup.Name;
            //oPCBrowser.Item

            //myKepGroup. lsbGroups.SelectedItem.ToString()

            //string str = oPCBrowser.Item(gp);
            //MessageBox.Show(str);
            // return;
            //int index = 2;

            //展开叶子
            oPCBrowser.ShowLeafs(true);
            foreach (object turn in oPCBrowser)
            {
                //if (turn.ToString() == lsbGroups.SelectedItem.ToString())
                //{
                //  MessageBox.Show(turn.ToString());
                //}
                listBox1.Items.Add(turn.ToString());
            }
            // OPCGroup myKepGroup = KepGroups.Item(1);
            // int c= KepGroups.Count;
            //OPCItems myitems = myKepGroup.OPCItems;
            //foreach (object it in myitems)
            //{
            //     listBox1.Items.Add(it.ToString());
            //}
            //MessageBox.Show(c.ToString());
        }