QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
weightscalemessage.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 WeightScaleMessage, and WeightScaleMessagePrivate classes.
28  */
29 
30 #include "weightscalemessage.h"
31 #include "weightscalemessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class WeightScaleMessage
40  *
41  * The WeightScaleMessage class represents a FIT WeightScaleMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a WeightScaleMessage 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 WeightScaleMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the WeightScaleMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const WeightScaleMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the WeightScaleMessage data message's \c weight field's current value.
82  *
83  * \return the \c weight field value.
84  */
86 {
87  Q_D(const WeightScaleMessage);
88  return d->weight;
89 }
90 
91 /*!
92  * Returns the WeightScaleMessage data message's \c percentFat field's current value.
93  *
94  * \return the \c percentFat field value.
95  */
97 {
98  Q_D(const WeightScaleMessage);
99  return d->percentFat;
100 }
101 
102 /*!
103  * Returns the WeightScaleMessage data message's \c percentHydration field's current value.
104  *
105  * \return the \c percentHydration field value.
106  */
108 {
109  Q_D(const WeightScaleMessage);
110  return d->percentHydration;
111 }
112 
113 /*!
114  * Returns the WeightScaleMessage data message's \c visceralFatMass field's current value.
115  *
116  * \return the \c visceralFatMass field value.
117  */
119 {
120  Q_D(const WeightScaleMessage);
121  return d->visceralFatMass;
122 }
123 
124 /*!
125  * Returns the WeightScaleMessage data message's \c boneMass field's current value.
126  *
127  * \return the \c boneMass field value.
128  */
130 {
131  Q_D(const WeightScaleMessage);
132  return d->boneMass;
133 }
134 
135 /*!
136  * Returns the WeightScaleMessage data message's \c muscleMass field's current value.
137  *
138  * \return the \c muscleMass field value.
139  */
141 {
142  Q_D(const WeightScaleMessage);
143  return d->muscleMass;
144 }
145 
146 /*!
147  * Returns the WeightScaleMessage data message's \c basalMet field's current value.
148  *
149  * \return the \c basalMet field value.
150  */
152 {
153  Q_D(const WeightScaleMessage);
154  return d->basalMet;
155 }
156 
157 /*!
158  * Returns the WeightScaleMessage data message's \c physiqueRating field's current value.
159  *
160  * \return the \c physiqueRating field value.
161  */
163 {
164  Q_D(const WeightScaleMessage);
165  return d->physiqueRating;
166 }
167 
168 /*!
169  * Returns the WeightScaleMessage data message's \c activeMet field's current value.
170  *
171  * ~4kJ per kcal, 0.25 allows max 16384 kcal
172  *
173  * \return the \c activeMet field value.
174  */
176 {
177  Q_D(const WeightScaleMessage);
178  return d->activeMet;
179 }
180 
181 /*!
182  * Returns the WeightScaleMessage data message's \c metabolicAge field's current value.
183  *
184  * \return the \c metabolicAge field value.
185  */
187 {
188  Q_D(const WeightScaleMessage);
189  return d->metabolicAge;
190 }
191 
192 /*!
193  * Returns the WeightScaleMessage data message's \c visceralFatRating field's current value.
194  *
195  * \return the \c visceralFatRating field value.
196  */
198 {
199  Q_D(const WeightScaleMessage);
200  return d->visceralFatRating;
201 }
202 
203 /*!
204  * Returns the WeightScaleMessage data message's \c userProfileIndex field's current value.
205  *
206  * Associates this weight scale message to a user. This corresponds to the index of the user
207  * profile message in the weight scale file.
208  *
209  * \return the \c userProfileIndex field value.
210  */
212 {
213  Q_D(const WeightScaleMessage);
214  return d->userProfileIndex;
215 }
216 
217 /*!
218  * Sets the \c timestamp field to \a timestamp.
219  *
220  * \param timestamp The field value to set.
221  */
223 {
224  Q_D(WeightScaleMessage);
225  d->timestamp = timestamp;
226 }
227 /*!
228  * Sets the \c weight field to \a weight.
229  *
230  * \param weight The field value to set.
231  */
233 {
234  Q_D(WeightScaleMessage);
235  d->weight = weight;
236 }
237 /*!
238  * Sets the \c percentFat field to \a percentFat.
239  *
240  * \param percentFat The field value to set.
241  */
242 void WeightScaleMessage::setPercentFat(const quint16 percentFat)
243 {
244  Q_D(WeightScaleMessage);
245  d->percentFat = percentFat;
246 }
247 /*!
248  * Sets the \c percentHydration field to \a percentHydration.
249  *
250  * \param percentHydration The field value to set.
251  */
252 void WeightScaleMessage::setPercentHydration(const quint16 percentHydration)
253 {
254  Q_D(WeightScaleMessage);
255  d->percentHydration = percentHydration;
256 }
257 /*!
258  * Sets the \c visceralFatMass field to \a visceralFatMass.
259  *
260  * \param visceralFatMass The field value to set.
261  */
262 void WeightScaleMessage::setVisceralFatMass(const quint16 visceralFatMass)
263 {
264  Q_D(WeightScaleMessage);
265  d->visceralFatMass = visceralFatMass;
266 }
267 /*!
268  * Sets the \c boneMass field to \a boneMass.
269  *
270  * \param boneMass The field value to set.
271  */
272 void WeightScaleMessage::setBoneMass(const quint16 boneMass)
273 {
274  Q_D(WeightScaleMessage);
275  d->boneMass = boneMass;
276 }
277 /*!
278  * Sets the \c muscleMass field to \a muscleMass.
279  *
280  * \param muscleMass The field value to set.
281  */
282 void WeightScaleMessage::setMuscleMass(const quint16 muscleMass)
283 {
284  Q_D(WeightScaleMessage);
285  d->muscleMass = muscleMass;
286 }
287 /*!
288  * Sets the \c basalMet field to \a basalMet.
289  *
290  * \param basalMet The field value to set.
291  */
292 void WeightScaleMessage::setBasalMet(const quint16 basalMet)
293 {
294  Q_D(WeightScaleMessage);
295  d->basalMet = basalMet;
296 }
297 /*!
298  * Sets the \c physiqueRating field to \a physiqueRating.
299  *
300  * \param physiqueRating The field value to set.
301  */
302 void WeightScaleMessage::setPhysiqueRating(const quint8 physiqueRating)
303 {
304  Q_D(WeightScaleMessage);
305  d->physiqueRating = physiqueRating;
306 }
307 /*!
308  * Sets the \c activeMet field to \a activeMet.
309  *
310  * \param activeMet The field value to set.
311  */
312 void WeightScaleMessage::setActiveMet(const quint16 activeMet)
313 {
314  Q_D(WeightScaleMessage);
315  d->activeMet = activeMet;
316 }
317 /*!
318  * Sets the \c metabolicAge field to \a metabolicAge.
319  *
320  * \param metabolicAge The field value to set.
321  */
322 void WeightScaleMessage::setMetabolicAge(const quint8 metabolicAge)
323 {
324  Q_D(WeightScaleMessage);
325  d->metabolicAge = metabolicAge;
326 }
327 /*!
328  * Sets the \c visceralFatRating field to \a visceralFatRating.
329  *
330  * \param visceralFatRating The field value to set.
331  */
332 void WeightScaleMessage::setVisceralFatRating(const quint8 visceralFatRating)
333 {
334  Q_D(WeightScaleMessage);
335  d->visceralFatRating = visceralFatRating;
336 }
337 /*!
338  * Sets the \c userProfileIndex field to \a userProfileIndex.
339  *
340  * \param userProfileIndex The field value to set.
341  */
343 {
344  Q_D(WeightScaleMessage);
345  d->userProfileIndex = userProfileIndex;
346 }
347 
348 /// \cond internal
349 
350 /*!
351  * \internal
352  *
353  * \class WeightScaleMessagePrivate
354  *
355  * The WeightScaleMessagePrivate class provides private implementation for the WeightScaleMessage.
356  *
357  * \sa WeightScaleMessage
358  */
359 
360 /*!
361  * \internal
362  *
363  * Constructs a WeightScaleMessagePrivate object with public implementation \a q.
364  *
365  * \param q Pointer to public implementaton.
366  */
367 WeightScaleMessagePrivate::WeightScaleMessagePrivate(WeightScaleMessage * const q)
369  , timestamp(static_cast<DateTime>(-1))
370  , weight(static_cast<Weight>(-1))
371  , percentFat(0xFFFF)
372  , percentHydration(0xFFFF)
373  , visceralFatMass(0xFFFF)
374  , boneMass(0xFFFF)
375  , muscleMass(0xFFFF)
376  , basalMet(0xFFFF)
377  , physiqueRating(0xFF)
378  , activeMet(0xFFFF)
379  , metabolicAge(0xFF)
380  , visceralFatRating(0xFF)
381  , userProfileIndex(static_cast<MessageIndex>(-1))
382 {
383  globalMessageNumber = MesgNum::WeightScale;
384 }
385 
386 /*!
387  * \internal
388  *
389  * Destroys the WeightScaleMessagePrivate object.
390  */
392 {
393 
394 }
395 
397  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
398 {
399  switch (fieldId) {
400  case 253: // See Profile.xlsx::Messages:weight_scale.timestamp
401  if (!verify(data, baseType, 4, FitBaseType::Uint32, "weight_scale.timestamp")) return false;
402  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
403  break;
404  case 0: // See Profile.xlsx::Messages:weight_scale.weight
405  if (!verify(data, baseType, 2, FitBaseType::Uint16, "weight_scale.weight")) return false;
406  this->weight = static_cast<Weight>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
407  break;
408  case 1: // See Profile.xlsx::Messages:weight_scale.percentFat
409  if (!verify(data, baseType, 2, FitBaseType::Uint16, "weight_scale.percentFat")) return false;
410  this->percentFat = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
411  break;
412  case 2: // See Profile.xlsx::Messages:weight_scale.percentHydration
413  if (!verify(data, baseType, 2, FitBaseType::Uint16, "weight_scale.percentHydration")) return false;
414  this->percentHydration = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
415  break;
416  case 3: // See Profile.xlsx::Messages:weight_scale.visceralFatMass
417  if (!verify(data, baseType, 2, FitBaseType::Uint16, "weight_scale.visceralFatMass")) return false;
418  this->visceralFatMass = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
419  break;
420  case 4: // See Profile.xlsx::Messages:weight_scale.boneMass
421  if (!verify(data, baseType, 2, FitBaseType::Uint16, "weight_scale.boneMass")) return false;
422  this->boneMass = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
423  break;
424  case 5: // See Profile.xlsx::Messages:weight_scale.muscleMass
425  if (!verify(data, baseType, 2, FitBaseType::Uint16, "weight_scale.muscleMass")) return false;
426  this->muscleMass = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
427  break;
428  case 7: // See Profile.xlsx::Messages:weight_scale.basalMet
429  if (!verify(data, baseType, 2, FitBaseType::Uint16, "weight_scale.basalMet")) return false;
430  this->basalMet = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
431  break;
432  case 8: // See Profile.xlsx::Messages:weight_scale.physiqueRating
433  if (!verify(data, baseType, 1, FitBaseType::Uint8, "weight_scale.physiqueRating")) return false;
434  this->physiqueRating = static_cast<quint8>(data.at(0));
435  break;
436  case 9: // See Profile.xlsx::Messages:weight_scale.activeMet
437  if (!verify(data, baseType, 2, FitBaseType::Uint16, "weight_scale.activeMet")) return false;
438  this->activeMet = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
439  break;
440  case 10: // See Profile.xlsx::Messages:weight_scale.metabolicAge
441  if (!verify(data, baseType, 1, FitBaseType::Uint8, "weight_scale.metabolicAge")) return false;
442  this->metabolicAge = static_cast<quint8>(data.at(0));
443  break;
444  case 11: // See Profile.xlsx::Messages:weight_scale.visceralFatRating
445  if (!verify(data, baseType, 1, FitBaseType::Uint8, "weight_scale.visceralFatRating")) return false;
446  this->visceralFatRating = static_cast<quint8>(data.at(0));
447  break;
448  case 12: // See Profile.xlsx::Messages:weight_scale.userProfileIndex
449  if (!verify(data, baseType, 2, FitBaseType::Uint16, "weight_scale.userProfileIndex")) return false;
450  this->userProfileIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
451  break;
452  default:
453  qWarning() << "ignoring unknown weight_scale message field number" << fieldId << bigEndian;
454  // Fall through to return true, as its still 'safe' to continue parsing data messages.
455  }
456  return true;
457 }
458 
459 /// \endcond
460 
#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.
quint16 percentFat
The WeightScaleMessage FIT message's percentFat field.
quint8 visceralFatRating
The WeightScaleMessage FIT message's visceralFatRating field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
MessageIndex userProfileIndex
The WeightScaleMessage FIT message's userProfileIndex field.
quint8 metabolicAge
The WeightScaleMessage FIT message's metabolicAge field.
quint8 physiqueRating
The WeightScaleMessage FIT message's physiqueRating field.
DateTime timestamp
The WeightScaleMessage FIT message's timestamp field.
quint16 muscleMass
The WeightScaleMessage FIT message's muscleMass field.
quint16 boneMass
The WeightScaleMessage FIT message's boneMass field.
quint16 activeMet
The WeightScaleMessage FIT message's activeMet field.
quint16 visceralFatMass
The WeightScaleMessage FIT message's visceralFatMass field.
quint16 percentHydration
The WeightScaleMessage FIT message's percentHydration field.
quint16 basalMet
The WeightScaleMessage FIT message's basalMet field.
Weight weight
The WeightScaleMessage FIT message's weight field.
The WeightScaleMessage class represents a FIT WeightScaleMessage data message.
quint16 boneMass() const
Returns the WeightScaleMessage data message's boneMass field's current value.
void setBoneMass(const quint16 boneMass)
Sets the boneMass field to boneMass.
quint8 physiqueRating() const
Returns the WeightScaleMessage data message's physiqueRating field's current value.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
quint8 visceralFatRating() const
Returns the WeightScaleMessage data message's visceralFatRating field's current value.
quint16 activeMet() const
Returns the WeightScaleMessage data message's activeMet field's current value.
void setVisceralFatMass(const quint16 visceralFatMass)
Sets the visceralFatMass field to visceralFatMass.
void setPercentFat(const quint16 percentFat)
Sets the percentFat field to percentFat.
quint16 muscleMass() const
Returns the WeightScaleMessage data message's muscleMass field's current value.
void setPhysiqueRating(const quint8 physiqueRating)
Sets the physiqueRating field to physiqueRating.
MessageIndex userProfileIndex() const
Returns the WeightScaleMessage data message's userProfileIndex field's current value.
void setBasalMet(const quint16 basalMet)
Sets the basalMet field to basalMet.
quint8 metabolicAge() const
Returns the WeightScaleMessage data message's metabolicAge field's current value.
quint16 percentFat() const
Returns the WeightScaleMessage data message's percentFat field's current value.
quint16 visceralFatMass() const
Returns the WeightScaleMessage data message's visceralFatMass field's current value.
Weight weight() const
Returns the WeightScaleMessage data message's weight field's current value.
void setPercentHydration(const quint16 percentHydration)
Sets the percentHydration field to percentHydration.
DateTime timestamp() const
Returns the WeightScaleMessage data message's timestamp field's current value.
quint16 percentHydration() const
Returns the WeightScaleMessage data message's percentHydration field's current value.
void setMuscleMass(const quint16 muscleMass)
Sets the muscleMass field to muscleMass.
void setActiveMet(const quint16 activeMet)
Sets the activeMet field to activeMet.
WeightScaleMessage()
Constructs a WeightScaleMessage object.
void setUserProfileIndex(const MessageIndex userProfileIndex)
Sets the userProfileIndex field to userProfileIndex.
void setMetabolicAge(const quint8 metabolicAge)
Sets the metabolicAge field to metabolicAge.
void setVisceralFatRating(const quint8 visceralFatRating)
Sets the visceralFatRating field to visceralFatRating.
void setWeight(const Weight weight)
Sets the weight field to weight.
quint16 basalMet() const
Returns the WeightScaleMessage data message's basalMet field's current value.
Weight
Garmin FIT Weight type.
Definition: types.h:2188
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237
Declares the WeightScaleMessage class.
Declares the WeightScaleMessagePrivate class.