이 페이지에서

QOpcUaNode Class

QOpcUaNode를 사용하면 OPC UA 노드와 상호 작용할 수 있습니다. 더 보기...

헤더: #include <QOpcUaNode>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpcUa)
target_link_libraries(mytarget PRIVATE Qt6::OpcUa)
qmake: QT += opcua
상속: QObject

공개 유형

공개 함수

QVariant attribute(QOpcUa::NodeAttribute attribute) const
QOpcUa::UaStatusCode attributeError(QOpcUa::NodeAttribute attribute) const
bool browse(const QOpcUaBrowseRequest &request)
bool browseChildren(QOpcUa::ReferenceTypeId referenceType = QOpcUa::ReferenceTypeId::HierarchicalReferences, QOpcUa::NodeClasses nodeClassMask = QOpcUa::NodeClass::Undefined)
bool callMethod(const QString &methodNodeId, const QList<QOpcUa::TypedVariant> &args = QList<QOpcUa::TypedVariant>())
QOpcUaClient *client() const
bool disableMonitoring(QOpcUa::NodeAttributes attr)
bool enableMonitoring(QOpcUa::NodeAttributes attr, const QOpcUaMonitoringParameters &settings)
bool modifyDataChangeFilter(QOpcUa::NodeAttribute attr, const QOpcUaMonitoringParameters::DataChangeFilter &filter)
bool modifyEventFilter(const QOpcUaMonitoringParameters::EventFilter &eventFilter)
bool modifyMonitoring(QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameter item, const QVariant &value)
QOpcUaMonitoringParameters monitoringStatus(QOpcUa::NodeAttribute attr)
QString nodeId() const
bool readAttributeRange(QOpcUa::NodeAttribute attribute, const QString &indexRange)
bool readAttributes(QOpcUa::NodeAttributes attributes = mandatoryBaseAttributes())
(since 6.7) QOpcUaHistoryReadResponse *readHistoryEvents(const QDateTime &startTime, const QDateTime &endTime, QOpcUaMonitoringParameters::EventFilter &filter, quint32 numValues = 0)
(since 6.3) QOpcUaHistoryReadResponse *readHistoryRaw(const QDateTime &startTime, const QDateTime &endTime, quint32 numValues, bool returnBounds)
(since 6.7) QOpcUaHistoryReadResponse *readHistoryRaw(const QDateTime &startTime, const QDateTime &endTime, quint32 numValues, bool returnBounds, QOpcUa::TimestampsToReturn timestampsToReturn)
bool readValueAttribute()
bool resolveBrowsePath(const QList<QOpcUaRelativePathElement> &path)
QDateTime serverTimestamp(QOpcUa::NodeAttribute attribute) const
QDateTime sourceTimestamp(QOpcUa::NodeAttribute attribute) const
QVariant valueAttribute() const
QOpcUa::UaStatusCode valueAttributeError() const
bool writeAttribute(QOpcUa::NodeAttribute attribute, const QVariant &value, QOpcUa::Types type = QOpcUa::Types::Undefined)
bool writeAttributeRange(QOpcUa::NodeAttribute attribute, const QVariant &value, const QString &indexRange, QOpcUa::Types type = QOpcUa::Types::Undefined)
bool writeAttributes(const QOpcUaNode::AttributeMap &toWrite, QOpcUa::Types valueAttributeType = QOpcUa::Types::Undefined)
bool writeValueAttribute(const QVariant &value, QOpcUa::Types type = QOpcUa::Types::Undefined)

신호

void attributeRead(QOpcUa::NodeAttributes attributes)
void attributeUpdated(QOpcUa::NodeAttribute attr, QVariant value)
void attributeWritten(QOpcUa::NodeAttribute attribute, QOpcUa::UaStatusCode statusCode)
void browseFinished(QList<QOpcUaReferenceDescription> children, QOpcUa::UaStatusCode statusCode)
void dataChangeOccurred(QOpcUa::NodeAttribute attr, QVariant value)
void disableMonitoringFinished(QOpcUa::NodeAttribute attr, QOpcUa::UaStatusCode statusCode)
void enableMonitoringFinished(QOpcUa::NodeAttribute attr, QOpcUa::UaStatusCode statusCode)
void eventOccurred(QVariantList eventFields)
void methodCallFinished(QString methodNodeId, QVariant result, QOpcUa::UaStatusCode statusCode)
void monitoringStatusChanged(QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameters items, QOpcUa::UaStatusCode statusCode)
void resolveBrowsePathFinished(QList<QOpcUaBrowsePathTarget> targets, QList<QOpcUaRelativePathElement> path, QOpcUa::UaStatusCode statusCode)
(since 6.7) void valueAttributeUpdated(const QVariant &value)

정적 공용 멤버

QOpcUa::NodeAttributes allBaseAttributes()
QOpcUa::NodeAttributes mandatoryBaseAttributes()

상세 설명

