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

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