본문으로 건너뛰기

browse_with_paging

browse references 목록만 반환하고 continuation_point는 버리며, "자식 노드 수가 한 페이지 이내인(기본적으로 한 번의 요청당 최대 1000개)" 노드에 적합합니다. 자식 노드 수가 한 페이지를 초과할 수 있는 노드는 browse_with_paging 명시적으로 가져와야 합니다 BrowsePage.

사전 읽기

서명​

def browse_with_paging(self,
node_id: str,
filter: NodeClass = NodeClass.Unspecified) -> BrowsePage: ...

사용법​

page = ua.browse_with_paging("ns=2;s=BigFolder")
print(f"Got {len(page.references)} children, more = {page.continuation_point is not None}")

if page.continuation_point is not None:
nxt = ua.browse_next(page.continuation_point)
print(f"Next page: {len(nxt.references)} more children")

언제 사용하나요 browse vs browse_with_paging​

시나리오API
자식 노드의 수가 한 페이지 이내(≤ 1000)인 것으로 알려져 있으며, 페이지 나누기는 고려하지 않습니다.browse(...)
자녀 수가 불확실하므로, 안전을 위해browse_with_paging(...) + 반복 browse_next
노드 수가 수천 개에 달할 수도 있는 대규모 노드browse_with_paging(...) 필수
한 번에 browse 여러 노드browse_many(...) (현재 browse_many는 결과를 반환하지 않습니다. ContinuationPoint)

전체 템플릿​

Python SDK에는 내장 자동 페이지 넘김 API가 없습니다(C# 쪽에만 BrowseAll 확장 메서드가 있습니다). 직접 헬퍼 함수로 작성하면 됩니다:

from darra_opcua import OpcUaSession, NodeClass, Reference
from typing import List

def browse_all_refs(ua: OpcUaSession,
node_id: str,
filter: NodeClass = NodeClass.Unspecified) -> List[Reference]:
all_refs: List[Reference] = []
page = ua.browse_with_paging(node_id, filter)
all_refs.extend(page.references)
while page.continuation_point is not None:
page = ua.browse_next(page.continuation_point)
all_refs.extend(page.references)
return all_refs

다음 단계​