노드는 OPC UA 주소 공간의 기본 구성 요소입니다. 노드에는 탐색 이름, 값, 관련 속성과 같은 속성이 있으며, 주소 공간 내의 다른 노드에 대한 참조를 가질 수 있습니다. 노드는 네임스페이스별로 구성되며, ID는 숫자, 문자열, 네임스페이스별 형식(opaque) 또는 전역 고유 식별자(GUID) 등으로 지정될 수 있습니다. 노드는 네임스페이스 ID와 노드 ID로 식별됩니다. 이 식별자는 일반적으로 문자열로 지정됩니다. 예를 들어, 네임스페이스 0에 위치하고 숫자 식별자가 42인 노드의 식별자는 ns=0;i=42 라는 문자열이 됩니다. 문자열 식별자를 가진 노드는 ns=0;s=myStringIdentifier 을 통해 참조할 수 있습니다.

이 유형의 객체는 사용자가 소유하며, 더 이상 필요하지 않을 때는 삭제해야 합니다. 이 객체들은 이를 생성한 QOpcUaClient 가 존재하는 한 유효합니다.

속성의 읽기 및 쓰기

노드 속성은 ` readAttributes()` 또는 ` readAttributeRange()`가 호출될 때 서버에서 읽혀집니다. 결과는 로컬에 캐시되며, ` attributeRead ` 신호를 수신한 후 ` attribute()`를 사용하여 가져올 수 있습니다.

사용자에게 필요한 권한이 있는 경우, writeAttribute(), writeAttributes() 및 writeAttributeRange()을 사용하여 속성을 쓸 수 있습니다. 쓰기 작업의 성공 여부는 attributeWritten 신호를 통해 보고됩니다.

attributeError()에는 속성에 대한 마지막 읽기 또는 쓰기 작업과 관련된 상태 코드가 포함되어 있습니다. 이는 OPC UA 서비스에서 반환하는 저수준 상태 코드입니다. 이 상태 코드는 QOpcUa::errorCategory()를 사용하여 QOpcUa::ErrorCategory 로 변환함으로써 단순화할 수 있습니다.

구독 및 모니터링 항목

구독(Subscriptions)은 OPC UA의 개념으로, 노드의 변경 사항을 지속적으로 폴링하는 대신 데이터 변경이나 이벤트 발생 시 알림을 수신할 수 있게 해줍니다. 모니터링 대상 항목은 노드의 속성 변경 사항을 감시하는 방식을 정의합니다. 이 항목들은 구독에 추가되며, 생성된 모든 알림은 구독을 통해 사용자에게 전달됩니다. 업데이트 간격은 물론 모니터링 대상 항목 및 구독의 기타 다양한 옵션은 사용자가 구성할 수 있습니다.

QOpcUaNode 는 구독 및 모니터링 대상 항목과 상호 작용하기 위한 추상화 기능을 제공합니다. ` enableMonitoring()`는 하나 이상의 속성에 대한 데이터 변경 알림을 활성화합니다. ` dataChangeOccurred ` 신호에는 새로운 값이 포함되며, 로컬 캐시가 업데이트됩니다. ` disableMonitoring()`는 데이터 변경 알림을 비활성화합니다. ` monitoringStatusChanged ` 신호는 모니터링 상태의 변경(예: 수동 활성화 및 비활성화 후 또는 서버의 상태 변경 후)을 알립니다.

이벤트 모니터링은 설정 및 수명 주기 관리에 동일한 API를 사용합니다. EventNotifier 속성은 EventFilter 를 사용하여 모니터링해야 하며, 이 는 필요한 이벤트 필드를 선택하고 사용자 정의 기준에 따라 보고된 이벤트를 필터링합니다. 이벤트는 eventOccurred() 신호를 통해 QVariantList 로 보고되며, 여기에는 선택된 이벤트 필드의 값이 포함됩니다.

구독 및 모니터링 대상 항목의 설정은 modifyMonitoring()를 사용하여 런타임 중에 수정할 수 있습니다.

주소 공간 탐색

OPC UA 주소 공간은 참조로 연결된 노드들로 구성됩니다. ` browseChildren `는 이러한 참조를 순방향으로 추적하며, ` QOpcUaNode ` 인스턴스 뒤에 있는 노드에 연결된 모든 노드의 속성을 ` browseFinished ` 신호를 통해 반환합니다. ` browse()`는 ` browseChildren()`와 유사하지만, 탐색 호출을 구성할 수 있는 더 많은 옵션을 제공합니다.

메서드 호출

OPC UA는 사용자가 호출할 수 있는 서버 측 메서드를 정의합니다. QOpcUaNode 는 매개변수를 받아 methodCallFinished 신호를 통해 호출 결과를 반환하는 callMethod 를 통해 이를 지원합니다.

브라우즈 경로 해결

유형 설명을 기반으로 한 프로그래밍을 지원하기 위해, OPC UA는 특정 노드에서 시작하여 대상 노드의 노드 ID를 얻기 위한 탐색 이름 경로의 해결을 지원합니다. resolveBrowsePath() 메서드는 호출된 노드에서 시작하는 경로를 따라가며, 그 결과를 resolveBrowsePathFinished() 시그널을 통해 반환합니다.

