跳到主要内容

BrowseWithPaging

Browse 只返回 References 列表, 丢弃 ContinuationPoint, 适合"已知小节点"场景. 大节点 (子节点 100+) 用 BrowseWithPaging 显式拿到 BrowsePage.

前置阅读

签名

public BrowsePage BrowseWithPaging(string nodeId, NodeClass filter = NodeClass.Unspecified);

用法

var page = ua.BrowseWithPaging("ns=2;s=BigFolder");
Console.WriteLine($"Got {page.References.Count} children, more = {page.ContinuationPoint != null}");

if (page.ContinuationPoint != null)
{
var next = ua.BrowseNext(page.ContinuationPoint);
Console.WriteLine($"Next page: {next.References.Count} more children");
}

何时用 Browse vs BrowseWithPaging

场景API
已知节点子数 ≤ 50, 不关心分页Browse(...)
不确定子数, 安全起见BrowseWithPaging(...) + 循环 BrowseNext
100+ 子节点的大节点BrowseWithPaging(...) 必选
一次 Browse 多个节点BrowseMany(...) (注意当前 BrowseMany 不返回 ContinuationPoint)

完整模板

public static List<OpcUaReference> BrowseAll(
DarraOpcUa ua,
string nodeId,
NodeClass filter = NodeClass.Unspecified)
{
var all = new List<OpcUaReference>();
var page = ua.BrowseWithPaging(nodeId, filter);
all.AddRange(page.References);
while (page.ContinuationPoint != null)
{
page = ua.BrowseNext(page.ContinuationPoint);
all.AddRange(page.References);
}
return all;
}

下一步