当前位置: 首页>>代码示例>>C#>>正文


C# Session.BrowseNext方法代码示例

本文整理汇总了C#中Opc.Ua.Client.Session.BrowseNext方法的典型用法代码示例。如果您正苦于以下问题:C# Session.BrowseNext方法的具体用法?C# Session.BrowseNext怎么用?C# Session.BrowseNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Opc.Ua.Client.Session的用法示例。


在下文中一共展示了Session.BrowseNext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Browse

 public static ReferenceDescriptionCollection Browse(Session session, BrowseDescription nodeToBrowse, bool throwOnError)
 {
     try
       {
     var descriptionCollection = new ReferenceDescriptionCollection();
     var nodesToBrowse = new BrowseDescriptionCollection { nodeToBrowse };
     BrowseResultCollection results;
     DiagnosticInfoCollection diagnosticInfos;
     session.Browse(null, null, 0U, nodesToBrowse, out results, out diagnosticInfos);
     ClientBase.ValidateResponse(results, nodesToBrowse);
     ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToBrowse);
     while (!StatusCode.IsBad(results[0].StatusCode))
     {
       for (var index = 0; index < results[0].References.Count; ++index)
     descriptionCollection.Add(results[0].References[index]);
       if (results[0].References.Count == 0 || results[0].ContinuationPoint == null)
     return descriptionCollection;
       var continuationPoints = new ByteStringCollection();
       continuationPoints.Add(results[0].ContinuationPoint);
       session.BrowseNext(null, false, continuationPoints, out results, out diagnosticInfos);
       ClientBase.ValidateResponse(results, continuationPoints);
       ClientBase.ValidateDiagnosticInfos(diagnosticInfos, continuationPoints);
     }
     throw new ServiceResultException(results[0].StatusCode);
       }
       catch (Exception ex)
       {
     if (throwOnError)
       throw new ServiceResultException(ex, 2147549184U);
     return null;
       }
 }
开发者ID:pilhokim,项目名称:h-opc,代码行数:32,代码来源:ClientUtils.cs

示例2: Browse

        /// <summary>
        /// Browses the address space and returns the references found.
        /// </summary>
        public static ReferenceDescriptionCollection Browse(Session session, ViewDescription view, BrowseDescription nodeToBrowse, bool throwOnError)
        {
            try
            {
                ReferenceDescriptionCollection references = new ReferenceDescriptionCollection();

                // construct browse request.
                BrowseDescriptionCollection nodesToBrowse = new BrowseDescriptionCollection();
                nodesToBrowse.Add(nodeToBrowse);

                // start the browse operation.
                BrowseResultCollection results = null;
                DiagnosticInfoCollection diagnosticInfos = null;

                session.Browse(
                    null,
                    view,
                    0,
                    nodesToBrowse,
                    out results,
                    out diagnosticInfos);

                ClientBase.ValidateResponse(results, nodesToBrowse);
                ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToBrowse);

                do
                {
                    // check for error.
                    if (StatusCode.IsBad(results[0].StatusCode))
                    {
                        throw new ServiceResultException(results[0].StatusCode);
                    }

                    // process results.
                    for (int ii = 0; ii < results[0].References.Count; ii++)
                    {
                        references.Add(results[0].References[ii]);
                    }

                    // check if all references have been fetched.
                    if (results[0].References.Count == 0 || results[0].ContinuationPoint == null)
                    {
                        break;
                    }

                    // continue browse operation.
                    ByteStringCollection continuationPoints = new ByteStringCollection();
                    continuationPoints.Add(results[0].ContinuationPoint);

                    session.BrowseNext(
                        null,
                        false,
                        continuationPoints,
                        out results,
                        out diagnosticInfos);

                    ClientBase.ValidateResponse(results, continuationPoints);
                    ClientBase.ValidateDiagnosticInfos(diagnosticInfos, continuationPoints);
                }
                while (true);

                //return complete list.
                return references;
            }
            catch (Exception exception)
            {
                if (throwOnError)
                {
                    throw new ServiceResultException(exception, StatusCodes.BadUnexpectedError);
                }

                return null;
            }
        }
