본문으로 건너뛰기

OpcUaNode

OpcUaNode 네 NodeCollection.get 반환된 래퍼 객체는 원격 노드 하나를 나타냅니다. Lazy Load — 속성에 접근할 때만 트리거됩니다 RPC.

사전 읽기
  • 진입점은 NodeCollection을(를) 참조하십시오.
  • 연쇄 인덱싱으로 인한 반복을 피하려면 다음을 사용하십시오 RPC . TranslateBrowsePaths 경로를 한 번에 분석합니다.

공용 메서드​

분류속성유형접근설명
표식 (없음 RPC)getNodeId()StringR노드 ID 문자열
데이터 (트리거 RPC)getValue()OpcUaDataValueR현재 값 — read(Value)를 트리거하며, 반환 후 close가 필요함
getDisplayName()StringR표시 이름 — read(DisplayName) 호출
getBrowseName()StringR브라우즈 이름 — read(BrowseName) 호출
getDescription()StringR설명 — read(Description)을 호출합니다
getNodeClass()Enums.NodeClassR노드 클래스 — read(NodeClass) 호출
getDataTypeNodeId()StringR데이터 유형 NodeId — read(DataType) 호출
isReadable()booleanRAccessLevel bit0 — read(AccessLevel) 호출
isWritable()booleanRAccessLevel bit1 — 위와 동일
자식 노드 (트리거 RPC)getChildren()List<Reference>R자식 노드 목록 — 트리거 browse

자식 노드 액세스​

방법반환값설명
node.get(String browseName)OpcUaNode (찾을 수 없음, null 반환)/ BrowseName 키를 눌러 직접 자식 노드를 DisplayName 선택합니다.
node.resolve(String path)OpcUaNode다층 BrowsePath 분석에 따라

사용 방법​

방법설명
readAttribute(Enums.AttributeId attr)지정된 Attribute를 읽고, 반환합니다 ( OpcUaDataValue close 필요)
write(OpcUaVariant v)Value를 입력하고, 반환 Enums.StatusCode
writeAttribute(Enums.AttributeId attr, OpcUaVariant v)지정된 Attribute를 작성하고, 반환 Enums.StatusCode
call(String parentObjectNodeId, OpcUaVariant... inputs)이 노드를 메서드처럼 호출하여 반환합니다. List<OpcUaVariant>

예시​

// 1. 노드 가져오기 (없음 RPC)
OpcUaNode temp = ua.nodes.get("ns=2;s=Temperature");

// 2. 기본 정보 읽기 (각 1회 RPC)
System.out.println("NodeId = " + temp.getNodeId());
System.out.println("DisplayName = " + temp.getDisplayName());
System.out.println("DataType = " + temp.getDataTypeNodeId());
System.out.println("NodeClass = " + temp.getNodeClass());

// 3. 판독값
try (OpcUaDataValue dv = temp.getValue()) {
System.out.println("Value = " + dv.variant().asDouble() + " °C");
}

// 4. 쓰기
try (OpcUaVariant v = new OpcUaVariant().setDouble(25.5)) {
temp.write(v);
}

// 5. 자식 노드 탐색
for (Reference child : temp.getChildren()) {
System.out.println(" " + child.getBrowseName() + " -> " + child.getNodeId());
}

// 6. 연쇄 호출 (Server.ServerStatus.CurrentTime)
try (OpcUaDataValue time = ua.nodes.server().get("ServerStatus").get("CurrentTime").getValue()) {
long ft = time.variant().asFileTime();
System.out.println("Server time FileTime = " + ft);
}

주의사항​

  • 모든 트리거 RPC 메서드는 "한 번 읽으면 한 번 반환"하는 방식이며, 캐시하지 않음. 변수에 저장한 내용을 캐시하고 싶다
  • 연쇄 호출 a.get("b").get("c") 각 세그먼트마다 한 번씩 Browse RPC, 총 N번
  • OpcUaDataValue 반드시 close해야 합니다. 그렇지 않으면 네이티브 메모리가 누수됩니다.
  • 스레드 간 사용은 OpcUaNode 안전합니다(상태가 없음), 하지만 OpcUaDataValue 스레드 간에는 사용하지 마십시오
  • node.get(browseName)은 찾을 수 없으면 null을 반환합니다 (Java 스타일), 예외를 발생시키지 않음 — 상위 레벨에서 명시적으로 null 확인

resolve와의 비교​

// 방법 A: 연쇄 인덱스 - 4회 RPC
try (OpcUaDataValue time = ua.nodes.server().get("ServerStatus").get("CurrentTime").getValue()) {
// 4회 읽기: server() (없음 RPC) + get("ServerStatus") + get("CurrentTime") + getValue()
// 실제로 3회 Browse + 1회 읽기
}

// 방법 B: 경로 해석 - 2회 RPC
OpcUaNode node = ua.resolve("/Objects/Server/ServerStatus/CurrentTime"); // 1회
try (OpcUaDataValue time = node.getValue()) { /* 1회 */ }

// 방법 C: 직접 NodeId - 1회 RPC
try (OpcUaDataValue time = ua.read("i=2258")) { /* ... */ }

경로가 이미 알려진 경우 → 방식 C; 탐색형 개발 → 방식 A.

다음 단계​