/// <summary>
        /// Invokes the callback an passes the new browse filters.
        /// </summary>
        private void ApplyChanges()
        {
            TsCDaBrowseFilters filters = new TsCDaBrowseFilters();

            filters.BrowseFilter        = (TsCDaBrowseFilter)BrowseFilterCTRL.Value;
            filters.MaxElementsReturned = (int)MaxElementsReturnedCTRL.Value;
            filters.ElementNameFilter   = ElementNameFilterTB.Text;
            filters.VendorFilter        = VendorFilterTB.Text;

            if (!ReturnPropertiesCB.Checked)
            {
                filters.ReturnAllProperties  = false;
                filters.ReturnPropertyValues = false;
                filters.PropertyIDs          = null;
            }
            else
            {
                filters.ReturnAllProperties  = PropertyFiltersCTRL.ReturnAllProperties;
                filters.ReturnPropertyValues = PropertyFiltersCTRL.ReturnPropertyValues;

                if (!filters.ReturnAllProperties)
                {
                    filters.PropertyIDs = PropertyFiltersCTRL.PropertyIDs;
                }
                else
                {
                    filters.PropertyIDs = null;
                }
            }

            if (m_callback != null)
            {
                m_callback(filters);
            }
        }
        /// <summary>
        /// Displays all servers that support the specified specification.
        /// </summary>
        public void ShowAllServers(OpcSpecification specification, TsCDaBrowseFilters filters)
        {
            Clear();

            mSpecification_ = specification;
            mFilters_       = (filters == null)?new TsCDaBrowseFilters():filters;

            browseTv_.ContextMenuStrip = popupMenu_;

            mLocalServers_                    = new TreeNode("Local Servers");
            mLocalServers_.ImageIndex         = Resources.IMAGE_LOCAL_COMPUTER;
            mLocalServers_.SelectedImageIndex = Resources.IMAGE_LOCAL_COMPUTER;
            mLocalServers_.Tag                = null;

            BrowseServers(mLocalServers_);
            browseTv_.Nodes.Add(mLocalServers_);

            //localNetwork_                    = new TreeNode("Local Network");
            //localNetwork_.ImageIndex         = Resources.IMAGE_LOCAL_NETWORK;
            //localNetwork_.SelectedImageIndex = Resources.IMAGE_LOCAL_NETWORK;
            //localNetwork_.Tag                = null;

            //BrowseNetwork(localNetwork_);
            //browseTv_.Nodes.Add(localNetwork_);
        }
Example #3
0
        /// <summary>
        /// Displays the address space for the specified server.
        /// </summary>
        public OpcItem ShowDialog(TsCDaServer server)
        {
            try
            {
                if (server == null)
                {
                    throw new ArgumentNullException("server");
                }

                m_server = server;
                m_itemID = null;

                TsCDaBrowseFilters filters = new TsCDaBrowseFilters();

                filters.ReturnAllProperties  = false;
                filters.ReturnPropertyValues = false;

                BrowseCTRL.ShowSingleServer(m_server, filters);

                if (ShowDialog() != DialogResult.OK)
                {
                    return(null);
                }

                return(m_itemID);
            }
            finally
            {
                // ensure server connection in the browse control are closed.
                BrowseCTRL.Clear();
            }
        }
Example #4
0
		TsCDaBrowseElement[] Browse(TsCDaServer server)
		{
			TsCDaBrowseFilters filters;
			List<TsCDaBrowseElement> elementList;
			TsCDaBrowseElement[] elements;
			TsCDaBrowsePosition position;
			OpcItem path = new OpcItem();

			filters = new TsCDaBrowseFilters();
			filters.BrowseFilter = TsCDaBrowseFilter.All;
			filters.ReturnAllProperties = true;
			filters.ReturnPropertyValues = true;

			elementList = new List<TsCDaBrowseElement>();

			elements = server.Browse(path, filters, out position);

			foreach (var item in elements)
			{
				item.ItemPath = OpcDaTag.ROOT + OpcDaTag.SPLITTER + item.ItemName;
				elementList.Add(item);

				if (!item.IsItem)
				{
					path = new OpcItem(item.ItemPath, item.Name);
					BrowseChildren(path, filters, elementList, server);
				}

			}
			return elementList.ToArray();
		}
