public List <ReferenceDescription> Browse(Session session, NodeId nodeId) { BrowseContext context = new BrowseContext(); context.BrowseDirection = BrowseDirection.Forward; context.ReferenceTypeId = ReferenceTypeIds.HierarchicalReferences; context.IncludeSubtypes = true; context.MaxReferencesToReturn = 0; byte[] continuationPoint = null; List <ReferenceDescription> references = session.Browse(nodeId, context, new RequestSettings() { OperationTimeout = 10000 }, out continuationPoint); List <ReferenceDescription> ret = new List <ReferenceDescription>(); foreach (ReferenceDescription reference in references) { ret.Add(reference); } // process any continuation points. while (!ByteString.IsNull(continuationPoint)) { references = session.BrowseNext(new RequestSettings() { OperationTimeout = 10000 }, ref continuationPoint); foreach (ReferenceDescription reference in references) { ret.Add(reference); } } return(ret); }
private RemoteHelper(OpcUaSession session) { _session = session; _parentNode = null; _browseContext = new BrowseContext { BrowseDirection = BrowseDirection.Forward, ReferenceTypeId = ReferenceTypeIds.HierarchicalReferences, IncludeSubtypes = true, MaxReferencesToReturn = 0 }; _session.ConnectionStatusUpdate += SessionOnConnectionStatusUpdate; }
protected List <ReferenceDescription> BrowseFolder(NodeId FolderNodeId) { var nodeReferences = new List <ReferenceDescription>(); try { if (_session == null) { return(nodeReferences); } BrowseContext context = new BrowseContext { BrowseDirection = BrowseDirection.Forward, ReferenceTypeId = ReferenceTypeIds.Organizes, MaxReferencesToReturn = MAX_NODES_TO_RETURN, IncludeSubtypes = true }; //byte[] continuationPoint = null; nodeReferences = _session.Browse( FolderNodeId, context, new RequestSettings { OperationTimeout = 10 * SECONDS }, out byte[] continuationPoint); } catch (Exception exception) { log.Error("Error in BrowseFolder", exception); } return(nodeReferences); }
/// <summary> /// Call the Browse service of an UA server. /// </summary> /// <param name="parentNode">The node of the treeview to browse.</param> public int Browse(TreeNode parentNode) { NodeId nodeToBrowse = null; TreeNodeCollection parentCollection = null; int ret = 0; // Check if we browse from root if (parentNode == null) { nodeToBrowse = new NodeId(Objects.RootFolder, 0); // Get all the tree nodes that are assigned to the control parentCollection = tvBrowseTree.Nodes; } else { // Get the data about the parent tree node ReferenceDescription parentRefDescription = (ReferenceDescription)parentNode.Tag; if (parentRefDescription == null) { return(-1); } // XXX ToDo // set nodeid nodeToBrowse = ExpandedNodeId.ToNodeId(parentRefDescription.NodeId, Session.NamespaceUris); parentCollection = parentNode.Nodes; } bool bBrowse; // Set wait cursor. Cursor.Current = Cursors.WaitCursor; // Check if we want to browse on the server. if (m_RebrowseOnExpandNode) { bBrowse = true; } else if (parentNode == null) { bBrowse = true; } else if (parentNode.Checked) { bBrowse = false; } else { bBrowse = true; } // Delete children if required. if (bBrowse) { if (parentNode == null) { BrowseTree.BeginUpdate(); BrowseTree.Nodes.Clear(); BrowseTree.EndUpdate(); } else { BrowseTree.BeginUpdate(); parentNode.Nodes.Clear(); BrowseTree.EndUpdate(); } byte[] continuationPoint; List <ReferenceDescription> results; BrowseContext browseContext = new BrowseContext() { BrowseDirection = BrowseDirection.Forward, ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.HierarchicalReferences, IncludeSubtypes = true, NodeClassMask = 0, ResultMask = (uint)BrowseResultMask.All, MaxReferencesToReturn = 100 }; try { // Call browse service. results = m_Session.Browse( nodeToBrowse, browseContext, out continuationPoint); // Add children. tvBrowseTree.BeginUpdate(); // Mark parent node as browsed. if (parentNode != null) { parentNode.Checked = true; } AddResultsToTree(parentCollection, results); while (continuationPoint != null) { results = m_Session.BrowseNext(ref continuationPoint); AddResultsToTree(parentCollection, results); } // Sort the tree nodes of the particular node collection this.SortTreeNode((parentNode == null) ? tvBrowseTree.Nodes : parentNode.Nodes); tvBrowseTree.EndUpdate(); // Update status label. OnUpdateStatusLabel("Browse succeeded.", true); } catch (Exception e) { ret = -1; // Update status label. OnUpdateStatusLabel("An exception occured while browsing: " + e.Message, false); } } // Restore default cursor. Cursor.Current = Cursors.Default; return(ret); }