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 "qopcuaaxisinformation.h" |
5 | #include "qopcuaeuinformation.h" |
6 | #include "qopcuarange.h" |
7 | #include "qopcualocalizedtext.h" |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | /*! |
12 | \class QOpcUaAxisInformation |
13 | \inmodule QtOpcUa |
14 | \brief The OPC UA AxisInformation type. |
15 | |
16 | This is the Qt OPC UA representation for the OPC UA AxisInformation type defined in OPC-UA part 8, 5.6.6. |
17 | It contains information about an axis which can be used for multiple purposes. A common use case could |
18 | involve the plotting of display data. The engineering units and the title are used for the text on the plot, |
19 | range, axisScaleType and axisSteps provide the scaling and the axis ranges of the plot. |
20 | */ |
21 | |
22 | class QOpcUaAxisInformationData : public QSharedData |
23 | { |
24 | public: |
25 | QOpcUaEUInformation engineeringUnits; |
26 | QOpcUaRange eURange; |
27 | QOpcUaLocalizedText title; |
28 | QOpcUa::AxisScale axisScaleType{QOpcUa::AxisScale::Linear}; |
29 | QList<double> axisSteps; |
30 | }; |
31 | |
32 | QOpcUaAxisInformation::QOpcUaAxisInformation() |
33 | : data(new QOpcUaAxisInformationData) |
34 | { |
35 | } |
36 | |
37 | /*! |
38 | Constructs axis information from \a rhs. |
39 | */ |
40 | QOpcUaAxisInformation::QOpcUaAxisInformation(const QOpcUaAxisInformation &rhs) |
41 | : data(rhs.data) |
42 | { |
43 | } |
44 | |
45 | /*! |
46 | Sets the values from \a rhs in this axis information. |
47 | */ |
48 | QOpcUaAxisInformation &QOpcUaAxisInformation::operator=(const QOpcUaAxisInformation &rhs) |
49 | { |
50 | if (this != &rhs) |
51 | data.operator=(o: rhs.data); |
52 | return *this; |
53 | } |
54 | |
55 | QOpcUaAxisInformation::~QOpcUaAxisInformation() |
56 | { |
57 | } |
58 | |
59 | /*! |
60 | Returns the lower and upper values of this axis. |
61 | */ |
62 | QOpcUaRange QOpcUaAxisInformation::eURange() const |
63 | { |
64 | return data->eURange; |
65 | } |
66 | |
67 | /*! |
68 | Sets the lower and upper values of this axis to \a eURange. |
69 | */ |
70 | void QOpcUaAxisInformation::setEURange(const QOpcUaRange &eURange) |
71 | { |
72 | data->eURange = eURange; |
73 | } |
74 | |
75 | /*! |
76 | Returns the title of this axis. |
77 | */ |
78 | QOpcUaLocalizedText QOpcUaAxisInformation::title() const |
79 | { |
80 | return data->title; |
81 | } |
82 | |
83 | /*! |
84 | Sets the title to \a title. |
85 | */ |
86 | void QOpcUaAxisInformation::setTitle(const QOpcUaLocalizedText &title) |
87 | { |
88 | data->title = title; |
89 | } |
90 | |
91 | /*! |
92 | Returns the scaling of this axis, defined by \l QOpcUa::AxisScale. |
93 | */ |
94 | QOpcUa::AxisScale QOpcUaAxisInformation::axisScaleType() const |
95 | { |
96 | return data->axisScaleType; |
97 | } |
98 | |
99 | /*! |
100 | Sets the axis scale type to \a axisScaleType. |
101 | */ |
102 | void QOpcUaAxisInformation::setAxisScaleType(QOpcUa::AxisScale axisScaleType) |
103 | { |
104 | data->axisScaleType = axisScaleType; |
105 | } |
106 | |
107 | /*! |
108 | Returns specific values for each axis step. |
109 | |
110 | This value is empty if the points are equally distributed and the step size can be |
111 | calculated from the number of steps and the range. |
112 | If the steps are different for each point but constant over a longer time, there is an entry for |
113 | each data point. |
114 | */ |
115 | QList<double> QOpcUaAxisInformation::axisSteps() const |
116 | { |
117 | return data->axisSteps; |
118 | } |
119 | |
120 | /*! |
121 | Sets the axis steps to \a axisSteps. |
122 | */ |
123 | void QOpcUaAxisInformation::setAxisSteps(const QList<double> &axisSteps) |
124 | { |
125 | data->axisSteps = axisSteps; |
126 | } |
127 | |
128 | /*! |
129 | Returns a reference to the axis steps. |
130 | */ |
131 | QList<double> &QOpcUaAxisInformation::axisStepsRef() |
132 | { |
133 | return data->axisSteps; |
134 | } |
135 | |
136 | /*! |
137 | Returns the engineering units of this axis. |
138 | */ |
139 | QOpcUaEUInformation QOpcUaAxisInformation::engineeringUnits() const |
140 | { |
141 | return data->engineeringUnits; |
142 | } |
143 | |
144 | /*! |
145 | Sets the engineering units to \a engineeringUnits. |
146 | */ |
147 | void QOpcUaAxisInformation::setEngineeringUnits(const QOpcUaEUInformation &engineeringUnits) |
148 | { |
149 | data->engineeringUnits = engineeringUnits; |
150 | } |
151 | |
152 | /*! |
153 | Returns \c true if this axis information has the same value as \a rhs. |
154 | */ |
155 | bool QOpcUaAxisInformation::operator==(const QOpcUaAxisInformation &rhs) const |
156 | { |
157 | return data->axisScaleType == rhs.axisScaleType() && |
158 | data->axisSteps == rhs.axisSteps() && |
159 | data->engineeringUnits == rhs.engineeringUnits() && |
160 | data->eURange == rhs.eURange() && |
161 | data->title == rhs.title(); |
162 | } |
163 | |
164 | /*! |
165 | Converts this axis information to \l QVariant. |
166 | */ |
167 | QOpcUaAxisInformation::operator QVariant() const |
168 | { |
169 | return QVariant::fromValue(value: *this); |
170 | } |
171 | |
172 | /*! |
173 | Constructs axis information with engineering units \a engineeringUnits, |
174 | range \a eURange, title \a title, scaling \a axisScaleType and axis steps \a axisSteps. |
175 | */ |
176 | QOpcUaAxisInformation::QOpcUaAxisInformation(const QOpcUaEUInformation &engineeringUnits, const QOpcUaRange &eURange, const QOpcUaLocalizedText &title, |
177 | const QOpcUa::AxisScale &axisScaleType, const QList<double> &axisSteps) |
178 | : data (new QOpcUaAxisInformationData) |
179 | { |
180 | data->engineeringUnits = engineeringUnits; |
181 | data->eURange = eURange; |
182 | data->title = title; |
183 | data->axisScaleType = axisScaleType; |
184 | data->axisSteps = axisSteps; |
185 | } |
186 | |
187 | QT_END_NAMESPACE |
188 | |