| 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 1.05 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 | /*! | 
| 33 |     Default constructs an axis information with no parameters set. | 
| 34 | */ | 
| 35 | QOpcUaAxisInformation::QOpcUaAxisInformation() | 
| 36 |     : data(new QOpcUaAxisInformationData) | 
| 37 | { | 
| 38 | } | 
| 39 |  | 
| 40 | /*! | 
| 41 |     Constructs axis information from \a rhs. | 
| 42 | */ | 
| 43 | QOpcUaAxisInformation::QOpcUaAxisInformation(const QOpcUaAxisInformation &rhs) | 
| 44 |     : data(rhs.data) | 
| 45 | { | 
| 46 | } | 
| 47 |  | 
| 48 | /*! | 
| 49 |     Sets the values from \a rhs in this axis information. | 
| 50 | */ | 
| 51 | QOpcUaAxisInformation &QOpcUaAxisInformation::operator=(const QOpcUaAxisInformation &rhs) | 
| 52 | { | 
| 53 |     if (this != &rhs) | 
| 54 |         data.operator=(o: rhs.data); | 
| 55 |     return *this; | 
| 56 | } | 
| 57 |  | 
| 58 | QOpcUaAxisInformation::~QOpcUaAxisInformation() | 
| 59 | { | 
| 60 | } | 
| 61 |  | 
| 62 | /*! | 
| 63 |     Returns the lower and upper values of this axis. | 
| 64 | */ | 
| 65 | QOpcUaRange QOpcUaAxisInformation::eURange() const | 
| 66 | { | 
| 67 |     return data->eURange; | 
| 68 | } | 
| 69 |  | 
| 70 | /*! | 
| 71 |     Sets the lower and upper values of this axis to \a eURange. | 
| 72 | */ | 
| 73 | void QOpcUaAxisInformation::setEURange(const QOpcUaRange &eURange) | 
| 74 | { | 
| 75 |     data->eURange = eURange; | 
| 76 | } | 
| 77 |  | 
| 78 | /*! | 
| 79 |     Returns the title of this axis. | 
| 80 | */ | 
| 81 | QOpcUaLocalizedText QOpcUaAxisInformation::title() const | 
| 82 | { | 
| 83 |     return data->title; | 
| 84 | } | 
| 85 |  | 
| 86 | /*! | 
| 87 |     Sets the title to \a title. | 
| 88 | */ | 
| 89 | void QOpcUaAxisInformation::setTitle(const QOpcUaLocalizedText &title) | 
| 90 | { | 
| 91 |     data->title = title; | 
| 92 | } | 
| 93 |  | 
| 94 | /*! | 
| 95 |     Returns the scaling of this axis, defined by \l QOpcUa::AxisScale. | 
| 96 | */ | 
| 97 | QOpcUa::AxisScale QOpcUaAxisInformation::axisScaleType() const | 
| 98 | { | 
| 99 |     return data->axisScaleType; | 
| 100 | } | 
| 101 |  | 
| 102 | /*! | 
| 103 |     Sets the axis scale type to \a axisScaleType. | 
| 104 | */ | 
| 105 | void QOpcUaAxisInformation::setAxisScaleType(QOpcUa::AxisScale axisScaleType) | 
| 106 | { | 
| 107 |     data->axisScaleType = axisScaleType; | 
| 108 | } | 
| 109 |  | 
| 110 | /*! | 
| 111 |     Returns specific values for each axis step. | 
| 112 |  | 
| 113 |     This value is empty if the points are equally distributed and the step size can be | 
| 114 |     calculated from the number of steps and the range. | 
| 115 |     If the steps are different for each point but constant over a longer time, there is an entry for | 
| 116 |     each data point. | 
| 117 | */ | 
| 118 | QList<double> QOpcUaAxisInformation::axisSteps() const | 
| 119 | { | 
| 120 |     return data->axisSteps; | 
| 121 | } | 
| 122 |  | 
| 123 | /*! | 
| 124 |     Sets the axis steps to \a axisSteps. | 
| 125 | */ | 
| 126 | void QOpcUaAxisInformation::setAxisSteps(const QList<double> &axisSteps) | 
| 127 | { | 
| 128 |     data->axisSteps = axisSteps; | 
| 129 | } | 
| 130 |  | 
| 131 | /*! | 
| 132 |     Returns a reference to the axis steps. | 
| 133 | */ | 
| 134 | QList<double> &QOpcUaAxisInformation::axisStepsRef() | 
| 135 | { | 
| 136 |     return data->axisSteps; | 
| 137 | } | 
| 138 |  | 
| 139 | /*! | 
| 140 |     Returns the engineering units of this axis. | 
| 141 | */ | 
| 142 | QOpcUaEUInformation QOpcUaAxisInformation::engineeringUnits() const | 
| 143 | { | 
| 144 |     return data->engineeringUnits; | 
| 145 | } | 
| 146 |  | 
| 147 | /*! | 
| 148 |     Sets the engineering units to \a engineeringUnits. | 
| 149 | */ | 
| 150 | void QOpcUaAxisInformation::setEngineeringUnits(const QOpcUaEUInformation &engineeringUnits) | 
| 151 | { | 
| 152 |     data->engineeringUnits = engineeringUnits; | 
| 153 | } | 
| 154 |  | 
| 155 | /*! | 
| 156 |     Returns \c true if this axis information has the same value as \a rhs. | 
| 157 | */ | 
| 158 | bool QOpcUaAxisInformation::operator==(const QOpcUaAxisInformation &rhs) const | 
| 159 | { | 
| 160 |     return data->axisScaleType == rhs.axisScaleType() && | 
| 161 |             data->axisSteps == rhs.axisSteps() && | 
| 162 |             data->engineeringUnits == rhs.engineeringUnits() && | 
| 163 |             data->eURange == rhs.eURange() && | 
| 164 |             data->title == rhs.title(); | 
| 165 | } | 
| 166 |  | 
| 167 | /*! | 
| 168 |     Converts this axis information to \l QVariant. | 
| 169 | */ | 
| 170 | QOpcUaAxisInformation::operator QVariant() const | 
| 171 | { | 
| 172 |     return QVariant::fromValue(value: *this); | 
| 173 | } | 
| 174 |  | 
| 175 | /*! | 
| 176 |     Constructs axis information with engineering units \a engineeringUnits, | 
| 177 |     range \a eURange, title \a title, scaling \a axisScaleType and axis steps \a axisSteps. | 
| 178 | */ | 
| 179 | QOpcUaAxisInformation::QOpcUaAxisInformation(const QOpcUaEUInformation &engineeringUnits, const QOpcUaRange &eURange, const QOpcUaLocalizedText &title, | 
| 180 |                                              const QOpcUa::AxisScale &axisScaleType, const QList<double> &axisSteps) | 
| 181 |     : data (new QOpcUaAxisInformationData) | 
| 182 | { | 
| 183 |     data->engineeringUnits = engineeringUnits; | 
| 184 |     data->eURange = eURange; | 
| 185 |     data->title = title; | 
| 186 |     data->axisScaleType = axisScaleType; | 
| 187 |     data->axisSteps = axisSteps; | 
| 188 | } | 
| 189 |  | 
| 190 | QT_END_NAMESPACE | 
| 191 |  |