1// Copyright (C) 2015 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#ifndef QOPCUANODE_H
5#define QOPCUANODE_H
6
7#include <QtOpcUa/qopcuabrowserequest.h>
8#include <QtOpcUa/qopcuaglobal.h>
9#include <QtOpcUa/qopcuamonitoringparameters.h>
10#include <QtOpcUa/qopcuareferencedescription.h>
11#include <QtOpcUa/qopcuatype.h>
12#include <QtOpcUa/qopcuabrowsepathtarget.h>
13#include <QtOpcUa/qopcuarelativepathelement.h>
14
15#include <QtCore/qdatetime.h>
16#include <QtCore/qdebug.h>
17#include <QtCore/qvariant.h>
18#include <QtCore/qobject.h>
19#include <QtCore/qmap.h>
20
21QT_BEGIN_NAMESPACE
22
23class QOpcUaNodePrivate;
24class QOpcUaNodeImpl;
25class QOpcUaClient;
26class QOpcUaHistoryReadRawRequest;
27class QOpcUaHistoryReadResponse;
28
29class Q_OPCUA_EXPORT QOpcUaNode : public QObject
30{
31 Q_OBJECT
32
33public:
34 Q_DECLARE_PRIVATE(QOpcUaNode)
35
36 static Q_DECL_CONSTEXPR QOpcUa::NodeAttributes mandatoryBaseAttributes();
37 static Q_DECL_CONSTEXPR QOpcUa::NodeAttributes allBaseAttributes();
38 typedef QMap<QOpcUa::NodeAttribute, QVariant> AttributeMap;
39
40 QOpcUaNode(QOpcUaNodeImpl *impl, QOpcUaClient *client, QObject *parent = nullptr);
41 virtual ~QOpcUaNode();
42
43 bool readAttributes(QOpcUa::NodeAttributes attributes = mandatoryBaseAttributes());
44 bool readAttributeRange(QOpcUa::NodeAttribute attribute, const QString &indexRange);
45 bool readValueAttribute();
46 QVariant attribute(QOpcUa::NodeAttribute attribute) const;
47 QVariant valueAttribute() const;
48 QOpcUa::UaStatusCode attributeError(QOpcUa::NodeAttribute attribute) const;
49 QOpcUa::UaStatusCode valueAttributeError() const;
50 QDateTime sourceTimestamp(QOpcUa::NodeAttribute attribute) const;
51 QDateTime serverTimestamp(QOpcUa::NodeAttribute attribute) const;
52 bool writeAttribute(QOpcUa::NodeAttribute attribute, const QVariant &value, QOpcUa::Types type = QOpcUa::Types::Undefined);
53 bool writeAttributeRange(QOpcUa::NodeAttribute attribute, const QVariant &value,
54 const QString &indexRange, QOpcUa::Types type = QOpcUa::Types::Undefined);
55 bool writeAttributes(const AttributeMap &toWrite, QOpcUa::Types valueAttributeType = QOpcUa::Types::Undefined);
56 bool writeValueAttribute(const QVariant &value, QOpcUa::Types type = QOpcUa::Types::Undefined);
57
58 bool enableMonitoring(QOpcUa::NodeAttributes attr, const QOpcUaMonitoringParameters &settings);
59 bool disableMonitoring(QOpcUa::NodeAttributes attr);
60 bool modifyMonitoring(QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameter item, const QVariant &value);
61 QOpcUaMonitoringParameters monitoringStatus(QOpcUa::NodeAttribute attr);
62 bool modifyEventFilter(const QOpcUaMonitoringParameters::EventFilter &eventFilter);
63 bool modifyDataChangeFilter(QOpcUa::NodeAttribute attr, const QOpcUaMonitoringParameters::DataChangeFilter &filter);
64
65 bool browseChildren(QOpcUa::ReferenceTypeId referenceType = QOpcUa::ReferenceTypeId::HierarchicalReferences,
66 QOpcUa::NodeClasses nodeClassMask = QOpcUa::NodeClass::Undefined);
67
68 QString nodeId() const;
69 QOpcUaClient *client() const;
70
71 bool callMethod(const QString &methodNodeId, const QList<QOpcUa::TypedVariant> &args = QList<QOpcUa::TypedVariant>());
72
73 bool resolveBrowsePath(const QList<QOpcUaRelativePathElement> &path);
74
75 bool browse(const QOpcUaBrowseRequest &request);
76
77 QOpcUaHistoryReadResponse *readHistoryRaw(const QDateTime &startTime, const QDateTime &endTime, quint32 numValues, bool returnBounds);
78 QOpcUaHistoryReadResponse *readHistoryRaw(const QDateTime &startTime, const QDateTime &endTime, quint32 numValues, bool returnBounds, QOpcUa::TimestampsToReturn timestampsToReturn);
79
80 QOpcUaHistoryReadResponse *readHistoryEvents(const QDateTime &startTime, const QDateTime &endTime,
81 QOpcUaMonitoringParameters::EventFilter &filter, quint32 numValues = 0);
82
83Q_SIGNALS:
84 void attributeRead(QOpcUa::NodeAttributes attributes);
85 void attributeWritten(QOpcUa::NodeAttribute attribute, QOpcUa::UaStatusCode statusCode);
86 void dataChangeOccurred(QOpcUa::NodeAttribute attr, QVariant value);
87 void attributeUpdated(QOpcUa::NodeAttribute attr, QVariant value);
88 void valueAttributeUpdated(const QVariant &value);
89 void eventOccurred(QVariantList eventFields);
90
91 void monitoringStatusChanged(QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameters items,
92 QOpcUa::UaStatusCode statusCode);
93 void enableMonitoringFinished(QOpcUa::NodeAttribute attr, QOpcUa::UaStatusCode statusCode);
94 void disableMonitoringFinished(QOpcUa::NodeAttribute attr, QOpcUa::UaStatusCode statusCode);
95 void methodCallFinished(QString methodNodeId, QVariant result, QOpcUa::UaStatusCode statusCode);
96 void browseFinished(QList<QOpcUaReferenceDescription> children, QOpcUa::UaStatusCode statusCode);
97 void resolveBrowsePathFinished(QList<QOpcUaBrowsePathTarget> targets,
98 QList<QOpcUaRelativePathElement> path, QOpcUa::UaStatusCode statusCode);
99
100private:
101 Q_DISABLE_COPY(QOpcUaNode)
102};
103
104Q_OPCUA_EXPORT QDebug operator<<(QDebug dbg, const QOpcUaNode &node);
105
106QT_END_NAMESPACE
107
108Q_DECLARE_METATYPE(QOpcUaNode::AttributeMap)
109
110inline Q_DECL_CONSTEXPR QOpcUa::NodeAttributes QOpcUaNode::mandatoryBaseAttributes()
111{
112 return QOpcUa::NodeAttribute::NodeId | QOpcUa::NodeAttribute::NodeClass |
113 QOpcUa::NodeAttribute::BrowseName | QOpcUa::NodeAttribute::DisplayName;
114}
115
116inline Q_DECL_CONSTEXPR QOpcUa::NodeAttributes QOpcUaNode::allBaseAttributes()
117{
118 return QOpcUa::NodeAttribute::NodeId | QOpcUa::NodeAttribute::NodeClass | QOpcUa::NodeAttribute::BrowseName |
119 QOpcUa::NodeAttribute::DisplayName | QOpcUa::NodeAttribute::Description | QOpcUa::NodeAttribute::WriteMask |
120 QOpcUa::NodeAttribute::UserWriteMask;
121}
122
123#endif // QOPCUANODE_H
124

Provided by KDAB

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

source code of qtopcua/src/opcua/client/qopcuanode.h