开发者ID:OPCFoundation,项目名称:UA-.NETStandardLibrary,代码行数:77,代码来源:ClientUtils.cs

示例3: FindTargetOfReference

        /// <summary>
        /// Finds the targets for the specified reference.
        /// </summary>
        private static List<NodeId> FindTargetOfReference(Session session, List<NodeId> nodeIds, NodeId referenceTypeId, bool throwOnError)
        {
            try
            {
                // construct browse request.
                BrowseDescriptionCollection nodesToBrowse = new BrowseDescriptionCollection();

                for (int ii = 0; ii < nodeIds.Count; ii++)
                {
                    BrowseDescription nodeToBrowse = new BrowseDescription();
                    nodeToBrowse.NodeId = nodeIds[ii];
                    nodeToBrowse.BrowseDirection = BrowseDirection.Forward;
                    nodeToBrowse.ReferenceTypeId = referenceTypeId;
                    nodeToBrowse.IncludeSubtypes = false;
                    nodeToBrowse.NodeClassMask = 0;
                    nodeToBrowse.ResultMask = (uint)BrowseResultMask.None;
                    nodesToBrowse.Add(nodeToBrowse);
                }

                // start the browse operation.
                BrowseResultCollection results = null;
                DiagnosticInfoCollection diagnosticInfos = null;

                session.Browse(
                    null,
                    null,
                    1,
                    nodesToBrowse,
                    out results,
                    out diagnosticInfos);

                ClientBase.ValidateResponse(results, nodesToBrowse);
                ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToBrowse);

                List<NodeId> targetIds = new List<NodeId>();
                ByteStringCollection continuationPoints = new ByteStringCollection();

                for (int ii = 0; ii < nodeIds.Count; ii++)
                {
                    targetIds.Add(null);

                    // check for error.
                    if (StatusCode.IsBad(results[ii].StatusCode))
                    {
                        continue;
                    }

                    // check for continuation point.
                    if (results[ii].ContinuationPoint != null && results[ii].ContinuationPoint.Length > 0)
                    {
                        continuationPoints.Add(results[ii].ContinuationPoint);
                    }

                    // get the node id.
                    if (results[ii].References.Count > 0)
                    {
                        if (NodeId.IsNull(results[ii].References[0].NodeId) || results[ii].References[0].NodeId.IsAbsolute)
                        {
                            continue;
                        }

                        targetIds[ii] = (NodeId)results[ii].References[0].NodeId;
                    }
                }

                // release continuation points.
                if (continuationPoints.Count > 0)
                {
                    session.BrowseNext(
                        null,
                        true,
                        continuationPoints,
                        out results,
                        out diagnosticInfos);

                    ClientBase.ValidateResponse(results, nodesToBrowse);
                    ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToBrowse);
                }

                //return complete list.
                return targetIds;
            }
            catch (Exception exception)
            {
                if (throwOnError)
                {
                    throw new ServiceResultException(exception, StatusCodes.BadUnexpectedError);
                }

                return null;
            }
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:95,代码来源:ClientUtils.cs

