QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
metzonemessage.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 MetZoneMessage, and MetZoneMessagePrivate classes.
28  */
29 
30 #include "metzonemessage.h"
31 #include "metzonemessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class MetZoneMessage
40  *
41  * The MetZoneMessage class represents a FIT MetZoneMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a MetZoneMessage 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 MetZoneMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the MetZoneMessage data message's \c messageIndex field's current value.
71  *
72  * \return the \c messageIndex field value.
73  */
75 {
76  Q_D(const MetZoneMessage);
77  return d->messageIndex;
78 }
79 
80 /*!
81  * Returns the MetZoneMessage data message's \c highBpm field's current value.
82  *
83  * \return the \c highBpm field value.
84  */
86 {
87  Q_D(const MetZoneMessage);
88  return d->highBpm;
89 }
90 
91 /*!
92  * Returns the MetZoneMessage data message's \c calories field's current value.
93  *
94  * \return the \c calories field value.
95  */
96 quint16 MetZoneMessage::calories() const
97 {
98  Q_D(const MetZoneMessage);
99  return d->calories;
100 }
101 
102 /*!
103  * Returns the MetZoneMessage data message's \c fatCalories field's current value.
104  *
105  * \return the \c fatCalories field value.
106  */
108 {
109  Q_D(const MetZoneMessage);
110  return d->fatCalories;
111 }
112 
113 /*!
114  * Sets the \c messageIndex field to \a messageIndex.
115  *
116  * \param messageIndex The field value to set.
117  */
119 {
120  Q_D(MetZoneMessage);
121  d->messageIndex = messageIndex;
122 }
123 /*!
124  * Sets the \c highBpm field to \a highBpm.
125  *
126  * \param highBpm The field value to set.
127  */
128 void MetZoneMessage::setHighBpm(const quint8 highBpm)
129 {
130  Q_D(MetZoneMessage);
131  d->highBpm = highBpm;
132 }
133 /*!
134  * Sets the \c calories field to \a calories.
135  *
136  * \param calories The field value to set.
137  */
138 void MetZoneMessage::setCalories(const quint16 calories)
139 {
140  Q_D(MetZoneMessage);
141  d->calories = calories;
142 }
143 /*!
144  * Sets the \c fatCalories field to \a fatCalories.
145  *
146  * \param fatCalories The field value to set.
147  */
148 void MetZoneMessage::setFatCalories(const quint8 fatCalories)
149 {
150  Q_D(MetZoneMessage);
151  d->fatCalories = fatCalories;
152 }
153 
154 /// \cond internal
155 
156 /*!
157  * \internal
158  *
159  * \class MetZoneMessagePrivate
160  *
161  * The MetZoneMessagePrivate class provides private implementation for the MetZoneMessage.
162  *
163  * \sa MetZoneMessage
164  */
165 
166 /*!
167  * \internal
168  *
169  * Constructs a MetZoneMessagePrivate object with public implementation \a q.
170  *
171  * \param q Pointer to public implementaton.
172  */
173 MetZoneMessagePrivate::MetZoneMessagePrivate(MetZoneMessage * const q)
175  , messageIndex(static_cast<MessageIndex>(-1))
176  , highBpm(0xFF)
177  , calories(0xFFFF)
178  , fatCalories(0xFF)
179 {
180  globalMessageNumber = MesgNum::MetZone;
181 }
182 
183 /*!
184  * \internal
185  *
186  * Destroys the MetZoneMessagePrivate object.
187  */
189 {
190 
191 }
192 
194  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
195 {
196  switch (fieldId) {
197  case 254: // See Profile.xlsx::Messages:met_zone.messageIndex
198  if (!verify(data, baseType, 2, FitBaseType::Uint16, "met_zone.messageIndex")) return false;
199  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
200  break;
201  case 1: // See Profile.xlsx::Messages:met_zone.highBpm
202  if (!verify(data, baseType, 1, FitBaseType::Uint8, "met_zone.highBpm")) return false;
203  this->highBpm = static_cast<quint8>(data.at(0));
204  break;
205  case 2: // See Profile.xlsx::Messages:met_zone.calories
206  if (!verify(data, baseType, 2, FitBaseType::Uint16, "met_zone.calories")) return false;
207  this->calories = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
208  break;
209  case 3: // See Profile.xlsx::Messages:met_zone.fatCalories
210  if (!verify(data, baseType, 1, FitBaseType::Uint8, "met_zone.fatCalories")) return false;
211  this->fatCalories = static_cast<quint8>(data.at(0));
212  break;
213  default:
214  qWarning() << "ignoring unknown met_zone message field number" << fieldId << bigEndian;
215  // Fall through to return true, as its still 'safe' to continue parsing data messages.
216  }
217  return true;
218 }
219 
220 /// \endcond
221 
#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.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
MessageIndex messageIndex
The MetZoneMessage FIT message's messageIndex field.
quint16 calories
The MetZoneMessage FIT message's calories field.
quint8 highBpm
The MetZoneMessage FIT message's highBpm field.
quint8 fatCalories
The MetZoneMessage FIT message's fatCalories field.
The MetZoneMessage class represents a FIT MetZoneMessage data message.
MessageIndex messageIndex() const
Returns the MetZoneMessage data message's messageIndex field's current value.
void setCalories(const quint16 calories)
Sets the calories field to calories.
quint8 fatCalories() const
Returns the MetZoneMessage data message's fatCalories field's current value.
void setHighBpm(const quint8 highBpm)
Sets the highBpm field to highBpm.
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
quint8 highBpm() const
Returns the MetZoneMessage data message's highBpm field's current value.
MetZoneMessage()
Constructs a MetZoneMessage object.
quint16 calories() const
Returns the MetZoneMessage data message's calories field's current value.
void setFatCalories(const quint8 fatCalories)
Sets the fatCalories field to fatCalories.
Declares the MetZoneMessage class.
Declares the MetZoneMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263