BrowseWithPaging
Browse References 목록만 반환하고 나머지는 생략하므로 ContinuationPoint, "알려진 자식 노드가 많지 않은" 경우에 적합합니다. 자식 노드 수가 한 페이지당 상한선(클라이언트가 요청한 고정값 requestedMaxReferencesPerNode 1000)을 초과할 수 있는 경우, BrowseWithPaging 명시적으로 BrowsePage가져와야만 페이징을 계속할 수 있습니다.
사전 읽기
- 다음 페이지로 넘어가기용 BrowseNext.
서명
BrowseWithPaging 이는 Session 의 멤버 메서드입니다.
namespace darra::opcua {
class Session {
public:
BrowsePage BrowseWithPaging(
std::string const& node_id,
NodeClass filter = NodeClass::Unspecified);
};
}
사용법
#include <darra/opcua/client.hpp>
#include <iostream>
using namespace darra::opcua;
Session s("opc.tcp://localhost:4840");
s.Connect();
auto page = s.BrowseWithPaging("ns=2;s=BigFolder");
std::cout << "Got " << page.references.size()
<< " children, more = " << !page.continuation_point.empty() << "\n";
if (!page.continuation_point.empty()) {
auto next = s.BrowseNext(page.continuation_point);
std::cout << "Next page: " << next.references.size() << " more children\n";
}
언제 사용하나요 Browse vs BrowseWithPaging
| 시나리오 | API |
|---|---|
| 자식 노드 수가 한 페이지당 상한선 이내로 정해지며, 페이지 나누기는 고려하지 않습니다. | Browse(...) |
| 자식 노드 수가 불확실함 | BrowseWithPaging(...) + 반복 BrowseNext |
| 자식 노드가 수천 개에 달할 수도 있다 | BrowseWithPaging(...) 필수 (그렇지 않으면 첫 페이지만 자동으로 가져옵니다) |
| 한 번에 여러 노드 보기 | BrowseMany(...) (현재는 반환되지 BrowseMany 않습니다 ContinuationPoint) |
전체 템플릿
이건 네가 직접 작성한 보조
SDK 함수다 없음BrowseAll 이것 API —— 아래 문장은 BrowseWithPaging + BrowseNext 를 이어 붙인 것입니다.사용자 측 템플릿, 자신의 프로젝트에 복사해서 사용하세요. 외부에서 #include 호출하지 마세요.
// 사용자 측 보조 기능 (비 SDK API): 모든 페이지를 자동으로 끝까지 넘기기
std::vector<darra::opcua::Reference> BrowseAll(
darra::opcua::Session& s,
std::string const& node_id,
darra::opcua::NodeClass filter = darra::opcua::NodeClass::Unspecified)
{
std::vector<darra::opcua::Reference> all;
auto page = s.BrowseWithPaging(node_id, filter);
all.insert(all.end(), page.references.begin(), page.references.end());
while (!page.continuation_point.empty()) {
page = s.BrowseNext(page.continuation_point);
all.insert(all.end(), page.references.begin(), page.references.end());
}
return all;
}