예시

클라이언트를 서버에 연결하고 QOpcUaNode 객체를 가져오려면 QOpcUaClient 를 참조하십시오.

노드가 성공적으로 생성된 후, 루트 노드의 BrowseName을 서버에서 읽어옵니다:

QOpcUaNode*rootNode; // 앞서 생성된 변수입니다. QOpcUaClient 문서를 참조하십시오.
// attributeRead 신호에 연결합니다. 람다 대신 QObject의 호환되는 슬롯을 사용할 수 있습니다.
QObject::connect(rootNode, &QOpcUaNode::attributeRead, [rootNode, client](QOpcUa::NodeAttributes attr) {
    qDebug() << "Signal for attributes:" << attr;
   if (rootNode->attributeError(QOpcUa::NodeAttribute::BrowseName) != QOpcUa::UaStatusCode::Good) {
        qDebug() << "Failed to read attribute:" << rootNode->attributeError(QOpcUa::NodeAttribute::BrowseName);
        client->disconnectFromEndpoint();
    }
    qDebug() << "Browse name:" << rootNode->attribute(QOpcUa::NodeAttribute::BrowseName).value<QOpcUaQualifiedName>().name();
});
rootNode->readAttributes(QOpcUa::NodeAttribute::BrowseName); // 노드의 BrowseName 속성에 대한 읽기 작업을 시작합니다.

멤버 유형 설명서

QOpcUaNode::AttributeMap

이 유형은 ` writeAttributes()` 함수가 한 번에 여러 속성을 기록할 때 사용됩니다. 기록할 속성에는 ` QVariant ` 값이 할당되어 있어야 합니다.

멤버 함수 설명서

[static constexpr] QOpcUa::NodeAttributes QOpcUaNode::allBaseAttributes()

OPC UA 기본 노드 클래스의 모든 속성을 포함합니다.

QVariant QOpcUaNode::attribute(QOpcUa::NodeAttribute attribute) const

attribute 에 지정된 속성의 값을 반환합니다.

이 값은 attributeRead 신호가 발신된 후에만 유효합니다. 해당 속성에 대해 캐시된 값이 없는 경우, 빈 QVariant 가 반환됩니다.

QOpcUa::UaStatusCode QOpcUaNode::attributeError(QOpcUa::NodeAttribute attribute) const

attribute 에 지정된 속성에 대한 오류 코드를 반환합니다.

이 오류 코드는 attributeRead 또는 attributeWritten 신호가 발생된 후에만 유효합니다.

속성 캐시에 항목이 없는 경우, BadNoEntryExists 가 반환됩니다.

QOpcUa::errorCategory도 참조하십시오 .

[signal] void QOpcUaNode::attributeRead(QOpcUa::NodeAttributes attributes)

이 신호는 ` readAttributes()` 또는 ` readAttributeRange()` 작업이 완료된 후 전송됩니다. 수신자는 ` attributes`에 포함된 속성에 대한 상태 코드를 확인해야 합니다.

[signal] void QOpcUaNode::attributeUpdated(QOpcUa::NodeAttribute attr, QVariant value)

이 신호는 서버로부터의 데이터 변경 알림, 읽기 또는 쓰기 작업으로 인해 속성 캐시의 값이 업데이트된 후에 발송됩니다. value 에는 노드 속성 attr 의 새 값이 포함되어 있습니다.

attribute(), attributeError(), serverTimestamp(), sourceTimestamp() 및 valueAttributeUpdated()도 참조하십시오 .

[signal] void QOpcUaNode::attributeWritten(QOpcUa::NodeAttribute attribute, QOpcUa::UaStatusCode statusCode)

이 신호는 writeAttribute(), writeAttributes() 또는 writeAttributeRange() 작업이 완료된 후에 발생합니다.

이 신호가 발생하기 전에, 쓰기 작업이 성공한 경우 속성 캐시가 업데이트됩니다. writeAttributes()의 경우, 쓰기 호출에 포함된 각 속성마다 신호가 발생합니다. statusCode 에는 attribute 에 대한 쓰기 작업의 성공 정보가 포함됩니다.

bool QOpcUaNode::browse(const QOpcUaBrowseRequest &request)

이 노드에서 탐색 호출을 시작합니다.

비동기 호출이 성공적으로 디스패치된 경우 ` true `를 반환합니다.

request 에 지정된 조건과 일치하는 모든 참조는 browseFinished() 시그널을 통해 반환됩니다.

예를 들어, 역 탐색 호출을 사용하여 속성 노드의 부모 노드를 찾을 수 있습니다:

QOpcUaBrowseRequest request;
request.setBrowseDirection(QOpcUaBrowseRequest::BrowseDirection::Inverse);
request.setReferenceTypeId(QOpcUa::ReferenceTypeId::HasProperty);
propertyNode->browse(request);

