QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
workoutstepmessage.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 WorkoutStepMessage, and WorkoutStepMessagePrivate classes.
28  */
29 
30 #include "workoutstepmessage.h"
31 #include "workoutstepmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class WorkoutStepMessage
40  *
41  * The WorkoutStepMessage class represents a FIT WorkoutStepMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a WorkoutStepMessage 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 WorkoutStepMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the WorkoutStepMessage data message's \c messageIndex field's current value.
71  *
72  * \return the \c messageIndex field value.
73  */
75 {
76  Q_D(const WorkoutStepMessage);
77  return d->messageIndex;
78 }
79 
80 /*!
81  * Returns the WorkoutStepMessage data message's \c wktStepName field's current value.
82  *
83  * \return the \c wktStepName field value.
84  */
86 {
87  Q_D(const WorkoutStepMessage);
88  return d->wktStepName;
89 }
90 
91 /*!
92  * Returns the WorkoutStepMessage data message's \c durationType field's current value.
93  *
94  * \return the \c durationType field value.
95  */
97 {
98  Q_D(const WorkoutStepMessage);
99  return d->durationType;
100 }
101 
102 /*!
103  * Returns the WorkoutStepMessage data message's \c durationValue field's current value.
104  *
105  * \return the \c durationValue field value.
106  */
108 {
109  Q_D(const WorkoutStepMessage);
110  return d->durationValue;
111 }
112 
113 /*!
114  * Returns the WorkoutStepMessage data message's \c targetType field's current value.
115  *
116  * \return the \c targetType field value.
117  */
119 {
120  Q_D(const WorkoutStepMessage);
121  return d->targetType;
122 }
123 
124 /*!
125  * Returns the WorkoutStepMessage data message's \c targetValue field's current value.
126  *
127  * \return the \c targetValue field value.
128  */
130 {
131  Q_D(const WorkoutStepMessage);
132  return d->targetValue;
133 }
134 
135 /*!
136  * Returns the WorkoutStepMessage data message's \c customTargetValueLow field's current value.
137  *
138  * \return the \c customTargetValueLow field value.
139  */
141 {
142  Q_D(const WorkoutStepMessage);
143  return d->customTargetValueLow;
144 }
145 
146 /*!
147  * Returns the WorkoutStepMessage data message's \c customTargetValueHigh field's current value.
148  *
149  * \return the \c customTargetValueHigh field value.
150  */
152 {
153  Q_D(const WorkoutStepMessage);
154  return d->customTargetValueHigh;
155 }
156 
157 /*!
158  * Returns the WorkoutStepMessage data message's \c intensity field's current value.
159  *
160  * \return the \c intensity field value.
161  */
163 {
164  Q_D(const WorkoutStepMessage);
165  return d->intensity;
166 }
167 
168 /*!
169  * Returns the WorkoutStepMessage data message's \c notes field's current value.
170  *
171  * \return the \c notes field value.
172  */
174 {
175  Q_D(const WorkoutStepMessage);
176  return d->notes;
177 }
178 
179 /*!
180  * Returns the WorkoutStepMessage data message's \c equipment field's current value.
181  *
182  * \return the \c equipment field value.
183  */
185 {
186  Q_D(const WorkoutStepMessage);
187  return d->equipment;
188 }
189 
190 /*!
191  * Returns the WorkoutStepMessage data message's \c exerciseCategory field's current value.
192  *
193  * \return the \c exerciseCategory field value.
194  */
196 {
197  Q_D(const WorkoutStepMessage);
198  return d->exerciseCategory;
199 }
200 
201 /*!
202  * Returns the WorkoutStepMessage data message's \c exerciseName field's current value.
203  *
204  * \return the \c exerciseName field value.
205  */
207 {
208  Q_D(const WorkoutStepMessage);
209  return d->exerciseName;
210 }
211 
212 /*!
213  * Returns the WorkoutStepMessage data message's \c exerciseWeight field's current value.
214  *
215  * \return the \c exerciseWeight field value.
216  */
218 {
219  Q_D(const WorkoutStepMessage);
220  return d->exerciseWeight;
221 }
222 
223 /*!
224  * Returns the WorkoutStepMessage data message's \c weightDisplayUnit field's current value.
225  *
226  * \return the \c weightDisplayUnit field value.
227  */
229 {
230  Q_D(const WorkoutStepMessage);
231  return d->weightDisplayUnit;
232 }
233 
234 /*!
235  * Sets the \c messageIndex field to \a messageIndex.
236  *
237  * \param messageIndex The field value to set.
238  */
240 {
241  Q_D(WorkoutStepMessage);
242  d->messageIndex = messageIndex;
243 }
244 /*!
245  * Sets the \c wktStepName field to \a wktStepName.
246  *
247  * \param wktStepName The field value to set.
248  */
249 void WorkoutStepMessage::setWktStepName(const QString wktStepName)
250 {
251  Q_D(WorkoutStepMessage);
252  d->wktStepName = wktStepName;
253 }
254 /*!
255  * Sets the \c durationType field to \a durationType.
256  *
257  * \param durationType The field value to set.
258  */
260 {
261  Q_D(WorkoutStepMessage);
262  d->durationType = durationType;
263 }
264 /*!
265  * Sets the \c durationValue field to \a durationValue.
266  *
267  * \param durationValue The field value to set.
268  */
269 void WorkoutStepMessage::setDurationValue(const quint32 durationValue)
270 {
271  Q_D(WorkoutStepMessage);
272  d->durationValue = durationValue;
273 }
274 /*!
275  * Sets the \c targetType field to \a targetType.
276  *
277  * \param targetType The field value to set.
278  */
280 {
281  Q_D(WorkoutStepMessage);
282  d->targetType = targetType;
283 }
284 /*!
285  * Sets the \c targetValue field to \a targetValue.
286  *
287  * \param targetValue The field value to set.
288  */
289 void WorkoutStepMessage::setTargetValue(const quint32 targetValue)
290 {
291  Q_D(WorkoutStepMessage);
292  d->targetValue = targetValue;
293 }
294 /*!
295  * Sets the \c customTargetValueLow field to \a customTargetValueLow.
296  *
297  * \param customTargetValueLow The field value to set.
298  */
299 void WorkoutStepMessage::setCustomTargetValueLow(const quint32 customTargetValueLow)
300 {
301  Q_D(WorkoutStepMessage);
302  d->customTargetValueLow = customTargetValueLow;
303 }
304 /*!
305  * Sets the \c customTargetValueHigh field to \a customTargetValueHigh.
306  *
307  * \param customTargetValueHigh The field value to set.
308  */
309 void WorkoutStepMessage::setCustomTargetValueHigh(const quint32 customTargetValueHigh)
310 {
311  Q_D(WorkoutStepMessage);
312  d->customTargetValueHigh = customTargetValueHigh;
313 }
314 /*!
315  * Sets the \c intensity field to \a intensity.
316  *
317  * \param intensity The field value to set.
318  */
320 {
321  Q_D(WorkoutStepMessage);
322  d->intensity = intensity;
323 }
324 /*!
325  * Sets the \c notes field to \a notes.
326  *
327  * \param notes The field value to set.
328  */
329 void WorkoutStepMessage::setNotes(const QString notes)
330 {
331  Q_D(WorkoutStepMessage);
332  d->notes = notes;
333 }
334 /*!
335  * Sets the \c equipment field to \a equipment.
336  *
337  * \param equipment The field value to set.
338  */
340 {
341  Q_D(WorkoutStepMessage);
342  d->equipment = equipment;
343 }
344 /*!
345  * Sets the \c exerciseCategory field to \a exerciseCategory.
346  *
347  * \param exerciseCategory The field value to set.
348  */
350 {
351  Q_D(WorkoutStepMessage);
352  d->exerciseCategory = exerciseCategory;
353 }
354 /*!
355  * Sets the \c exerciseName field to \a exerciseName.
356  *
357  * \param exerciseName The field value to set.
358  */
359 void WorkoutStepMessage::setExerciseName(const quint16 exerciseName)
360 {
361  Q_D(WorkoutStepMessage);
362  d->exerciseName = exerciseName;
363 }
364 /*!
365  * Sets the \c exerciseWeight field to \a exerciseWeight.
366  *
367  * \param exerciseWeight The field value to set.
368  */
369 void WorkoutStepMessage::setExerciseWeight(const quint16 exerciseWeight)
370 {
371  Q_D(WorkoutStepMessage);
372  d->exerciseWeight = exerciseWeight;
373 }
374 /*!
375  * Sets the \c weightDisplayUnit field to \a weightDisplayUnit.
376  *
377  * \param weightDisplayUnit The field value to set.
378  */
380 {
381  Q_D(WorkoutStepMessage);
382  d->weightDisplayUnit = weightDisplayUnit;
383 }
384 
385 /// \cond internal
386 
387 /*!
388  * \internal
389  *
390  * \class WorkoutStepMessagePrivate
391  *
392  * The WorkoutStepMessagePrivate class provides private implementation for the WorkoutStepMessage.
393  *
394  * \sa WorkoutStepMessage
395  */
396 
397 /*!
398  * \internal
399  *
400  * Constructs a WorkoutStepMessagePrivate object with public implementation \a q.
401  *
402  * \param q Pointer to public implementaton.
403  */
404 WorkoutStepMessagePrivate::WorkoutStepMessagePrivate(WorkoutStepMessage * const q)
406  , messageIndex(static_cast<MessageIndex>(-1))
407  , durationType(static_cast<WktStepDuration>(-1))
408  , durationValue(0xFFFFFFFF)
409  , targetType(static_cast<WktStepTarget>(-1))
410  , targetValue(0xFFFFFFFF)
411  , customTargetValueLow(0xFFFFFFFF)
412  , customTargetValueHigh(0xFFFFFFFF)
413  , intensity(static_cast<Intensity>(-1))
414  , equipment(static_cast<WorkoutEquipment>(-1))
415  , exerciseCategory(static_cast<ExerciseCategory>(-1))
416  , exerciseName(0xFFFF)
417  , exerciseWeight(0xFFFF)
418  , weightDisplayUnit(static_cast<FitBaseUnit>(-1))
419 {
420  globalMessageNumber = MesgNum::WorkoutStep;
421 }
422 
423 /*!
424  * \internal
425  *
426  * Destroys the WorkoutStepMessagePrivate object.
427  */
429 {
430 
431 }
432 
434  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
435 {
436  switch (fieldId) {
437  case 254: // See Profile.xlsx::Messages:workout_step.messageIndex
438  if (!verify(data, baseType, 2, FitBaseType::Uint16, "workout_step.messageIndex")) return false;
439  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
440  break;
441  case 0: // See Profile.xlsx::Messages:workout_step.wktStepName
442  if (!verify(data, baseType, 1, FitBaseType::String, "workout_step.wktStepName")) return false;
443  this->wktStepName = QString::fromUtf8(data);
444  break;
445  case 1: // See Profile.xlsx::Messages:workout_step.durationType
446  if (!verify(data, baseType, 1, FitBaseType::Enum, "workout_step.durationType")) return false;
447  this->durationType = static_cast<WktStepDuration>(data.at(0));
448  break;
449  case 2: // See Profile.xlsx::Messages:workout_step.durationValue
450  if (!verify(data, baseType, 4, FitBaseType::Uint32, "workout_step.durationValue")) return false;
451  this->durationValue = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
452  break;
453  case 3: // See Profile.xlsx::Messages:workout_step.targetType
454  if (!verify(data, baseType, 1, FitBaseType::Enum, "workout_step.targetType")) return false;
455  this->targetType = static_cast<WktStepTarget>(data.at(0));
456  break;
457  case 4: // See Profile.xlsx::Messages:workout_step.targetValue
458  if (!verify(data, baseType, 4, FitBaseType::Uint32, "workout_step.targetValue")) return false;
459  this->targetValue = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
460  break;
461  case 5: // See Profile.xlsx::Messages:workout_step.customTargetValueLow
462  if (!verify(data, baseType, 4, FitBaseType::Uint32, "workout_step.customTargetValueLow")) return false;
463  this->customTargetValueLow = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
464  break;
465  case 6: // See Profile.xlsx::Messages:workout_step.customTargetValueHigh
466  if (!verify(data, baseType, 4, FitBaseType::Uint32, "workout_step.customTargetValueHigh")) return false;
467  this->customTargetValueHigh = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
468  break;
469  case 7: // See Profile.xlsx::Messages:workout_step.intensity
470  if (!verify(data, baseType, 1, FitBaseType::Enum, "workout_step.intensity")) return false;
471  this->intensity = static_cast<Intensity>(data.at(0));
472  break;
473  case 8: // See Profile.xlsx::Messages:workout_step.notes
474  if (!verify(data, baseType, 1, FitBaseType::String, "workout_step.notes")) return false;
475  this->notes = QString::fromUtf8(data);
476  break;
477  case 9: // See Profile.xlsx::Messages:workout_step.equipment
478  if (!verify(data, baseType, 1, FitBaseType::Enum, "workout_step.equipment")) return false;
479  this->equipment = static_cast<WorkoutEquipment>(data.at(0));
480  break;
481  case 10: // See Profile.xlsx::Messages:workout_step.exerciseCategory
482  if (!verify(data, baseType, 2, FitBaseType::Uint16, "workout_step.exerciseCategory")) return false;
483  this->exerciseCategory = static_cast<ExerciseCategory>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
484  break;
485  case 11: // See Profile.xlsx::Messages:workout_step.exerciseName
486  if (!verify(data, baseType, 2, FitBaseType::Uint16, "workout_step.exerciseName")) return false;
487  this->exerciseName = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
488  break;
489  case 12: // See Profile.xlsx::Messages:workout_step.exerciseWeight
490  if (!verify(data, baseType, 2, FitBaseType::Uint16, "workout_step.exerciseWeight")) return false;
491  this->exerciseWeight = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
492  break;
493  case 13: // See Profile.xlsx::Messages:workout_step.weightDisplayUnit
494  if (!verify(data, baseType, 2, FitBaseType::Uint16, "workout_step.weightDisplayUnit")) return false;
495  this->weightDisplayUnit = static_cast<FitBaseUnit>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
496  break;
497  default:
498  qWarning() << "ignoring unknown workout_step message field number" << fieldId << bigEndian;
499  // Fall through to return true, as its still 'safe' to continue parsing data messages.
500  }
501  return true;
502 }
503 
504 /// \endcond
505 
#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 exerciseName
The WorkoutStepMessage FIT message's exerciseName field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
quint32 customTargetValueLow
The WorkoutStepMessage FIT message's customTargetValueLow field.
ExerciseCategory exerciseCategory
The WorkoutStepMessage FIT message's exerciseCategory field.
MessageIndex messageIndex
The WorkoutStepMessage FIT message's messageIndex field.
quint16 exerciseWeight
The WorkoutStepMessage FIT message's exerciseWeight field.
quint32 targetValue
The WorkoutStepMessage FIT message's targetValue field.
Intensity intensity
The WorkoutStepMessage FIT message's intensity field.
QString wktStepName
The WorkoutStepMessage FIT message's wktStepName field.
WorkoutEquipment equipment
The WorkoutStepMessage FIT message's equipment field.
FitBaseUnit weightDisplayUnit
The WorkoutStepMessage FIT message's weightDisplayUnit field.
quint32 durationValue
The WorkoutStepMessage FIT message's durationValue field.
WktStepTarget targetType
The WorkoutStepMessage FIT message's targetType field.
QString notes
The WorkoutStepMessage FIT message's notes field.
quint32 customTargetValueHigh
The WorkoutStepMessage FIT message's customTargetValueHigh field.
WktStepDuration durationType
The WorkoutStepMessage FIT message's durationType field.
The WorkoutStepMessage class represents a FIT WorkoutStepMessage data message.
void setWktStepName(const QString wktStepName)
Sets the wktStepName field to wktStepName.
void setExerciseWeight(const quint16 exerciseWeight)
Sets the exerciseWeight field to exerciseWeight.
Intensity intensity() const
Returns the WorkoutStepMessage data message's intensity field's current value.
QString wktStepName() const
Returns the WorkoutStepMessage data message's wktStepName field's current value.
WktStepTarget targetType() const
Returns the WorkoutStepMessage data message's targetType field's current value.
void setTargetValue(const quint32 targetValue)
Sets the targetValue field to targetValue.
void setCustomTargetValueLow(const quint32 customTargetValueLow)
Sets the customTargetValueLow field to customTargetValueLow.
void setDurationType(const WktStepDuration durationType)
Sets the durationType field to durationType.
quint32 customTargetValueHigh() const
Returns the WorkoutStepMessage data message's customTargetValueHigh field's current value.
ExerciseCategory exerciseCategory() const
Returns the WorkoutStepMessage data message's exerciseCategory field's current value.
void setIntensity(const Intensity intensity)
Sets the intensity field to intensity.
WorkoutEquipment equipment() const
Returns the WorkoutStepMessage data message's equipment field's current value.
void setTargetType(const WktStepTarget targetType)
Sets the targetType field to targetType.
void setDurationValue(const quint32 durationValue)
Sets the durationValue field to durationValue.
quint32 customTargetValueLow() const
Returns the WorkoutStepMessage data message's customTargetValueLow field's current value.
FitBaseUnit weightDisplayUnit() const
Returns the WorkoutStepMessage data message's weightDisplayUnit field's current value.
quint32 durationValue() const
Returns the WorkoutStepMessage data message's durationValue field's current value.
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
WktStepDuration durationType() const
Returns the WorkoutStepMessage data message's durationType field's current value.
quint32 targetValue() const
Returns the WorkoutStepMessage data message's targetValue field's current value.
void setNotes(const QString notes)
Sets the notes field to notes.
void setWeightDisplayUnit(const FitBaseUnit weightDisplayUnit)
Sets the weightDisplayUnit field to weightDisplayUnit.
void setEquipment(const WorkoutEquipment equipment)
Sets the equipment field to equipment.
QString notes() const
Returns the WorkoutStepMessage data message's notes field's current value.
void setExerciseName(const quint16 exerciseName)
Sets the exerciseName field to exerciseName.
quint16 exerciseWeight() const
Returns the WorkoutStepMessage data message's exerciseWeight field's current value.
MessageIndex messageIndex() const
Returns the WorkoutStepMessage data message's messageIndex field's current value.
quint16 exerciseName() const
Returns the WorkoutStepMessage data message's exerciseName field's current value.
WorkoutStepMessage()
Constructs a WorkoutStepMessage object.
void setCustomTargetValueHigh(const quint32 customTargetValueHigh)
Sets the customTargetValueHigh field to customTargetValueHigh.
void setExerciseCategory(const ExerciseCategory exerciseCategory)
Sets the exerciseCategory field to exerciseCategory.
Intensity
Garmin FIT Intensity type.
Definition: types.h:994
WorkoutEquipment
Garmin FIT WorkoutEquipment type.
Definition: types.h:2835
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
WktStepTarget
Garmin FIT WktStepTarget type.
Definition: types.h:1354
WktStepDuration
Garmin FIT WktStepDuration type.
Definition: types.h:1311
Declares the WorkoutStepMessage class.
Declares the WorkoutStepMessagePrivate class.