1// Copyright (C) 2016 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 QOPCUACLIENTIMPL_P_H
5#define QOPCUACLIENTIMPL_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtOpcUa/qopcuaclient.h>
19#include <QtOpcUa/qopcuaglobal.h>
20#include <QtOpcUa/qopcuaendpointdescription.h>
21#include <private/qopcuanodeimpl_p.h>
22
23#include <QtCore/qobject.h>
24#include <QtCore/qpointer.h>
25#include <QtCore/qset.h>
26
27QT_BEGIN_NAMESPACE
28
29class QOpcUaNode;
30class QOpcUaClient;
31class QOpcUaBackend;
32class QOpcUaMonitoringParameters;
33
34class Q_OPCUA_EXPORT QOpcUaClientImpl : public QObject
35{
36 Q_OBJECT
37
38public:
39 QOpcUaClientImpl(QObject *parent = 0);
40 virtual ~QOpcUaClientImpl();
41
42 virtual void connectToEndpoint(const QOpcUaEndpointDescription &endpoint) = 0;
43 virtual void disconnectFromEndpoint() = 0;
44 virtual QOpcUaNode *node(const QString &nodeId) = 0;
45 virtual QString backend() const = 0;
46 virtual bool requestEndpoints(const QUrl &url) = 0;
47 virtual bool findServers(const QUrl &url, const QStringList &localeIds, const QStringList &serverUris) = 0;
48 virtual bool readNodeAttributes(const QList<QOpcUaReadItem> &nodesToRead) = 0;
49 virtual bool writeNodeAttributes(const QList<QOpcUaWriteItem> &nodesToWrite) = 0;
50
51 virtual QOpcUaHistoryReadResponse *readHistoryData(const QOpcUaHistoryReadRawRequest &request) = 0;
52
53 bool registerNode(QPointer<QOpcUaNodeImpl> obj);
54 void unregisterNode(QPointer<QOpcUaNodeImpl> obj);
55
56 virtual bool addNode(const QOpcUaAddNodeItem &nodeToAdd) = 0;
57 virtual bool deleteNode(const QString &nodeId, bool deleteTargetReferences) = 0;
58
59 virtual bool addReference(const QOpcUaAddReferenceItem &referenceToAdd) = 0;
60 virtual bool deleteReference(const QOpcUaDeleteReferenceItem &referenceToDelete) = 0;
61
62 void connectBackendWithClient(QOpcUaBackend *backend);
63
64 virtual QStringList supportedSecurityPolicies() const = 0;
65 virtual QList<QOpcUaUserTokenPolicy::TokenType> supportedUserTokenTypes() const = 0;
66
67 QOpcUaClient *m_client;
68
69private Q_SLOTS:
70 void handleAttributesRead(quint64 handle, QList<QOpcUaReadResult> attr, QOpcUa::UaStatusCode serviceResult);
71 void handleAttributeWritten(quint64 handle, QOpcUa::NodeAttribute attr, const QVariant &value, QOpcUa::UaStatusCode statusCode);
72 void handleDataChangeOccurred(quint64 handle, const QOpcUaReadResult &value);
73 void handleMonitoringEnableDisable(quint64 handle, QOpcUa::NodeAttribute attr, bool subscribe, QOpcUaMonitoringParameters status);
74 void handleMonitoringStatusChanged(quint64 handle, QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameters items,
75 QOpcUaMonitoringParameters param);
76 void handleMethodCallFinished(quint64 handle, QString methodNodeId, QVariant result, QOpcUa::UaStatusCode statusCode);
77 void handleBrowseFinished(quint64 handle, const QList<QOpcUaReferenceDescription> &children, QOpcUa::UaStatusCode statusCode);
78
79 void handleResolveBrowsePathFinished(quint64 handle, QList<QOpcUaBrowsePathTarget> targets,
80 QList<QOpcUaRelativePathElement> path, QOpcUa::UaStatusCode status);
81
82 void handleNewEvent(quint64 handle, QVariantList eventFields);
83
84signals:
85 void connected();
86 void disconnected();
87 void stateAndOrErrorChanged(QOpcUaClient::ClientState state,
88 QOpcUaClient::ClientError error);
89 void endpointsRequestFinished(QList<QOpcUaEndpointDescription> endpoints, QOpcUa::UaStatusCode statusCode, QUrl requestUrl);
90 void findServersFinished(QList<QOpcUaApplicationDescription> servers, QOpcUa::UaStatusCode statusCode, QUrl requestUrl);
91 void readNodeAttributesFinished(QList<QOpcUaReadResult> results, QOpcUa::UaStatusCode serviceResult);
92 void writeNodeAttributesFinished(QList<QOpcUaWriteResult> results, QOpcUa::UaStatusCode serviceResult);
93 void addNodeFinished(QOpcUaExpandedNodeId requestedNodeId, QString assignedNodeId, QOpcUa::UaStatusCode statusCode);
94 void deleteNodeFinished(QString nodeId, QOpcUa::UaStatusCode statusCode);
95 void addReferenceFinished(QString sourceNodeId, QString referenceTypeId, QOpcUaExpandedNodeId targetNodeId, bool isForwardReference,
96 QOpcUa::UaStatusCode statusCode);
97 void deleteReferenceFinished(QString sourceNodeId, QString referenceTypeId, QOpcUaExpandedNodeId targetNodeId, bool isForwardReference,
98 QOpcUa::UaStatusCode statusCode);
99 void connectError(QOpcUaErrorState *errorState);
100 void passwordForPrivateKeyRequired(const QString keyFilePath, QString *password, bool previousTryWasInvalid);
101
102private:
103 Q_DISABLE_COPY(QOpcUaClientImpl)
104 QHash<quint64, QPointer<QOpcUaNodeImpl>> m_handles;
105 quint64 m_handleCounter;
106};
107
108#if QT_VERSION >= 0x060000
109inline size_t qHash(const QPointer<QOpcUaNodeImpl>& n)
110#else
111inline uint qHash(const QPointer<QOpcUaNodeImpl>& n)
112#endif
113{
114 return ::qHash(key: n.data());
115}
116
117QT_END_NAMESPACE
118
119#endif // QOPCUACLIENTIMPL_P_H
120

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