QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
threedsensorcalibrationmessage.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2021 Paul Colby
3 
4  This file is part of QtFit.
5 
6  QtFit is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  QtFit is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with QtFit. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 /*!
21  * \file
22  * \note This file is automatcially generated. Any changes here are likely to be overwritten.
23  */
24 
25 /*!
26  * \file
27  * Defines the ThreeDSensorCalibrationMessage, and ThreeDSensorCalibrationMessagePrivate classes.
28  */
29 
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class ThreeDSensorCalibrationMessage
40  *
41  * The ThreeDSensorCalibrationMessage class represents a FIT ThreeDSensorCalibrationMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a ThreeDSensorCalibrationMessage object.
48  *
49  * Typically, instances of this class will be returned by FitStreamReader::readNext, but this
50  * constructor may be used, along with the relevant setter methods, to create a valid message.
51  */
53 {
54 
55 }
56 
57 /*!
58  * \internal
59  *
60  * Constructs a ThreeDSensorCalibrationMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the ThreeDSensorCalibrationMessage data message's \c timestamp field's current value.
71  *
72  * Whole second part of the timestamp
73  *
74  * \return the \c timestamp field value.
75  */
77 {
79  return d->timestamp;
80 }
81 
82 /*!
83  * Returns the ThreeDSensorCalibrationMessage data message's \c sensorType field's current value.
84  *
85  * Indicates which sensor the calibration is for
86  *
87  * \return the \c sensorType field value.
88  */
90 {
92  return d->sensorType;
93 }
94 
95 /*!
96  * Returns the ThreeDSensorCalibrationMessage data message's \c calibrationFactor field's current value.
97  *
98  * Calibration factor used to convert from raw ADC value to degrees, g, etc.
99  *
100  * \return the \c calibrationFactor field value.
101  */
103 {
105  return d->calibrationFactor;
106 }
107 
108 /*!
109  * Returns the ThreeDSensorCalibrationMessage data message's \c calibrationDivisor field's current value.
110  *
111  * Calibration factor divisor
112  *
113  * \return the \c calibrationDivisor field value.
114  */
116 {
118  return d->calibrationDivisor;
119 }
120 
121 /*!
122  * Returns the ThreeDSensorCalibrationMessage data message's \c levelShift field's current value.
123  *
124  * Level shift value used to shift the ADC value back into range
125  *
126  * \return the \c levelShift field value.
127  */
129 {
131  return d->levelShift;
132 }
133 
134 /*!
135  * Returns the ThreeDSensorCalibrationMessage data message's \c offsetCal field's current value.
136  *
137  * Internal calibration factors, one for each: xy, yx, zx
138  *
139  * \return the \c offsetCal field value.
140  */
142 {
144  return d->offsetCal;
145 }
146 
147 /*!
148  * Returns the ThreeDSensorCalibrationMessage data message's \c orientationMatrix field's current value.
149  *
150  * 3 x 3 rotation matrix (row major)
151  *
152  * \return the \c orientationMatrix field value.
153  */
155 {
157  return d->orientationMatrix;
158 }
159 
160 /*!
161  * Sets the \c timestamp field to \a timestamp.
162  *
163  * \param timestamp The field value to set.
164  */
166 {
168  d->timestamp = timestamp;
169 }
170 /*!
171  * Sets the \c sensorType field to \a sensorType.
172  *
173  * \param sensorType The field value to set.
174  */
176 {
178  d->sensorType = sensorType;
179 }
180 /*!
181  * Sets the \c calibrationFactor field to \a calibrationFactor.
182  *
183  * \param calibrationFactor The field value to set.
184  */
185 void ThreeDSensorCalibrationMessage::setCalibrationFactor(const quint32 calibrationFactor)
186 {
188  d->calibrationFactor = calibrationFactor;
189 }
190 /*!
191  * Sets the \c calibrationDivisor field to \a calibrationDivisor.
192  *
193  * \param calibrationDivisor The field value to set.
194  */
195 void ThreeDSensorCalibrationMessage::setCalibrationDivisor(const quint32 calibrationDivisor)
196 {
198  d->calibrationDivisor = calibrationDivisor;
199 }
200 /*!
201  * Sets the \c levelShift field to \a levelShift.
202  *
203  * \param levelShift The field value to set.
204  */
205 void ThreeDSensorCalibrationMessage::setLevelShift(const quint32 levelShift)
206 {
208  d->levelShift = levelShift;
209 }
210 /*!
211  * Sets the \c offsetCal field to \a offsetCal.
212  *
213  * \param offsetCal The field value to set.
214  */
216 {
218  d->offsetCal = offsetCal;
219 }
220 /*!
221  * Sets the \c orientationMatrix field to \a orientationMatrix.
222  *
223  * \param orientationMatrix The field value to set.
224  */
225 void ThreeDSensorCalibrationMessage::setOrientationMatrix(const qint32 orientationMatrix)
226 {
228  d->orientationMatrix = orientationMatrix;
229 }
230 
231 /// \cond internal
232 
233 /*!
234  * \internal
235  *
236  * \class ThreeDSensorCalibrationMessagePrivate
237  *
238  * The ThreeDSensorCalibrationMessagePrivate class provides private implementation for the ThreeDSensorCalibrationMessage.
239  *
240  * \sa ThreeDSensorCalibrationMessage
241  */
242 
243 /*!
244  * \internal
245  *
246  * Constructs a ThreeDSensorCalibrationMessagePrivate object with public implementation \a q.
247  *
248  * \param q Pointer to public implementaton.
249  */
250 ThreeDSensorCalibrationMessagePrivate::ThreeDSensorCalibrationMessagePrivate(ThreeDSensorCalibrationMessage * const q)
252  , timestamp(static_cast<DateTime>(-1))
253  , sensorType(static_cast<SensorType>(-1))
254  , calibrationFactor(0xFFFFFFFF)
255  , calibrationDivisor(0xFFFFFFFF)
256  , levelShift(0xFFFFFFFF)
257  , offsetCal(0x7FFFFFFF)
258  , orientationMatrix(0x7FFFFFFF)
259 {
260  globalMessageNumber = MesgNum::ThreeDSensorCalibration;
261 }
262 
263 /*!
264  * \internal
265  *
266  * Destroys the ThreeDSensorCalibrationMessagePrivate object.
267  */
269 {
270 
271 }
272 
274  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
275 {
276  switch (fieldId) {
277  case 253: // See Profile.xlsx::Messages:three_d_sensor_calibration.timestamp
278  if (!verify(data, baseType, 4, FitBaseType::Uint32, "three_d_sensor_calibration.timestamp")) return false;
279  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
280  break;
281  case 0: // See Profile.xlsx::Messages:three_d_sensor_calibration.sensorType
282  if (!verify(data, baseType, 1, FitBaseType::Enum, "three_d_sensor_calibration.sensorType")) return false;
283  this->sensorType = static_cast<SensorType>(data.at(0));
284  break;
285  case 1: // See Profile.xlsx::Messages:three_d_sensor_calibration.calibrationFactor
286  if (!verify(data, baseType, 4, FitBaseType::Uint32, "three_d_sensor_calibration.calibrationFactor")) return false;
287  this->calibrationFactor = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
288  break;
289  case 2: // See Profile.xlsx::Messages:three_d_sensor_calibration.calibrationDivisor
290  if (!verify(data, baseType, 4, FitBaseType::Uint32, "three_d_sensor_calibration.calibrationDivisor")) return false;
291  this->calibrationDivisor = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
292  break;
293  case 3: // See Profile.xlsx::Messages:three_d_sensor_calibration.levelShift
294  if (!verify(data, baseType, 4, FitBaseType::Uint32, "three_d_sensor_calibration.levelShift")) return false;
295  this->levelShift = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
296  break;
297  case 4: // See Profile.xlsx::Messages:three_d_sensor_calibration.offsetCal
298  if (!verify(data, baseType, 4, FitBaseType::Sint32, "three_d_sensor_calibration.offsetCal")) return false;
299  this->offsetCal = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
300  break;
301  case 5: // See Profile.xlsx::Messages:three_d_sensor_calibration.orientationMatrix
302  if (!verify(data, baseType, 4, FitBaseType::Sint32, "three_d_sensor_calibration.orientationMatrix")) return false;
303  this->orientationMatrix = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
304  break;
305  default:
306  qWarning() << "ignoring unknown three_d_sensor_calibration message field number" << fieldId << bigEndian;
307  // Fall through to return true, as its still 'safe' to continue parsing data messages.
308  }
309  return true;
310 }
311 
312 /// \endcond
313 
#define QTFIT_END_NAMESPACE
Macro for ending the QtFit library's top-most namespace (if one is defined).
Definition: QtFit_global.h:78
#define QTFIT_BEGIN_NAMESPACE
Macro for starting the QtFit library's top-most namespace (if one is defined).
Definition: QtFit_global.h:77
MesgNum globalMessageNumber
FIT Globla Message Number for this FIT Data Message.
bool verify(const QByteArray &data, const FitBaseType actualType, const int expectedSize, const FitBaseType expectedType, const char *messageFieldName)
The AbstractDataMessage class is the polymorphic base class for all FIT Data Message classes.
SensorType sensorType
The ThreeDSensorCalibrationMessage FIT message's sensorType field.
DateTime timestamp
The ThreeDSensorCalibrationMessage FIT message's timestamp field.
quint32 calibrationFactor
The ThreeDSensorCalibrationMessage FIT message's calibrationFactor field.
qint32 offsetCal
The ThreeDSensorCalibrationMessage FIT message's offsetCal field.
qint32 orientationMatrix
The ThreeDSensorCalibrationMessage FIT message's orientationMatrix field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
quint32 levelShift
The ThreeDSensorCalibrationMessage FIT message's levelShift field.
quint32 calibrationDivisor
The ThreeDSensorCalibrationMessage FIT message's calibrationDivisor field.
The ThreeDSensorCalibrationMessage class represents a FIT ThreeDSensorCalibrationMessage data message...
quint32 calibrationDivisor() const
Returns the ThreeDSensorCalibrationMessage data message's calibrationDivisor field's current value.
void setSensorType(const SensorType sensorType)
Sets the sensorType field to sensorType.
DateTime timestamp() const
Returns the ThreeDSensorCalibrationMessage data message's timestamp field's current value.
void setOrientationMatrix(const qint32 orientationMatrix)
Sets the orientationMatrix field to orientationMatrix.
void setCalibrationDivisor(const quint32 calibrationDivisor)
Sets the calibrationDivisor field to calibrationDivisor.
ThreeDSensorCalibrationMessage()
Constructs a ThreeDSensorCalibrationMessage object.
SensorType sensorType() const
Returns the ThreeDSensorCalibrationMessage data message's sensorType field's current value.
void setLevelShift(const quint32 levelShift)
Sets the levelShift field to levelShift.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
void setOffsetCal(const qint32 offsetCal)
Sets the offsetCal field to offsetCal.
qint32 orientationMatrix() const
Returns the ThreeDSensorCalibrationMessage data message's orientationMatrix field's current value.
quint32 levelShift() const
Returns the ThreeDSensorCalibrationMessage data message's levelShift field's current value.
qint32 offsetCal() const
Returns the ThreeDSensorCalibrationMessage data message's offsetCal field's current value.
void setCalibrationFactor(const quint32 calibrationFactor)
Sets the calibrationFactor field to calibrationFactor.
quint32 calibrationFactor() const
Returns the ThreeDSensorCalibrationMessage data message's calibrationFactor field's current value.
Declares the ThreeDSensorCalibrationMessage class.
Declares the ThreeDSensorCalibrationMessagePrivate class.
SensorType
Garmin FIT SensorType type.
Definition: types.h:2956
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237