bool QOpcUaNode::browseChildren(QOpcUa::ReferenceTypeId referenceType = QOpcUa::ReferenceTypeId::HierarchicalReferences, QOpcUa::NodeClasses nodeClassMask = QOpcUa::NodeClass::Undefined)

이 메서드가 호출된 노드를 시작으로 순방향 탐색 호출을 실행합니다. 탐색 작업은 해당 노드에 연결된 자식 노드에 대한 정보를 수집하고, 그 결과를 browseFinished() 신호를 통해 전달합니다.

비동기 호출이 성공적으로 디스패치된 경우 true 를 반환합니다.

특정 참조 유형을 통해 노드에 연결된 자식 노드만 요청하려면 ` referenceType `을 해당 참조 유형으로 설정해야 합니다. 예를 들어, ` referenceType`에서 ` HasProperty `를 전달하여 노드의 모든 속성을 가져올 때 이 방법을 사용할 수 있습니다. ` nodeClassMask`에 특정 노드 클래스를 설정하여, 해당 클래스를 가진 노드만 포함하도록 결과를 필터링할 수 있습니다.

[signal] void QOpcUaNode::browseFinished(QList<QOpcUaReferenceDescription> children, QOpcUa::UaStatusCode statusCode)

이 신호는 browseChildren() 또는 browse() 작업이 완료된 후에 발생합니다.

children browseChildren()에서 지정된 조건에 부합하는 모든 노드에 대한 정보를 포함합니다. 는 browse 작업의 서비스 결과를 포함합니다. 가 가 아닌 경우, 전달된 벡터는 비어 있습니다. statusCode statusCode Good children

QOpcUaReferenceDescription도 참조하십시오 .

bool QOpcUaNode::callMethod(const QString &methodNodeId, const QList<QOpcUa::TypedVariant> &args = QList<QOpcUa::TypedVariant>())

args 를 통해 전달된 매개변수를 사용하여 OPC UA 메서드 methodNodeId 를 호출합니다. 결과는 methodCallFinished 신호를 통해 반환됩니다.

비동기 호출이 성공적으로 디스패치된 경우 true 를 반환합니다.

QOpcUaClient *QOpcUaNode::client() const

이 노드를 생성한 클라이언트에 대한 포인터를 반환합니다.

[signal] void QOpcUaNode::dataChangeOccurred(QOpcUa::NodeAttribute attr, QVariant value)

이 신호는 데이터 변경 알림을 수신한 후에 전송됩니다. value 에는 노드 속성 attr 의 새 값이 포함되어 있습니다.

attribute(), serverTimestamp() 및 sourceTimestamp()도 참조하십시오 .

bool QOpcUaNode::disableMonitoring(QOpcUa::NodeAttributes attr)

이 메서드는 attr 에 지정된 속성에 대한 모니터링을 비활성화합니다.

비동기 호출이 성공적으로 디스패치된 경우 true 를 반환합니다.

호출이 완료되면 disableMonitoringFinished 신호가 발생하고, monitoringStatus 는 attr 에 대해 상태 코드 BadMonitoredItemIdIinvalid를 가진 기본 생성된 값을 반환합니다.

[signal] void QOpcUaNode::disableMonitoringFinished(QOpcUa::NodeAttribute attr, QOpcUa::UaStatusCode statusCode)

이 신호는 ` disableMonitoring()`에 대한 비동기 호출이 완료된 후 발생합니다. ` statusCode `에는 해당 작업에서 생성된 상태 코드가 포함됩니다. 이 신호가 발생한 후, ` monitoringStatus `는 ` attr`에 대해 상태 코드 `BadMonitoredItemIdIinvalid`를 가진 기본 생성된 값을 반환합니다.

bool QOpcUaNode::enableMonitoring(QOpcUa::NodeAttributes attr, const QOpcUaMonitoringParameters &settings)

이 메서드는 attr 에 지정된 각 속성에 대해 모니터링 대상을 생성합니다. 모니터링 대상 생성 및 구독 설정에는 settings 의 설정이 사용됩니다.

비동기 호출이 성공적으로 전송된 경우 true 를 반환합니다.

호출이 완료되면 enableMonitoringFinished 신호가 발송됩니다. 잘못된 상태 코드가 생성되는 오류 사례는 여러 가지가 있습니다: settings 에 지정된 구독 ID를 가진 구독이 존재하지 않거나, 서버에 노드가 존재하지 않거나, 노드에 요청된 속성이 없거나, 서버의 모니터링 항목 최대 수에 도달한 경우입니다.

이벤트 모니터링을 활성화하는 데도 동일한 메서드가 사용됩니다. 이벤트는 OPC UA 주소 공간 내의 특수한 객체로, 발생한 이벤트에 대한 정보를 포함합니다. 서버에서 이벤트가 트리거되면, 이벤트 모니터링 항목은 이벤트 객체 및 그 자식 노드의 노드 속성 중 선택된 값들을 수집합니다. 이벤트 소스를 가진 모든 노드는 이벤트 모니터링 대상이 될 수 있습니다. 노드의 이벤트를 모니터링하려면, 사용자에게 필요한 이벤트 필드를 포함하고, 선택적으로 기준에 따라 이벤트를 필터링하는 데 사용되는 where 절을 포함하는 EventFilter를 사용하여 ‘ EventNotifier ’ 속성을 모니터링해야 합니다(자세한 내용은 QOpcUaMonitoringParameters::EventFilter 참조).

