| 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 |  | 
| 27 | QT_BEGIN_NAMESPACE | 
| 28 |  | 
| 29 | class QOpcUaNode; | 
| 30 | class QOpcUaClient; | 
| 31 | class QOpcUaBackend; | 
| 32 | class QOpcUaMonitoringParameters; | 
| 33 |  | 
| 34 | class Q_OPCUA_EXPORT QOpcUaClientImpl : public QObject | 
| 35 | { | 
| 36 |     Q_OBJECT | 
| 37 |  | 
| 38 | public: | 
| 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 |     virtual QOpcUaHistoryReadResponse *readHistoryEvents(const QOpcUaHistoryReadEventRequest &request) = 0; | 
| 53 |  | 
| 54 |     bool registerNode(QPointer<QOpcUaNodeImpl> obj); | 
| 55 |     void unregisterNode(QPointer<QOpcUaNodeImpl> obj); | 
| 56 |  | 
| 57 |     virtual bool addNode(const QOpcUaAddNodeItem &nodeToAdd) = 0; | 
| 58 |     virtual bool deleteNode(const QString &nodeId, bool deleteTargetReferences) = 0; | 
| 59 |  | 
| 60 |     virtual bool addReference(const QOpcUaAddReferenceItem &referenceToAdd) = 0; | 
| 61 |     virtual bool deleteReference(const QOpcUaDeleteReferenceItem &referenceToDelete) = 0; | 
| 62 |  | 
| 63 |     void connectBackendWithClient(QOpcUaBackend *backend); | 
| 64 |  | 
| 65 |     virtual QStringList supportedSecurityPolicies() const = 0; | 
| 66 |     virtual QList<QOpcUaUserTokenPolicy::TokenType> supportedUserTokenTypes() const = 0; | 
| 67 |  | 
| 68 |     virtual bool registerNodes(const QStringList &nodesToRegister) = 0; | 
| 69 |     virtual bool unregisterNodes(const QStringList &nodesToUnregister) = 0; | 
| 70 |  | 
| 71 |     QOpcUaClient *m_client; | 
| 72 |  | 
| 73 | private Q_SLOTS: | 
| 74 |     void handleAttributesRead(quint64 handle, QList<QOpcUaReadResult> attr, QOpcUa::UaStatusCode serviceResult); | 
| 75 |     void handleAttributeWritten(quint64 handle, QOpcUa::NodeAttribute attr, const QVariant &value, QOpcUa::UaStatusCode statusCode); | 
| 76 |     void handleDataChangeOccurred(quint64 handle, const QOpcUaReadResult &value); | 
| 77 |     void handleMonitoringEnableDisable(quint64 handle, QOpcUa::NodeAttribute attr, bool subscribe, QOpcUaMonitoringParameters status); | 
| 78 |     void handleMonitoringStatusChanged(quint64 handle, QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameters items, | 
| 79 |                                  QOpcUaMonitoringParameters param); | 
| 80 |     void handleMethodCallFinished(quint64 handle, QString methodNodeId, QVariant result, QOpcUa::UaStatusCode statusCode); | 
| 81 |     void handleBrowseFinished(quint64 handle, const QList<QOpcUaReferenceDescription> &children, QOpcUa::UaStatusCode statusCode); | 
| 82 |  | 
| 83 |     void handleResolveBrowsePathFinished(quint64 handle, QList<QOpcUaBrowsePathTarget> targets, | 
| 84 |                                            QList<QOpcUaRelativePathElement> path, QOpcUa::UaStatusCode status); | 
| 85 |  | 
| 86 |     void handleNewEvent(quint64 handle, QVariantList eventFields); | 
| 87 |  | 
| 88 | signals: | 
| 89 |     void connected(); | 
| 90 |     void disconnected(); | 
| 91 |     void stateAndOrErrorChanged(QOpcUaClient::ClientState state, | 
| 92 |                                 QOpcUaClient::ClientError error); | 
| 93 |     void endpointsRequestFinished(QList<QOpcUaEndpointDescription> endpoints, QOpcUa::UaStatusCode statusCode, QUrl requestUrl); | 
| 94 |     void findServersFinished(QList<QOpcUaApplicationDescription> servers, QOpcUa::UaStatusCode statusCode, QUrl requestUrl); | 
| 95 |     void readNodeAttributesFinished(QList<QOpcUaReadResult> results, QOpcUa::UaStatusCode serviceResult); | 
| 96 |     void writeNodeAttributesFinished(QList<QOpcUaWriteResult> results, QOpcUa::UaStatusCode serviceResult); | 
| 97 |     void addNodeFinished(QOpcUaExpandedNodeId requestedNodeId, QString assignedNodeId, QOpcUa::UaStatusCode statusCode); | 
| 98 |     void deleteNodeFinished(QString nodeId, QOpcUa::UaStatusCode statusCode); | 
| 99 |     void addReferenceFinished(QString sourceNodeId, QString referenceTypeId, QOpcUaExpandedNodeId targetNodeId, bool isForwardReference, | 
| 100 |                               QOpcUa::UaStatusCode statusCode); | 
| 101 |     void deleteReferenceFinished(QString sourceNodeId, QString referenceTypeId, QOpcUaExpandedNodeId targetNodeId, bool isForwardReference, | 
| 102 |                               QOpcUa::UaStatusCode statusCode); | 
| 103 |     void connectError(QOpcUaErrorState *errorState); | 
| 104 |     void passwordForPrivateKeyRequired(const QString keyFilePath, QString *password, bool previousTryWasInvalid); | 
| 105 |     void registerNodesFinished(QStringList nodesToRegister, QStringList registeredNodeIds, QOpcUa::UaStatusCode statusCode); | 
| 106 |     void unregisterNodesFinished(QStringList nodesToUnregister, QOpcUa::UaStatusCode statusCode); | 
| 107 |  | 
| 108 | private: | 
| 109 |     Q_DISABLE_COPY(QOpcUaClientImpl) | 
| 110 |     QHash<quint64, QPointer<QOpcUaNodeImpl>> m_handles; | 
| 111 |     quint64 m_handleCounter; | 
| 112 | }; | 
| 113 |  | 
| 114 | #if QT_VERSION >= 0x060000 | 
| 115 | inline size_t qHash(const QPointer<QOpcUaNodeImpl>& n) | 
| 116 | #else | 
| 117 | inline uint qHash(const QPointer<QOpcUaNodeImpl>& n) | 
| 118 | #endif | 
| 119 | { | 
| 120 |     return ::qHash(key: n.data()); | 
| 121 | } | 
| 122 |  | 
| 123 | QT_END_NAMESPACE | 
| 124 |  | 
| 125 | #endif // QOPCUACLIENTIMPL_P_H | 
| 126 |  |