Example #5
0
        /// <summary>
        /// Displays the browse filters in a non-model dialog.
        /// </summary>
        public void Show(
            Form owner,
            TsCDaBrowseFilters filters,
            BrowseFiltersChangedCallback callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            Owner      = owner;
            mCallback_ = callback;

            browseFilterCtrl_.Value        = filters.BrowseFilter;
            maxElementsReturnedCtrl_.Value = (decimal)filters.MaxElementsReturned;
            elementNameFilterTb_.Text      = filters.ElementNameFilter;
            vendorFilterTb_.Text           = filters.VendorFilter;
            returnPropertiesCb_.Checked    = (filters.PropertyIDs != null || filters.ReturnAllProperties);

            propertyFiltersCtrl_.ReturnAllProperties  = filters.ReturnAllProperties;
            propertyFiltersCtrl_.ReturnPropertyValues = filters.ReturnPropertyValues;
            propertyFiltersCtrl_.PropertyIDs          = filters.PropertyIDs;

            Show();
        }
        /// <summary>
        /// Displays the address space for the specified server.
        /// </summary>
        public OpcItem ShowDialog(TsCDaServer server)
        {
            try
            {
                if (server == null)
                {
                    throw new ArgumentNullException("server");
                }

                mServer_ = server;
                mItemId_ = null;

                TsCDaBrowseFilters filters = new TsCDaBrowseFilters();

                filters.ReturnAllProperties  = false;
                filters.ReturnPropertyValues = false;

                browseCtrl_.ShowSingleServer(mServer_, filters);
                propertiesCtrl_.Initialize(null);

                if (ShowDialog() != DialogResult.OK)
                {
                    return(null);
                }

                return(mItemId_);
            }
            finally
            {
                // ensure server connection in the browse control are closed.
                browseCtrl_.Clear();
            }
        }
