1 | // Copyright (C) 2015 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 | #include "qopcuaeuinformation.h" |
5 | #include "qopcualocalizedtext.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | /*! |
10 | \class QOpcUaEUInformation |
11 | \inmodule QtOpcUa |
12 | \brief The OPC UA EURange type. |
13 | |
14 | This is the Qt OPC UA representation for the OPC UA EUInformation type defined in OPC-UA part 8, 5.6.3. |
15 | EUInformation values contain information about units and are mostly used as property of a node with a numeric value attribute. |
16 | The information can e. g. be used to add text and tooltips to GUI elements. |
17 | */ |
18 | |
19 | class QOpcUaEUInformationData : public QSharedData |
20 | { |
21 | public: |
22 | QString namespaceUri; |
23 | qint32 unitId{0}; |
24 | QOpcUaLocalizedText displayName; |
25 | QOpcUaLocalizedText description; |
26 | }; |
27 | |
28 | QOpcUaEUInformation::QOpcUaEUInformation() |
29 | : data(new QOpcUaEUInformationData) |
30 | { |
31 | } |
32 | |
33 | /*! |
34 | Constructs a EUinformation from \a rhs. |
35 | */ |
36 | QOpcUaEUInformation::QOpcUaEUInformation(const QOpcUaEUInformation &rhs) |
37 | : data(rhs.data) |
38 | { |
39 | } |
40 | |
41 | /*! |
42 | Constructs a EUinformation with namespace URI \a namespaceUri, unit id \a unitId, |
43 | display name \a displayName and description \a description. |
44 | */ |
45 | QOpcUaEUInformation::QOpcUaEUInformation(const QString &namespaceUri, qint32 unitId, const QOpcUaLocalizedText &displayName, |
46 | const QOpcUaLocalizedText &description) |
47 | : data(new QOpcUaEUInformationData) |
48 | { |
49 | data->namespaceUri = namespaceUri; |
50 | data->unitId = unitId; |
51 | data->displayName = displayName; |
52 | data->description = description; |
53 | } |
54 | |
55 | |
56 | /*! |
57 | Sets the values from \a rhs in this EUinformation. |
58 | */ |
59 | QOpcUaEUInformation &QOpcUaEUInformation::operator=(const QOpcUaEUInformation &rhs) |
60 | { |
61 | if (this != &rhs) |
62 | data.operator=(o: rhs.data); |
63 | return *this; |
64 | } |
65 | |
66 | /*! |
67 | Returns \c true if this EUinformation has the same value as \a rhs. |
68 | */ |
69 | bool QOpcUaEUInformation::operator==(const QOpcUaEUInformation &rhs) const |
70 | { |
71 | return data->namespaceUri == rhs.namespaceUri() && |
72 | data->unitId == rhs.unitId() && |
73 | data->displayName == rhs.displayName() && |
74 | data->description == rhs.description(); |
75 | } |
76 | |
77 | QOpcUaEUInformation::~QOpcUaEUInformation() |
78 | { |
79 | } |
80 | |
81 | /*! |
82 | Returns the description of the unit, for example \e {degree Celsius}. |
83 | */ |
84 | QOpcUaLocalizedText QOpcUaEUInformation::description() const |
85 | { |
86 | return data->description; |
87 | } |
88 | |
89 | /*! |
90 | Sets the description if the unit to \a description. |
91 | */ |
92 | void QOpcUaEUInformation::setDescription(const QOpcUaLocalizedText &description) |
93 | { |
94 | data->description = description; |
95 | } |
96 | |
97 | /*! |
98 | Returns the display name of the unit, for example \e {°C}. |
99 | */ |
100 | QOpcUaLocalizedText QOpcUaEUInformation::displayName() const |
101 | { |
102 | return data->displayName; |
103 | } |
104 | |
105 | /*! |
106 | Sets the display name of the unit to \a displayName. |
107 | */ |
108 | void QOpcUaEUInformation::setDisplayName(const QOpcUaLocalizedText &displayName) |
109 | { |
110 | data->displayName = displayName; |
111 | } |
112 | |
113 | /*! |
114 | Returns the machine-readable identifier for the unit. |
115 | */ |
116 | qint32 QOpcUaEUInformation::unitId() const |
117 | { |
118 | return data->unitId; |
119 | } |
120 | |
121 | /*! |
122 | Sets the machine-readable identifier for the unit to \a unitId. |
123 | */ |
124 | void QOpcUaEUInformation::setUnitId(qint32 unitId) |
125 | { |
126 | data->unitId = unitId; |
127 | } |
128 | |
129 | /*! |
130 | Returns the namespace URI of the unit. |
131 | */ |
132 | QString QOpcUaEUInformation::namespaceUri() const |
133 | { |
134 | return data->namespaceUri; |
135 | } |
136 | |
137 | /*! |
138 | Sets the namespace URI of the unit to \a namespaceUri. |
139 | */ |
140 | void QOpcUaEUInformation::setNamespaceUri(const QString &namespaceUri) |
141 | { |
142 | data->namespaceUri = namespaceUri; |
143 | } |
144 | |
145 | /*! |
146 | Converts this EUinformation to \l QVariant. |
147 | */ |
148 | QOpcUaEUInformation::operator QVariant() const |
149 | { |
150 | return QVariant::fromValue(value: *this); |
151 | } |
152 | |
153 | QT_END_NAMESPACE |
154 |