| 1 | // Copyright (C) 2018 The Qt Company Ltd. |
|---|---|
| 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 QOPCUA_OPCUAVALUENODE_P_H |
| 5 | #define QOPCUA_OPCUAVALUENODE_P_H |
| 6 | |
| 7 | #include <private/opcuanode_p.h> |
| 8 | #include <private/opcuadatachangefilter_p.h> |
| 9 | |
| 10 | #include <QDateTime> |
| 11 | |
| 12 | // |
| 13 | // W A R N I N G |
| 14 | // ------------- |
| 15 | // |
| 16 | // This file is not part of the Qt API. It exists purely as an |
| 17 | // implementation detail. This header file may change from version to |
| 18 | // version without notice, or even be removed. |
| 19 | // |
| 20 | // We mean it. |
| 21 | // |
| 22 | |
| 23 | QT_BEGIN_NAMESPACE |
| 24 | |
| 25 | class OpcUaValueNode : public OpcUaNode |
| 26 | { |
| 27 | Q_OBJECT |
| 28 | Q_DISABLE_COPY(OpcUaValueNode) |
| 29 | Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) |
| 30 | Q_PROPERTY(QOpcUa::Types valueType READ valueType WRITE setValueType) |
| 31 | Q_PROPERTY(QDateTime serverTimestamp READ serverTimestamp) |
| 32 | Q_PROPERTY(QDateTime sourceTimestamp READ sourceTimestamp) |
| 33 | Q_PROPERTY(bool monitored READ monitored WRITE setMonitored NOTIFY monitoredChanged) |
| 34 | Q_PROPERTY(double publishingInterval READ publishingInterval WRITE setPublishingInterval NOTIFY publishingIntervalChanged) |
| 35 | Q_PROPERTY(OpcUaDataChangeFilter *filter READ filter WRITE setFilter NOTIFY filterChanged) |
| 36 | |
| 37 | QML_NAMED_ELEMENT(ValueNode) |
| 38 | QML_ADDED_IN_VERSION(5, 12) |
| 39 | |
| 40 | public: |
| 41 | OpcUaValueNode(QObject *parent = nullptr); |
| 42 | ~OpcUaValueNode(); |
| 43 | QVariant value() const; |
| 44 | |
| 45 | QDateTime serverTimestamp() const; |
| 46 | QDateTime sourceTimestamp() const; |
| 47 | bool monitored() const; |
| 48 | double publishingInterval() const; |
| 49 | QOpcUa::Types valueType() const; |
| 50 | OpcUaDataChangeFilter *filter() const; |
| 51 | void setFilter(OpcUaDataChangeFilter *filter); |
| 52 | |
| 53 | public slots: |
| 54 | void setValue(const QVariant &); |
| 55 | void setMonitored(bool monitored); |
| 56 | void setPublishingInterval(double publishingInterval); |
| 57 | void setValueType(QOpcUa::Types valueType); |
| 58 | |
| 59 | |
| 60 | signals: |
| 61 | void valueChanged(const QVariant &value); |
| 62 | void monitoredChanged(bool monitored); |
| 63 | void publishingIntervalChanged(double publishingInterval); |
| 64 | void dataChangeOccurred(const QVariant &value); |
| 65 | void filterChanged(); |
| 66 | |
| 67 | private slots: |
| 68 | void setupNode(const QString &absolutePath) override; |
| 69 | void updateSubscription(); |
| 70 | void updateFilters() const; |
| 71 | |
| 72 | private: |
| 73 | bool checkValidity() override; |
| 74 | bool m_monitored = true; |
| 75 | bool m_monitoredState = false; |
| 76 | double m_publishingInterval = 100; |
| 77 | QOpcUa::Types m_valueType = QOpcUa::Types::Undefined; |
| 78 | OpcUaDataChangeFilter *m_filter = nullptr; |
| 79 | }; |
| 80 | |
| 81 | QT_END_NAMESPACE |
| 82 | |
| 83 | #endif // QOPCUA_OPCUAVALUENODE_P_H |
| 84 |
