본문으로 건너뛰기

Browse

s.browse(node_id, filter) — 지정된 노드의 직접 자식 노드(한 단계)를 나열합니다.

사전 읽기 / 부록

서명​

pub fn Session::browse(&self, node_id: &str, filter: NodeClass)
-> Result<Vec<Reference>, OpcUaError>;

pub fn Session::browse_many(&self, node_ids: &[&str], filter: NodeClass)
-> Result<Vec<Vec<Reference>>, OpcUaError>;

Reference 필드​

pub struct Reference {
pub node_id: String,
pub browse_name: String, // "2:Temperature"와 같은 NamespaceIndex 접두사가 포함된 경우
pub display_name: String,
pub node_class: NodeClass,
}

예시​

use darra_opcua::NodeClass;

// Boiler1 아래의 모든 자노드를 나열합니다.
let children = s.browse("ns=2;s=Boiler1", NodeClass::Unspecified)?;
for c in &children {
println!(" {:?} {} -> {}", c.node_class, c.browse_name, c.node_id);
}

// Variable 유형만 보기
let vars = s.browse("ns=2;s=Boiler1", NodeClass::Variable)?;

// Method만 보기
let methods = s.browse("ns=2;s=Calculator", NodeClass::Method)?;

일괄 열람 (browse_many)​

여러 노드를 동시에 탐색하려는 경우(예: 트리를 처음 GUI 펼칠 때), 다음을 한 번 browse_many 사용하면 됩니다 RPC:

let roots = ["i=85", "i=86"];   // Objects + Types
let results = s.browse_many(&roots, NodeClass::Unspecified)?;
for (root, children) in roots.iter().zip(results.iter()) {
println!("{}:", root);
for c in children {
println!(" {}", c.browse_name);
}
}

특정 노드의 탐색에 실패(NodeId 오류)할 경우, 해당 슬롯은 빈 값을 반환하며 Vec, 반환하지 않음 Err.

NodeClass filter​

pub enum NodeClass {
Unspecified = 0,
Object = 1,
Variable = 2,
Method = 4,
ObjectType = 8,
VariableType = 16,
ReferenceType = 32,
DataType = 64,
View = 128,
}
값포함
Unspecified전체
ObjectObject만
VariableVariable만
MethodMethod만

현재는 단일 NodeClass 필터만 SDK 지원됩니다(비트별 OR 조합은 지원되지 않음). 여러 클래스가 필요한 경우, Unspecified 모든 데이터를 가져온 후 클라이언트 측에서 필터링하시기 바랍니다.

오류​

OpcUaError 휴대:

  • BAD_NODE_ID_UNKNOWN — 노드가 존재하지 않습니다
  • BAD_COMMUNICATION_ERROR — 네트워크 장애
  • INVALID_ARGUMENT — node_id에 포함된 NUL

전송 실패 시 반환되며 Err, 개별 하위 노드 분석 실패 시 반환되지 않습니다 Err.

대형 노드의 페이징 (ContinuationPoint)​

한 번에 browse 반환되는 참조의 수는 서버 측에서 결정하며, 서버 측의 한 번에 반환 가능한 최대 한도를 초과하면 잘립니다. 잘릴 경우 첫 페이지만 browse 반환됩니다.

전체를 보려면, 다음을 사용하세요. BrowseWithPaging + BrowseNext:

let mut page = s.browse_with_paging("ns=2;s=BigFolder", NodeClass::Unspecified)?;
let mut all_refs = page.references.clone();
while let Some(cp) = page.continuation_point.take() {
if cp.is_empty() { break; }
page = s.browse_next(&cp, false)?;
all_refs.extend(page.references.iter().cloned());
}

또는 한 줄 형식:

let all = s.browse_all("ns=2;s=BigFolder", NodeClass::Unspecified, 100)?;

참조 → Node 변환​

for r in s.browse("ns=2;s=Boiler1", NodeClass::Variable)? {
let node = r.to_node(&s); // 회전 가능 Node
let dv = node.value()?;
println!("{} = {:?}", r.display_name, dv.variant());
}

성능​

  • 단일 실행 Browse: 네트워크 왕복 한 번 + 서버 측 순회. 소요 시간은 네트워크 및 서버에 따라 달라지며, 사용자의 환경에서 실제 테스트를 통해 확인해야 합니다.
  • browse_many 일괄 처리: 총 소요 시간 ≈ 단일 처리 (N-1회의 왕복 이동 절약)
  • 자식 노드의 수가 서버의 단일 응답 제한을 초과할 경우 페이징이 적용되며, browse_all / 로 browse_next 처리됩니다.

browse_filtered — 방향 + 참조 유형 필터링​

browse_filtered 의 API 에 browse 를 기반으로 BrowseDirection + reference_type_id + include_subtypes + result_mask 네 개의 매개변수가 추가됩니다 (Part 4 §5.8.2.2). 현재 이 네 가지 매개변수가 적용되지 않습니다., 아래의 「구현 설명」을 참조하십시오.

pub fn browse_filtered(
&self,
node_id: &str,
node_class_filter: NodeClass,
direction: BrowseDirection,
reference_type_id: Option<&str>,
include_subtypes: bool,
result_mask: u32,
) -> Result<Vec<Reference>, OpcUaError>

관련 구조:

pub enum BrowseDirection {
Forward = 0, // 양방향만, 부모→자식
Inverse = 1, // 오직 역방향, 자식→부모
Both = 2, // 양방향 모두 반환
}

예시​

use darra_opcua::BrowseDirection;

// 1) 양의 방향 전달 + HierarchicalReferences (i=33) —— 현재 구현에서는 에 따라만 NodeClass 필터링합니다
let children = ua.browse_filtered("ns=2;s=Boiler1",
NodeClass::Unspecified, BrowseDirection::Forward,
Some("i=33"), true, 0x3F)?;

// 2) 역방향 전송 —— "부모 노드만 남기"가 필요한 경우 클라이언트 측에서 직접 필터링해 주십시오
let parents = ua.browse_filtered("ns=2;s=Tank.Level",
NodeClass::Unspecified, BrowseDirection::Inverse, None, true, 0x3F)?;
for p in &parents {
println!("父: {}", p.browse_name);
}

// 3) 양방향
let all = ua.browse_filtered("ns=2;s=Robot.Joint1",
NodeClass::Unspecified, BrowseDirection::Both, None, true, 0x3F)?;

구현 설명​

현재 구현일률적으로 하락~ browse(node_id, node_class_filter), 오직 NodeClass 필터링이 적용됩니다:

  • direction / reference_type_id / include_subtypes / result_mask 네 개의 매개변수가 구현 과정에서 직접 버려집니다 (let _ = (direction, reference_type_id, include_subtypes, result_mask);), 작동하지도 않고, 경고도 표시되지 않는다.
  • DarraUa_Session_BrowseWithFilter 현재 내보내지 않음 (관련된 하위 경로는 DarraUa_Session_BrowseNode / DarraUa_Session_BrowseNodes / 뿐입니다 DarraUa_Session_BrowseNext), 이 이름으로 호출하면 실패합니다.

추후 해당 진입점을 저수준으로 내보낸 후 네이티브 호출로 전환할 수 있으며, 공통 부분은 API 변경되지 않습니다.

현재 동작

위 예시에서 direction / reference_type_id 매개변수현재는 반환 결과에 영향을 미치지 않습니다.. 방향/참조 유형별로 필터링해야 할 경우, 클라이언트 측에서 반환된 데이터를 직접 Reference 필터링해 주십시오.

다음 단계​