/// <summary>
        /// Browse all references if max references is null and user
        /// wants all. If user has requested maximum to return use
        /// <see cref="IBrowseServices{T}.NodeBrowseFirstAsync"/>
        /// </summary>
        /// <param name="endpoint"></param>
        /// <param name="service"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public static async Task <BrowseResultModel> NodeBrowseAsync <T>(
            this IBrowseServices <T> service, T endpoint, BrowseRequestModel request)
        {
            if (request.MaxReferencesToReturn != null)
            {
                return(await service.NodeBrowseFirstAsync(endpoint, request));
            }
            while (true)
            {
                var result = await service.NodeBrowseFirstAsync(endpoint, request);

                while (result.ContinuationToken != null)
                {
                    try {
                        var next = await service.NodeBrowseNextAsync(endpoint,
                                                                     new BrowseNextRequestModel {
                            ContinuationToken = result.ContinuationToken
                        });

                        result.References.AddRange(next.References);
                        result.ContinuationToken = next.ContinuationToken;
                    }
                    catch (Exception) {
                        // TODO: Catch other exceptions and continue, e.g. in case of timeout
                        throw;
                    }
                }
                return(result);
            }
        }
Example #2
0
        /// <inheritdoc/>
        public async Task <BrowseResultModel> NodeBrowseFirstAsync(
            string endpoint, BrowseRequestModel request)
        {
            var result = await _client.NodeBrowseFirstAsync(endpoint,
                                                            Map <BrowseRequestApiModel>(request));

            return(Map <BrowseResultModel>(result));
        }
Example #3
0
        /// <inheritdoc/>
        public async Task <BrowseResultModel> NodeBrowseFirstAsync(
            EndpointApiModel endpoint, BrowseRequestModel request)
        {
            var result = await _client.NodeBrowseFirstAsync(endpoint,
                                                            request.Map <BrowseRequestApiModel>());

            return(result.Map <BrowseResultModel>());
        }
        /// <inheritdoc/>
        public async Task <BrowseResultModel> NodeBrowseFirstAsync(
            EndpointRegistrationModel registration, BrowseRequestModel request)
        {
            var result = await CallServiceOnSupervisorAsync <BrowseRequestModel, BrowseResultModel>(
                "Browse_V2", registration, request);

            return(result);
        }
Example #5
0
        /// <inheritdoc/>
        public async Task <BrowseResultModel> NodeBrowseFirstAsync(
            string endpoint, BrowseRequestModel request)
        {
            var result = await _client.NodeBrowseFirstAsync(endpoint,
                                                            request.ToApiModel());

            return(result.ToServiceModel());
        }
Example #6
0
        /// <inheritdoc/>
        public async Task <BrowseResultModel> NodeBrowseFirstAsync(string endpointId,
                                                                   BrowseRequestModel request)
        {
            var result = await CallServiceOnTwinAsync <BrowseRequestModel, BrowseResultModel>(
                "Browse_V2", endpointId, request);

            return(result);
        }
        public async Task <BrowseResponseApiModel> GetSetOfUniqueNodesAsync(
            string endpointId, [FromQuery] string nodeId)
        {
            if (string.IsNullOrEmpty(nodeId))
            {
                nodeId = null;
            }
            var request = new BrowseRequestModel {
                NodeId             = nodeId,
                TargetNodesOnly    = true,
                ReadVariableValues = true
            };
            var browseresult = await _broser.NodeBrowseAsync(endpointId, request);

            return(new BrowseResponseApiModel(browseresult));
        }
