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

source code of qtopcua/src/declarative_opcua/opcuavaluenode_p.h