/// <summary> /// Continues browsing the server's address space at the specified position. /// </summary> /// <param name="maxElements">The maximum number of elements to return.</param> /// <param name="position">The position object used to continue a browse operation.</param> /// <returns>The set of elements that meet the filter criteria.</returns> public TsCAeBrowseElement[] BrowseNext(int maxElements, ref IOpcBrowsePosition position) { LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); if (Server == null) { throw new NotConnectedException(); } return(((ITsCAeServer)Server).BrowseNext(maxElements, ref position)); }
//====================================================================== // Browse /// <summary> /// Browses the server's address space at the specified branch. /// </summary> /// <param name="itemID">The item id of the branch to search.</param> /// <returns>The set of elements that meet the filter criteria.</returns> public TsCHdaBrowseElement[] Browse(OpcItem itemID) { IOpcBrowsePosition position = null; TsCHdaBrowseElement[] elements = Browse(itemID, 0, out position); if (position != null) { position.Dispose(); } return(elements); }
/// <summary> /// Browses for all children of the specified area that meet the filter criteria. /// </summary> /// <param name="areaID">The full-qualified id for the area.</param> /// <param name="browseType">The type of children to return.</param> /// <param name="browseFilter">The expression used to filter the names of children returned.</param> /// <param name="maxElements">The maximum number of elements to return.</param> /// <param name="position">The object used to continue the browse if the number nodes exceeds the maximum specified.</param> /// <returns>The set of elements that meet the filter criteria.</returns> public Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseElement[] Browse( string areaID, Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType browseType, string browseFilter, int maxElements, out IOpcBrowsePosition position) { if (_server == null) { throw new NotConnectedException(); } return(((ITsCAeServer)_server).Browse(areaID, browseType, browseFilter, maxElements, out position)); }
/// <summary> /// Browses for all children of the specified area that meet the filter criteria. /// </summary> /// <param name="areaId">The full-qualified id for the area.</param> /// <param name="browseType">The type of children to return.</param> /// <param name="browseFilter">The expression used to filter the names of children returned.</param> /// <param name="maxElements">The maximum number of elements to return.</param> /// <param name="position">The object used to continue the browse if the number nodes exceeds the maximum specified.</param> /// <returns>The set of elements that meet the filter criteria.</returns> public TsCAeBrowseElement[] Browse( string areaId, TsCAeBrowseType browseType, string browseFilter, int maxElements, out IOpcBrowsePosition position) { LicenseHandler.ValidateFeatures(LicenseHandler.ProductFeature.AlarmsConditions); if (Server == null) { throw new NotConnectedException(); } return(((ITsCAeServer)Server).Browse(areaId, browseType, browseFilter, maxElements, out position)); }
/// <summary> /// Continues browsing the server's address space at the specified position. /// </summary> /// <param name="maxElements">The maximum number of elements to return.</param> /// <param name="position">The position object used to continue a browse operation.</param> /// <returns>The set of elements that meet the filter criteria.</returns> public Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseElement[] BrowseNext(int maxElements, ref IOpcBrowsePosition position) { if (_server == null) { throw new NotConnectedException(); } return(((ITsCAeServer)_server).BrowseNext(maxElements, ref position)); }
/// <summary> /// Browses for child nodes and populates the tree. /// </summary> private void Browse(TreeNode parent, TsCHdaBrowseElement branch) { // clear existing children. parent.Nodes.Clear(); // browse for the children of the node. TsCHdaBrowseElement[] children = null; IOpcBrowsePosition position = null; do { // fetch next batch of elements from the server. try { if (position == null) { children = m_browser.Browse(branch, m_maxElements, out position); } else { children = m_browser.BrowseNext(m_maxElements, ref position); } } catch (Exception e) { MessageBox.Show(e.Message); break; } // nothing more to do. if (children == null) { break; } // create a tree node for each child. foreach (TsCHdaBrowseElement child in children) { // create new node. TreeNode node = new TreeNode(child.Name); // set node icon. if (child.IsItem) { node.ImageIndex = Resources.IMAGE_GREEN_SCROLL; node.SelectedImageIndex = Resources.IMAGE_GREEN_SCROLL; } else { node.ImageIndex = Resources.IMAGE_CLOSED_YELLOW_FOLDER; node.SelectedImageIndex = Resources.IMAGE_CLOSED_YELLOW_FOLDER; } // save element. node.Tag = child; // add dummy child node for branches. if (child.HasChildren) { node.Nodes.Add(new TreeNode()); } // add top level node to root node. parent.Nodes.Add(node); } // prompt use to continue browse operation. if (position != null) { if (MessageBox.Show("More items exist. Continue browsing?", "Browse Items", MessageBoxButtons.YesNo) == DialogResult.No) { break; } } }while (position != null); // release browse position object if browse halted. if (position != null) { position.Dispose(); position = null; } }
//====================================================================== // BrowseNext /// <summary> /// Continues browsing the server's address space at the specified position. /// </summary> /// <param name="maxElements">The maximum number of elements to return.</param> /// <param name="position">The position object used to continue a browse operation.</param> /// <returns>The set of elements that meet the filter criteria.</returns> public TsCHdaBrowseElement[] BrowseNext(int maxElements, ref IOpcBrowsePosition position) { // check arguments. if (position == null || position.GetType() != typeof(BrowsePosition)) { throw new ArgumentException("Not a valid browse position object.", nameof(position)); } // interpret invalid values as 'no limit'. if (maxElements <= 0) { maxElements = Int32.MaxValue; } lock (this) { BrowsePosition pos = (BrowsePosition)position; ArrayList elements = new ArrayList(); if (!pos.FetchingItems) { elements = FetchElements(pos.Enumerator, maxElements, true); // check if max element count reached. if (elements.Count >= maxElements) { return((TsCHdaBrowseElement[])elements.ToArray(typeof(TsCHdaBrowseElement))); } // release enumerator. pos.Enumerator.Dispose(); pos.Enumerator = null; pos.FetchingItems = true; // move to the correct position in the server's address space. try { m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, pos.BranchPath); } catch (Exception e) { throw Utilities.Interop.CreateException("IOPCHDA_Browser.ChangeBrowsePosition", e); } // create enumerator for items. pos.Enumerator = GetEnumerator(false); } // fetch next set of items. ArrayList items = FetchElements(pos.Enumerator, maxElements - elements.Count, false); if (items != null) { elements.AddRange(items); } // check if max element count reached. if (elements.Count >= maxElements) { return((TsCHdaBrowseElement[])elements.ToArray(typeof(TsCHdaBrowseElement))); } // release position object. position.Dispose(); position = null; // return elements. return((TsCHdaBrowseElement[])elements.ToArray(typeof(TsCHdaBrowseElement))); } }
/// <summary> /// Begins a browsing the server's address space at the specified branch. /// </summary> /// <param name="itemID">The item id of the branch to search.</param> /// <param name="maxElements">The maximum number of elements to return.</param> /// <param name="position">The position object used to continue a browse operation.</param> /// <returns>The set of elements that meet the filter criteria.</returns> public TsCHdaBrowseElement[] Browse(OpcItem itemID, int maxElements, out IOpcBrowsePosition position) { position = null; // interpret invalid values as 'no limit'. if (maxElements <= 0) { maxElements = Int32.MaxValue; } lock (this) { string branchPath = (itemID != null && itemID.ItemName != null)?itemID.ItemName:""; // move to the correct position in the server's address space. try { m_browser.ChangeBrowsePosition(OPCHDA_BROWSEDIRECTION.OPCHDA_BROWSE_DIRECT, branchPath); } catch (Exception e) { throw Utilities.Interop.CreateException("IOPCHDA_Browser.ChangeBrowsePosition", e); } // browse for branches EnumString enumerator = GetEnumerator(true); ArrayList elements = FetchElements(enumerator, maxElements, true); // check if max element count reached. if (elements.Count >= maxElements) { position = new BrowsePosition(branchPath, enumerator, false); return((TsCHdaBrowseElement[])elements.ToArray(typeof(TsCHdaBrowseElement))); } // release enumerator. enumerator.Dispose(); // browse for items enumerator = GetEnumerator(false); ArrayList items = FetchElements(enumerator, maxElements - elements.Count, false); if (items != null) { elements.AddRange(items); } // check if max element count reached. if (elements.Count >= maxElements) { position = new BrowsePosition(branchPath, enumerator, true); return((TsCHdaBrowseElement[])elements.ToArray(typeof(TsCHdaBrowseElement))); } // release enumerator. enumerator.Dispose(); return((TsCHdaBrowseElement[])elements.ToArray(typeof(TsCHdaBrowseElement))); } }
/// <summary> /// Populates the tree with the elements within the specified area. /// </summary> private void BrowseArea(TreeNodeCollection nodes, Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType browseType, Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseElement area) { IOpcBrowsePosition position = null; try { // fetch first batch of elements. Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseElement[] elements = mServer_.Browse( area?.QualifiedName, browseType, mBrowseFilter_, mMaxElements_, out position); do { // add elements to tree. for (int ii = 0; ii < elements.Length; ii++) { // create node. TreeNode node = new TreeNode(elements[ii].Name) { ImageIndex = (browseType == Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType.Area) ? Resources.IMAGE_CLOSED_BLUE_FOLDER : Resources.IMAGE_GREEN_SCROLL, SelectedImageIndex = (browseType == Technosoftware.DaAeHdaClient.Ae.TsCAeBrowseType.Area) ? Resources.IMAGE_OPEN_BLUE_FOLDER : Resources.IMAGE_GREEN_SCROLL, Tag = elements[ii] }; // add dummy child to ensure '+' sign is visible. node.Nodes.Add(new TreeNode()); // add to tree. nodes.Add(node); } // check if browse is complete. if (position == null) { break; } // prompt to continue browse. DialogResult result = MessageBox.Show( "More elements meeting search criteria exist. Continue browse?", "Browse " + browseType + "s", MessageBoxButtons.YesNo); if (result == DialogResult.No) { break; } // continue browse. elements = mServer_.BrowseNext(mMaxElements_, ref position); }while (true); } finally { // dipose position object on exit. if (position != null) { position.Dispose(); position = null; } } }