[signal] void QOpcUaNode::enableMonitoringFinished(QOpcUa::NodeAttribute attr, QOpcUa::UaStatusCode statusCode)

이 신호는 ` enableMonitoring()`에 대한 비동기 호출이 완료된 후 발생합니다. 이 신호가 발생한 후, ` monitoringStatus()`는 ` attr`에 대한 유효한 정보를 반환합니다. ` statusCode `에는 해당 작업의 상태 코드가 포함됩니다.

[signal] void QOpcUaNode::eventOccurred(QVariantList eventFields)

이 신호는 새로운 이벤트가 수신된 후에 전송됩니다.

eventFields 이 신호에는 이벤트 필터의 ` select ` 절에 지정된 순서대로 이벤트 필드의 값들이 포함됩니다.

[static constexpr] QOpcUa::NodeAttributes QOpcUaNode::mandatoryBaseAttributes()

OPC UA 기본 노드 클래스의 모든 필수 속성을 포함합니다.

[signal] void QOpcUaNode::methodCallFinished(QString methodNodeId, QVariant result, QOpcUa::UaStatusCode statusCode)

이 신호는 서버에서 ` methodNodeId `에 대한 메서드 호출이 완료된 후 발생합니다. ` statusCode `에는 메서드 호출의 상태 코드가 포함되며, ` result `에는 메서드의 출력 인자가 포함됩니다. 메서드에 출력 인자가 없거나 ` statusCode `가 ` Good`와 다를 경우, ` result `는 비어 있습니다. result 변형은 출력 인자가 하나뿐인 경우 단일 값을 가지며, 호출된 함수가 여러 개의 출력 인자를 반환한 경우에는 변형들의 목록을 포함합니다.

if (result.canConvert<QVariantList>()) {
    // handle list type
} else {
    // handle value type
}

bool QOpcUaNode::modifyDataChangeFilter(QOpcUa::NodeAttribute attr, const QOpcUaMonitoringParameters::DataChangeFilter &filter)

기존 데이터 변경 모니터링을 수정하여 데이터 변경 필터로 filter 를 사용하도록 설정합니다.

필터 수정 요청이 백엔드로 성공적으로 전송된 경우 true 을 반환합니다.

monitoringStatusChanged 작업이 완료된 후 attr 에 대한 이벤트가 발생합니다.

bool QOpcUaNode::modifyEventFilter(const QOpcUaMonitoringParameters::EventFilter &eventFilter)

기존 이벤트 모니터링을 수정하여 eventFilter 을 이벤트 필터로 사용하도록 설정합니다.

필터 수정 요청이 백엔드로 성공적으로 전송된 경우 true 를 반환합니다.

monitoringStatusChanged 작업이 완료된 후 ` EventNotifier `에 대한 이벤트가 발생합니다.

bool QOpcUaNode::modifyMonitoring(QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameter item, const QVariant &value)

이 메서드는 모니터링 대상 또는 구독의 설정을 수정합니다. ` attr `와 연결된 모니터링 대상 또는 구독의 ` item ` 매개변수를 ` value`로 설정하려고 시도합니다.

비동기 호출이 성공적으로 디스패치된 경우 ` true `를 반환합니다.

호출이 완료된 후, ` monitoringStatusChanged ` 신호가 발생합니다. 이 신호에는 수정된 매개변수와 상태 코드가 포함됩니다. 요청된 속성과 연관된 모니터링 항목이 없거나, 요청된 매개변수의 수정이 구현되지 않았거나, 서버가 요청된 값을 거부한 경우 잘못된 상태 코드가 생성됩니다.

QOpcUaMonitoringParameters QOpcUaNode::monitoringStatus(QOpcUa::NodeAttribute attr)

attr 속성과 관련된 모니터링 매개변수를 반환합니다. 이 기능은 enableMonitoring()의 성공 여부를 확인하거나 매개변수가 수정되었는지 확인하는 데 사용할 수 있습니다. 반환된 값은 attr 에 대해 enableMonitoringFinished 또는 monitoringStatusChanged 신호가 발생된 후에만 유효합니다. 신호가 발생되기 전에 상태를 조회하는 경우, QOpcUaMonitoringParameters::statusCode()은 BadNoEntryExists 을 반환합니다.

[signal] void QOpcUaNode::monitoringStatusChanged(QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameters items, QOpcUa::UaStatusCode statusCode)

이 신호는 ` modifyMonitoring()`에 대한 비동기 호출이 완료된 후 발생합니다. 작업이 요청된 노드 속성은 ` attr`에 반환됩니다. ` items `에는 수정된 매개변수가 포함됩니다. ` statusCode `에는 서버에서 수행된 수정 작업의 결과가 포함됩니다.

