Exemplo n.º 1
0
		/// <summary>
		/// Allocates and marshals an OPCBROWSEELEMENT structure.
		/// </summary>
		internal static OpcRcw.Da.OPCBROWSEELEMENT GetBrowseElement(BrowseElement input)
		{
			OpcRcw.Da.OPCBROWSEELEMENT output = new OpcRcw.Da.OPCBROWSEELEMENT();
			
			if (input != null)
			{
				output.szName         = input.Name;
				output.szItemID       = input.ItemId;
				output.dwFlagValue    = 0;
				output.ItemProperties = GetItemProperties(input.Properties);

				if (input.IsItem)
				{
					output.dwFlagValue |= OpcRcw.Da.Constants.OPC_BROWSE_ISITEM;
				}

				if (input.HasChildren)
				{
					output.dwFlagValue |= OpcRcw.Da.Constants.OPC_BROWSE_HASCHILDREN;
				}
			}

			return output;
		}
Exemplo n.º 2
0
        /// <summary>
        /// Applies the browse filters to a set of references.
        /// </summary>
        private void ApplyFilters(
            ReferenceDescriptionCollection currentBatch, 
			OPCBROWSEFILTER                dwBrowseFilter,
			string                         szElementNameFilter, 
            int                            maxReferencesReturned,
            IList<BrowseElement>           filteredResults,
            IList<BrowseElement>           unprocessedResults)
        {
            // apply the filters to each item in the batch.
            foreach (ReferenceDescription reference in currentBatch)
            {
                // check for a valid node.
                INode target = m_session.NodeCache.FetchNode(reference.NodeId);

                if (target == null)
                {
                    continue;
                }
                
                // create the browse element.
                BrowseElement element = new BrowseElement();
                
                element.Node   = target;
                element.Name   = target.BrowseName.Name;
                element.ItemId = NodeIdToItemId(target.NodeId);
    
                // apply the element name filter.
                if (!String.IsNullOrEmpty(szElementNameFilter))
                {
                    if (!ComUtils.Match(element.Name, szElementNameFilter, true))
                    {
                        continue;
                    }
                }

                element.IsItem = IsItem(target);
                element.HasChildren = HasChildren(target);

                // apply the browse filter.
                if (dwBrowseFilter != OPCBROWSEFILTER.OPC_BROWSE_FILTER_ALL)
                {
                    if (dwBrowseFilter == OPCBROWSEFILTER.OPC_BROWSE_FILTER_ITEMS)
                    {
                        if (!element.IsItem)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (!element.HasChildren)
                        {
                            continue;
                        }
                    }
                }               

                // must save the results to return in a subsequent browse.
                if (maxReferencesReturned != 0 && filteredResults.Count >= maxReferencesReturned)
                {
                    unprocessedResults.Add(element);
                }

                // can return the results in this browse.
                else
                {
                    filteredResults.Add(element);
                }
            }
        }