QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sdmprofilemessage.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 SdmProfileMessage, and SdmProfileMessagePrivate classes.
28  */
29 
30 #include "sdmprofilemessage.h"
31 #include "sdmprofilemessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class SdmProfileMessage
40  *
41  * The SdmProfileMessage class represents a FIT SdmProfileMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a SdmProfileMessage 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 SdmProfileMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the SdmProfileMessage data message's \c messageIndex field's current value.
71  *
72  * \return the \c messageIndex field value.
73  */
75 {
76  Q_D(const SdmProfileMessage);
77  return d->messageIndex;
78 }
79 
80 /*!
81  * Returns the SdmProfileMessage data message's \c enabled field's current value.
82  *
83  * \return the \c enabled field value.
84  */
86 {
87  Q_D(const SdmProfileMessage);
88  return d->enabled;
89 }
90 
91 /*!
92  * Returns the SdmProfileMessage data message's \c sdmAntId field's current value.
93  *
94  * \return the \c sdmAntId field value.
95  */
97 {
98  Q_D(const SdmProfileMessage);
99  return d->sdmAntId;
100 }
101 
102 /*!
103  * Returns the SdmProfileMessage data message's \c sdmCalFactor field's current value.
104  *
105  * \return the \c sdmCalFactor field value.
106  */
108 {
109  Q_D(const SdmProfileMessage);
110  return d->sdmCalFactor;
111 }
112 
113 /*!
114  * Returns the SdmProfileMessage data message's \c odometer field's current value.
115  *
116  * \return the \c odometer field value.
117  */
119 {
120  Q_D(const SdmProfileMessage);
121  return d->odometer;
122 }
123 
124 /*!
125  * Returns the SdmProfileMessage data message's \c speedSource field's current value.
126  *
127  * Use footpod for speed source instead of GPS
128  *
129  * \return the \c speedSource field value.
130  */
132 {
133  Q_D(const SdmProfileMessage);
134  return d->speedSource;
135 }
136 
137 /*!
138  * Returns the SdmProfileMessage data message's \c sdmAntIdTransType field's current value.
139  *
140  * \return the \c sdmAntIdTransType field value.
141  */
143 {
144  Q_D(const SdmProfileMessage);
145  return d->sdmAntIdTransType;
146 }
147 
148 /*!
149  * Returns the SdmProfileMessage data message's \c odometerRollover field's current value.
150  *
151  * Rollover counter that can be used to extend the odometer
152  *
153  * \return the \c odometerRollover field value.
154  */
156 {
157  Q_D(const SdmProfileMessage);
158  return d->odometerRollover;
159 }
160 
161 /*!
162  * Sets the \c messageIndex field to \a messageIndex.
163  *
164  * \param messageIndex The field value to set.
165  */
167 {
168  Q_D(SdmProfileMessage);
169  d->messageIndex = messageIndex;
170 }
171 /*!
172  * Sets the \c enabled field to \a enabled.
173  *
174  * \param enabled The field value to set.
175  */
176 void SdmProfileMessage::setEnabled(const bool enabled)
177 {
178  Q_D(SdmProfileMessage);
179  d->enabled = enabled;
180 }
181 /*!
182  * Sets the \c sdmAntId field to \a sdmAntId.
183  *
184  * \param sdmAntId The field value to set.
185  */
187 {
188  Q_D(SdmProfileMessage);
189  d->sdmAntId = sdmAntId;
190 }
191 /*!
192  * Sets the \c sdmCalFactor field to \a sdmCalFactor.
193  *
194  * \param sdmCalFactor The field value to set.
195  */
196 void SdmProfileMessage::setSdmCalFactor(const quint16 sdmCalFactor)
197 {
198  Q_D(SdmProfileMessage);
199  d->sdmCalFactor = sdmCalFactor;
200 }
201 /*!
202  * Sets the \c odometer field to \a odometer.
203  *
204  * \param odometer The field value to set.
205  */
206 void SdmProfileMessage::setOdometer(const quint32 odometer)
207 {
208  Q_D(SdmProfileMessage);
209  d->odometer = odometer;
210 }
211 /*!
212  * Sets the \c speedSource field to \a speedSource.
213  *
214  * \param speedSource The field value to set.
215  */
216 void SdmProfileMessage::setSpeedSource(const bool speedSource)
217 {
218  Q_D(SdmProfileMessage);
219  d->speedSource = speedSource;
220 }
221 /*!
222  * Sets the \c sdmAntIdTransType field to \a sdmAntIdTransType.
223  *
224  * \param sdmAntIdTransType The field value to set.
225  */
227 {
228  Q_D(SdmProfileMessage);
229  d->sdmAntIdTransType = sdmAntIdTransType;
230 }
231 /*!
232  * Sets the \c odometerRollover field to \a odometerRollover.
233  *
234  * \param odometerRollover The field value to set.
235  */
236 void SdmProfileMessage::setOdometerRollover(const quint8 odometerRollover)
237 {
238  Q_D(SdmProfileMessage);
239  d->odometerRollover = odometerRollover;
240 }
241 
242 /// \cond internal
243 
244 /*!
245  * \internal
246  *
247  * \class SdmProfileMessagePrivate
248  *
249  * The SdmProfileMessagePrivate class provides private implementation for the SdmProfileMessage.
250  *
251  * \sa SdmProfileMessage
252  */
253 
254 /*!
255  * \internal
256  *
257  * Constructs a SdmProfileMessagePrivate object with public implementation \a q.
258  *
259  * \param q Pointer to public implementaton.
260  */
261 SdmProfileMessagePrivate::SdmProfileMessagePrivate(SdmProfileMessage * const q)
263  , messageIndex(static_cast<MessageIndex>(-1))
264  , enabled(static_cast<bool>(-1))
265  , sdmAntId(0)
266  , sdmCalFactor(0xFFFF)
267  , odometer(0xFFFFFFFF)
268  , speedSource(static_cast<bool>(-1))
269  , sdmAntIdTransType(static_cast<quint8z>(-1))
270  , odometerRollover(0xFF)
271 {
272  globalMessageNumber = MesgNum::SdmProfile;
273 }
274 
275 /*!
276  * \internal
277  *
278  * Destroys the SdmProfileMessagePrivate object.
279  */
281 {
282 
283 }
284 
286  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
287 {
288  switch (fieldId) {
289  case 254: // See Profile.xlsx::Messages:sdm_profile.messageIndex
290  if (!verify(data, baseType, 2, FitBaseType::Uint16, "sdm_profile.messageIndex")) return false;
291  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
292  break;
293  case 0: // See Profile.xlsx::Messages:sdm_profile.enabled
294  if (!verify(data, baseType, 0, FitBaseType::Byte, "sdm_profile.enabled")) return false;
295  this->enabled = static_cast<bool>(data.at(0));
296  break;
297  case 1: // See Profile.xlsx::Messages:sdm_profile.sdmAntId
298  if (!verify(data, baseType, 2, FitBaseType::Uint16z, "sdm_profile.sdmAntId")) return false;
299  this->sdmAntId = static_cast<quint16z>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
300  break;
301  case 2: // See Profile.xlsx::Messages:sdm_profile.sdmCalFactor
302  if (!verify(data, baseType, 2, FitBaseType::Uint16, "sdm_profile.sdmCalFactor")) return false;
303  this->sdmCalFactor = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
304  break;
305  case 3: // See Profile.xlsx::Messages:sdm_profile.odometer
306  if (!verify(data, baseType, 4, FitBaseType::Uint32, "sdm_profile.odometer")) return false;
307  this->odometer = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
308  break;
309  case 4: // See Profile.xlsx::Messages:sdm_profile.speedSource
310  if (!verify(data, baseType, 0, FitBaseType::Byte, "sdm_profile.speedSource")) return false;
311  this->speedSource = static_cast<bool>(data.at(0));
312  break;
313  case 5: // See Profile.xlsx::Messages:sdm_profile.sdmAntIdTransType
314  if (!verify(data, baseType, 1, FitBaseType::Uint8z, "sdm_profile.sdmAntIdTransType")) return false;
315  this->sdmAntIdTransType = static_cast<quint8z>(data.at(0));
316  break;
317  case 7: // See Profile.xlsx::Messages:sdm_profile.odometerRollover
318  if (!verify(data, baseType, 1, FitBaseType::Uint8, "sdm_profile.odometerRollover")) return false;
319  this->odometerRollover = static_cast<quint8>(data.at(0));
320  break;
321  default:
322  qWarning() << "ignoring unknown sdm_profile message field number" << fieldId << bigEndian;
323  // Fall through to return true, as its still 'safe' to continue parsing data messages.
324  }
325  return true;
326 }
327 
328 /// \endcond
329 
#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.
quint16z sdmAntId
The SdmProfileMessage FIT message's sdmAntId field.
bool speedSource
The SdmProfileMessage FIT message's speedSource field.
quint16 sdmCalFactor
The SdmProfileMessage FIT message's sdmCalFactor field.
MessageIndex messageIndex
The SdmProfileMessage FIT message's messageIndex field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
quint32 odometer
The SdmProfileMessage FIT message's odometer field.
bool enabled
The SdmProfileMessage FIT message's enabled field.
quint8z sdmAntIdTransType
The SdmProfileMessage FIT message's sdmAntIdTransType field.
quint8 odometerRollover
The SdmProfileMessage FIT message's odometerRollover field.
The SdmProfileMessage class represents a FIT SdmProfileMessage data message.
void setOdometerRollover(const quint8 odometerRollover)
Sets the odometerRollover field to odometerRollover.
void setSdmAntIdTransType(const quint8z sdmAntIdTransType)
Sets the sdmAntIdTransType field to sdmAntIdTransType.
quint16 sdmCalFactor() const
Returns the SdmProfileMessage data message's sdmCalFactor field's current value.
void setSpeedSource(const bool speedSource)
Sets the speedSource field to speedSource.
void setSdmAntId(const quint16z sdmAntId)
Sets the sdmAntId field to sdmAntId.
bool enabled() const
Returns the SdmProfileMessage data message's enabled field's current value.
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
quint32 odometer() const
Returns the SdmProfileMessage data message's odometer field's current value.
bool speedSource() const
Returns the SdmProfileMessage data message's speedSource field's current value.
quint16z sdmAntId() const
Returns the SdmProfileMessage data message's sdmAntId field's current value.
void setOdometer(const quint32 odometer)
Sets the odometer field to odometer.
MessageIndex messageIndex() const
Returns the SdmProfileMessage data message's messageIndex field's current value.
quint8z sdmAntIdTransType() const
Returns the SdmProfileMessage data message's sdmAntIdTransType field's current value.
void setEnabled(const bool enabled)
Sets the enabled field to enabled.
void setSdmCalFactor(const quint16 sdmCalFactor)
Sets the sdmCalFactor field to sdmCalFactor.
quint8 odometerRollover() const
Returns the SdmProfileMessage data message's odometerRollover field's current value.
SdmProfileMessage()
Constructs a SdmProfileMessage object.
Declares the SdmProfileMessage class.
Declares the SdmProfileMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
quint16 quint16z
16-bit unsigned integer, with 0-is-invalid semantics.
Definition: types.h:46
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263
QTFIT_BEGIN_NAMESPACE typedef quint8 quint8z
8-bit unsigned integer, with 0-is-invalid semantics.
Definition: types.h:45