メインコンテンツまでスキップ

browse_with_paging

browse references リストのみを返し、continuation_point を破棄します。"子ノードの数が1ページ以内に収まる(下位レベルでの1回のリクエストで最大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

次のステップ​