summaryrefslogtreecommitdiffstats
path: root/src/opcua/client/qopcuahistoryreadrawrequest.cpp
blob: cf3bf8ea1c674be3ec06e76ddafcba507f5fda04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/****************************************************************************
**
** Copyright (C) 2019 basysKom GmbH, opensource@basyskom.com
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtOpcUa module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL3$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPLv3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or later as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information to
** ensure the GNU General Public License version 2.0 requirements will be
** met: http://www.gnu.org/licenses/gpl-2.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qopcuahistoryreadrawrequest.h"

QT_BEGIN_NAMESPACE

/*!
    \class QOpcUaHistoryReadRawRequest
    \inmodule QtOpcUa
    \brief This class stores the necessary information to request historic data from a server.

    This is the Qt OPC UA representation for the OPC UA ReadRawModifiedDetails for reading historical data
    defined in \l {https://reference.opcfoundation.org/Core/docs/Part11/6.4.3/} {OPC-UA part 11, 6.4.3}.

    When requesting historic data from a server, several values need to be provided to the server
    to know which data to collect. The QOpcUaHistoryReadRawRequest class provides the required values.
    \a startTimestamp and \a endTimestamp define the timerange where historic data should be collected from.
    \a nodesToRead defines from which nodes historic data should be collected.
    \a numValuesPerNode defines the maximum number of data values that should be returned per node.
    \a returnBounds defines if the bounding values should be included in the result.
*/
class QOpcUaHistoryReadRawRequestData : public QSharedData
{
public:
    QDateTime startTimestamp;
    QDateTime endTimestamp;
    quint32 numValuesPerNode;
    bool returnBounds;
    QList<QOpcUaReadItem> nodesToRead;
};

QOpcUaHistoryReadRawRequest::QOpcUaHistoryReadRawRequest()
    : data(new QOpcUaHistoryReadRawRequestData)
{
}

/*!
    Constructs a QOpcUaHistoryReadRawRequest item with the given values.
*/
QOpcUaHistoryReadRawRequest::QOpcUaHistoryReadRawRequest(QList<QOpcUaReadItem> nodesToRead,
                                                         QDateTime startTimestamp,
                                                         QDateTime endTimestamp,
                                                         quint32 numValuesPerNode,
                                                         bool returnBounds)
    : data(new QOpcUaHistoryReadRawRequestData)
{
    data->startTimestamp = startTimestamp;
    data->endTimestamp = endTimestamp;
    data->numValuesPerNode = numValuesPerNode;
    data->returnBounds = returnBounds;
    data->nodesToRead = nodesToRead;
}

/*!
    Constructs a QOpcUaHistoryReadRawRequest item from \a other.
*/
QOpcUaHistoryReadRawRequest::QOpcUaHistoryReadRawRequest(const QOpcUaHistoryReadRawRequest &other)
    : data(other.data)
{
}

QOpcUaHistoryReadRawRequest::~QOpcUaHistoryReadRawRequest()
{
}

/*!
    Returns the start time stamp.
*/
QDateTime QOpcUaHistoryReadRawRequest::startTimestamp() const
{
    return data->startTimestamp;
}

/*!
    Sets the start time stamp.
*/
void QOpcUaHistoryReadRawRequest::setStartTimestamp(QDateTime startTimestamp)
{
    if (data->startTimestamp == startTimestamp)
        return;

    data->startTimestamp = startTimestamp;
}

/*!
    Returns the end time stamp.
*/
QDateTime QOpcUaHistoryReadRawRequest::endTimestamp() const
{
    return data->endTimestamp;
}

/*!
    Sets the end time stamp.
*/
void QOpcUaHistoryReadRawRequest::setEndTimestamp(QDateTime endTimestamp)
{
    if (data->endTimestamp == endTimestamp)
        return;

    data->endTimestamp = endTimestamp;
}

/*!
    Returns the number of values per node.
*/
quint32 QOpcUaHistoryReadRawRequest::numValuesPerNode() const
{
    return data->numValuesPerNode;
}

/*!
    Sets the number of values per node.
*/
void QOpcUaHistoryReadRawRequest::setNumValuesPerNode(quint32 numValuesPerNode)
{
    if (data->numValuesPerNode == numValuesPerNode)
        return;

    data->numValuesPerNode = numValuesPerNode;
}

/*!
    Returns if the return bounds should be requested.
*/
bool QOpcUaHistoryReadRawRequest::returnBounds() const
{
    return data->returnBounds;
}

/*!
    Sets if the return bounds should be requested.
*/
void QOpcUaHistoryReadRawRequest::setReturnBounds(bool returnBounds)
{
    data->returnBounds = returnBounds;
}

/*!
    Returns the list of nodes to read.
*/
QList<QOpcUaReadItem> QOpcUaHistoryReadRawRequest::nodesToRead() const
{
    return data->nodesToRead;
}

/*!
    Sets the list of nodes to read.
*/
void QOpcUaHistoryReadRawRequest::setNodesToRead(QList<QOpcUaReadItem> nodesToRead)
{
    data->nodesToRead = nodesToRead;
}

/*!
    Adds a node to the list of nodes to read.
*/
void QOpcUaHistoryReadRawRequest::addNodeToRead(QOpcUaReadItem nodeToRead)
{
    data->nodesToRead.append(nodeToRead);
}

/*!
    Sets the values from \a rhs in this QOpcUaHistoryReadRawRequest item.
*/
QOpcUaHistoryReadRawRequest &QOpcUaHistoryReadRawRequest::operator=(const QOpcUaHistoryReadRawRequest &rhs)
{
    if (this != &rhs)
        data.operator=(rhs.data);
    return *this;
}

/*!
    Returns true if other is equal to this QOpcUaHistoryReadRawRequest item; otherwise returns false.

    Two QOpcUaHistoryReadRawRequest items are considered equal if their \a startTimestamp, \a endTimestamp,
    \a numValuesPerNode, \a returnBounds and \a nodesToRead are equal.
*/
bool QOpcUaHistoryReadRawRequest::operator==(const QOpcUaHistoryReadRawRequest &other) const
{
    return (data->startTimestamp == other.startTimestamp() &&
            data->endTimestamp == other.endTimestamp() &&
            data->numValuesPerNode == other.numValuesPerNode() &&
            data->returnBounds == other.returnBounds() &&
            data->nodesToRead == other.nodesToRead());
}

/*!
    Returns true if other is not equal to this QOpcUaHistoryReadRawRequest item; otherwise returns false.

    Two QOpcUaHistoryReadRawRequest items are considered not equal if their \a startTimestamp, \a endTimestamp,
    \a numValuesPerNode, \a returnBounds or \a nodesToRead are not equal.
*/
bool QOpcUaHistoryReadRawRequest::operator!=(const QOpcUaHistoryReadRawRequest &other) const
{
    return (data->startTimestamp != other.startTimestamp() ||
            data->endTimestamp != other.endTimestamp() ||
            data->numValuesPerNode != other.numValuesPerNode() ||
            data->returnBounds != other.returnBounds() ||
            data->nodesToRead != other.nodesToRead());
}

QT_END_NAMESPACE