Example #7
0
        /// <summary>
        /// Invokes the callback an passes the new browse filters.
        /// </summary>
        private void ApplyChanges()
        {
            TsCDaBrowseFilters filters = new TsCDaBrowseFilters();

            filters.BrowseFilter        = (TsCDaBrowseFilter)browseFilterCtrl_.Value;
            filters.MaxElementsReturned = (int)maxElementsReturnedCtrl_.Value;
            filters.ElementNameFilter   = elementNameFilterTb_.Text;
            filters.VendorFilter        = vendorFilterTb_.Text;

            if (!returnPropertiesCb_.Checked)
            {
                filters.ReturnAllProperties  = false;
                filters.ReturnPropertyValues = false;
                filters.PropertyIDs          = null;
            }
            else
            {
                filters.ReturnAllProperties  = propertyFiltersCtrl_.ReturnAllProperties;
                filters.ReturnPropertyValues = propertyFiltersCtrl_.ReturnPropertyValues;

                if (!filters.ReturnAllProperties)
                {
                    filters.PropertyIDs = propertyFiltersCtrl_.PropertyIDs;
                }
                else
                {
                    filters.PropertyIDs = null;
                }
            }

            if (mCallback_ != null)
            {
                mCallback_(filters);
            }
        }
        /// <summary>
        /// Displays the browse filters in a non-model dialog.
        /// </summary>
        public void Show(
            Form owner,
            TsCDaBrowseFilters filters,
            BrowseFiltersChangedCallback callback)
        {
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            Owner      = owner;
            m_callback = callback;

            BrowseFilterCTRL.Value        = filters.BrowseFilter;
            MaxElementsReturnedCTRL.Value = (decimal)filters.MaxElementsReturned;
            ElementNameFilterTB.Text      = filters.ElementNameFilter;
            VendorFilterTB.Text           = filters.VendorFilter;
            ReturnPropertiesCB.Checked    = (filters.PropertyIDs != null || filters.ReturnAllProperties);

            PropertyFiltersCTRL.ReturnAllProperties  = filters.ReturnAllProperties;
            PropertyFiltersCTRL.ReturnPropertyValues = filters.ReturnPropertyValues;
            PropertyFiltersCTRL.PropertyIDs          = filters.PropertyIDs;

            Show();
        }
        /// <summary>
        /// Displays all servers that support the specified specification.
        /// </summary>
        public void ShowAllServers(OpcSpecification specification, TsCDaBrowseFilters filters)
        {
            Clear();

            m_specification = specification;
            m_filters       = (filters == null)?new TsCDaBrowseFilters():filters;

            BrowseTV.ContextMenu = PopupMenu;

            m_localServers                    = new TreeNode("Local Servers");
            m_localServers.ImageIndex         = Resources.IMAGE_LOCAL_COMPUTER;
            m_localServers.SelectedImageIndex = Resources.IMAGE_LOCAL_COMPUTER;
            m_localServers.Tag                = null;

            BrowseServers(m_localServers);
            BrowseTV.Nodes.Add(m_localServers);

            m_localNetwork                    = new TreeNode("Local Network");
            m_localNetwork.ImageIndex         = Resources.IMAGE_LOCAL_NETWORK;
            m_localNetwork.SelectedImageIndex = Resources.IMAGE_LOCAL_NETWORK;
            m_localNetwork.Tag                = null;

            BrowseNetwork(m_localNetwork);
            BrowseTV.Nodes.Add(m_localNetwork);
        }
 /// <summary>
 /// Initializes a browse position
 /// </summary>
 internal BrowsePosition(
     Technosoftware.DaAeHdaClient.OpcItem itemID,
     TsCDaBrowseFilters filters,
     string continuationPoint)
     :
     base(itemID, filters)
 {
     ContinuationPoint = continuationPoint;
 }
 /// <summary>
 /// Initializes a browse position
 /// </summary>
 internal BrowsePosition(
     OpcItem itemID,
     TsCDaBrowseFilters filters,
     string continuationPoint)
     :
     base(itemID, filters)
 {
     ContinuationPoint = continuationPoint;
 }
        /// <summary>
        /// Fetches the set of data filters from the server.
        /// </summary>
        /// <param name="server">The server object</param>
        public TsCCpxComplexItem[] GetDataFilters(TsCDaServer server)
        {
            // not a valid operation for data filter items.
            if (_unfilteredItemID != null)
            {
                return(null);
            }

            // data filters not supported by the item.
            if (_filterItem == null)
            {
                return(null);
            }

            TsCDaBrowsePosition position = null;

            try
            {
                // browse any existing filter instances.
                TsCDaBrowseFilters filters = new TsCDaBrowseFilters {
                    ElementNameFilter = null, BrowseFilter = TsCDaBrowseFilter.Item, ReturnAllProperties = false, PropertyIDs = CPX_PROPERTIES, ReturnPropertyValues = true
                };

                TsCDaBrowseElement[] elements = server.Browse(_filterItem, filters, out position);

                // nothing found.
                if (elements == null || elements.Length == 0)
                {
                    return(new TsCCpxComplexItem[0]);
                }

                // contruct an array of complex data items for each available data filter.
                ArrayList dataFilters = new ArrayList(elements.Length);

                Array.ForEach(elements, element =>
                {
                    TsCCpxComplexItem item = new TsCCpxComplexItem();
                    if (item.Init(element))
                    {
                        dataFilters.Add(item);
                    }
                });

                // return the set of available data filters.
                return((TsCCpxComplexItem[])dataFilters.ToArray(typeof(TsCCpxComplexItem)));
            }
            finally
            {
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
        }
        /// <summary>
        /// Called when the browse filters have changed.
        /// </summary>
        private void OnBrowseFiltersChanged(TsCDaBrowseFilters filters)
        {
            m_filters = filters;

            if (IsBrowseElementNode(BrowseTV.SelectedNode))
            {
                TsCDaBrowseElement element = (TsCDaBrowseElement)BrowseTV.SelectedNode.Tag;

                if (!element.HasChildren)
                {
                    GetProperties(BrowseTV.SelectedNode);
                    return;
                }
            }

            Browse(BrowseTV.SelectedNode);
        }
Example #14
0
        /// <summary>
        /// Browses the address space for a single server.
        /// </summary>
        public void ShowSingleServer(TsCDaServer server, TsCDaBrowseFilters filters)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            Clear();

            m_filters = (filters == null)?new TsCDaBrowseFilters():filters;

            m_singleServer                    = new TreeNode(server.ServerName);
            m_singleServer.ImageIndex         = Resources.IMAGE_LOCAL_SERVER;
            m_singleServer.SelectedImageIndex = Resources.IMAGE_LOCAL_SERVER;
            m_singleServer.Tag                = server.Duplicate();

            Connect(m_singleServer);
            BrowseTV.Nodes.Add(m_singleServer);
        }
        /// <summary>
        /// Browses the address space for a single server.
        /// </summary>
        public void ShowSingleServer(TsCDaServer server, TsCDaBrowseFilters filters)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            Clear();

            mFilters_ = (filters == null)?new TsCDaBrowseFilters():filters;

            browseTv_.ContextMenuStrip = popupMenu_;

            mSingleServer_                    = new TreeNode(server.ServerName);
            mSingleServer_.ImageIndex         = Resources.IMAGE_LOCAL_SERVER;
            mSingleServer_.SelectedImageIndex = Resources.IMAGE_LOCAL_SERVER;
            mSingleServer_.Tag                = server.Duplicate();

            Connect(mSingleServer_);
            browseTv_.Nodes.Add(mSingleServer_);
        }
