QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hrmprofilemessage.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 HrmProfileMessage, and HrmProfileMessagePrivate classes.
28  */
29 
30 #include "hrmprofilemessage.h"
31 #include "hrmprofilemessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class HrmProfileMessage
40  *
41  * The HrmProfileMessage class represents a FIT HrmProfileMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a HrmProfileMessage 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 HrmProfileMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the HrmProfileMessage data message's \c messageIndex field's current value.
71  *
72  * \return the \c messageIndex field value.
73  */
75 {
76  Q_D(const HrmProfileMessage);
77  return d->messageIndex;
78 }
79 
80 /*!
81  * Returns the HrmProfileMessage data message's \c enabled field's current value.
82  *
83  * \return the \c enabled field value.
84  */
86 {
87  Q_D(const HrmProfileMessage);
88  return d->enabled;
89 }
90 
91 /*!
92  * Returns the HrmProfileMessage data message's \c hrmAntId field's current value.
93  *
94  * \return the \c hrmAntId field value.
95  */
97 {
98  Q_D(const HrmProfileMessage);
99  return d->hrmAntId;
100 }
101 
102 /*!
103  * Returns the HrmProfileMessage data message's \c logHrv field's current value.
104  *
105  * \return the \c logHrv field value.
106  */
108 {
109  Q_D(const HrmProfileMessage);
110  return d->logHrv;
111 }
112 
113 /*!
114  * Returns the HrmProfileMessage data message's \c hrmAntIdTransType field's current value.
115  *
116  * \return the \c hrmAntIdTransType field value.
117  */
119 {
120  Q_D(const HrmProfileMessage);
121  return d->hrmAntIdTransType;
122 }
123 
124 /*!
125  * Sets the \c messageIndex field to \a messageIndex.
126  *
127  * \param messageIndex The field value to set.
128  */
130 {
131  Q_D(HrmProfileMessage);
132  d->messageIndex = messageIndex;
133 }
134 /*!
135  * Sets the \c enabled field to \a enabled.
136  *
137  * \param enabled The field value to set.
138  */
139 void HrmProfileMessage::setEnabled(const bool enabled)
140 {
141  Q_D(HrmProfileMessage);
142  d->enabled = enabled;
143 }
144 /*!
145  * Sets the \c hrmAntId field to \a hrmAntId.
146  *
147  * \param hrmAntId The field value to set.
148  */
150 {
151  Q_D(HrmProfileMessage);
152  d->hrmAntId = hrmAntId;
153 }
154 /*!
155  * Sets the \c logHrv field to \a logHrv.
156  *
157  * \param logHrv The field value to set.
158  */
159 void HrmProfileMessage::setLogHrv(const bool logHrv)
160 {
161  Q_D(HrmProfileMessage);
162  d->logHrv = logHrv;
163 }
164 /*!
165  * Sets the \c hrmAntIdTransType field to \a hrmAntIdTransType.
166  *
167  * \param hrmAntIdTransType The field value to set.
168  */
170 {
171  Q_D(HrmProfileMessage);
172  d->hrmAntIdTransType = hrmAntIdTransType;
173 }
174 
175 /// \cond internal
176 
177 /*!
178  * \internal
179  *
180  * \class HrmProfileMessagePrivate
181  *
182  * The HrmProfileMessagePrivate class provides private implementation for the HrmProfileMessage.
183  *
184  * \sa HrmProfileMessage
185  */
186 
187 /*!
188  * \internal
189  *
190  * Constructs a HrmProfileMessagePrivate object with public implementation \a q.
191  *
192  * \param q Pointer to public implementaton.
193  */
194 HrmProfileMessagePrivate::HrmProfileMessagePrivate(HrmProfileMessage * const q)
196  , messageIndex(static_cast<MessageIndex>(-1))
197  , enabled(static_cast<bool>(-1))
198  , hrmAntId(0)
199  , logHrv(static_cast<bool>(-1))
200  , hrmAntIdTransType(static_cast<quint8z>(-1))
201 {
202  globalMessageNumber = MesgNum::HrmProfile;
203 }
204 
205 /*!
206  * \internal
207  *
208  * Destroys the HrmProfileMessagePrivate 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 254: // See Profile.xlsx::Messages:hrm_profile.messageIndex
220  if (!verify(data, baseType, 2, FitBaseType::Uint16, "hrm_profile.messageIndex")) return false;
221  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
222  break;
223  case 0: // See Profile.xlsx::Messages:hrm_profile.enabled
224  if (!verify(data, baseType, 0, FitBaseType::Byte, "hrm_profile.enabled")) return false;
225  this->enabled = static_cast<bool>(data.at(0));
226  break;
227  case 1: // See Profile.xlsx::Messages:hrm_profile.hrmAntId
228  if (!verify(data, baseType, 2, FitBaseType::Uint16z, "hrm_profile.hrmAntId")) return false;
229  this->hrmAntId = static_cast<quint16z>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
230  break;
231  case 2: // See Profile.xlsx::Messages:hrm_profile.logHrv
232  if (!verify(data, baseType, 0, FitBaseType::Byte, "hrm_profile.logHrv")) return false;
233  this->logHrv = static_cast<bool>(data.at(0));
234  break;
235  case 3: // See Profile.xlsx::Messages:hrm_profile.hrmAntIdTransType
236  if (!verify(data, baseType, 1, FitBaseType::Uint8z, "hrm_profile.hrmAntIdTransType")) return false;
237  this->hrmAntIdTransType = static_cast<quint8z>(data.at(0));
238  break;
239  default:
240  qWarning() << "ignoring unknown hrm_profile 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.
bool logHrv
The HrmProfileMessage FIT message's logHrv field.
quint8z hrmAntIdTransType
The HrmProfileMessage FIT message's hrmAntIdTransType field.
MessageIndex messageIndex
The HrmProfileMessage FIT message's messageIndex field.
quint16z hrmAntId
The HrmProfileMessage FIT message's hrmAntId field.
bool enabled
The HrmProfileMessage FIT message's enabled field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
The HrmProfileMessage class represents a FIT HrmProfileMessage data message.
void setEnabled(const bool enabled)
Sets the enabled field to enabled.
void setHrmAntId(const quint16z hrmAntId)
Sets the hrmAntId field to hrmAntId.
quint8z hrmAntIdTransType() const
Returns the HrmProfileMessage data message's hrmAntIdTransType field's current value.
HrmProfileMessage()
Constructs a HrmProfileMessage object.
void setHrmAntIdTransType(const quint8z hrmAntIdTransType)
Sets the hrmAntIdTransType field to hrmAntIdTransType.
MessageIndex messageIndex() const
Returns the HrmProfileMessage data message's messageIndex field's current value.
void setLogHrv(const bool logHrv)
Sets the logHrv field to logHrv.
bool enabled() const
Returns the HrmProfileMessage data message's enabled field's current value.
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
quint16z hrmAntId() const
Returns the HrmProfileMessage data message's hrmAntId field's current value.
bool logHrv() const
Returns the HrmProfileMessage data message's logHrv field's current value.
Declares the HrmProfileMessage class.
Declares the HrmProfileMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
quint16 quint16z
16-bit unsigned integer, with 0-is-invalid semantics.
Definition: types.h:46
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263
QTFIT_BEGIN_NAMESPACE typedef quint8 quint8z
8-bit unsigned integer, with 0-is-invalid semantics.
Definition: types.h:45