QString QOpcUaNode::nodeId() const

OPC UA 노드의 ID를 반환합니다.

bool QOpcUaNode::readAttributeRange(QOpcUa::NodeAttribute attribute, const QString &indexRange)

노드 속성 attribute 에 대한 비동기 읽기 작업을 시작합니다. ` indexRange `는 배열의 일부를 선택하는 데 사용할 수 있는 문자열입니다. 이는 OPC UA 1.05 파트 4, 7.27에 정의되어 있습니다. 배열의 첫 번째 요소는 0이며, "1"은 두 번째 요소를, "0:9"는 처음 10개의 요소를, "0,1"은 2차원 배열의 첫 번째 행에서 두 번째 요소를 반환합니다.

비동기 호출이 성공적으로 디스패치된 경우 ` true `를 반환합니다.

속성 값은 attributeRead 신호가 발신된 후에만 유효한 정보를 포함합니다.

bool QOpcUaNode::readAttributes(QOpcUa::NodeAttributes attributes = mandatoryBaseAttributes())

attributes 에 있는 노드 속성에 대한 비동기 읽기 작업을 시작합니다.

비동기 호출이 성공적으로 전달된 경우 ` true `를 반환합니다.

attributeRead 신호가 발송된 후에야 속성 값에 유효한 정보가 포함됩니다.

[since 6.7] QOpcUaHistoryReadResponse *QOpcUaNode::readHistoryEvents(const QDateTime &startTime, const QDateTime &endTime, QOpcUaMonitoringParameters::EventFilter &filter, quint32 numValues = 0)

startTime, endTime, filter 및 numValues 매개변수를 사용하여 이 노드에 대한 읽기 이벤트 기록 요청을 시작합니다. filter 는 서버가 어떤 이벤트와 해당 이벤트의 어떤 필드 집합을 반환할지 결정하는 데 사용됩니다.

비동기 요청이 성공적으로 전달된 경우, 요청의 상태를 포함하는 ` QOpcUaHistoryReadResponse `를 반환합니다. 결과는 ` QOpcUaHistoryReadResponse::readHistoryEventsFinished(const QList<QOpcUaHistoryEvent> &results, QOpcUa::UaStatusCode serviceResult)` 시그널을 통해 반환됩니다.

다음 예제는 지난 이틀간의 기록 이벤트를 가져옵니다. 한 번에 최대 10개의 이벤트가 반환됩니다. 필터와 지정된 시간 범위에 일치하는 이벤트가 더 있는 경우, ` hasMoreData() `는 `true`가 되며 `readMoreData()`를 통해 더 많은 이벤트를 가져올 수 있습니다.

QScopedPointer<QOpcUaNode> node(opcuaClient->node("ns=2;s=EventHistorian"));
QVERIFY(node != nullptr);

QOpcUaMonitoringParameters::EventFilter filter;
filter << QOpcUaSimpleAttributeOperand("Message");
filter << QOpcUaSimpleAttributeOperand("Time");

const auto response = node->readHistoryEvents(QDateTime::currentDateTime().addDays(-2), QDateTime::currentDateTime(), filter, 10);

QObject::connect(response, &QOpcUaHistoryReadResponse::readHistoryEventsFinished, this,
                 [response](const QList<QOpcUaHistoryEvent> &results, QOpcUa::UaStatusCode serviceResult) {
                     if (serviceResult != QOpcUa::UaStatusCode::Good) {
                         qDebug() << "Service call failed with" << serviceResult;
                        return;
                     }

                     // 지금까지 얻은 결과를 출력합니다
                     for (const auto &result: response->events()) {
                         qDebug() << "Results for" << result.nodeId() << result.statusCode();
                        for (const auto &event: result.events())
                             qDebug() << "    Event:" << event;
                     }

                     if (response->hasMoreData())
                         response->readMoreData();
                 });

이 함수는 Qt 6.7에서 도입되었습니다.

[since 6.3] QOpcUaHistoryReadResponse *QOpcUaNode::readHistoryRaw(const QDateTime &startTime, const QDateTime &endTime, quint32 numValues, bool returnBounds)

이 노드에 대한 읽기 이력 요청을 시작합니다. 이는 OPC UA 1.05 파트 4, 5.10.3에 정의된 원시 이력 데이터를 읽기 위한 OPC UA ReadHistory 서비스의 Qt OPC UA 표현입니다. 이 요청은 startTime, endTime, numValues 및 returnBounds 매개변수를 기반으로 이력을 읽습니다.

비동기 요청이 성공적으로 전송된 경우, 요청의 상태를 포함하는 ` QOpcUaHistoryReadResponse `를 반환합니다. 결과는 ` QOpcUaHistoryReadResponse::readHistoryDataFinished(const QList<QOpcUaHistoryData> &results, QOpcUa::UaStatusCode serviceResult)` 시그널을 통해 반환됩니다.