Example #16
0
        /// <summary>
        /// Displays the address space for the specified server.
        /// </summary>
        public void Initialize(TsCDaServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            m_server = server;

            TsCDaBrowseFilters filters = new TsCDaBrowseFilters();

            filters.ReturnAllProperties  = true;
            filters.ReturnPropertyValues = true;

            BrowseCTRL.ShowSingleServer(m_server, filters);

            ShowDialog();

            // ensure server connection in the browse control are closed.
            BrowseCTRL.Clear();
        }
        /// <summary>
        /// Displays the address space for the specified server.
        /// </summary>
        public void Initialize(Technosoftware.DaAeHdaClient.Da.TsCDaServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            mServer_ = server;

            TsCDaBrowseFilters filters = new TsCDaBrowseFilters();

            filters.ReturnAllProperties  = true;
            filters.ReturnPropertyValues = true;

            browseCtrl_.ShowSingleServer(mServer_, filters);
            propertiesCtrl_.Initialize(null);

            ShowDialog();

            // ensure server connection in the browse control are closed.
            browseCtrl_.Clear();
        }
Example #18
0
		void BrowseChildren(OpcItem opcItem, TsCDaBrowseFilters filters,
			IList<TsCDaBrowseElement> elementList, TsCDaServer server)
		{
			TsCDaBrowsePosition position;
			OpcItem path;

			var elements = server.Browse(opcItem, filters, out position);

			if (elements != null)
			{
				foreach (var item in elements)
				{
					item.ItemPath = opcItem.ItemPath + OpcDaTag.SPLITTER + item.ItemName;
					elementList.Add(item);

					if (!item.IsItem)
					{
						path = new OpcItem(item.ItemPath, item.ItemName);
						BrowseChildren(path, filters, elementList, server);
					}
				}
			}
		}
