QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
setmessage.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 SetMessage, and SetMessagePrivate classes.
28  */
29 
30 #include "setmessage.h"
31 #include "setmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class SetMessage
40  *
41  * The SetMessage class represents a FIT SetMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a SetMessage 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 SetMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the SetMessage data message's \c timestamp field's current value.
71  *
72  * Timestamp of the set
73  *
74  * \return the \c timestamp field value.
75  */
77 {
78  Q_D(const SetMessage);
79  return d->timestamp;
80 }
81 
82 /*!
83  * Returns the SetMessage data message's \c duration field's current value.
84  *
85  * \return the \c duration field value.
86  */
87 quint32 SetMessage::duration() const
88 {
89  Q_D(const SetMessage);
90  return d->duration;
91 }
92 
93 /*!
94  * Returns the SetMessage data message's \c repetitions field's current value.
95  *
96  * # of repitions of the movement
97  *
98  * \return the \c repetitions field value.
99  */
100 quint16 SetMessage::repetitions() const
101 {
102  Q_D(const SetMessage);
103  return d->repetitions;
104 }
105 
106 /*!
107  * Returns the SetMessage data message's \c weight field's current value.
108  *
109  * Amount of weight applied for the set
110  *
111  * \return the \c weight field value.
112  */
113 quint16 SetMessage::weight() const
114 {
115  Q_D(const SetMessage);
116  return d->weight;
117 }
118 
119 /*!
120  * Returns the SetMessage data message's \c setType field's current value.
121  *
122  * \return the \c setType field value.
123  */
125 {
126  Q_D(const SetMessage);
127  return d->setType;
128 }
129 
130 /*!
131  * Returns the SetMessage data message's \c startTime field's current value.
132  *
133  * Start time of the set
134  *
135  * \return the \c startTime field value.
136  */
138 {
139  Q_D(const SetMessage);
140  return d->startTime;
141 }
142 
143 /*!
144  * Returns the SetMessage data message's \c category field's current value.
145  *
146  * \return the \c category field value.
147  */
149 {
150  Q_D(const SetMessage);
151  return d->category;
152 }
153 
154 /*!
155  * Returns the SetMessage data message's \c categorySubtype field's current value.
156  *
157  * Based on the associated category, see [category]_exercise_names
158  *
159  * \return the \c categorySubtype field value.
160  */
162 {
163  Q_D(const SetMessage);
164  return d->categorySubtype;
165 }
166 
167 /*!
168  * Returns the SetMessage data message's \c weightDisplayUnit field's current value.
169  *
170  * \return the \c weightDisplayUnit field value.
171  */
173 {
174  Q_D(const SetMessage);
175  return d->weightDisplayUnit;
176 }
177 
178 /*!
179  * Returns the SetMessage data message's \c messageIndex field's current value.
180  *
181  * \return the \c messageIndex field value.
182  */
184 {
185  Q_D(const SetMessage);
186  return d->messageIndex;
187 }
188 
189 /*!
190  * Returns the SetMessage data message's \c wktStepIndex field's current value.
191  *
192  * \return the \c wktStepIndex field value.
193  */
195 {
196  Q_D(const SetMessage);
197  return d->wktStepIndex;
198 }
199 
200 /*!
201  * Sets the \c timestamp field to \a timestamp.
202  *
203  * \param timestamp The field value to set.
204  */
205 void SetMessage::setTimestamp(const DateTime timestamp)
206 {
207  Q_D(SetMessage);
208  d->timestamp = timestamp;
209 }
210 /*!
211  * Sets the \c duration field to \a duration.
212  *
213  * \param duration The field value to set.
214  */
215 void SetMessage::setDuration(const quint32 duration)
216 {
217  Q_D(SetMessage);
218  d->duration = duration;
219 }
220 /*!
221  * Sets the \c repetitions field to \a repetitions.
222  *
223  * \param repetitions The field value to set.
224  */
225 void SetMessage::setRepetitions(const quint16 repetitions)
226 {
227  Q_D(SetMessage);
228  d->repetitions = repetitions;
229 }
230 /*!
231  * Sets the \c weight field to \a weight.
232  *
233  * \param weight The field value to set.
234  */
235 void SetMessage::setWeight(const quint16 weight)
236 {
237  Q_D(SetMessage);
238  d->weight = weight;
239 }
240 /*!
241  * Sets the \c setType field to \a setType.
242  *
243  * \param setType The field value to set.
244  */
245 void SetMessage::setSetType(const SetType setType)
246 {
247  Q_D(SetMessage);
248  d->setType = setType;
249 }
250 /*!
251  * Sets the \c startTime field to \a startTime.
252  *
253  * \param startTime The field value to set.
254  */
255 void SetMessage::setStartTime(const DateTime startTime)
256 {
257  Q_D(SetMessage);
258  d->startTime = startTime;
259 }
260 /*!
261  * Sets the \c category field to \a category.
262  *
263  * \param category The field value to set.
264  */
266 {
267  Q_D(SetMessage);
268  d->category = category;
269 }
270 /*!
271  * Sets the \c categorySubtype field to \a categorySubtype.
272  *
273  * \param categorySubtype The field value to set.
274  */
275 void SetMessage::setCategorySubtype(const quint16 categorySubtype)
276 {
277  Q_D(SetMessage);
278  d->categorySubtype = categorySubtype;
279 }
280 /*!
281  * Sets the \c weightDisplayUnit field to \a weightDisplayUnit.
282  *
283  * \param weightDisplayUnit The field value to set.
284  */
285 void SetMessage::setWeightDisplayUnit(const FitBaseUnit weightDisplayUnit)
286 {
287  Q_D(SetMessage);
288  d->weightDisplayUnit = weightDisplayUnit;
289 }
290 /*!
291  * Sets the \c messageIndex field to \a messageIndex.
292  *
293  * \param messageIndex The field value to set.
294  */
296 {
297  Q_D(SetMessage);
298  d->messageIndex = messageIndex;
299 }
300 /*!
301  * Sets the \c wktStepIndex field to \a wktStepIndex.
302  *
303  * \param wktStepIndex The field value to set.
304  */
306 {
307  Q_D(SetMessage);
308  d->wktStepIndex = wktStepIndex;
309 }
310 
311 /// \cond internal
312 
313 /*!
314  * \internal
315  *
316  * \class SetMessagePrivate
317  *
318  * The SetMessagePrivate class provides private implementation for the SetMessage.
319  *
320  * \sa SetMessage
321  */
322 
323 /*!
324  * \internal
325  *
326  * Constructs a SetMessagePrivate object with public implementation \a q.
327  *
328  * \param q Pointer to public implementaton.
329  */
330 SetMessagePrivate::SetMessagePrivate(SetMessage * const q)
332  , timestamp(static_cast<DateTime>(-1))
333  , duration(0xFFFFFFFF)
334  , repetitions(0xFFFF)
335  , weight(0xFFFF)
336  , setType(static_cast<SetType>(-1))
337  , startTime(static_cast<DateTime>(-1))
338  , category(static_cast<ExerciseCategory>(-1))
339  , categorySubtype(0xFFFF)
340  , weightDisplayUnit(static_cast<FitBaseUnit>(-1))
341  , messageIndex(static_cast<MessageIndex>(-1))
342  , wktStepIndex(static_cast<MessageIndex>(-1))
343 {
344  globalMessageNumber = MesgNum::Set;
345 }
346 
347 /*!
348  * \internal
349  *
350  * Destroys the SetMessagePrivate object.
351  */
353 {
354 
355 }
356 
358  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
359 {
360  switch (fieldId) {
361  case 254: // See Profile.xlsx::Messages:set.timestamp
362  if (!verify(data, baseType, 4, FitBaseType::Uint32, "set.timestamp")) return false;
363  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
364  break;
365  case 0: // See Profile.xlsx::Messages:set.duration
366  if (!verify(data, baseType, 4, FitBaseType::Uint32, "set.duration")) return false;
367  this->duration = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
368  break;
369  case 3: // See Profile.xlsx::Messages:set.repetitions
370  if (!verify(data, baseType, 2, FitBaseType::Uint16, "set.repetitions")) return false;
371  this->repetitions = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
372  break;
373  case 4: // See Profile.xlsx::Messages:set.weight
374  if (!verify(data, baseType, 2, FitBaseType::Uint16, "set.weight")) return false;
375  this->weight = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
376  break;
377  case 5: // See Profile.xlsx::Messages:set.setType
378  if (!verify(data, baseType, 1, FitBaseType::Uint8, "set.setType")) return false;
379  this->setType = static_cast<SetType>(data.at(0));
380  break;
381  case 6: // See Profile.xlsx::Messages:set.startTime
382  if (!verify(data, baseType, 4, FitBaseType::Uint32, "set.startTime")) return false;
383  this->startTime = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
384  break;
385  case 7: // See Profile.xlsx::Messages:set.category
386  if (!verify(data, baseType, 2, FitBaseType::Uint16, "set.category")) return false;
387  this->category = static_cast<ExerciseCategory>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
388  break;
389  case 8: // See Profile.xlsx::Messages:set.categorySubtype
390  if (!verify(data, baseType, 2, FitBaseType::Uint16, "set.categorySubtype")) return false;
391  this->categorySubtype = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
392  break;
393  case 9: // See Profile.xlsx::Messages:set.weightDisplayUnit
394  if (!verify(data, baseType, 2, FitBaseType::Uint16, "set.weightDisplayUnit")) return false;
395  this->weightDisplayUnit = static_cast<FitBaseUnit>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
396  break;
397  case 10: // See Profile.xlsx::Messages:set.messageIndex
398  if (!verify(data, baseType, 2, FitBaseType::Uint16, "set.messageIndex")) return false;
399  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
400  break;
401  case 11: // See Profile.xlsx::Messages:set.wktStepIndex
402  if (!verify(data, baseType, 2, FitBaseType::Uint16, "set.wktStepIndex")) return false;
403  this->wktStepIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
404  break;
405  default:
406  qWarning() << "ignoring unknown set message field number" << fieldId << bigEndian;
407  // Fall through to return true, as its still 'safe' to continue parsing data messages.
408  }
409  return true;
410 }
411 
412 /// \endcond
413 
#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 duration
The SetMessage FIT message's duration field.
Definition: setmessage_p.h:51
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
Definition: setmessage.cpp:357
virtual ~SetMessagePrivate()
Definition: setmessage.cpp:352
SetType setType
The SetMessage FIT message's setType field.
Definition: setmessage_p.h:70
quint16 weight
The SetMessage FIT message's weight field.
Definition: setmessage_p.h:65
MessageIndex wktStepIndex
The SetMessage FIT message's wktStepIndex field.
Definition: setmessage_p.h:104
quint16 repetitions
The SetMessage FIT message's repetitions field.
Definition: setmessage_p.h:58
quint16 categorySubtype
The SetMessage FIT message's categorySubtype field.
Definition: setmessage_p.h:89
DateTime timestamp
The SetMessage FIT message's timestamp field.
Definition: setmessage_p.h:46
FitBaseUnit weightDisplayUnit
The SetMessage FIT message's weightDisplayUnit field.
Definition: setmessage_p.h:94
ExerciseCategory category
The SetMessage FIT message's category field.
Definition: setmessage_p.h:82
DateTime startTime
The SetMessage FIT message's startTime field.
Definition: setmessage_p.h:77
MessageIndex messageIndex
The SetMessage FIT message's messageIndex field.
Definition: setmessage_p.h:99
The SetMessage class represents a FIT SetMessage data message.
Definition: setmessage.h:39
void setWeightDisplayUnit(const FitBaseUnit weightDisplayUnit)
Sets the weightDisplayUnit field to weightDisplayUnit.
Definition: setmessage.cpp:285
void setWktStepIndex(const MessageIndex wktStepIndex)
Sets the wktStepIndex field to wktStepIndex.
Definition: setmessage.cpp:305
SetMessage()
Constructs a SetMessage object.
Definition: setmessage.cpp:52
void setDuration(const quint32 duration)
Sets the duration field to duration.
Definition: setmessage.cpp:215
DateTime timestamp() const
Returns the SetMessage data message's timestamp field's current value.
Definition: setmessage.cpp:76
quint16 weight() const
Returns the SetMessage data message's weight field's current value.
Definition: setmessage.cpp:113
MessageIndex messageIndex() const
Returns the SetMessage data message's messageIndex field's current value.
Definition: setmessage.cpp:183
void setSetType(const SetType setType)
Sets the setType field to setType.
Definition: setmessage.cpp:245
void setWeight(const quint16 weight)
Sets the weight field to weight.
Definition: setmessage.cpp:235
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
Definition: setmessage.cpp:205
ExerciseCategory category() const
Returns the SetMessage data message's category field's current value.
Definition: setmessage.cpp:148
void setStartTime(const DateTime startTime)
Sets the startTime field to startTime.
Definition: setmessage.cpp:255
void setRepetitions(const quint16 repetitions)
Sets the repetitions field to repetitions.
Definition: setmessage.cpp:225
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
Definition: setmessage.cpp:295
SetType setType() const
Returns the SetMessage data message's setType field's current value.
Definition: setmessage.cpp:124
void setCategory(const ExerciseCategory category)
Sets the category field to category.
Definition: setmessage.cpp:265
FitBaseUnit weightDisplayUnit() const
Returns the SetMessage data message's weightDisplayUnit field's current value.
Definition: setmessage.cpp:172
quint16 repetitions() const
Returns the SetMessage data message's repetitions field's current value.
Definition: setmessage.cpp:100
MessageIndex wktStepIndex() const
Returns the SetMessage data message's wktStepIndex field's current value.
Definition: setmessage.cpp:194
quint32 duration() const
Returns the SetMessage data message's duration field's current value.
Definition: setmessage.cpp:87
DateTime startTime() const
Returns the SetMessage data message's startTime field's current value.
Definition: setmessage.cpp:137
void setCategorySubtype(const quint16 categorySubtype)
Sets the categorySubtype field to categorySubtype.
Definition: setmessage.cpp:275
quint16 categorySubtype() const
Returns the SetMessage data message's categorySubtype field's current value.
Definition: setmessage.cpp:161
Declares the SetMessage class.
Declares the SetMessagePrivate class.
SetType
Garmin FIT SetType type.
Definition: types.h:3496
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
ExerciseCategory
Garmin FIT ExerciseCategory type.
Definition: types.h:3510
FitBaseUnit
Garmin FIT FitBaseUnit type.
Definition: types.h:3481
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237