다음 예제에서는 노드의 지난 이틀간의 기록 데이터를 요청하여 출력합니다. 결과는 노드당 10개 값으로 제한됩니다.

QOpcUaHistoryReadResponse*response = node->readHistoryRaw(QDateTime::currentDateTime(),
                                                           QDateTime::currentDateTime().addDays(-2),
                                                           10,
                                                           true);
if (response) {
    QObject::connect(response123, &QOpcUaHistoryReadResponse::readHistoryDataFinished,
                     [] (QList<QOpcUaHistoryData> results, QOpcUa::UaStatusCode serviceResult) {
        if (serviceResult != QOpcUa::UaStatusCode::Good) {
            qWarning() << "Fetching historical data failed with:" << serviceResult;
        } else {
            for (const auto& result : results) {
                qInfo() << "NodeId:" << result.nodeId();
               for (const auto &dataValue: result.result())
                    qInfo() << "Value:" << dataValue.value();
            }
        }
    });
}

이 함수는 Qt 6.3에서 도입되었습니다.

[since 6.7] QOpcUaHistoryReadResponse *QOpcUaNode::readHistoryRaw(const QDateTime &startTime, const QDateTime &endTime, quint32 numValues, bool returnBounds, QOpcUa::TimestampsToReturn timestampsToReturn)

이 노드에 대한 읽기 내역 요청을 시작합니다. 추가 매개변수인 ` timestampsToReturn `는 각 값에 대해 어떤 타임스탬프가 반환될지 결정합니다.

이 함수는 Qt 6.7에서 도입되었습니다.

bool QOpcUaNode::readValueAttribute()

노드의 Value 속성에 대한 비동기 읽기 작업을 시작합니다.

비동기 호출이 성공적으로 디스패치된 경우 ` true `를 반환합니다.

readAttributes()도 참조하십시오 .

bool QOpcUaNode::resolveBrowsePath(const QList<QOpcUaRelativePathElement> &path)

OPC UA 1.05 파트 4, 5.8.4에 명시된 TranslateBrowsePathsToNodeIds 서비스를 사용하여, 탐색 경로 path 를 이 노드를 시작으로 하는 하나 이상의 노드 ID로 변환합니다.

비동기 호출이 성공적으로 디스패치된 경우 true 를 반환합니다.

TranslateBrowsePathsToNodeIds는 주로 OPC UA 주소 공간 내의 구체적인 노드 집합 대신 유형 정의를 기반으로 프로그래밍하는 데 사용됩니다. 예를 들어, 기계 모델에 대한 유형 정의는 브라우즈 이름이 "Machine"인 시작 노드로 구성될 수 있으며, 이 노드에는 브라우즈 이름이 "Fan"인 컴포넌트가 포함될 수 있습니다. Fan에는 "RPM"이라는 브라우즈 이름을 가진 컴포넌트가 있으며, 이는 팬의 현재 RPM 값을 저장하는 변수(Variable) 노드입니다. 해당 유형의 기계가 여러 대 존재하며, 각 기계는 기계 유형의 객체로 OPC UA 주소 공간에 매핑됩니다. 이러한 각 기계 객체에 대해, 기계 노드에서 “RPM” 노드로 이어지는 경로는 동일합니다. 클라이언트가 현재 RPM 값을 읽으려면, 기계 노드를 시작 노드로 하고 기계에서 “RPM” 노드로 이어지는 탐색 경로를 매개변수로 지정하여 resolveBrowsePath()를 호출해야 합니다:

QScopedPointer<QOpcUaNode> node(opcuaClient->node("ns=1;s=machine1"));

QList<QOpcUaRelativePathElement> path;
path.append(QOpcUaRelativePathElement(QOpcUaQualifiedName(1, "Fan"), QOpcUa::ReferenceTypeId::HasComponent));
path.append(QOpcUaRelativePathElement(QOpcUaQualifiedName(1, "RPM"), QOpcUa::ReferenceTypeId::HasComponent));
node->resolveBrowsePath(path);

resolveBrowsePathFinished()에서 반환된 결과에는 "RPM" 노드의 노드 ID가 포함되어 있으며, 이를 사용하여 해당 노드의 속성에 접근할 수 있습니다:

if (!results.size()) {
    qWarning() << "Browse path resolution failed";
   return;
}

if (results.at(0).isFullyResolved()) {
   QOpcUaNode*rpmNode = client->node(results.at(0).targetId());
   if (!rpmNode) {
       qWarning() << "Failed to create node";
      return;
   }
   // 슬롯 연결, 메서드 호출
} else {
    qWarning() << "Browse path could not be fully resolved, the target node is on another server";
   return;
}

[signal] void QOpcUaNode::resolveBrowsePathFinished(QList<QOpcUaBrowsePathTarget> targets, QList<QOpcUaRelativePathElement> path, QOpcUa::UaStatusCode statusCode)

이 신호는 ` resolveBrowsePath()` 호출이 완료된 후에 발생합니다.

