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