Example #19
0
        /// <summary>
        /// Continues a browse operation with previously specified search criteria.
        /// </summary>
        /// <param name="position">An object containing the browse operation state information.</param>
        /// <returns>The set of elements found.</returns>
        public virtual TsCDaBrowseElement[] BrowseNext(ref Technosoftware.DaAeHdaClient.Da.TsCDaBrowsePosition position)
        {
            lock (this)
            {
                if (m_server == null)
                {
                    throw new NotConnectedException();
                }
                string methodName = "IOPCBrowse.Browse";

                // check for valid position object.
                if (position == null || position.GetType() != typeof(Technosoftware.DaAeHdaClient.Com.Da.BrowsePosition))
                {
                    throw new BrowseCannotContinueException();
                }

                Technosoftware.DaAeHdaClient.Com.Da.BrowsePosition pos = (Technosoftware.DaAeHdaClient.Com.Da.BrowsePosition)position;

                // check for valid continuation point.
                if (pos == null || pos.ContinuationPoint == null || pos.ContinuationPoint == "")
                {
                    throw new BrowseCannotContinueException();
                }

                // initialize arguments.
                int count        = 0;
                int moreElements = 0;

                OpcItem            itemID  = ((BrowsePosition)position).ItemID;
                TsCDaBrowseFilters filters = ((BrowsePosition)position).Filters;

                IntPtr pContinuationPoint = Marshal.StringToCoTaskMemUni(pos.ContinuationPoint);
                IntPtr pElements          = IntPtr.Zero;

                // invoke COM method.
                try
                {
                    IOPCBrowse server = BeginComCall <IOPCBrowse>(methodName, true);
                    server.Browse(
                        (itemID != null && itemID.ItemName != null) ? itemID.ItemName : "",
                        ref pContinuationPoint,
                        filters.MaxElementsReturned,
                        Technosoftware.DaAeHdaClient.Com.Da.Interop.GetBrowseFilter(filters.BrowseFilter),
                        (filters.ElementNameFilter != null) ? filters.ElementNameFilter : "",
                        (filters.VendorFilter != null) ? filters.VendorFilter : "",
                        (filters.ReturnAllProperties) ? 1 : 0,
                        (filters.ReturnPropertyValues) ? 1 : 0,
                        (filters.PropertyIDs != null) ? filters.PropertyIDs.Length : 0,
                        Technosoftware.DaAeHdaClient.Com.Da.Interop.GetPropertyIDs(filters.PropertyIDs),
                        out moreElements,
                        out count,
                        out pElements);
                }
                catch (Exception e)
                {
                    ComCallError(methodName, e);
                    throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException(methodName, e);
                }
                finally
                {
                    EndComCall(methodName);
                }

                // unmarshal results.
                TsCDaBrowseElement[] elements = Technosoftware.DaAeHdaClient.Com.Da.Interop.GetBrowseElements(ref pElements, count, true);

                pos.ContinuationPoint = Marshal.PtrToStringUni(pContinuationPoint);
                Marshal.FreeCoTaskMem(pContinuationPoint);

                // check if more no results exist.
                if (moreElements == 0 && (pos.ContinuationPoint == null || pos.ContinuationPoint == ""))
                {
                    position = null;
                }

                // process results.
                ProcessResults(elements, filters.PropertyIDs);

                return(elements);
            }
        }
