BrowseWithPaging
Browse References 목록만 반환하고 나머지는 생략하므로 ContinuationPoint, "알려진 자식 노드가 많지 않은" 경우에 적합합니다. 자식 노드가 1000 (SDK 단일 페이지 상한)인 노드를 BrowseWithPaging 명시적으로 가져옵니다 BrowsePage.
사전 읽기
- 다음 페이지로 넘어가기용 BrowseNext.
서명
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 |
|---|---|
| 자식 노드가 많지 않은 것으로 알려져 있으며, 페이징은 고려하지 않습니다. | Browse(...) |
| 자녀 수가 불확실하므로, 안전을 위해 | BrowseWithPaging(...) + 반복 BrowseNext |
| 자식 노드가 수천 개에 달할 수 있는 대규모 노드 | BrowseWithPaging(...) 필수 |
| 한 번에 Browse 여러 노드 | BrowseMany(...) (현재는 반환되지 BrowseMany 않습니다 ContinuationPoint) |
페이지 나누기의 트리거 조건은 "자식 노드가 몇 개인가"가 아니라,서버 측에서 한 번에 얼마나 주었나요?: SDK 페이지당 최대 1000개의 참조를 요청할 수 있으며, 서버 측에서 더 적은 수를 반환할 수도 있습니다. 이 항목이 남아 있다면 다음 페이지가 있다는 ContinuationPoint 의미입니다.
전체 템플릿
직접 루프를 작성할 필요 없음 — 이미 SDK 내장되어 있음 BrowseAll, 한 줄로 모두 가져오기:
var all = ua.BrowseAll("ns=2;s=BigFolder"); // 끝까지 자동으로 페이지 넘김 계속하기
그에 상응하는 전개 (페이지 넘기는 속도를 조절해야 함 / 시간을 미리 멈춰야만 손으로 작성 가능):
public static List<OpcUaReference> Collect(
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;
}
BrowseAll 위의 방법보다 두 가지 작업을 더 수행합니다: 페이지 수 제한 maxPages (기본값 32페이지)을 두고, 모든 페이지를 넘긴 후에는 서버의 리소스를 최대한 확보하기 위해 노력합니다.