QOpcUaBrowsePathTarget targets 에는 일치하는 항목이 포함되어 있으며, ` `는 작업의 상태 코드입니다. ` `가 ` `가 아닌 경우, ` `는 비어 있습니다. 탐색 경로 ` `는 요청에서 가져온 탐색 경로입니다. 이 경로를 사용하여 결과를 요청과 연결할 수 있습니다. statusCode statusCode Good targets path

QDateTime QOpcUaNode::serverTimestamp(QOpcUa::NodeAttribute attribute) const

attribute 의 마지막 읽기 또는 데이터 변경 시점의 서버 타임스탬프를 반환합니다. attributeRead 또는 dataChangeOccurred 신호가 하나 이상 발생하기 전에는 null datetime이 반환됩니다.

QDateTime QOpcUaNode::sourceTimestamp(QOpcUa::NodeAttribute attribute) const

attribute 의 마지막 읽기 또는 데이터 변경 시점의 소스 타임스탬프를 반환합니다. attributeRead 또는 dataChangeOccurred 신호가 적어도 하나 발생하기 전에는 null datetime이 반환됩니다.

QVariant QOpcUaNode::valueAttribute() const

노드의 Value 속성 값을 반환합니다.

반환된 값은 Value 속성이 성공적으로 읽히거나 쓰인 후, 또는 모니터링을 통한 데이터 변경으로 속성 캐시가 업데이트된 후에만 유효합니다. 이는 Value 속성에 대해 상태 코드 Good 를 가진 attributeRead() 또는 attributeWritten() 신호, 혹은 dataChangeOccurred() 신호로 표시됩니다.

속성 캐시에 값이 없는 경우, 유효하지 않은 QVariant 이 반환됩니다.

readValueAttribute(), writeValueAttribute() 및 valueAttributeError()도 참조하십시오 .

QOpcUa::UaStatusCode QOpcUaNode::valueAttributeError() const

노드의 Value 속성에 대한 오류 코드를 반환합니다. 상태 코드 Good 는 valueAttribute()의 유효한 반환 값을 나타냅니다. 속성 캐시에 해당 항목이 없는 경우, BadNoEntryExists 가 반환됩니다.

[signal, since 6.7] void QOpcUaNode::valueAttributeUpdated(const QVariant &value)

이 신호는 서버로부터의 데이터 변경 알림, 읽기 또는 쓰기 작업으로 인해 속성 캐시의 value 속성이 업데이트된 후에 발생합니다. ` value `에는 value 속성의 새로운 값이 포함됩니다.

이 함수는 Qt 6.7에서 도입되었습니다.

attribute(), attributeError(), serverTimestamp(), sourceTimestamp(), attributeUpdated()도 참조하십시오 .

bool QOpcUaNode::writeAttribute(QOpcUa::NodeAttribute attribute, const QVariant &value, QOpcUa::Types type = QOpcUa::Types::Undefined)

type 에서 제공하는 유형 정보를 사용하여 attribute 에 지정된 속성에 value 를 기록합니다. 비동기 호출이 성공적으로 디스패치된 경우 true 를 반환합니다.

type 매개변수가 생략되면 백엔드는 올바른 타입을 찾으려고 시도합니다. 다음의 기본 타입이 가정됩니다:

Qt MetaTypeOPC UA 유형
BoolBoolean
UChar바이트
CharSByte
UShortUInt16
ShortInt16
IntInt32
UIntUInt32
ULongLongUInt64
LongLongInt64
DoubleDouble
FloatFloat
QStringString
QDateTimeDateTime
QByteArray바이트 문자열
QUuidGUID

bool QOpcUaNode::writeAttributeRange(QOpcUa::NodeAttribute attribute, const QVariant &value, const QString &indexRange, QOpcUa::Types type = QOpcUa::Types::Undefined)

type 의 유형 정보를 사용하여 attribute 에 지정된 속성에 value 를 기록합니다. indexRange 에 대해서는 readAttributeRange()을 참조하십시오.

비동기 호출이 성공적으로 디스패치된 경우 true 를 반환합니다.

bool QOpcUaNode::writeAttributes(const QOpcUaNode::AttributeMap &toWrite, QOpcUa::Types valueAttributeType = QOpcUa::Types::Undefined)

toWrite 에 지정된 속성과 값에 대한 쓰기 작업을 수행합니다.

비동기 호출이 성공적으로 디스패치된 경우 true 를 반환합니다.

valueAttributeType 매개변수는 value 속성에 대한 유형 정보를 제공하는 데 사용할 수 있습니다. 그 외의 모든 속성은 알려진 유형을 가집니다.

writeAttribute()도 참조하십시오 .

bool QOpcUaNode::writeValueAttribute(const QVariant &value, QOpcUa::Types type = QOpcUa::Types::Undefined)

type 에서 제공하는 유형 정보를 사용하여 노드의 Value 속성에 value 를 기록합니다.

비동기 호출이 성공적으로 디스패치된 경우 true 를 반환합니다.

writeAttribute()도 참조하십시오 .

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.