Ejemplo n.º 1
0
 public override BrowseElement[] BrowseNext(ref Opc.Da.BrowsePosition position)
 {
     lock (this)
     {
         if (base.m_server == null)
         {
             throw new NotConnectedException();
         }
         if ((position == null) && (position.GetType() != typeof(OpcCom.Da20.BrowsePosition)))
         {
             throw new BrowseCannotContinueException();
         }
         OpcCom.Da20.BrowsePosition position2 = (OpcCom.Da20.BrowsePosition)position;
         ItemIdentifier             itemID    = position2.ItemID;
         BrowseFilters filters = position2.Filters;
         ArrayList     list    = new ArrayList();
         if (position2.IsBranch)
         {
             BrowseElement[] c = this.GetElements(list.Count, itemID, filters, true, ref position2);
             if (c != null)
             {
                 list.AddRange(c);
             }
             position = position2;
             if (position != null)
             {
                 return((BrowseElement[])list.ToArray(typeof(BrowseElement)));
             }
         }
         if (filters.BrowseFilter != browseFilter.branch)
         {
             BrowseElement[] elementArray2 = this.GetElements(list.Count, itemID, filters, false, ref position2);
             if (elementArray2 != null)
             {
                 list.AddRange(elementArray2);
             }
             position = position2;
         }
         return((BrowseElement[])list.ToArray(typeof(BrowseElement)));
     }
 }
Ejemplo n.º 2
0
 public override BrowseElement[] Browse(ItemIdentifier itemID, BrowseFilters filters, out Opc.Da.BrowsePosition position)
 {
     if (filters == null)
     {
         throw new ArgumentNullException("filters");
     }
     position = null;
     lock (this)
     {
         if (base.m_server == null)
         {
             throw new NotConnectedException();
         }
         OpcCom.Da20.BrowsePosition position2 = null;
         ArrayList list = new ArrayList();
         if (filters.BrowseFilter != browseFilter.item)
         {
             BrowseElement[] c = this.GetElements(list.Count, itemID, filters, true, ref position2);
             if (c != null)
             {
                 list.AddRange(c);
             }
             position = position2;
             if (position != null)
             {
                 return((BrowseElement[])list.ToArray(typeof(BrowseElement)));
             }
         }
         if (filters.BrowseFilter != browseFilter.branch)
         {
             BrowseElement[] elementArray2 = this.GetElements(list.Count, itemID, filters, false, ref position2);
             if (elementArray2 != null)
             {
                 list.AddRange(elementArray2);
             }
             position = position2;
         }
         return((BrowseElement[])list.ToArray(typeof(BrowseElement)));
     }
 }
Ejemplo n.º 3
0
 public override object Clone()
 {
     OpcCom.Da20.BrowsePosition position = (OpcCom.Da20.BrowsePosition)base.MemberwiseClone();
     position.Enumerator = this.Enumerator.Clone();
     return(position);
 }
Ejemplo n.º 4
0
        private BrowseElement[] GetElements(int elementsFound, ItemIdentifier itemID, BrowseFilters filters, bool branches, ref OpcCom.Da20.BrowsePosition position)
        {
            EnumString enumerator = null;

            if (position == null)
            {
                IOPCBrowseServerAddressSpace server         = (IOPCBrowseServerAddressSpace)base.m_server;
                OPCNAMESPACETYPE             pNameSpaceType = OPCNAMESPACETYPE.OPC_NS_HIERARCHIAL;
                try
                {
                    server.QueryOrganization(out pNameSpaceType);
                }
                catch (Exception exception)
                {
                    throw OpcCom.Interop.CreateException("IOPCBrowseServerAddressSpace.QueryOrganization", exception);
                }
                if ((pNameSpaceType == OPCNAMESPACETYPE.OPC_NS_FLAT) && branches)
                {
                    return(new BrowseElement[0]);
                }
                enumerator = this.GetEnumerator((itemID != null) ? itemID.ItemName : null, filters, branches);
            }
            else
            {
                enumerator = position.Enumerator;
            }
            ArrayList     list    = new ArrayList();
            BrowseElement element = null;
            int           index   = 0;

            string[] names = null;
            if (position != null)
            {
                index    = position.Index;
                names    = position.Names;
                position = null;
            }
Label_0089:
            if (names != null)
            {
                for (int i = index; i < names.Length; i++)
                {
                    if ((filters.MaxElementsReturned != 0) && (filters.MaxElementsReturned == (list.Count + elementsFound)))
                    {
                        position       = new OpcCom.Da20.BrowsePosition(itemID, filters, enumerator, branches);
                        position.Names = names;
                        position.Index = i;
                        break;
                    }
                    element = this.GetElement(names[i], filters, branches);
                    if (element == null)
                    {
                        break;
                    }
                    list.Add(element);
                }
            }
            if (position == null)
            {
                names = enumerator.Next(10);
                index = 0;
                if ((names != null) && (names.Length > 0))
                {
                    goto Label_0089;
                }
            }
            if (position == null)
            {
                enumerator.Dispose();
            }
            return((BrowseElement[])list.ToArray(typeof(BrowseElement)));
        }