/// <summary> /// Creates a new browser object with a set of filters. /// </summary> public Browser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable<IReference> additionalReferences, bool internalOnly, Opc.Ua.Client.Session client, NamespaceMapper mapper, NodeState source, NodeId rootId) : base( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly) { m_client = client; m_mapper = mapper; m_source = source; m_rootId = rootId; m_stage = Stage.Begin; }
/// <summary> /// Creates a new browser object with a set of filters. /// </summary> /// <param name="context">The system context to use.</param> /// <param name="view">The view which may restrict the set of references/nodes found.</param> /// <param name="referenceType">The type of references being followed.</param> /// <param name="includeSubtypes">Whether subtypes of the reference type are followed.</param> /// <param name="browseDirection">Which way the references are being followed.</param> /// <param name="browseName">The browse name of a specific target (used when translating browse paths).</param> /// <param name="additionalReferences">Any additional references that should be included.</param> /// <param name="internalOnly">If true the browser should not making blocking calls to external systems.</param> /// <param name="itemId">The item id.</param> /// <param name="namespaceIndex">Index of the namespace.</param> public DaElementBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable <IReference> additionalReferences, bool internalOnly, string itemId, ushort namespaceIndex) : base( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly) { m_itemId = itemId; m_namespaceIndex = namespaceIndex; m_stage = Stage.Begin; }
/// <summary> /// Creates a new browser object with a set of filters. /// </summary> public NodeBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable<IReference> additionalReferences, bool internalOnly) { m_context = context; m_view = view; m_referenceType = referenceType; m_includeSubtypes = includeSubtypes; m_browseDirection = browseDirection; m_browseName = browseName; m_internalOnly = internalOnly; m_references = new List<IReference>(); m_index = 0; // add any additional references if they meet the criteria. if (additionalReferences != null) { foreach (IReference reference in additionalReferences) { if (IsRequired(reference.ReferenceTypeId, reference.IsInverse)) { m_references.Add(reference); } } } }
/// <summary> /// Creates a new browser object with a set of filters. /// </summary> public AreaBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable<IReference> additionalReferences, bool internalOnly, AreaState area) : base( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly) { m_stage = Stage.Begin; if (area != null) { m_area = AreaState.GetDirectory(context, area.NodeId); m_isRoot = area.IsRoot; } }
/// <summary> /// Creates a new browser object with a set of filters. /// </summary> public NodeBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable <IReference> additionalReferences, bool internalOnly) { m_context = context; m_view = view; m_referenceType = referenceType; m_includeSubtypes = includeSubtypes; m_browseDirection = browseDirection; m_browseName = browseName; m_internalOnly = internalOnly; m_references = new List <IReference>(); m_index = 0; // add any additional references if they meet the criteria. if (additionalReferences != null) { foreach (IReference reference in additionalReferences) { if (IsRequired(reference.ReferenceTypeId, reference.IsInverse)) { m_references.Add(reference); } } } }
/// <summary> /// Creates a new browser object with a set of filters. /// </summary> public AreaBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable <IReference> additionalReferences, bool internalOnly, AreaState area) : base( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly) { m_stage = Stage.Begin; if (area != null) { m_area = AreaState.GetDirectory(context, area.NodeId); m_isRoot = area.IsRoot; } }
/// <summary> /// Creates a browser that finds the references to the branch. /// </summary> /// <param name="context">The system context to use.</param> /// <param name="view">The view which may restrict the set of references/nodes found.</param> /// <param name="referenceType">The type of references being followed.</param> /// <param name="includeSubtypes">Whether subtypes of the reference type are followed.</param> /// <param name="browseDirection">Which way the references are being followed.</param> /// <param name="browseName">The browse name of a specific target (used when translating browse paths).</param> /// <param name="additionalReferences">Any additional references that should be included.</param> /// <param name="internalOnly">If true the browser should not making blocking calls to external systems.</param> /// <returns>The browse object (must be disposed).</returns> public override INodeBrowser CreateBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable <IReference> additionalReferences, bool internalOnly) { NodeBrowser browser = new HdaElementBrower( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly, m_itemId, TypeDefinitionId, BrowseName, this.NodeId.NamespaceIndex); PopulateBrowser(context, browser); return(browser); }
/// <summary> /// Adds the targets of references to the control. /// </summary> private void AddReferences(NodeId referenceTypeId, BrowseDirection browseDirection) { // fetch the attributes for the reference type. INode referenceType = m_session.NodeCache.Find(referenceTypeId); if (referenceType == null) { return; } // browse for the references. Browser browser = new Browser(m_session); browser.BrowseDirection = browseDirection; browser.ReferenceTypeId = referenceTypeId; browser.IncludeSubtypes = true; browser.NodeClassMask = 0; browser.ContinueUntilDone = true; ReferenceDescriptionCollection references = browser.Browse(m_nodeId); // add results to list. foreach (ReferenceDescription reference in references) { NodeField field = new NodeField(); field.Name = referenceType.ToString(); field.Value = reference.ToString(); field.StatusCode = StatusCodes.Good; AddItem(field, "ReferenceType", -1); } }
/// <summary> /// Creates a browser that explores the structure of the block. /// </summary> /// <param name="context">The system context to use.</param> /// <param name="view">The view which may restrict the set of references/nodes found.</param> /// <param name="referenceType">The type of references being followed.</param> /// <param name="includeSubtypes">Whether subtypes of the reference type are followed.</param> /// <param name="browseDirection">Which way the references are being followed.</param> /// <param name="browseName">The browse name of a specific target (used when translating browse paths).</param> /// <param name="additionalReferences">Any additional references that should be included.</param> /// <param name="internalOnly">If true the browser should not making blocking calls to external systems.</param> /// <returns>The browse object (must be disposed).</returns> public override INodeBrowser CreateBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable <IReference> additionalReferences, bool internalOnly) { NodeBrowser browser = new SegmentBrowser( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly, this); PopulateBrowser(context, browser); return(browser); }
/// <summary> /// Creates a new browser object with a set of filters. /// </summary> /// <param name="context">The system context to use.</param> /// <param name="view">The view which may restrict the set of references/nodes found.</param> /// <param name="referenceType">The type of references being followed.</param> /// <param name="includeSubtypes">Whether subtypes of the reference type are followed.</param> /// <param name="browseDirection">Which way the references are being followed.</param> /// <param name="browseName">The browse name of a specific target (used when translating browse paths).</param> /// <param name="additionalReferences">Any additional references that should be included.</param> /// <param name="internalOnly">If true the browser should not making blocking calls to external systems.</param> /// <param name="itemId">The item id.</param> /// <param name="namespaceIndex">Index of the namespace.</param> public DaElementBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable<IReference> additionalReferences, bool internalOnly, string itemId, ushort namespaceIndex) : base( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly) { m_itemId = itemId; m_namespaceIndex = namespaceIndex; m_stage = Stage.Begin; }
/// <summary> /// Creates a new browser object with a set of filters. /// </summary> public Browser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable <IReference> additionalReferences, bool internalOnly, Opc.Ua.Client.Session client, NamespaceMapper mapper, NodeState source, NodeId rootId) : base( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly) { m_client = client; m_mapper = mapper; m_source = source; m_rootId = rootId; m_stage = Stage.Begin; }
/// <summary> /// Displays the a root in the control. /// </summary> public void Initialize( Session session, NodeId rootId, NodeId viewId, NodeId referenceTypeId, BrowseDirection browseDirection) { m_session = session; m_rootId = rootId; m_viewId = viewId; m_referenceTypeId = referenceTypeId; m_browseDirection = browseDirection; NodesTV.Nodes.Clear(); if (m_session == null) { return; } if (NodeId.IsNull(m_rootId)) { m_rootId = Objects.RootFolder; } if (NodeId.IsNull(m_referenceTypeId)) { m_referenceTypeId = ReferenceTypeIds.HierarchicalReferences; } ReferenceTypeCTRL.Initialize(m_session, ReferenceTypeIds.HierarchicalReferences); ReferenceTypeCTRL.SelectedTypeId = m_referenceTypeId; ILocalNode root = m_session.NodeCache.Find(m_rootId) as ILocalNode; if (root == null) { return; } ReferenceDescription reference = new ReferenceDescription(); reference.ReferenceTypeId = referenceTypeId; reference.IsForward = true; reference.NodeId = root.NodeId; reference.NodeClass = root.NodeClass; reference.BrowseName = root.BrowseName; reference.DisplayName = root.DisplayName; reference.TypeDefinition = root.TypeDefinitionId; TreeNode rootNode = new TreeNode(reference.ToString()); rootNode.ImageKey = rootNode.SelectedImageKey = GuiUtils.GetTargetIcon(session, reference); rootNode.Tag = reference; rootNode.Nodes.Add(new TreeNode()); NodesTV.Nodes.Add(rootNode); }
/// <summary> /// Browse the tree nodes /// </summary> /// <param name="id"></param> /// <param name="parentId"></param> /// <param name="direction"></param> private async Task BrowseTreeAsync(BrowseDirection direction, int index, bool isLoadingMore, string id = null, List <string> parentId = null) { IsLoading = true; if (!isLoadingMore) { ParentId = parentId; Items = await BrowseManager.GetTreeAsync(EndpointId, id, parentId, DiscovererId, direction, index, Credential); } else { Items = await BrowseManager.GetTreeNextAsync(EndpointId, ParentId, DiscovererId, Credential, Items); } PublishedNodes = await Publisher.PublishedAsync(EndpointId, false); foreach (var node in Items.Results) { if (node.NodeClass == NodeClass.Variable) { node.Value = await BrowseManager.ReadValueAsync(EndpointId, node.Id, Credential); // check if publishing enabled foreach (var publishedNode in PublishedNodes.Results) { if (node.Id == publishedNode.PublishedItem.NodeId) { node.PublishedItem = publishedNode.PublishedItem; node.Publishing = true; break; } } } } if (string.IsNullOrEmpty(DiscovererId)) { NavigationManager.NavigateTo(NavigationManager.BaseUri + "browser/" + "/" + ApplicationId + "/" + EndpointId); } else { NavigationManager.NavigateTo(NavigationManager.BaseUri + "browser/" + "/" + DiscovererId + "/" + ApplicationId + "/" + SupervisorId + "/" + EndpointId); } IsLoading = false; }
/// <summary> /// Browse the tree nodes /// </summary> /// <param name="id"></param> /// <param name="parentId"></param> /// <param name="direction"></param> private async Task BrowseTreeAsync(BrowseDirection direction, int index, bool firstPage, int page, string id = null, List <string> parentId = null) { CommonHelper.Spinner = "loader-big"; if (firstPage) { ParentId = parentId; NodeList = await BrowseManager.GetTreeAsync(EndpointId, id, parentId, DiscovererId, direction, index, Credential); } else { NodeList = await BrowseManager.GetTreeNextAsync(EndpointId, ParentId, DiscovererId, Credential, NodeList); } PublishedNodes = await Publisher.PublishedAsync(EndpointId, false); foreach (var node in NodeList.Results) { if (node.NodeClass == NodeClass.Variable) { // check if publishing enabled foreach (var publishedNode in PublishedNodes.Results) { if (node.Id == publishedNode.PublishedItem.NodeId) { node.PublishedItem = publishedNode.PublishedItem; node.Publishing = true; break; } } } } PagedNodeList = NodeList.GetPaged(page, CommonHelper.PageLength, NodeList.Error); if (string.IsNullOrEmpty(DiscovererId)) { NavigationManager.NavigateTo(NavigationManager.BaseUri + "browser/" + page + "/" + ApplicationId + "/" + EndpointId); } else { NavigationManager.NavigateTo(NavigationManager.BaseUri + "browser/" + page + "/" + DiscovererId + "/" + ApplicationId + "/" + SupervisorId + "/" + EndpointId); } CommonHelper.Spinner = ""; }
internal static string ToSerializedValue(this BrowseDirection value) { switch (value) { case BrowseDirection.Forward: return("Forward"); case BrowseDirection.Backward: return("Backward"); case BrowseDirection.Both: return("Both"); } return(null); }
public BrowseDescription( NodeId Id, BrowseDirection Direction, NodeId ReferenceType, bool IncludeSubtypes, uint NodeClassMask, BrowseResultMask ResultMask) { this.Id = Id; this.Direction = Direction; this.ReferenceType = ReferenceType; this.IncludeSubtypes = IncludeSubtypes; this.NodeClassMask = NodeClassMask; this.ResultMask = ResultMask; }
/// <summary> /// Convert browse direction /// </summary> /// <param name="mode"></param> /// <returns></returns> public static UaBrowseDirection ToStackType(this BrowseDirection mode) { switch (mode) { case BrowseDirection.Forward: return(UaBrowseDirection.Forward); case BrowseDirection.Backward: return(UaBrowseDirection.Inverse); case BrowseDirection.Both: return(UaBrowseDirection.Both); default: return(UaBrowseDirection.Forward); } }
private void BrowseDirectionCTRL_SelectedIndexChanged(object sender, EventArgs e) { try { m_browseDirection = (BrowseDirection)BrowseDirectionCTRL.SelectedItem; if (NodesTV.SelectedNode != null) { NodesTV.SelectedNode.Collapse(); NodesTV.SelectedNode.Nodes.Clear(); NodesTV.SelectedNode.Nodes.Add(new TreeNode()); NodesTV.SelectedNode.Expand(); return; } } catch (Exception exception) { GuiUtils.HandleException(this.Text, MethodBase.GetCurrentMethod(), exception); } }
/// <summary> /// Async browse service /// </summary> /// <param name="client"></param> /// <param name="requestHeader"></param> /// <param name="view"></param> /// <param name="nodeToBrowse"></param> /// <param name="maxResultsToReturn"></param> /// <param name="browseDirection"></param> /// <param name="referenceTypeId"></param> /// <param name="includeSubtypes"></param> /// <param name="nodeClassMask"></param> /// <param name="resultMask"></param> /// <param name="ct"></param> /// <returns></returns> public static Task <BrowseResponse> BrowseAsync(this SessionClient client, RequestHeader requestHeader, ViewDescription view, NodeId nodeToBrowse, uint maxResultsToReturn, BrowseDirection browseDirection, NodeId referenceTypeId, bool includeSubtypes, uint nodeClassMask, BrowseResultMask resultMask = BrowseResultMask.All, CancellationToken ct = default) { return(client.BrowseAsync(requestHeader, view, maxResultsToReturn, new BrowseDescriptionCollection { new BrowseDescription { BrowseDirection = browseDirection, IncludeSubtypes = includeSubtypes, NodeClassMask = nodeClassMask, NodeId = nodeToBrowse, ReferenceTypeId = referenceTypeId, ResultMask = (uint)resultMask } }, ct)); }
/// <summary> /// Creates a new browser object with a set of filters. /// </summary> public MemoryRegisterBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable <IReference> additionalReferences, bool internalOnly, MemoryRegisterState parent) : base( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly) { _parent = parent; _stage = Stage.Begin; }
/// <summary> /// Creates a new browser object with a set of filters. /// </summary> public MemoryBufferBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable<IReference> additionalReferences, bool internalOnly, MemoryBufferState buffer) : base( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly) { m_buffer = buffer; m_stage = Stage.Begin; }
/// <summary> /// Creates a new browser object with a set of filters. /// </summary> /// <param name="context">The system context to use.</param> /// <param name="view">The view which may restrict the set of references/nodes found.</param> /// <param name="referenceType">The type of references being followed.</param> /// <param name="includeSubtypes">Whether subtypes of the reference type are followed.</param> /// <param name="browseDirection">Which way the references are being followed.</param> /// <param name="browseName">The browse name of a specific target (used when translating browse paths).</param> /// <param name="additionalReferences">Any additional references that should be included.</param> /// <param name="internalOnly">If true the browser should not making blocking calls to external systems.</param> /// <param name="source">The segment being accessed.</param> public ArchiveFolderBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable<IReference> additionalReferences, bool internalOnly, ArchiveFolderState source) : base( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly) { m_source = source; m_stage = Stage.Begin; }
/// <summary> /// Creates a new browser object with a set of filters. /// </summary> /// <param name="context">The system context to use.</param> /// <param name="view">The view which may restrict the set of references/nodes found.</param> /// <param name="referenceType">The type of references being followed.</param> /// <param name="includeSubtypes">Whether subtypes of the reference type are followed.</param> /// <param name="browseDirection">Which way the references are being followed.</param> /// <param name="browseName">The browse name of a specific target (used when translating browse paths).</param> /// <param name="additionalReferences">Any additional references that should be included.</param> /// <param name="internalOnly">If true the browser should not making blocking calls to external systems.</param> /// <param name="source">The segment being accessed.</param> public SegmentBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable <IReference> additionalReferences, bool internalOnly, SegmentState source) : base( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly) { m_source = source; m_stage = Stage.Begin; }
public static Entry For(BrowseDirection direction) { string text = null; switch (direction) { case BrowseDirection.Forward: text = "Forward"; break; case BrowseDirection.Inverse: text = "Inverse"; break; case BrowseDirection.Both: text = "Both"; break; case BrowseDirection.Invalid: text = "Invalid"; break; } return(new StringEntry(text)); }
/// <summary> /// Get tree /// </summary> /// <param name="endpointId"></param> /// <param name="id"></param> /// <param name="parentId"></param> /// <param name="discovererId"></param> /// <param name="direction"></param> /// <returns>ListNode</returns> public async Task <PagedResult <ListNode> > GetTreeAsync(string endpointId, string id, List <string> parentId, string discovererId, BrowseDirection direction) { var pageResult = new PagedResult <ListNode>(); var model = new BrowseRequestApiModel { TargetNodesOnly = true }; if (direction == BrowseDirection.Forward) { model.MaxReferencesToReturn = _MAX_REFERENCES; model.NodeId = id; if (id == string.Empty) { Path = string.Empty; } } else { model.NodeId = parentId.ElementAt(parentId.Count - 2); } try { var browseData = await _twinService.NodeBrowseAsync(endpointId, model); var continuationToken = browseData.ContinuationToken; var references = browseData.References; var browseDataNext = new BrowseNextResponseApiModel(); if (direction == BrowseDirection.Forward) { parentId.Add(browseData.Node.NodeId); Path += "/" + browseData.Node.DisplayName; } else { parentId.RemoveAt(parentId.Count - 1); Path = Path.Substring(0, Path.LastIndexOf("/")); } do { if (references != null) { foreach (var nodeReference in references) { pageResult.Results.Add(new ListNode { Id = nodeReference.Target.NodeId.ToString(), NodeClass = nodeReference.Target.NodeClass ?? 0, NodeName = nodeReference.Target.DisplayName.ToString(), Children = (bool)nodeReference.Target.Children, ParentIdList = parentId, DiscovererId = discovererId, AccessLevel = nodeReference.Target.AccessLevel ?? 0, ParentName = browseData.Node.DisplayName, DataType = nodeReference.Target.DataType, Value = string.Empty, Publishing = false, PublishedItem = null }); } } if (!string.IsNullOrEmpty(continuationToken)) { var modelNext = new BrowseNextRequestApiModel { ContinuationToken = continuationToken }; browseDataNext = await _twinService.NodeBrowseNextAsync(endpointId, modelNext); references = browseDataNext.References; continuationToken = browseDataNext.ContinuationToken; } else { browseDataNext.References = null; } } while (!string.IsNullOrEmpty(continuationToken) || browseDataNext.References != null); } catch (Exception e) { // skip this node Trace.TraceError("Can not browse node '{0}'", id); var errorMessage = string.Concat(e.Message, e.InnerException?.Message ?? "--", e?.StackTrace ?? "--"); Trace.TraceError(errorMessage); pageResult.Results.Add(new ListNode { NodeName = e.Message, DiscovererId = discovererId, ParentName = "Root" }); } pageResult.PageSize = 10; pageResult.RowCount = pageResult.Results.Count; pageResult.PageCount = (int)Math.Ceiling((decimal)pageResult.RowCount / 10); return(pageResult); }
/// <summary> /// Get tree /// </summary> /// <param name="endpointId"></param> /// <param name="id"></param> /// <param name="parentId"></param> /// <param name="discovererId"></param> /// <param name="direction"></param> /// <returns>ListNode</returns> public async Task <PagedResult <ListNode> > GetTreeAsync(string endpointId, string id, List <string> parentId, string discovererId, BrowseDirection direction, int index, CredentialModel credential = null) { var pageResult = new PagedResult <ListNode>(); var model = new BrowseRequestApiModel { TargetNodesOnly = true, ReadVariableValues = true }; if (direction == BrowseDirection.Forward) { model.MaxReferencesToReturn = _MAX_REFERENCES; model.NodeId = id; if (id == string.Empty) { Path = new List <string>(); } } else { model.NodeId = parentId.ElementAt(index - 1); } model.Header = Elevate(new RequestHeaderApiModel(), credential); try { var browseData = await _twinService.NodeBrowseAsync(endpointId, model); var continuationToken = browseData.ContinuationToken; var references = browseData.References; var browseDataNext = new BrowseNextResponseApiModel(); if (direction == BrowseDirection.Forward) { parentId.Add(browseData.Node.NodeId); Path.Add(browseData.Node.DisplayName); } else { parentId.RemoveAt(parentId.Count - 1); Path.RemoveRange(index, Path.Count - index); } do { if (references != null) { foreach (var nodeReference in references) { pageResult.Results.Add(new ListNode { Id = nodeReference.Target.NodeId.ToString(), NodeClass = nodeReference.Target.NodeClass ?? 0, NodeName = nodeReference.Target.DisplayName.ToString(), Children = (bool)nodeReference.Target.Children, ParentIdList = parentId, DiscovererId = discovererId, AccessLevel = nodeReference.Target.AccessLevel ?? 0, ParentName = browseData.Node.DisplayName, DataType = nodeReference.Target.DataType, Value = nodeReference.Target.Value?.ToString(), Publishing = false, PublishedItem = null }); } } if (!string.IsNullOrEmpty(continuationToken)) { bool?abort = null; if (pageResult.Results.Count > 5) { // TODO: !!! Implement real paging - need to make ux responsive for large # tags !!! abort = true; } var modelNext = new BrowseNextRequestApiModel { ContinuationToken = continuationToken, Abort = abort }; browseDataNext = await _twinService.NodeBrowseNextAsync(endpointId, modelNext); if (abort == true) { break; } references = browseDataNext.References; continuationToken = browseDataNext.ContinuationToken; } else { browseDataNext.References = null; } } while (!string.IsNullOrEmpty(continuationToken) || browseDataNext.References != null); } catch (Exception e) { // skip this node _logger.Error($"Can not browse node '{id}'"); var errorMessage = string.Concat(e.Message, e.InnerException?.Message ?? "--", e?.StackTrace ?? "--"); _logger.Error(errorMessage); string error = JToken.Parse(e.Message).ToString(Formatting.Indented); if (error.Contains(StatusCodes.Status401Unauthorized.ToString())) { pageResult.Error = "Unauthorized access: Bad User Access Denied."; } else { pageResult.Error = error; } } pageResult.PageSize = 10; pageResult.RowCount = pageResult.Results.Count; pageResult.PageCount = (int)Math.Ceiling((decimal)pageResult.RowCount / 10); return(pageResult); }
/// <summary> /// Change current browse position. /// </summary> /// <param name="direction">The direction to browse OPC Server namespace. See <see cref="BrowseDirection"/>.</param> /// <param name="filter">Mask of item/folder name.</param> public void ChangeBrowsePosition(BrowseDirection direction, string filter) { _browseServerSpace.ChangeBrowsePosition(direction, filter); }
/// <summary> /// Called to create the browser for the item configuration. /// </summary> private NodeBrowser OnCreateItemConfigurationBrowser( ISystemContext context, NodeState node, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable<IReference> additionalReferences, bool internalOnly) { HdaParsedNodeId nodeId = HdaParsedNodeId.Parse(node.NodeId); if (nodeId == null) { return null; } return new HdaElementBrower( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly, nodeId.RootId, Opc.Ua.ObjectTypeIds.HistoricalDataConfigurationType, Opc.Ua.BrowseNames.HAConfiguration, NamespaceIndex); }
/// <summary> /// Returns true is the target meets the filter criteria. /// </summary> private bool ApplyBrowseFilters( IReference reference, BrowseDirection browseDirection, NodeId referenceTypeId, bool includeSubtypes) { // check browse direction. if (reference.IsInverse) { if (browseDirection == BrowseDirection.Forward) { return false; } } else { if (browseDirection == BrowseDirection.Inverse) { return false; } } // check reference type filter. if (!NodeId.IsNull(referenceTypeId)) { if (reference.ReferenceTypeId != referenceTypeId) { if (includeSubtypes) { if (m_server.TypeTree.IsTypeOf(reference.ReferenceTypeId, referenceTypeId)) { return true; } } return false; } } // include reference for now. return true; }
/// <summary> /// Get tree /// </summary> /// <param name="endpointId"></param> /// <param name="id"></param> /// <param name="parentId"></param> /// <param name="discovererId"></param> /// <param name="direction"></param> /// <param name="index"></param> /// <param name="credential"></param> /// <returns>ListNode</returns> public async Task <PagedResult <ListNode> > GetTreeAsync(string endpointId, string id, List <string> parentId, string discovererId, BrowseDirection direction, int index, CredentialModel credential = null) { var pageResult = new PagedResult <ListNode>(); var header = Elevate(new RequestHeaderApiModel(), credential); var previousPage = new PagedResult <ListNode>(); var model = new BrowseRequestApiModel { TargetNodesOnly = true, ReadVariableValues = true, MaxReferencesToReturn = _MAX_REFERENCES }; if (direction == BrowseDirection.Forward) { model.NodeId = id; if (id == string.Empty) { Path = new List <string>(); } } else { model.NodeId = parentId.ElementAt(index - 1); } model.Header = header; try { var browseData = await _twinService.NodeBrowseAsync(endpointId, model); _displayName = browseData.Node.DisplayName; if (direction == BrowseDirection.Forward) { parentId.Add(browseData.Node.NodeId); Path.Add(browseData.Node.DisplayName); } else { parentId.RemoveAt(parentId.Count - 1); Path.RemoveRange(index, Path.Count - index); } if (!string.IsNullOrEmpty(browseData.ContinuationToken)) { pageResult.PageCount = 2; } if (browseData.References != null) { foreach (var nodeReference in browseData.References) { previousPage.Results.Add(new ListNode { Id = nodeReference.Target.NodeId.ToString(), NodeClass = nodeReference.Target.NodeClass ?? 0, NodeName = nodeReference.Target.DisplayName.ToString(), Children = (bool)nodeReference.Target.Children, ParentIdList = parentId, DiscovererId = discovererId, AccessLevel = nodeReference.Target.AccessLevel ?? 0, ParentName = _displayName, DataType = nodeReference.Target.DataType, Value = nodeReference.Target.Value?.ToJson()?.TrimQuotes(), Publishing = false, PublishedItem = null }); } } pageResult.Results = previousPage.Results; pageResult.ContinuationToken = browseData.ContinuationToken; pageResult.PageSize = _commonHelper.PageLength; pageResult.RowCount = pageResult.Results.Count; } catch (UnauthorizedAccessException) { pageResult.Error = "Unauthorized access: Bad User Access Denied."; } catch (Exception e) { // skip this node _logger.Error(e, "Can not browse node '{id}'", id); var errorMessage = string.Concat(e.Message, e.InnerException?.Message ?? "--", e?.StackTrace ?? "--"); pageResult.Error = errorMessage; } return(pageResult); }
/// <summary> /// Change current browse position. /// </summary> /// <param name="direction">The direction to browse OPC Server namespace. See <see cref="BrowseDirection"/>.</param> /// <param name="filter">Mask of item/folder name.</param> public void ChangeBrowsePosition(BrowseDirection direction, string filter) { browseServerSpace.ChangeBrowsePosition(direction, filter); }
/// <summary> /// Creates a browser that finds the references to the branch. /// </summary> /// <param name="context">The system context to use.</param> /// <param name="view">The view which may restrict the set of references/nodes found.</param> /// <param name="referenceType">The type of references being followed.</param> /// <param name="includeSubtypes">Whether subtypes of the reference type are followed.</param> /// <param name="browseDirection">Which way the references are being followed.</param> /// <param name="browseName">The browse name of a specific target (used when translating browse paths).</param> /// <param name="additionalReferences">Any additional references that should be included.</param> /// <param name="internalOnly">If true the browser should not making blocking calls to external systems.</param> /// <returns>The browse object (must be disposed).</returns> public override INodeBrowser CreateBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable<IReference> additionalReferences, bool internalOnly) { NodeBrowser browser = new DaElementBrowser( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly, this.ItemId, this.NodeId.NamespaceIndex); PopulateBrowser(context, browser); return browser; }
/// <summary> /// Used to receive notifications when a node browser is created. /// </summary> public NodeBrowser OnCreateBrowser( ISystemContext context, NodeState node, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable<IReference> additionalReferences, bool internalOnly) { Browser browser = new Browser( context, view, referenceType, includeSubtypes, browseDirection, browseName, null, false, GetClientSession(context as ServerSystemContext), m_mapper, Object.ReferenceEquals(node, m_root)?null:node, m_root.NodeId); return browser; }
/// <summary> /// Invokes the Browse service. /// </summary> /// <param name="requestHeader">The request header.</param> /// <param name="view">The view to browse.</param> /// <param name="nodeToBrowse">The node to browse.</param> /// <param name="maxResultsToReturn">The maximum number of returned values.</param> /// <param name="browseDirection">The browse direction.</param> /// <param name="referenceTypeId">The reference type id.</param> /// <param name="includeSubtypes">If set to <c>true</c> the subtypes of the ReferenceType will be included in the browse.</param> /// <param name="nodeClassMask">The node class mask.</param> /// <param name="continuationPoint">The continuation point.</param> /// <param name="references">The list of node references.</param> /// <returns></returns> public virtual ResponseHeader Browse( RequestHeader requestHeader, ViewDescription view, NodeId nodeToBrowse, uint maxResultsToReturn, BrowseDirection browseDirection, NodeId referenceTypeId, bool includeSubtypes, uint nodeClassMask, out byte[] continuationPoint, out ReferenceDescriptionCollection references) { BrowseDescription description = new BrowseDescription(); description.NodeId = nodeToBrowse; description.BrowseDirection = browseDirection; description.ReferenceTypeId = referenceTypeId; description.IncludeSubtypes = includeSubtypes; description.NodeClassMask = nodeClassMask; description.ResultMask = (uint)BrowseResultMask.All; BrowseDescriptionCollection nodesToBrowse = new BrowseDescriptionCollection(); nodesToBrowse.Add(description); BrowseResultCollection results; DiagnosticInfoCollection diagnosticInfos; ResponseHeader responseHeader = Browse( requestHeader, view, maxResultsToReturn, nodesToBrowse, out results, out diagnosticInfos); ClientBase.ValidateResponse(results, nodesToBrowse); ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToBrowse); if (StatusCode.IsBad(results[0].StatusCode)) { throw new ServiceResultException(new ServiceResult(results[0].StatusCode, 0, diagnosticInfos, responseHeader.StringTable)); } continuationPoint = results[0].ContinuationPoint; references = results[0].References; return responseHeader; }
/// <summary> /// Begins an asynchronous invocation of the Browse service. /// </summary> /// <param name="requestHeader">The request header.</param> /// <param name="view">The view to browse.</param> /// <param name="nodeToBrowse">The node to browse.</param> /// <param name="maxResultsToReturn">The maximum number of returned values..</param> /// <param name="browseDirection">The browse direction.</param> /// <param name="referenceTypeId">The reference type id.</param> /// <param name="includeSubtypes">If set to <c>true</c> the subtypes of the ReferenceType will be included in the browse.</param> /// <param name="nodeClassMask">The node class mask.</param> /// <param name="callback">The callback.</param> /// <param name="asyncState"></param> /// <returns></returns> public IAsyncResult BeginBrowse( RequestHeader requestHeader, ViewDescription view, NodeId nodeToBrowse, uint maxResultsToReturn, BrowseDirection browseDirection, NodeId referenceTypeId, bool includeSubtypes, uint nodeClassMask, AsyncCallback callback, object asyncState) { BrowseDescription description = new BrowseDescription(); description.NodeId = nodeToBrowse; description.BrowseDirection = browseDirection; description.ReferenceTypeId = referenceTypeId; description.IncludeSubtypes = includeSubtypes; description.NodeClassMask = nodeClassMask; description.ResultMask = (uint)BrowseResultMask.All; BrowseDescriptionCollection nodesToBrowse = new BrowseDescriptionCollection(); nodesToBrowse.Add(description); return BeginBrowse( requestHeader, view, maxResultsToReturn, nodesToBrowse, callback, asyncState); }
public override INodeBrowser CreateBrowser( ISystemContext context, ViewDescription view, NodeId referenceType, bool includeSubtypes, BrowseDirection browseDirection, QualifiedName browseName, IEnumerable<IReference> additionalReferences, bool internalOnly) { MemoryRegisterBrowser browser = new MemoryRegisterBrowser( context, view, referenceType, includeSubtypes, browseDirection, browseName, additionalReferences, internalOnly, this); return browser; }