summaryrefslogtreecommitdiffstats
path: root/src/opcua/client/qopcuanode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/opcua/client/qopcuanode.cpp')
-rw-r--r--src/opcua/client/qopcuanode.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/opcua/client/qopcuanode.cpp b/src/opcua/client/qopcuanode.cpp
index 27003a3..7647bc5 100644
--- a/src/opcua/client/qopcuanode.cpp
+++ b/src/opcua/client/qopcuanode.cpp
@@ -784,6 +784,51 @@ bool QOpcUaNode::browse(const QOpcUaBrowseRequest &request)
return d->m_impl->browse(request);
}
+/*!
+ Starts a read history request for this node. This is the Qt OPC UA representation for the OPC UA
+ ReadHistory service for reading raw historical data defined in
+ \l {https://reference.opcfoundation.org/v104/Core/docs/Part4/5.10.3/} {OPC-UA part 4, 5.10.3}.
+ The start timestamp, end timestamp, number of values per node and returnBounds can
+ be specified in the according parameters.
+
+ Returns a \l QOpcUaHistoryReadResponse which contains the state of the request if the asynchronous
+ request has been successfully dispatched. The results are returned in the
+ \l QOpcUaHistoryReadResponse::readHistoryDataFinished(QList<QOpcUaHistoryData> results, QOpcUa::UaStatusCode serviceResult)
+ signal.
+
+ In the following example, the historic data from the last two days of a node are requested and printed.
+ The result is limited to ten values per node.
+
+ \code
+ 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();
+ }
+ }
+ });
+ }
+ \endcode
+*/
+QOpcUaHistoryReadResponse *QOpcUaNode::readHistoryRaw(const QDateTime &startTime, const QDateTime &endTime, quint32 numValues, bool returnBounds)
+{
+ Q_D(QOpcUaNode);
+ if (d->m_client.isNull() || d->m_client->state() != QOpcUaClient::Connected)
+ return nullptr;
+
+ return d->m_impl->readHistoryRaw(startTime, endTime, numValues, returnBounds);
+}
+
QDebug operator<<(QDebug dbg, const QOpcUaNode &node)
{
dbg << "QOpcUaNode {"