QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
totalsmessage.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 TotalsMessage, and TotalsMessagePrivate classes.
28  */
29 
30 #include "totalsmessage.h"
31 #include "totalsmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class TotalsMessage
40  *
41  * The TotalsMessage class represents a FIT TotalsMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a TotalsMessage 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 TotalsMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the TotalsMessage data message's \c messageIndex field's current value.
71  *
72  * \return the \c messageIndex field value.
73  */
75 {
76  Q_D(const TotalsMessage);
77  return d->messageIndex;
78 }
79 
80 /*!
81  * Returns the TotalsMessage data message's \c timestamp field's current value.
82  *
83  * \return the \c timestamp field value.
84  */
86 {
87  Q_D(const TotalsMessage);
88  return d->timestamp;
89 }
90 
91 /*!
92  * Returns the TotalsMessage data message's \c timerTime field's current value.
93  *
94  * Excludes pauses
95  *
96  * \return the \c timerTime field value.
97  */
98 quint32 TotalsMessage::timerTime() const
99 {
100  Q_D(const TotalsMessage);
101  return d->timerTime;
102 }
103 
104 /*!
105  * Returns the TotalsMessage data message's \c distance field's current value.
106  *
107  * \return the \c distance field value.
108  */
109 quint32 TotalsMessage::distance() const
110 {
111  Q_D(const TotalsMessage);
112  return d->distance;
113 }
114 
115 /*!
116  * Returns the TotalsMessage data message's \c calories field's current value.
117  *
118  * \return the \c calories field value.
119  */
120 quint32 TotalsMessage::calories() const
121 {
122  Q_D(const TotalsMessage);
123  return d->calories;
124 }
125 
126 /*!
127  * Returns the TotalsMessage data message's \c sport field's current value.
128  *
129  * \return the \c sport field value.
130  */
132 {
133  Q_D(const TotalsMessage);
134  return d->sport;
135 }
136 
137 /*!
138  * Returns the TotalsMessage data message's \c elapsedTime field's current value.
139  *
140  * Includes pauses
141  *
142  * \return the \c elapsedTime field value.
143  */
145 {
146  Q_D(const TotalsMessage);
147  return d->elapsedTime;
148 }
149 
150 /*!
151  * Returns the TotalsMessage data message's \c sessions field's current value.
152  *
153  * \return the \c sessions field value.
154  */
155 quint16 TotalsMessage::sessions() const
156 {
157  Q_D(const TotalsMessage);
158  return d->sessions;
159 }
160 
161 /*!
162  * Returns the TotalsMessage data message's \c activeTime field's current value.
163  *
164  * \return the \c activeTime field value.
165  */
167 {
168  Q_D(const TotalsMessage);
169  return d->activeTime;
170 }
171 
172 /*!
173  * Returns the TotalsMessage data message's \c sportIndex field's current value.
174  *
175  * \return the \c sportIndex field value.
176  */
178 {
179  Q_D(const TotalsMessage);
180  return d->sportIndex;
181 }
182 
183 /*!
184  * Sets the \c messageIndex field to \a messageIndex.
185  *
186  * \param messageIndex The field value to set.
187  */
189 {
190  Q_D(TotalsMessage);
191  d->messageIndex = messageIndex;
192 }
193 /*!
194  * Sets the \c timestamp field to \a timestamp.
195  *
196  * \param timestamp The field value to set.
197  */
199 {
200  Q_D(TotalsMessage);
201  d->timestamp = timestamp;
202 }
203 /*!
204  * Sets the \c timerTime field to \a timerTime.
205  *
206  * \param timerTime The field value to set.
207  */
208 void TotalsMessage::setTimerTime(const quint32 timerTime)
209 {
210  Q_D(TotalsMessage);
211  d->timerTime = timerTime;
212 }
213 /*!
214  * Sets the \c distance field to \a distance.
215  *
216  * \param distance The field value to set.
217  */
218 void TotalsMessage::setDistance(const quint32 distance)
219 {
220  Q_D(TotalsMessage);
221  d->distance = distance;
222 }
223 /*!
224  * Sets the \c calories field to \a calories.
225  *
226  * \param calories The field value to set.
227  */
228 void TotalsMessage::setCalories(const quint32 calories)
229 {
230  Q_D(TotalsMessage);
231  d->calories = calories;
232 }
233 /*!
234  * Sets the \c sport field to \a sport.
235  *
236  * \param sport The field value to set.
237  */
239 {
240  Q_D(TotalsMessage);
241  d->sport = sport;
242 }
243 /*!
244  * Sets the \c elapsedTime field to \a elapsedTime.
245  *
246  * \param elapsedTime The field value to set.
247  */
248 void TotalsMessage::setElapsedTime(const quint32 elapsedTime)
249 {
250  Q_D(TotalsMessage);
251  d->elapsedTime = elapsedTime;
252 }
253 /*!
254  * Sets the \c sessions field to \a sessions.
255  *
256  * \param sessions The field value to set.
257  */
258 void TotalsMessage::setSessions(const quint16 sessions)
259 {
260  Q_D(TotalsMessage);
261  d->sessions = sessions;
262 }
263 /*!
264  * Sets the \c activeTime field to \a activeTime.
265  *
266  * \param activeTime The field value to set.
267  */
268 void TotalsMessage::setActiveTime(const quint32 activeTime)
269 {
270  Q_D(TotalsMessage);
271  d->activeTime = activeTime;
272 }
273 /*!
274  * Sets the \c sportIndex field to \a sportIndex.
275  *
276  * \param sportIndex The field value to set.
277  */
278 void TotalsMessage::setSportIndex(const quint8 sportIndex)
279 {
280  Q_D(TotalsMessage);
281  d->sportIndex = sportIndex;
282 }
283 
284 /// \cond internal
285 
286 /*!
287  * \internal
288  *
289  * \class TotalsMessagePrivate
290  *
291  * The TotalsMessagePrivate class provides private implementation for the TotalsMessage.
292  *
293  * \sa TotalsMessage
294  */
295 
296 /*!
297  * \internal
298  *
299  * Constructs a TotalsMessagePrivate object with public implementation \a q.
300  *
301  * \param q Pointer to public implementaton.
302  */
303 TotalsMessagePrivate::TotalsMessagePrivate(TotalsMessage * const q)
305  , messageIndex(static_cast<MessageIndex>(-1))
306  , timestamp(static_cast<DateTime>(-1))
307  , timerTime(0xFFFFFFFF)
308  , distance(0xFFFFFFFF)
309  , calories(0xFFFFFFFF)
310  , sport(static_cast<Sport>(-1))
311  , elapsedTime(0xFFFFFFFF)
312  , sessions(0xFFFF)
313  , activeTime(0xFFFFFFFF)
314  , sportIndex(0xFF)
315 {
316  globalMessageNumber = MesgNum::Totals;
317 }
318 
319 /*!
320  * \internal
321  *
322  * Destroys the TotalsMessagePrivate object.
323  */
325 {
326 
327 }
328 
330  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
331 {
332  switch (fieldId) {
333  case 254: // See Profile.xlsx::Messages:totals.messageIndex
334  if (!verify(data, baseType, 2, FitBaseType::Uint16, "totals.messageIndex")) return false;
335  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
336  break;
337  case 253: // See Profile.xlsx::Messages:totals.timestamp
338  if (!verify(data, baseType, 4, FitBaseType::Uint32, "totals.timestamp")) return false;
339  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
340  break;
341  case 0: // See Profile.xlsx::Messages:totals.timerTime
342  if (!verify(data, baseType, 4, FitBaseType::Uint32, "totals.timerTime")) return false;
343  this->timerTime = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
344  break;
345  case 1: // See Profile.xlsx::Messages:totals.distance
346  if (!verify(data, baseType, 4, FitBaseType::Uint32, "totals.distance")) return false;
347  this->distance = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
348  break;
349  case 2: // See Profile.xlsx::Messages:totals.calories
350  if (!verify(data, baseType, 4, FitBaseType::Uint32, "totals.calories")) return false;
351  this->calories = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
352  break;
353  case 3: // See Profile.xlsx::Messages:totals.sport
354  if (!verify(data, baseType, 1, FitBaseType::Enum, "totals.sport")) return false;
355  this->sport = static_cast<Sport>(data.at(0));
356  break;
357  case 4: // See Profile.xlsx::Messages:totals.elapsedTime
358  if (!verify(data, baseType, 4, FitBaseType::Uint32, "totals.elapsedTime")) return false;
359  this->elapsedTime = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
360  break;
361  case 5: // See Profile.xlsx::Messages:totals.sessions
362  if (!verify(data, baseType, 2, FitBaseType::Uint16, "totals.sessions")) return false;
363  this->sessions = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
364  break;
365  case 6: // See Profile.xlsx::Messages:totals.activeTime
366  if (!verify(data, baseType, 4, FitBaseType::Uint32, "totals.activeTime")) return false;
367  this->activeTime = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
368  break;
369  case 9: // See Profile.xlsx::Messages:totals.sportIndex
370  if (!verify(data, baseType, 1, FitBaseType::Uint8, "totals.sportIndex")) return false;
371  this->sportIndex = static_cast<quint8>(data.at(0));
372  break;
373  default:
374  qWarning() << "ignoring unknown totals message field number" << fieldId << bigEndian;
375  // Fall through to return true, as its still 'safe' to continue parsing data messages.
376  }
377  return true;
378 }
379 
380 /// \endcond
381 
#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 elapsedTime
The TotalsMessage FIT message's elapsedTime field.
quint32 activeTime
The TotalsMessage FIT message's activeTime field.
quint32 distance
The TotalsMessage FIT message's distance field.
DateTime timestamp
The TotalsMessage FIT message's timestamp field.
virtual ~TotalsMessagePrivate()
Sport sport
The TotalsMessage FIT message's sport field.
MessageIndex messageIndex
The TotalsMessage FIT message's messageIndex field.
quint8 sportIndex
The TotalsMessage FIT message's sportIndex field.
quint16 sessions
The TotalsMessage FIT message's sessions field.
quint32 calories
The TotalsMessage FIT message's calories field.
quint32 timerTime
The TotalsMessage FIT message's timerTime field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
The TotalsMessage class represents a FIT TotalsMessage data message.
Definition: totalsmessage.h:39
void setSportIndex(const quint8 sportIndex)
Sets the sportIndex field to sportIndex.
quint32 calories() const
Returns the TotalsMessage data message's calories field's current value.
void setSport(const Sport sport)
Sets the sport field to sport.
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
DateTime timestamp() const
Returns the TotalsMessage data message's timestamp field's current value.
quint8 sportIndex() const
Returns the TotalsMessage data message's sportIndex field's current value.
void setDistance(const quint32 distance)
Sets the distance field to distance.
TotalsMessage()
Constructs a TotalsMessage object.
void setActiveTime(const quint32 activeTime)
Sets the activeTime field to activeTime.
quint32 activeTime() const
Returns the TotalsMessage data message's activeTime field's current value.
MessageIndex messageIndex() const
Returns the TotalsMessage data message's messageIndex field's current value.
void setElapsedTime(const quint32 elapsedTime)
Sets the elapsedTime field to elapsedTime.
void setCalories(const quint32 calories)
Sets the calories field to calories.
Sport sport() const
Returns the TotalsMessage data message's sport field's current value.
quint32 elapsedTime() const
Returns the TotalsMessage data message's elapsedTime field's current value.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
quint32 distance() const
Returns the TotalsMessage data message's distance field's current value.
void setTimerTime(const quint32 timerTime)
Sets the timerTime field to timerTime.
quint32 timerTime() const
Returns the TotalsMessage data message's timerTime field's current value.
void setSessions(const quint16 sessions)
Sets the sessions field to sessions.
quint16 sessions() const
Returns the TotalsMessage data message's sessions field's current value.
Declares the TotalsMessage class.
Declares the TotalsMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
Sport
Garmin FIT Sport type.
Definition: types.h:685
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237