Example #20
0
        /// <summary>
        /// Fetches the children of a branch that meet the filter criteria.
        /// </summary>
        /// <param name="itemID">The identifier of branch which is the target of the search.</param>
        /// <param name="filters">The filters to use to limit the set of child elements returned.</param>
        /// <param name="position">An object used to continue a browse that could not be completed.</param>
        /// <returns>The set of elements found.</returns>
        public virtual TsCDaBrowseElement[] Browse(
            OpcItem itemID,
            TsCDaBrowseFilters filters,
            out Technosoftware.DaAeHdaClient.Da.TsCDaBrowsePosition position)
        {
            if (filters == null)
            {
                throw new ArgumentNullException(nameof(filters));
            }

            lock (this)
            {
                if (m_server == null)
                {
                    throw new NotConnectedException();
                }
                string methodName = "IOPCBrowse.Browse";

                position = null;

                // initialize arguments.
                int count        = 0;
                int moreElements = 0;

                IntPtr pContinuationPoint = IntPtr.Zero;
                IntPtr pElements          = IntPtr.Zero;

                // invoke COM method.
                try
                {
                    IOPCBrowse server = BeginComCall <IOPCBrowse>(methodName, true);
                    server.Browse(
                        (itemID != null && itemID.ItemName != null) ? itemID.ItemName : "",
                        ref pContinuationPoint,
                        filters.MaxElementsReturned,
                        Technosoftware.DaAeHdaClient.Com.Da.Interop.GetBrowseFilter(filters.BrowseFilter),
                        (filters.ElementNameFilter != null) ? filters.ElementNameFilter : "",
                        (filters.VendorFilter != null) ? filters.VendorFilter : "",
                        (filters.ReturnAllProperties) ? 1 : 0,
                        (filters.ReturnPropertyValues) ? 1 : 0,
                        (filters.PropertyIDs != null) ? filters.PropertyIDs.Length : 0,
                        Technosoftware.DaAeHdaClient.Com.Da.Interop.GetPropertyIDs(filters.PropertyIDs),
                        out moreElements,
                        out count,
                        out pElements);
                }
                catch (Exception e)
                {
                    ComCallError(methodName, e);
                    throw Technosoftware.DaAeHdaClient.Com.Interop.CreateException(methodName, e);
                }
                finally
                {
                    EndComCall(methodName);
                }

                // unmarshal results.
                TsCDaBrowseElement[] elements = Technosoftware.DaAeHdaClient.Com.Da.Interop.GetBrowseElements(ref pElements, count, true);

                string continuationPoint = Marshal.PtrToStringUni(pContinuationPoint);
                Marshal.FreeCoTaskMem(pContinuationPoint);

                // check if more results exist.
                if (moreElements != 0 || (continuationPoint != null && continuationPoint != ""))
                {
                    // allocate new browse position object.
                    position = new Technosoftware.DaAeHdaClient.Com.Da.BrowsePosition(itemID, filters, continuationPoint);
                }

                // process results.
                ProcessResults(elements, filters.PropertyIDs);

                return(elements);
            }
        }
        /// <summary>
        /// Fetches the item id for the data filters items and stores it in the internal cache.
        /// </summary>
        /// <param name="server">The server object</param>
        public void GetDataFilterItem(TsCDaServer server)
        {
            _filterItem = null;

            // not a valid operation for data filter items.
            if (_unfilteredItemID != null)
            {
                return;
            }

            TsCDaBrowsePosition position = null;

            try
            {
                OpcItem itemID = new OpcItem(this);

                // browse any existing filter instances.
                TsCDaBrowseFilters filters = new TsCDaBrowseFilters {
                    ElementNameFilter = CPX_DATA_FILTERS, BrowseFilter = TsCDaBrowseFilter.All, ReturnAllProperties = false, PropertyIDs = null, ReturnPropertyValues = false
                };

                TsCDaBrowseElement[] elements = null;

                // browse for the 'CPX' branch first.
                if (_unconvertedItemID == null)
                {
                    filters.ElementNameFilter = CPX_BRANCH;

                    elements = server.Browse(itemID, filters, out position);

                    // nothing found.
                    if (elements == null || elements.Length == 0)
                    {
                        return;
                    }

                    // release the position object.
                    if (position != null)
                    {
                        position.Dispose();
                        position = null;
                    }

                    // update the item for the next browse operation.
                    itemID = new OpcItem(elements[0].ItemPath, elements[0].ItemName);

                    filters.ElementNameFilter = CPX_DATA_FILTERS;
                }

                // browse for the 'DataFilters' branch.
                elements = server.Browse(itemID, filters, out position);

                // nothing found.
                if (elements == null || elements.Length == 0)
                {
                    return;
                }

                _filterItem = new OpcItem(elements[0].ItemPath, elements[0].ItemName);
            }
            finally
            {
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
        }
		void BrowseChildren(OpcItem opcItem, TsCDaBrowseFilters filters, 
			IList<TsCDaBrowseElement> elementList)
		{
			TsCDaBrowsePosition position;
			OpcItem path;

			var elements = _activeOpcServer.Browse(opcItem, filters, out position);

			if (elements != null)
			{
				foreach (var item in elements)
				{
					item.ItemPath = opcItem.ItemPath + SPLITTER + item.ItemName;
					elementList.Add(item);

					if (!item.IsItem)
					{
						//if (item.HasChildren)
						//{
						path = new OpcItem(item.ItemPath, item.ItemName);
						BrowseChildren(path, filters, elementList);
						//}
					}
				}
			}
		}
        /// <summary>
        /// Fetches the set of type conversions from the server.
        /// </summary>
        /// <param name="server">The server object</param>
        public TsCCpxComplexItem[] GetTypeConversions(TsCDaServer server)
        {
            // only the root item can have type conversions.
            if (_unconvertedItemID != null || _unfilteredItemID != null)
            {
                return(null);
            }

            TsCDaBrowsePosition position = null;

            try
            {
                // look for the 'CPX' branch.
                TsCDaBrowseFilters filters = new TsCDaBrowseFilters {
                    ElementNameFilter = CPX_BRANCH, BrowseFilter = TsCDaBrowseFilter.Branch, ReturnAllProperties = false, PropertyIDs = null, ReturnPropertyValues = false
                };

                TsCDaBrowseElement[] elements = server.Browse(this, filters, out position);

                // nothing found.
                if (elements == null || elements.Length == 0)
                {
                    return(null);
                }

                // release the browse position object.
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }

                // browse for type conversions.
                OpcItem itemID = new OpcItem(elements[0].ItemPath, elements[0].ItemName);

                filters.ElementNameFilter    = null;
                filters.BrowseFilter         = TsCDaBrowseFilter.Item;
                filters.ReturnAllProperties  = false;
                filters.PropertyIDs          = CPX_PROPERTIES;
                filters.ReturnPropertyValues = true;

                elements = server.Browse(itemID, filters, out position);

                // nothing found.
                if (elements == null || elements.Length == 0)
                {
                    return(new TsCCpxComplexItem[0]);
                }

                // contruct an array of complex data items for each available conversion.
                ArrayList conversions = new ArrayList(elements.Length);

                Array.ForEach(elements, element =>
                {
                    if (element.Name != CPX_DATA_FILTERS)
                    {
                        TsCCpxComplexItem item = new TsCCpxComplexItem();
                        if (item.Init(element))
                        {
                            // check if data filters supported for type conversion.
                            item.GetDataFilterItem(server);
                            conversions.Add(item);
                        }
                    }
                });

                // return the set of available conversions.
                return((TsCCpxComplexItem[])conversions.ToArray(typeof(TsCCpxComplexItem)));
            }
            finally
            {
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
        }
        /// <summary>
        /// Creates a new data filter.
        /// </summary>
        /// <param name="server">The server object</param>
        /// <param name="filterName">The name of the filter</param>
        /// <param name="filterValue">The value of the filter</param>
        public TsCCpxComplexItem CreateDataFilter(TsCDaServer server, string filterName, string filterValue)
        {
            // not a valid operation for data filter items.
            if (_unfilteredItemID != null)
            {
                return(null);
            }

            // data filters not supported by the item.
            if (_filterItem == null)
            {
                return(null);
            }

            TsCDaBrowsePosition position = null;

            try
            {
                // write the desired filter to the server.
                TsCDaItemValue item = new TsCDaItemValue(_filterItem);

                // create the filter parameters document.
                using (StringWriter ostrm = new StringWriter())
                {
                    using (XmlTextWriter writer = new XmlTextWriter(ostrm))
                    {
                        writer.WriteStartElement("DataFilters");
                        writer.WriteAttributeString("Name", filterName);
                        writer.WriteString(filterValue);
                        writer.WriteEndElement();
                        writer.Close();
                    }
                    // create the value to write.
                    item.Value = ostrm.ToString();
                }
                item.Quality            = TsCDaQuality.Bad;
                item.QualitySpecified   = false;
                item.Timestamp          = DateTime.MinValue;
                item.TimestampSpecified = false;

                // write the value.
                OpcItemResult[] result = server.Write(new TsCDaItemValue[] { item });

                if (result == null || result.Length == 0)
                {
                    throw new OpcResultException(new OpcResult((int)OpcResult.E_FAIL.Code, OpcResult.FuncCallType.SysFuncCall, null), "Unexpected results returned from server.");
                }

                if (result[0].Result.Failed())
                {
                    throw new OpcResultException(new OpcResult((int)OpcResult.Cpx.E_FILTER_ERROR.Code, OpcResult.FuncCallType.SysFuncCall, null), "Could not create new data filter.");
                }

                // browse for new data filter item.
                TsCDaBrowseFilters filters = new TsCDaBrowseFilters {
                    ElementNameFilter = filterName, BrowseFilter = TsCDaBrowseFilter.Item, ReturnAllProperties = false, PropertyIDs = CPX_PROPERTIES, ReturnPropertyValues = true
                };

                TsCDaBrowseElement[] elements = server.Browse(_filterItem, filters, out position);

                // nothing found.
                if (elements == null || elements.Length == 0)
                {
                    throw new OpcResultException(new OpcResult((int)OpcResult.Cpx.E_FILTER_ERROR.Code, OpcResult.FuncCallType.SysFuncCall, null), "Could not browse to new data filter.");
                }

                TsCCpxComplexItem filterItem = new TsCCpxComplexItem();

                if (!filterItem.Init(elements[0]))
                {
                    throw new OpcResultException(new OpcResult((int)OpcResult.Cpx.E_FILTER_ERROR.Code, OpcResult.FuncCallType.SysFuncCall, null), "Could not initialize to new data filter.");
                }

                // return the new data filter.
                return(filterItem);
            }
            finally
            {
                if (position != null)
                {
                    position.Dispose();
                    position = null;
                }
            }
        }
		TsCDaBrowseElement[] Browse()
		{
			TsCDaBrowseFilters filters;
			List<TsCDaBrowseElement> elementList; 
			TsCDaBrowseElement[] elements;
			TsCDaBrowsePosition position;
			OpcItem path = new OpcItem();

			filters = new TsCDaBrowseFilters();
			filters.BrowseFilter = TsCDaBrowseFilter.All;
			filters.ReturnAllProperties = true;
			filters.ReturnPropertyValues = true;

			elementList = new List<TsCDaBrowseElement>();

			elements = _activeOpcServer.Browse(path, filters, out position);
		
			foreach(var item in elements)
			{
				//!!! OpcItem.ItemPath всегда равно null и видимо не участвует в коде. Буду заполнять руками
				item.ItemPath = ROOT + SPLITTER + item.ItemName;
				elementList.Add(item);
				
				if (!item.IsItem)
				{
					//if (item.HasChildren) На данный момент это не работает. Если элемент это группа, то всега true
					//{
						path = new OpcItem(item.ItemPath, item.Name);
						BrowseChildren(path, filters, elementList);
					//}
				}
				
			}
			return elementList.ToArray();
		}