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를 갖습니다. 노드는 네임스페이스 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 로 변환하여 단순화할 수 있습니다.
구독 및 모니터링되는 항목
구독은 노드에서 지속적으로 변경 사항을 폴링하는 대신 데이터 변경 또는 이벤트 발생 시 알림을 받을 수 있도록 하는 OPC UA의 개념입니다. 모니터링되는 항목은 노드의 속성이 변경되는지 감시하는 방법을 정의합니다. 이러한 항목은 구독에 추가되며 해당 항목에서 생성되는 모든 알림은 구독을 통해 사용자에게 전달됩니다. 업데이트 간격은 물론 모니터링되는 항목과 구독의 다른 많은 옵션은 사용자가 구성할 수 있습니다.
QOpcUaNode 는 구독 및 모니터링되는 항목과 상호 작용할 수 있는 추상화를 제공합니다. enableMonitoring()는 하나 이상의 속성에 대한 데이터 변경 알림을 활성화합니다. dataChangeOccurred 신호에는 새 값이 포함되며 로컬 캐시가 업데이트됩니다. disableMonitoring()는 데이터 변경 알림을 비활성화합니다. monitoringStatusChanged 신호는 수동으로 활성화 및 비활성화하거나 서버의 상태가 변경된 후 등 모니터링 상태의 변경에 대해 알립니다.
이벤트 모니터링은 설정 및 수명 주기 관리에 동일한 API를 사용합니다. EventNotifier 속성은 필수 이벤트 필드를 선택하고 사용자 정의 기준에 따라 보고된 이벤트를 필터링하는 EventFilter 을 사용하여 모니터링해야 합니다. 이벤트는 eventOccurred() 신호에서 선택한 이벤트 필드의 값을 포함하는 QVariantList 으로 보고됩니다.
구독 및 모니터링되는 항목의 설정은 modifyMonitoring()를 사용하여 런타임에 수정할 수 있습니다.
주소 공간 찾아보기
browseChildren 는 이러한 참조를 정방향으로 따라가며 browseFinished 신호에서 QOpcUaNode 의 인스턴스 뒤에 있는 노드에 연결된 모든 노드의 속성을 반환합니다. browse()는 browseChildren()와 유사하지만 찾아보기 호출을 구성하는 데 더 많은 옵션을 제공합니다.
메서드 호출
QOpcUaNode 는 callMethod 을 통해 이를 지원하며, 은 매개변수를 받아 methodCallFinished 신호로 호출 결과를 반환합니다.
찾아보기 경로 확인
유형 설명에 대한 프로그래밍을 지원하기 위해 OPC UA는 특정 노드에서 시작하는 찾아보기 이름 경로를 확인하여 대상 노드의 노드 ID를 가져오는 기능을 지원합니다. resolveBrowsePath () 메서드는 호출된 노드에서 시작하는 경로를 따라 resolveBrowsePathFinished() 신호로 결과를 반환합니다.
예제
클라이언트를 서버에 연결하고 QOpcUaNode 객체를 가져오려면 QOpcUaClient 을 참조하세요.
노드가 성공적으로 생성되면 서버에서 루트 노드의 BrowseName을 읽습니다:
QOpcUaNode *rootNode; // 이전에 생성된 경우, QOpcUaClient 문서 참조.// 속성Read 신호에 연결합니다. 람다 대신 호환 가능한 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); 클라이언트->종점으로부터의연결 끊기(); } 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 ()의 조건과 일치하는 모든 노드에 대한 정보를 포함합니다. 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 주소 공간의 특수 개체입니다. 서버에서 이벤트가 트리거되면 이벤트 모니터링 항목은 이벤트 개체와 그 하위 노드의 노드 속성 중 선택된 값을 수집합니다. 이벤트 소스가 있는 모든 노드에서 이벤트를 모니터링할 수 있습니다. 노드에서 이벤트를 모니터링하려면 사용자가 필요로 하는 이벤트 필드가 포함된 EventFilter 속성과 기준별로 이벤트를 필터링하는 데 사용되는 where 절을 사용하여 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 에는 메소드의 출력 인수가 포함됩니다. result 에는 출력 인수가 없는 경우 비어 있거나 statusCode 에는 Good 이 없는 경우 비어 있습니다. 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()
이 참이 되며 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; } // 지금까지 얻은 결과를 출력합니다(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 서비스를 사용하여 이 노드에서 시작하는 하나 이상의 노드 ID로 path 탐색 경로를 확인합니다.
비동기 호출이 성공적으로 디스패치되면 true
을 반환합니다.
TranslateBrowsePathsToNodeIds는 주로 OPC UA 주소 공간의 구체적인 노드 집합 대신 유형 정의에 대해 프로그래밍하는 데 사용됩니다. 예를 들어 기계 모델에 대한 유형 정의는 찾아보기 이름이 "Machine"인 시작 노드와 찾아보기 이름이 "Fan"인 구성 요소로 구성될 수 있습니다. Fan에는 찾아보기 이름이 "RPM"인 컴포넌트가 있으며, 이 컴포넌트는 팬의 현재 RPM 값을 보유하는 변수 노드입니다. 해당 유형의 기계가 여러 대 있으며 이러한 각 기계는 기계 유형의 오브젝트로서 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 날짜 시간이 반환됩니다.
QDateTime QOpcUaNode::sourceTimestamp(QOpcUa::NodeAttribute attribute) const
attribute 의 마지막 읽기 또는 데이터 변경의 소스 타임스탬프를 반환합니다. 하나 이상의 attributeRead 또는 dataChangeOccurred 신호가 전송되기 전에는 null 날짜/시간이 반환됩니다.
QVariant QOpcUaNode::valueAttribute() const
노드의 Value 속성 값을 반환합니다.
반환된 값은 Value 속성을 성공적으로 읽거나 쓴 후 또는 모니터링의 데이터 변경으로 인해 속성 캐시가 업데이트된 후에만 유효합니다. 이는 상태 코드가 Good 또는 Value 속성에 대한 dataChangeOccurred() 신호와 함께 attributeRead() 또는 attributeWritten() 신호로 표시됩니다.
속성 캐시에 값이 없으면 잘못된 QVariant 이 반환됩니다.
readValueAttribute(), writeValueAttribute() 및 valueAttributeError()도 참조하세요 .
QOpcUa::UaStatusCode QOpcUaNode::valueAttributeError() const
노드의 Value 속성에 대한 오류 코드를 반환합니다. 상태 코드 Good 는 valueAttribute()의 유효한 반환 값을 나타냅니다. 속성 캐시에 항목이 없는 경우 BadNoEntryExists 가 반환됩니다.
[signal, since 6.7]
void QOpcUaNode::valueAttributeUpdated(const QVariant &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 메타 타입 | OPC UA 유형 |
---|---|
Bool | Boolean |
UChar | 바이트 |
Char | SByte |
UShort | UInt16 |
Short | Int16 |
Int | Int32 |
UInt | UInt32 |
ULongLong | UInt64 |
LongLong | Int64 |
Double | Double |
Float | Float |
QString | 문자열 |
QDateTime | DateTime |
QByteArray | 바이트 문자열 |
QUuid | Guid |
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 매개변수는 값 속성의 유형 정보를 제공하는 데 사용할 수 있습니다. 다른 모든 속성에는 알려진 유형이 있습니다.
writeAttribute()도 참조하세요 .
bool QOpcUaNode::writeValueAttribute(const QVariant &value, QOpcUa::Types type = QOpcUa::Types::Undefined)
type 의 유형 정보를 사용하여 value 을 노드의 Value 속성에 씁니다.
비동기 호출이 성공적으로 디스패치되면 true
을 반환합니다.
writeAttribute()도 참조하세요 .
© 2025 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.