Example #1
0
        private void RecurBrowse(List <OPCNode> parentNodes, OPCNode parent, List <string> FullPathObj)
        {
            ArrayList lst = this.Browse(OPCBROWSETYPE.OPC_BRANCH);

            if (lst == null)
            {
                return;
            }
            if (lst.Count < 1)
            {
                return;
            }

            foreach (string s in lst)
            {
                this.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_DOWN, s);

                OPCNode node = new OPCNode(s);
                node.OpcServer = this;
                if (FullPathObj == null)
                {
                    FullPathObj = new List <string>();
                }
                FullPathObj.Add(s);
                node.FullPathObj = FullPathObj;
                node.Parent      = parent;

                this.OnEnumNodes(FullPathObj, node);
                parentNodes.Add(node);

                ArrayList lstItem = this.Browse(OPCBROWSETYPE.OPC_LEAF);
                node._NodeItems = new List <OPCNodeItem>();
                if (lstItem != null)
                {
                    foreach (string sItem in lstItem)
                    {
                        OPCNodeItem item = new OPCNodeItem();
                        item.Name = sItem;
                        item.ID   = this.GetItemID(sItem);
                        node._NodeItems.Add(item);
                    }
                }


                node._Nodes = new List <OPCNode>();
                RecurBrowse(node._Nodes, node, FullPathObj);
                this.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_UP, "");
            }
        }
Example #2
0
        public List <OPCNode> GetNodes(List <string> FullPathObj)
        {
            try
            {
                QueryOrganization();
            }
            catch (OnlyItemsException)
            {
                return(new List <OPCNode>());
            }
            catch (Exception)
            {
            }
            this.MoveToRoot();
            //this.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_TO, "/");
            if (FullPathObj == null)
            {
                FullPathObj = new List <string>();
            }

            foreach (string s in FullPathObj)
            {
                this.ChangeBrowsePosition(OPCBROWSEDIRECTION.OPC_BROWSE_DOWN, s);
            }

            List <OPCNode> newNodes = new List <OPCNode>();
            ArrayList      lst      = this.Browse(OPCBROWSETYPE.OPC_BRANCH);

            foreach (string s in lst)
            {
                OPCNode node = new OPCNode(s);
                newNodes.Add(node);
                node.FullPathObj = new List <string>();
                foreach (string path in FullPathObj)
                {
                    node.FullPathObj.Add(path);
                }
                node.FullPathObj.Add(s);
                node.OpcServer = this;
            }
            return(newNodes);
        }
Example #3
0
        private void Async_enumNodes(object param)
        {
            object[]      params_     = param as object[];
            List <string> FullPathObj = params_[0] as List <string>;
            bool          onlyitem    = (bool)params_[2];
            object        tag         = params_[1];

            ArrayList       lst = null;
            UCOMIEnumString enumerator;
            int             cft;

            string[] strF = new string[100];
            int      hresult;

            if (onlyitem == false)
            {
                BrowseOPCItemIDs(OPCBROWSETYPE.OPC_BRANCH, "", VarEnum.VT_EMPTY, 0, out enumerator);
                if (enumerator != null)
                {
                    do
                    {
                        cft     = 0;
                        hresult = enumerator.Next(1, strF, out cft);
                        if (cft > 0)
                        {
                            OPCNode newNode = new OPCNode(strF[0]);
                            newNode.FullPathObj = new List <string>();
                            foreach (string path in FullPathObj)
                            {
                                newNode.FullPathObj.Add(path);
                            }
                            newNode.FullPathObj.Add(newNode.Name);

                            if (AsyncGetNode != null)
                            {
                                AsyncGetNode(tag, newNode);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }while (hresult == HRESULTS.S_OK);
                }
            }

            BrowseOPCItemIDs(OPCBROWSETYPE.OPC_LEAF, "", VarEnum.VT_EMPTY, 0, out enumerator);
            if (enumerator == null)
            {
                if (AsyncGetNodeCompleted != null)
                {
                    this.AsyncGetNodeCompleted(this, tag);
                }
                return;
            }

            do
            {
                cft     = 0;
                hresult = enumerator.Next(1, strF, out cft);
                if (cft > 0)
                {
                    OPCNode newNode = new OPCNode(strF[0]);
                    newNode.FullPathObj = new List <string>();
                    foreach (string path in FullPathObj)
                    {
                        newNode.FullPathObj.Add(path);
                    }
                    newNode.FullPathObj.Add(newNode.Name);

                    if (AsyncGetNode != null)
                    {
                        newNode.ID             = this.GetItemID(newNode.Name);
                        newNode.IsItemProperty = true;
                        AsyncGetNode(tag, newNode);
                    }
                }
                else
                {
                    break;
                }
            }while (hresult == HRESULTS.S_OK);

            if (AsyncGetNodeCompleted != null)
            {
                this.AsyncGetNodeCompleted(this, tag);
            }
        }