1// Copyright (C) 2019 basysKom GmbH, opensource@basyskom.com
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qopcuahistoryreadrawrequest.h"
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \class QOpcUaHistoryReadRawRequest
10 \inmodule QtOpcUa
11 \brief This class stores the necessary information to request historic data from a server.
12 \since 6.3
13
14 This is the Qt OPC UA representation for the OPC UA ReadRawModifiedDetails for reading historical data
15 defined in \l {https://reference.opcfoundation.org/Core/docs/Part11/6.4.3/} {OPC-UA part 11, 6.4.3}.
16
17 When requesting historic data from a server, several values need to be provided to the server
18 to know which data to collect. The QOpcUaHistoryReadRawRequest class provides the required values.
19 \a startTimestamp and \a endTimestamp define the timerange where historic data should be collected from.
20 \a nodesToRead defines from which nodes historic data should be collected.
21 \a numValuesPerNode defines the maximum number of data values that should be returned per node.
22 \a returnBounds defines if the bounding values should be included in the result.
23*/
24class QOpcUaHistoryReadRawRequestData : public QSharedData
25{
26public:
27 QDateTime startTimestamp;
28 QDateTime endTimestamp;
29 quint32 numValuesPerNode;
30 bool returnBounds;
31 QList<QOpcUaReadItem> nodesToRead;
32};
33
34/*!
35 Constructs an invalid QOpcUaHistoryReadRawRequest.
36 */
37QOpcUaHistoryReadRawRequest::QOpcUaHistoryReadRawRequest()
38 : data(new QOpcUaHistoryReadRawRequestData)
39{
40}
41
42/*!
43 Constructs a QOpcUaHistoryReadRawRequest item with the given values.
44*/
45QOpcUaHistoryReadRawRequest::QOpcUaHistoryReadRawRequest(const QList<QOpcUaReadItem> &nodesToRead,
46 const QDateTime &startTimestamp,
47 const QDateTime &endTimestamp,
48 quint32 numValuesPerNode,
49 bool returnBounds)
50 : data(new QOpcUaHistoryReadRawRequestData)
51{
52 data->startTimestamp = startTimestamp;
53 data->endTimestamp = endTimestamp;
54 data->numValuesPerNode = numValuesPerNode;
55 data->returnBounds = returnBounds;
56 data->nodesToRead = nodesToRead;
57}
58
59/*!
60 Constructs a QOpcUaHistoryReadRawRequest item from \a other.
61*/
62QOpcUaHistoryReadRawRequest::QOpcUaHistoryReadRawRequest(const QOpcUaHistoryReadRawRequest &other)
63 : data(other.data)
64{
65}
66
67/*!
68 Destroys the request object.
69 */
70QOpcUaHistoryReadRawRequest::~QOpcUaHistoryReadRawRequest()
71{
72}
73
74/*!
75 \fn QOpcUaHistoryReadRawRequest::swap(QOpcUaHistoryReadRawRequest &other)
76
77 Swaps this request instance with \a other. This function is very
78 fast and never fails.
79 */
80
81/*!
82 Returns the start time stamp.
83*/
84QDateTime QOpcUaHistoryReadRawRequest::startTimestamp() const
85{
86 return data->startTimestamp;
87}
88
89/*!
90 Sets \a startTimestamp for the historical data to be fetched.
91*/
92void QOpcUaHistoryReadRawRequest::setStartTimestamp(const QDateTime &startTimestamp)
93{
94 if (data->startTimestamp == startTimestamp)
95 return;
96
97 data->startTimestamp = startTimestamp;
98}
99
100/*!
101 Returns the end time stamp.
102*/
103QDateTime QOpcUaHistoryReadRawRequest::endTimestamp() const
104{
105 return data->endTimestamp;
106}
107
108/*!
109 Sets \a endTimestamp for the historical data to be fetched.
110*/
111void QOpcUaHistoryReadRawRequest::setEndTimestamp(const QDateTime &endTimestamp)
112{
113 if (data->endTimestamp == endTimestamp)
114 return;
115
116 data->endTimestamp = endTimestamp;
117}
118
119/*!
120 Returns the number of values per node.
121*/
122quint32 QOpcUaHistoryReadRawRequest::numValuesPerNode() const
123{
124 return data->numValuesPerNode;
125}
126
127/*!
128 Sets \a numValuesPerNode to indicate the number of values per node to be
129 fetched.
130*/
131void QOpcUaHistoryReadRawRequest::setNumValuesPerNode(quint32 numValuesPerNode)
132{
133 if (data->numValuesPerNode == numValuesPerNode)
134 return;
135
136 data->numValuesPerNode = numValuesPerNode;
137}
138
139/*!
140 Returns if the return bounds should be requested.
141*/
142bool QOpcUaHistoryReadRawRequest::returnBounds() const
143{
144 return data->returnBounds;
145}
146
147/*!
148 Sets \a returnBounds to indicate if the return bounds should be requested.
149*/
150void QOpcUaHistoryReadRawRequest::setReturnBounds(bool returnBounds)
151{
152 data->returnBounds = returnBounds;
153}
154
155/*!
156 Returns the list of nodes to read.
157*/
158QList<QOpcUaReadItem> QOpcUaHistoryReadRawRequest::nodesToRead() const
159{
160 return data->nodesToRead;
161}
162
163/*!
164 Sets the \a nodesToRead list.
165*/
166void QOpcUaHistoryReadRawRequest::setNodesToRead(const QList<QOpcUaReadItem> &nodesToRead)
167{
168 data->nodesToRead = nodesToRead;
169}
170
171/*!
172 Adds a node to the \a nodeToRead list.
173*/
174void QOpcUaHistoryReadRawRequest::addNodeToRead(const QOpcUaReadItem &nodeToRead)
175{
176 data->nodesToRead.append(t: nodeToRead);
177}
178
179/*!
180 Sets the values from \a other in this QOpcUaHistoryReadRawRequest item.
181*/
182QOpcUaHistoryReadRawRequest &QOpcUaHistoryReadRawRequest::operator=(const QOpcUaHistoryReadRawRequest &other)
183{
184 if (this != &other)
185 data.operator=(o: other.data);
186 return *this;
187}
188
189/*!
190 \fn bool QOpcUaHistoryReadRawRequest::operator==(const QOpcUaHistoryReadRawRequest& lhs,
191 const QOpcUaHistoryReadRawRequest &rhs)
192
193 Returns \c true if \a lhs is equal to \a rhs; otherwise returns \c false.
194
195 Two QOpcUaHistoryReadRawRequest items are considered equal if their \c startTimestamp,
196 \c endTimestamp, \c numValuesPerNode, \c returnBounds and \c nodesToRead are equal.
197*/
198bool operator==(const QOpcUaHistoryReadRawRequest &lhs,
199 const QOpcUaHistoryReadRawRequest &rhs) noexcept
200{
201 return (lhs.data->startTimestamp == rhs.data->startTimestamp &&
202 lhs.data->endTimestamp == rhs.data->endTimestamp &&
203 lhs.data->numValuesPerNode == rhs.data->numValuesPerNode &&
204 lhs.data->returnBounds == rhs.data->returnBounds &&
205 lhs.data->nodesToRead == rhs.data->nodesToRead);
206}
207
208/*!
209 \fn bool QOpcUaHistoryReadRawRequest::operator!=(const QOpcUaHistoryReadRawRequest &lhs,
210 const QOpcUaHistoryReadRawRequest &rhs)
211
212 Returns \c true if \a lhs is not equal to \a rhs; otherwise returns \c false.
213
214 Two QOpcUaHistoryReadRawRequest items are considered not equal if their \c startTimestamp,
215 \c endTimestamp, \c numValuesPerNode, \c returnBounds or \c nodesToRead are not equal.
216*/
217
218QT_END_NAMESPACE
219

source code of qtopcua/src/opcua/client/qopcuahistoryreadrawrequest.cpp