QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
onedsensorcalibrationmessage.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 OneDSensorCalibrationMessage, and OneDSensorCalibrationMessagePrivate classes.
28  */
29 
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class OneDSensorCalibrationMessage
40  *
41  * The OneDSensorCalibrationMessage class represents a FIT OneDSensorCalibrationMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a OneDSensorCalibrationMessage 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 OneDSensorCalibrationMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the OneDSensorCalibrationMessage 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 OneDSensorCalibrationMessage 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 OneDSensorCalibrationMessage 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 {
104  Q_D(const OneDSensorCalibrationMessage);
105  return d->calibrationFactor;
106 }
107 
108 /*!
109  * Returns the OneDSensorCalibrationMessage data message's \c calibrationDivisor field's current value.
110  *
111  * Calibration factor divisor
112  *
113  * \return the \c calibrationDivisor field value.
114  */
116 {
117  Q_D(const OneDSensorCalibrationMessage);
118  return d->calibrationDivisor;
119 }
120 
121 /*!
122  * Returns the OneDSensorCalibrationMessage 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 {
130  Q_D(const OneDSensorCalibrationMessage);
131  return d->levelShift;
132 }
133 
134 /*!
135  * Returns the OneDSensorCalibrationMessage data message's \c offsetCal field's current value.
136  *
137  * Internal Calibration factor
138  *
139  * \return the \c offsetCal field value.
140  */
142 {
143  Q_D(const OneDSensorCalibrationMessage);
144  return d->offsetCal;
145 }
146 
147 /*!
148  * Sets the \c timestamp field to \a timestamp.
149  *
150  * \param timestamp The field value to set.
151  */
153 {
155  d->timestamp = timestamp;
156 }
157 /*!
158  * Sets the \c sensorType field to \a sensorType.
159  *
160  * \param sensorType The field value to set.
161  */
163 {
165  d->sensorType = sensorType;
166 }
167 /*!
168  * Sets the \c calibrationFactor field to \a calibrationFactor.
169  *
170  * \param calibrationFactor The field value to set.
171  */
172 void OneDSensorCalibrationMessage::setCalibrationFactor(const quint32 calibrationFactor)
173 {
175  d->calibrationFactor = calibrationFactor;
176 }
177 /*!
178  * Sets the \c calibrationDivisor field to \a calibrationDivisor.
179  *
180  * \param calibrationDivisor The field value to set.
181  */
182 void OneDSensorCalibrationMessage::setCalibrationDivisor(const quint32 calibrationDivisor)
183 {
185  d->calibrationDivisor = calibrationDivisor;
186 }
187 /*!
188  * Sets the \c levelShift field to \a levelShift.
189  *
190  * \param levelShift The field value to set.
191  */
192 void OneDSensorCalibrationMessage::setLevelShift(const quint32 levelShift)
193 {
195  d->levelShift = levelShift;
196 }
197 /*!
198  * Sets the \c offsetCal field to \a offsetCal.
199  *
200  * \param offsetCal The field value to set.
201  */
202 void OneDSensorCalibrationMessage::setOffsetCal(const qint32 offsetCal)
203 {
205  d->offsetCal = offsetCal;
206 }
207 
208 /// \cond internal
209 
210 /*!
211  * \internal
212  *
213  * \class OneDSensorCalibrationMessagePrivate
214  *
215  * The OneDSensorCalibrationMessagePrivate class provides private implementation for the OneDSensorCalibrationMessage.
216  *
217  * \sa OneDSensorCalibrationMessage
218  */
219 
220 /*!
221  * \internal
222  *
223  * Constructs a OneDSensorCalibrationMessagePrivate object with public implementation \a q.
224  *
225  * \param q Pointer to public implementaton.
226  */
227 OneDSensorCalibrationMessagePrivate::OneDSensorCalibrationMessagePrivate(OneDSensorCalibrationMessage * const q)
229  , timestamp(static_cast<DateTime>(-1))
230  , sensorType(static_cast<SensorType>(-1))
231  , calibrationFactor(0xFFFFFFFF)
232  , calibrationDivisor(0xFFFFFFFF)
233  , levelShift(0xFFFFFFFF)
234  , offsetCal(0x7FFFFFFF)
235 {
236  globalMessageNumber = MesgNum::OneDSensorCalibration;
237 }
238 
239 /*!
240  * \internal
241  *
242  * Destroys the OneDSensorCalibrationMessagePrivate object.
243  */
245 {
246 
247 }
248 
250  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
251 {
252  switch (fieldId) {
253  case 253: // See Profile.xlsx::Messages:one_d_sensor_calibration.timestamp
254  if (!verify(data, baseType, 4, FitBaseType::Uint32, "one_d_sensor_calibration.timestamp")) return false;
255  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
256  break;
257  case 0: // See Profile.xlsx::Messages:one_d_sensor_calibration.sensorType
258  if (!verify(data, baseType, 1, FitBaseType::Enum, "one_d_sensor_calibration.sensorType")) return false;
259  this->sensorType = static_cast<SensorType>(data.at(0));
260  break;
261  case 1: // See Profile.xlsx::Messages:one_d_sensor_calibration.calibrationFactor
262  if (!verify(data, baseType, 4, FitBaseType::Uint32, "one_d_sensor_calibration.calibrationFactor")) return false;
263  this->calibrationFactor = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
264  break;
265  case 2: // See Profile.xlsx::Messages:one_d_sensor_calibration.calibrationDivisor
266  if (!verify(data, baseType, 4, FitBaseType::Uint32, "one_d_sensor_calibration.calibrationDivisor")) return false;
267  this->calibrationDivisor = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
268  break;
269  case 3: // See Profile.xlsx::Messages:one_d_sensor_calibration.levelShift
270  if (!verify(data, baseType, 4, FitBaseType::Uint32, "one_d_sensor_calibration.levelShift")) return false;
271  this->levelShift = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
272  break;
273  case 4: // See Profile.xlsx::Messages:one_d_sensor_calibration.offsetCal
274  if (!verify(data, baseType, 4, FitBaseType::Sint32, "one_d_sensor_calibration.offsetCal")) return false;
275  this->offsetCal = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
276  break;
277  default:
278  qWarning() << "ignoring unknown one_d_sensor_calibration message field number" << fieldId << bigEndian;
279  // Fall through to return true, as its still 'safe' to continue parsing data messages.
280  }
281  return true;
282 }
283 
284 /// \endcond
285 
#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.
quint32 calibrationDivisor
The OneDSensorCalibrationMessage FIT message's calibrationDivisor field.
quint32 calibrationFactor
The OneDSensorCalibrationMessage FIT message's calibrationFactor field.
SensorType sensorType
The OneDSensorCalibrationMessage FIT message's sensorType field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
DateTime timestamp
The OneDSensorCalibrationMessage FIT message's timestamp field.
quint32 levelShift
The OneDSensorCalibrationMessage FIT message's levelShift field.
qint32 offsetCal
The OneDSensorCalibrationMessage FIT message's offsetCal field.
The OneDSensorCalibrationMessage class represents a FIT OneDSensorCalibrationMessage data message.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
void setLevelShift(const quint32 levelShift)
Sets the levelShift field to levelShift.
quint32 calibrationFactor() const
Returns the OneDSensorCalibrationMessage data message's calibrationFactor field's current value.
void setOffsetCal(const qint32 offsetCal)
Sets the offsetCal field to offsetCal.
void setCalibrationDivisor(const quint32 calibrationDivisor)
Sets the calibrationDivisor field to calibrationDivisor.
void setCalibrationFactor(const quint32 calibrationFactor)
Sets the calibrationFactor field to calibrationFactor.
void setSensorType(const SensorType sensorType)
Sets the sensorType field to sensorType.
OneDSensorCalibrationMessage()
Constructs a OneDSensorCalibrationMessage object.
SensorType sensorType() const
Returns the OneDSensorCalibrationMessage data message's sensorType field's current value.
quint32 calibrationDivisor() const
Returns the OneDSensorCalibrationMessage data message's calibrationDivisor field's current value.
quint32 levelShift() const
Returns the OneDSensorCalibrationMessage data message's levelShift field's current value.
qint32 offsetCal() const
Returns the OneDSensorCalibrationMessage data message's offsetCal field's current value.
DateTime timestamp() const
Returns the OneDSensorCalibrationMessage data message's timestamp field's current value.
Declares the OneDSensorCalibrationMessage class.
Declares the OneDSensorCalibrationMessagePrivate 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