本页内容

QOpcUaReadResult Class

该类用于存储读取操作的结果。更多内容...

头文件: #include <QOpcUaReadResult>
CMake: find_package(Qt6 REQUIRED COMPONENTS OpcUa)
target_link_libraries(mytarget PRIVATE Qt6::OpcUa)
qmake: QT += opcua

公共函数

QOpcUaReadResult()
QOpcUaReadResult(const QOpcUaReadResult &other)
QOpcUa::NodeAttribute attribute() const
QString indexRange() const
QString nodeId() const
QDateTime serverTimestamp() const
void setAttribute(QOpcUa::NodeAttribute attribute)
void setIndexRange(const QString &indexRange)
void setNodeId(const QString &nodeId)
void setServerTimestamp(const QDateTime &serverTimestamp)
void setSourceTimestamp(const QDateTime &sourceTimestamp)
void setStatusCode(QOpcUa::UaStatusCode statusCode)
void setValue(const QVariant &value)
QDateTime sourceTimestamp() const
QOpcUa::UaStatusCode statusCode() const
QVariant value() const
QOpcUaReadResult &operator=(const QOpcUaReadResult &rhs)

详细说明

对 OPC UA 服务器的读取操作将返回值以及时间戳,这些时间戳分别描述了源生成该值的时间以及服务器获取该值的时间。该操作还会返回一个状态码,用于说明是否成功读取了该值;若未成功,则说明读取失败的原因。

除了服务器返回的数据外,该类还包含请求中的节点 ID、属性及索引范围,以便客户端将结果与请求进行匹配。

该类的对象由QOpcUaClient::readNodeAttributesFinished()信号返回,其中包含作为QOpcUaClient::readNodeAttributes()请求一部分的读取操作结果。

另请参阅 QOpcUaClient::readNodeAttributes()、QOpcUaClient::readNodeAttributesFinished() 和QOpcUaReadItem 。

成员函数文档

QOpcUaReadResult::QOpcUaReadResult()

默认情况下会生成一个未设置任何参数的读取结果。

QOpcUaReadResult::QOpcUaReadResult(const QOpcUaReadResult &other)

根据other 生成读取结果。

QOpcUa::NodeAttribute QOpcUaReadResult::attribute() const

返回属性 id。

另请参阅 setAttribute()。

QString QOpcUaReadResult::indexRange() const

返回索引范围。

另请参阅 setIndexRange()。

QString QOpcUaReadResult::nodeId() const

返回节点 ID。

另请参阅 setNodeId()。

QDateTime QOpcUaReadResult::serverTimestamp() const

返回value() 的服务器时间戳。

另请参阅 setServerTimestamp()。

void QOpcUaReadResult::setAttribute(QOpcUa::NodeAttribute attribute)

将属性 id 设置为attribute 。

另请参阅 attribute()。

void QOpcUaReadResult::setIndexRange(const QString &indexRange)

将索引范围设置为indexRange 。

另请参阅 indexRange()。

void QOpcUaReadResult::setNodeId(const QString &nodeId)

将节点 ID 设置为nodeId 。

另请参阅 nodeId()。

void QOpcUaReadResult::setServerTimestamp(const QDateTime &serverTimestamp)

将服务器时间戳设置为serverTimestamp 。

另请参阅 serverTimestamp()。

void QOpcUaReadResult::setSourceTimestamp(const QDateTime &sourceTimestamp)

将源时间戳设置为sourceTimestamp 。

另请参阅 sourceTimestamp()。

void QOpcUaReadResult::setStatusCode(QOpcUa::UaStatusCode statusCode)

将状态码设置为statusCode 。

另请参阅 statusCode()。

void QOpcUaReadResult::setValue(const QVariant &value)

将值设置为value 。

另请参阅 value()。

QDateTime QOpcUaReadResult::sourceTimestamp() const

返回value() 的源时间戳。

另请参阅 setSourceTimestamp()。

QOpcUa::UaStatusCode QOpcUaReadResult::statusCode() const

返回该元素的状态码。如果状态码不是Good ,则该值和时间戳无效。

另请参阅 setStatusCode()。

QVariant QOpcUaReadResult::value() const

返回该值。

另请参阅 setValue()。

QOpcUaReadResult &QOpcUaReadResult::operator=(const QOpcUaReadResult &rhs)

将rhs 中的值设置到此读取结果中。

© 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.