Example #8
0
 /// <summary>
 /// Create from service model
 /// </summary>
 /// <param name="model"></param>
 public BrowseRequestApiModel(BrowseRequestModel model)
 {
     if (model == null)
     {
         throw new ArgumentNullException(nameof(model));
     }
     NodeId = model.NodeId;
     MaxReferencesToReturn = model.MaxReferencesToReturn;
     Direction             = model.Direction;
     ReferenceTypeId       = model.ReferenceTypeId;
     NoSubtypes            = model.NoSubtypes;
     TargetNodesOnly       = model.TargetNodesOnly;
     ReadVariableValues    = model.ReadVariableValues;
     View = model.View == null ? null :
            new BrowseViewApiModel(model.View);
     Header = model.Header == null ? null :
              new RequestHeaderApiModel(model.Header);
 }
 /// <summary>
 /// Create from service model
 /// </summary>
 /// <param name="model"></param>
 public static BrowseRequestApiModel ToApiModel(
     this BrowseRequestModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new BrowseRequestApiModel {
         NodeId = model.NodeId,
         MaxReferencesToReturn = model.MaxReferencesToReturn,
         Direction = (IIoT.OpcUa.Api.Twin.Models.BrowseDirection?)model.Direction,
         View = model.View.ToApiModel(),
         ReferenceTypeId = model.ReferenceTypeId,
         TargetNodesOnly = model.TargetNodesOnly,
         ReadVariableValues = model.ReadVariableValues,
         NoSubtypes = model.NoSubtypes,
         Header = model.Header.ToApiModel()
     });
 }
Example #10
0
        /// <summary>
        /// Browse all references if max references is null and user
        /// wants all. If user has requested maximum to return use
        /// <see cref="IBrowseServices{T}.NodeBrowseFirstAsync"/>
        /// </summary>
        /// <param name="endpoint"></param>
        /// <param name="service"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        public static async Task <BrowseResultModel> NodeBrowseAsync <T>(
            this IBrowseServices <T> service, T endpoint, BrowseRequestModel request)
        {
            if (request.MaxReferencesToReturn != null)
            {
                return(await service.NodeBrowseFirstAsync(endpoint, request));
            }
            while (true)
            {
                var result = await service.NodeBrowseFirstAsync(endpoint, request);

                while (result.ContinuationToken != null)
                {
                    try {
                        var next = await service.NodeBrowseNextAsync(endpoint,
                                                                     new BrowseNextRequestModel {
                            ContinuationToken  = result.ContinuationToken,
                            Header             = request.Header,
                            NodeIdsOnly        = request.NodeIdsOnly,
                            ReadVariableValues = request.ReadVariableValues,
                            TargetNodesOnly    = request.TargetNodesOnly
                        });

                        result.References.AddRange(next.References);
                        result.ContinuationToken = next.ContinuationToken;
                    }
                    catch (Exception) {
                        await Try.Async(() => service.NodeBrowseNextAsync(endpoint,
                                                                          new BrowseNextRequestModel {
                            ContinuationToken = result.ContinuationToken,
                            Abort             = true
                        }));

                        throw;
                    }
                }
                return(result);
            }
        }
 /// <summary>
 /// Create from service model
 /// </summary>
 /// <param name="model"></param>
 public static BrowseRequestApiModel ToApiModel(
     this BrowseRequestModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new BrowseRequestApiModel {
         NodeId = model.NodeId,
         MaxReferencesToReturn = model.MaxReferencesToReturn,
         Direction = (Core.Models.BrowseDirection?)model.Direction,
         View = model.View.ToApiModel(),
         ReferenceTypeId = model.ReferenceTypeId,
         TargetNodesOnly = model.TargetNodesOnly,
         ReadVariableValues = model.ReadVariableValues,
         NodeClassFilter = model.NodeClassFilter?
                           .Select(f => (Core.Models.NodeClass)f)
                           .ToList(),
         NoSubtypes = model.NoSubtypes,
         Header = model.Header.ToApiModel()
     });
 }
 /// <inheritdoc/>
 public Task <BrowseResultModel> NodeBrowseFirstAsync(string endpointId,
                                                      BrowseRequestModel request)
 {
     return(_browser.NodeBrowseFirstAsync(Endpoint, request));
 }