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/Part11/v104/docs/6.4.3} {OPC UA 1.04 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 = 0;
30 bool returnBounds = false;
31 QList<QOpcUaReadItem> nodesToRead;
32 QOpcUa::TimestampsToReturn timestampsToReturn = QOpcUa::TimestampsToReturn::Both;
33};
34
35/*!
36 Constructs an invalid QOpcUaHistoryReadRawRequest.
37 */
38QOpcUaHistoryReadRawRequest::QOpcUaHistoryReadRawRequest()
39 : data(new QOpcUaHistoryReadRawRequestData)
40{
41}
42
43/*!
44 Constructs a QOpcUaHistoryReadRawRequest item with the given values.
45*/
46QOpcUaHistoryReadRawRequest::QOpcUaHistoryReadRawRequest(const QList<QOpcUaReadItem> &nodesToRead,
47 const QDateTime &startTimestamp,
48 const QDateTime &endTimestamp,
49 quint32 numValuesPerNode,
50 bool returnBounds)
51 : data(new QOpcUaHistoryReadRawRequestData)
52{
53 data->startTimestamp = startTimestamp;
54 data->endTimestamp = endTimestamp;
55 data->numValuesPerNode = numValuesPerNode;
56 data->returnBounds = returnBounds;
57 data->nodesToRead = nodesToRead;
58}
59
60/*!
61 Constructs a QOpcUaHistoryReadRawRequest item with the given values.
62 The \a timestampsToReturn parameter determines the timestamps to return for each value.
63
64 \since 6.7
65*/
66QOpcUaHistoryReadRawRequest::QOpcUaHistoryReadRawRequest(const QList<QOpcUaReadItem> &nodesToRead,
67 const QDateTime &startTimestamp, const QDateTime &endTimestamp,
68 QOpcUa::TimestampsToReturn timestampsToReturn)
69 : data(new QOpcUaHistoryReadRawRequestData)
70{
71 data->startTimestamp = startTimestamp;
72 data->endTimestamp = endTimestamp;
73 data->nodesToRead = nodesToRead;
74 data->timestampsToReturn = timestampsToReturn;
75}
76
77/*!
78 Constructs a QOpcUaHistoryReadRawRequest item from \a other.
79*/
80QOpcUaHistoryReadRawRequest::QOpcUaHistoryReadRawRequest(const QOpcUaHistoryReadRawRequest &other)
81 : data(other.data)
82{
83}
84
85/*!
86 Destroys the request object.
87 */
88QOpcUaHistoryReadRawRequest::~QOpcUaHistoryReadRawRequest()
89{
90}
91
92/*!
93 \fn QOpcUaHistoryReadRawRequest::swap(QOpcUaHistoryReadRawRequest &other)
94
95 Swaps this request instance with \a other. This function is very
96 fast and never fails.
97 */
98
99/*!
100 Returns the start time stamp.
101*/
102QDateTime QOpcUaHistoryReadRawRequest::startTimestamp() const
103{
104 return data->startTimestamp;
105}
106
107/*!
108 Sets \a startTimestamp for the historical data to be fetched.
109*/
110void QOpcUaHistoryReadRawRequest::setStartTimestamp(const QDateTime &startTimestamp)
111{
112 if (data->startTimestamp == startTimestamp)
113 return;
114
115 data->startTimestamp = startTimestamp;
116}
117
118/*!
119 Returns the end time stamp.
120*/
121QDateTime QOpcUaHistoryReadRawRequest::endTimestamp() const
122{
123 return data->endTimestamp;
124}
125
126/*!
127 Sets \a endTimestamp for the historical data to be fetched.
128*/
129void QOpcUaHistoryReadRawRequest::setEndTimestamp(const QDateTime &endTimestamp)
130{
131 if (data->endTimestamp == endTimestamp)
132 return;
133
134 data->endTimestamp = endTimestamp;
135}
136
137/*!
138 Returns the number of values per node.
139*/
140quint32 QOpcUaHistoryReadRawRequest::numValuesPerNode() const
141{
142 return data->numValuesPerNode;
143}
144
145/*!
146 Sets \a numValuesPerNode to indicate the number of values per node to be
147 fetched.
148*/
149void QOpcUaHistoryReadRawRequest::setNumValuesPerNode(quint32 numValuesPerNode)
150{
151 if (data->numValuesPerNode == numValuesPerNode)
152 return;
153
154 data->numValuesPerNode = numValuesPerNode;
155}
156
157/*!
158 Returns if the return bounds should be requested.
159*/
160bool QOpcUaHistoryReadRawRequest::returnBounds() const
161{
162 return data->returnBounds;
163}
164
165/*!
166 Sets \a returnBounds to indicate if the return bounds should be requested.
167*/
168void QOpcUaHistoryReadRawRequest::setReturnBounds(bool returnBounds)
169{
170 data->returnBounds = returnBounds;
171}
172
173/*!
174 Returns the selected timestamps to return for each value.
175
176 \since 6.7
177*/
178QOpcUa::TimestampsToReturn QOpcUaHistoryReadRawRequest::timestampsToReturn() const
179{
180 return data->timestampsToReturn;
181}
182
183/*!
184 Sets the selected timestamps to return for each value to \a timestampsToReturn.
185
186 \since 6.7
187*/
188void QOpcUaHistoryReadRawRequest::setTimestampsToReturn(QOpcUa::TimestampsToReturn timestampsToReturn)
189{
190 data->timestampsToReturn = timestampsToReturn;
191}
192
193/*!
194 Returns the list of nodes to read.
195*/
196QList<QOpcUaReadItem> QOpcUaHistoryReadRawRequest::nodesToRead() const
197{
198 return data->nodesToRead;
199}
200
201/*!
202 Sets the \a nodesToRead list.
203*/
204void QOpcUaHistoryReadRawRequest::setNodesToRead(const QList<QOpcUaReadItem> &nodesToRead)
205{
206 data->nodesToRead = nodesToRead;
207}
208
209/*!
210 Adds a node to the \a nodeToRead list.
211*/
212void QOpcUaHistoryReadRawRequest::addNodeToRead(const QOpcUaReadItem &nodeToRead)
213{
214 data->nodesToRead.append(t: nodeToRead);
215}
216
217/*!
218 Sets the values from \a other in this QOpcUaHistoryReadRawRequest item.
219*/
220QOpcUaHistoryReadRawRequest &QOpcUaHistoryReadRawRequest::operator=(const QOpcUaHistoryReadRawRequest &other)
221{
222 if (this != &other)
223 data.operator=(o: other.data);
224 return *this;
225}
226
227/*!
228 \fn bool QOpcUaHistoryReadRawRequest::operator==(const QOpcUaHistoryReadRawRequest& lhs,
229 const QOpcUaHistoryReadRawRequest &rhs)
230
231 Returns \c true if \a lhs is equal to \a rhs; otherwise returns \c false.
232
233 Two QOpcUaHistoryReadRawRequest items are considered equal if their \c startTimestamp,
234 \c endTimestamp, \c numValuesPerNode, \c returnBounds and \c nodesToRead are equal.
235*/
236bool operator==(const QOpcUaHistoryReadRawRequest &lhs,
237 const QOpcUaHistoryReadRawRequest &rhs) noexcept
238{
239 return (lhs.data->startTimestamp == rhs.data->startTimestamp &&
240 lhs.data->endTimestamp == rhs.data->endTimestamp &&
241 lhs.data->numValuesPerNode == rhs.data->numValuesPerNode &&
242 lhs.data->returnBounds == rhs.data->returnBounds &&
243 lhs.data->nodesToRead == rhs.data->nodesToRead);
244}
245
246/*!
247 \fn bool QOpcUaHistoryReadRawRequest::operator!=(const QOpcUaHistoryReadRawRequest &lhs,
248 const QOpcUaHistoryReadRawRequest &rhs)
249
250 Returns \c true if \a lhs is not equal to \a rhs; otherwise returns \c false.
251
252 Two QOpcUaHistoryReadRawRequest items are considered not equal if their \c startTimestamp,
253 \c endTimestamp, \c numValuesPerNode, \c returnBounds or \c nodesToRead are not equal.
254*/
255
256QT_END_NAMESPACE
257

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

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