示例4: Browse

        /// <summary>
        /// Fetches the references for the node.
        /// </summary>
        private List<ReferenceDescription> Browse(Session session, NodeId nodeId)
        {
            List<ReferenceDescription> references = new List<ReferenceDescription>();

            // specify the references to follow and the fields to return.
            BrowseDescription nodeToBrowse = new BrowseDescription();

            nodeToBrowse.NodeId = nodeId;
            nodeToBrowse.ReferenceTypeId = ReferenceTypeIds.References;
            nodeToBrowse.IncludeSubtypes = true;
            nodeToBrowse.BrowseDirection = BrowseDirection.Both;
            nodeToBrowse.NodeClassMask = 0;
            nodeToBrowse.ResultMask = (uint)BrowseResultMask.All;

            BrowseDescriptionCollection nodesToBrowse = new BrowseDescriptionCollection();
            nodesToBrowse.Add(nodeToBrowse);
            
            // start the browse operation.
            BrowseResultCollection results = null;
            DiagnosticInfoCollection diagnosticInfos = null;

            ResponseHeader responseHeader = session.Browse(
                null,
                null,
                2,
                nodesToBrowse,
                out results,
                out diagnosticInfos);

            // these do sanity checks on the result - make sure response matched the request.
            ClientBase.ValidateResponse(results, nodesToBrowse);
            ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToBrowse);

            // check status.
            if (StatusCode.IsBad(results[0].StatusCode))
            {
                // embed the diagnostic information in a exception.
                throw ServiceResultException.Create(results[0].StatusCode, 0, diagnosticInfos, responseHeader.StringTable);
            }

            // add first batch.
            references.AddRange(results[0].References);

            // check if server limited the results.
            while (results[0].ContinuationPoint != null && results[0].ContinuationPoint.Length > 0)
            {
                ByteStringCollection continuationPoints = new ByteStringCollection();
                continuationPoints.Add(results[0].ContinuationPoint);

                // continue browse operation.
                responseHeader = session.BrowseNext(
                    null,
                    false,
                    continuationPoints,
                    out results,
                    out diagnosticInfos);

                ClientBase.ValidateResponse(results, continuationPoints);
                ClientBase.ValidateDiagnosticInfos(diagnosticInfos, continuationPoints);
                
                // check status.
                if (StatusCode.IsBad(results[0].StatusCode))
                {
                    // embed the diagnostic information in a exception.
                    throw ServiceResultException.Create(results[0].StatusCode, 0, diagnosticInfos, responseHeader.StringTable);
                }

                // add next batch.
                references.AddRange(results[0].References);
            }

            return references;
        }
开发者ID:yuriik83,项目名称:UA-.NET,代码行数:76,代码来源:ShowReferencesDlg.cs

示例5: BrowseBlock


//.........这里部分代码省略.........
                            {
                                combinedResult.StatusCode = results[ii].StatusCode;
                            }

                            continue;
                        }

                        // check if all references have been fetched.
                        if (results[ii].References.Count == 0)
                        {
                            continue;
                        }

                        // save results.
                        combinedResult.References.AddRange(results[ii].References);

                        // check for continuation point.
                        if (results[ii].ContinuationPoint != null && results[ii].ContinuationPoint.Length > 0)
                        {
                            continuationPoints.Add(results[ii].ContinuationPoint);
                            continuationPointIndexes.Add(index);
                        }
                    }

                    // process continuation points.
                    ByteStringCollection revisedContinuationPoints = new ByteStringCollection();
                    List<int> revisedContinuationPointIndexes = new List<int>();

                    while (continuationPoints.Count > 0)
                    {
                        bool releaseContinuationPoints = false;

                        // continue browse operation.
                        session.BrowseNext(
                            null,
                            releaseContinuationPoints,
                            continuationPoints,
                            out results,
                            out diagnosticInfos);

                        ClientBase.ValidateResponse(results, continuationPoints);
                        ClientBase.ValidateDiagnosticInfos(diagnosticInfos, continuationPoints);

                        revisedContinuationPoints.Clear();
                        revisedContinuationPointIndexes.Clear();

                        for (int ii = 0; ii < continuationPoints.Count; ii++)
                        {
                            int index = continuationPointIndexes[ii];

                            // look up results.
                            BrowseResult combinedResult = null;

                            if (!combinedResults.TryGetValue(index, out combinedResult))
                            {
                                combinedResults[index] = new BrowseResult();
                            }

                            // check for error.
                            if (StatusCode.IsBad(results[ii].StatusCode))
                            {
                                // save error.
                                if (StatusCode.IsGood(combinedResult.StatusCode))
                                {
                                    combinedResult.StatusCode = results[ii].StatusCode;
                                }
开发者ID:OPCFoundation,项目名称:UA-.NET,代码行数:67,代码来源:ComDaBrowseCache.cs


注:本文中的Opc.Ua.Client.Session.BrowseNext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。