| 1 | // Copyright (C) 2017 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 QOPCUABACKEND_P_H | 
| 5 | #define QOPCUABACKEND_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/qopcuaendpointdescription.h> | 
| 20 | #include <QtOpcUa/qopcuahistoryevent.h> | 
| 21 | #include <private/qopcuanodeimpl_p.h> | 
| 22 |  | 
| 23 | #include <QtCore/qobject.h> | 
| 24 |  | 
| 25 | #include <functional> | 
| 26 |  | 
| 27 | QT_BEGIN_NAMESPACE | 
| 28 |  | 
| 29 | class QOpcUaMonitoringParameters; | 
| 30 |  | 
| 31 | class Q_OPCUA_EXPORT QOpcUaBackend : public QObject | 
| 32 | { | 
| 33 |     Q_OBJECT | 
| 34 |  | 
| 35 | public: | 
| 36 |     explicit QOpcUaBackend(); | 
| 37 |     virtual ~QOpcUaBackend(); | 
| 38 |  | 
| 39 |     static Q_DECL_CONSTEXPR size_t nodeAttributeEnumBits() | 
| 40 |     { | 
| 41 |         return sizeof(std::underlying_type<QOpcUa::NodeAttribute>::type) * CHAR_BIT; | 
| 42 |     } | 
| 43 |  | 
| 44 |     QOpcUa::Types attributeIdToTypeId(QOpcUa::NodeAttribute attr); | 
| 45 |  | 
| 46 |     double revisePublishingInterval(double requestedValue, double minimumValue); | 
| 47 |     static bool verifyEndpointDescription(const QOpcUaEndpointDescription &endpoint, QString *message = nullptr); | 
| 48 |  | 
| 49 | Q_SIGNALS: | 
| 50 |     void stateAndOrErrorChanged(QOpcUaClient::ClientState state, | 
| 51 |                                 QOpcUaClient::ClientError error); | 
| 52 |     void attributesRead(quint64 handle, QList<QOpcUaReadResult> attributes, QOpcUa::UaStatusCode serviceResult); | 
| 53 |     void attributeWritten(quint64 handle, QOpcUa::NodeAttribute attribute, QVariant value, QOpcUa::UaStatusCode statusCode); | 
| 54 |     void methodCallFinished(quint64 handle, QString methodNodeId, QVariant result, QOpcUa::UaStatusCode statusCode); | 
| 55 |  | 
| 56 |     void dataChangeOccurred(quint64 handle, QOpcUaReadResult res); | 
| 57 |     void eventOccurred(quint64 handle, QVariantList fields); | 
| 58 |     void monitoringEnableDisable(quint64 handle, QOpcUa::NodeAttribute attr, bool subscribe, QOpcUaMonitoringParameters status); | 
| 59 |     void monitoringStatusChanged(quint64 handle, QOpcUa::NodeAttribute attr, QOpcUaMonitoringParameters::Parameters items, | 
| 60 |                            QOpcUaMonitoringParameters param); | 
| 61 |     void browseFinished(quint64 handle, QList<QOpcUaReferenceDescription> children, QOpcUa::UaStatusCode statusCode); | 
| 62 |  | 
| 63 |     void resolveBrowsePathFinished(quint64 handle, const QList<QOpcUaBrowsePathTarget> &targets, | 
| 64 |                                    const QList<QOpcUaRelativePathElement> &path, QOpcUa::UaStatusCode statusCode); | 
| 65 |     void endpointsRequestFinished(QList<QOpcUaEndpointDescription> endpoints, QOpcUa::UaStatusCode statusCode, QUrl requestUrl); | 
| 66 |     void findServersFinished(QList<QOpcUaApplicationDescription> servers, QOpcUa::UaStatusCode statusCode, QUrl requestUrl); | 
| 67 |     void readNodeAttributesFinished(QList<QOpcUaReadResult> results, QOpcUa::UaStatusCode serviceResult); | 
| 68 |     void writeNodeAttributesFinished(QList<QOpcUaWriteResult> results, QOpcUa::UaStatusCode serviceResult); | 
| 69 |     void readHistoryDataFinished(quint64 handle, bool isHandleValid, QOpcUaHistoryReadRawRequest request, QList<QOpcUaHistoryData> results, QOpcUa::UaStatusCode serviceResult); | 
| 70 |  | 
| 71 |     void addNodeFinished(QOpcUaExpandedNodeId requestedNodeId, QString assignedNodeId, QOpcUa::UaStatusCode statusCode); | 
| 72 |     void deleteNodeFinished(QString nodeId, QOpcUa::UaStatusCode statusCode); | 
| 73 |     void addReferenceFinished(QString sourceNodeId, QString referenceTypeId, QOpcUaExpandedNodeId targetNodeId, bool isForwardReference, | 
| 74 |                               QOpcUa::UaStatusCode statusCode); | 
| 75 |     void deleteReferenceFinished(QString sourceNodeId, QString referenceTypeId, QOpcUaExpandedNodeId targetNodeId, bool isForwardReference, | 
| 76 |                               QOpcUa::UaStatusCode statusCode); | 
| 77 |     void connectError(QOpcUaErrorState *errorState); | 
| 78 |     void passwordForPrivateKeyRequired(QString keyFilePath, QString *password, bool previousTryWasInvalid); | 
| 79 |  | 
| 80 |     void historyDataAvailable(QList<QOpcUaHistoryData> data, QList<QByteArray> continuationPoints, QOpcUa::UaStatusCode serviceResult, uintptr_t handle); | 
| 81 |     void historyEventsAvailable(QList<QOpcUaHistoryEvent> data, QList<QByteArray> continuationPoints, QOpcUa::UaStatusCode serviceResult, uintptr_t handle); | 
| 82 |  | 
| 83 |     void registerNodesFinished(QStringList nodesToRegister, QStringList registeredNodeIds, QOpcUa::UaStatusCode statusCode); | 
| 84 |     void unregisterNodesFinished(QStringList nodesToUnregister, QOpcUa::UaStatusCode statusCode); | 
| 85 |  | 
| 86 | private: | 
| 87 |     Q_DISABLE_COPY(QOpcUaBackend) | 
| 88 | }; | 
| 89 |  | 
| 90 | static inline void qt_forEachAttribute(QOpcUa::NodeAttributes attributes, const std::function<void(QOpcUa::NodeAttribute attribute)> &f) | 
| 91 | { | 
| 92 |     for (uint i = 0; i < QOpcUaBackend::nodeAttributeEnumBits(); ++i) { | 
| 93 |         if (!(attributes & (1 << i))) | 
| 94 |             continue; | 
| 95 |         QOpcUa::NodeAttribute currentAttribute = static_cast<QOpcUa::NodeAttribute>(1 << i); | 
| 96 |         f(currentAttribute); | 
| 97 |     } | 
| 98 | } | 
| 99 |  | 
| 100 | QT_END_NAMESPACE | 
| 101 |  | 
| 102 | #endif // QOPCUABACKEND_P_H | 
| 103 |  |