QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hrmessage.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 HrMessage, and HrMessagePrivate classes.
28  */
29 
30 #include "hrmessage.h"
31 #include "hrmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class HrMessage
40  *
41  * The HrMessage class represents a FIT HrMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a HrMessage 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 HrMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the HrMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const HrMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the HrMessage data message's \c fractionalTimestamp field's current value.
82  *
83  * \return the \c fractionalTimestamp field value.
84  */
86 {
87  Q_D(const HrMessage);
88  return d->fractionalTimestamp;
89 }
90 
91 /*!
92  * Returns the HrMessage data message's \c time256 field's current value.
93  *
94  * \return the \c time256 field value.
95  */
96 quint8 HrMessage::time256() const
97 {
98  Q_D(const HrMessage);
99  return d->time256;
100 }
101 
102 /*!
103  * Returns the HrMessage data message's \c filteredBpm field's current value.
104  *
105  * \return the \c filteredBpm field value.
106  */
108 {
109  Q_D(const HrMessage);
110  return d->filteredBpm;
111 }
112 
113 /*!
114  * Returns the HrMessage data message's \c eventTimestamp field's current value.
115  *
116  * \return the \c eventTimestamp field value.
117  */
119 {
120  Q_D(const HrMessage);
121  return d->eventTimestamp;
122 }
123 
124 /*!
125  * Returns the HrMessage data message's \c eventTimestamp12 field's current value.
126  *
127  * \return the \c eventTimestamp12 field value.
128  */
130 {
131  Q_D(const HrMessage);
132  return d->eventTimestamp12;
133 }
134 
135 /*!
136  * Sets the \c timestamp field to \a timestamp.
137  *
138  * \param timestamp The field value to set.
139  */
140 void HrMessage::setTimestamp(const DateTime timestamp)
141 {
142  Q_D(HrMessage);
143  d->timestamp = timestamp;
144 }
145 /*!
146  * Sets the \c fractionalTimestamp field to \a fractionalTimestamp.
147  *
148  * \param fractionalTimestamp The field value to set.
149  */
150 void HrMessage::setFractionalTimestamp(const quint16 fractionalTimestamp)
151 {
152  Q_D(HrMessage);
153  d->fractionalTimestamp = fractionalTimestamp;
154 }
155 /*!
156  * Sets the \c time256 field to \a time256.
157  *
158  * \param time256 The field value to set.
159  */
160 void HrMessage::setTime256(const quint8 time256)
161 {
162  Q_D(HrMessage);
163  d->time256 = time256;
164 }
165 /*!
166  * Sets the \c filteredBpm field to \a filteredBpm.
167  *
168  * \param filteredBpm The field value to set.
169  */
170 void HrMessage::setFilteredBpm(const quint8 filteredBpm)
171 {
172  Q_D(HrMessage);
173  d->filteredBpm = filteredBpm;
174 }
175 /*!
176  * Sets the \c eventTimestamp field to \a eventTimestamp.
177  *
178  * \param eventTimestamp The field value to set.
179  */
180 void HrMessage::setEventTimestamp(const quint32 eventTimestamp)
181 {
182  Q_D(HrMessage);
183  d->eventTimestamp = eventTimestamp;
184 }
185 /*!
186  * Sets the \c eventTimestamp12 field to \a eventTimestamp12.
187  *
188  * \param eventTimestamp12 The field value to set.
189  */
190 void HrMessage::setEventTimestamp12(const quint8 eventTimestamp12)
191 {
192  Q_D(HrMessage);
193  d->eventTimestamp12 = eventTimestamp12;
194 }
195 
196 /// \cond internal
197 
198 /*!
199  * \internal
200  *
201  * \class HrMessagePrivate
202  *
203  * The HrMessagePrivate class provides private implementation for the HrMessage.
204  *
205  * \sa HrMessage
206  */
207 
208 /*!
209  * \internal
210  *
211  * Constructs a HrMessagePrivate object with public implementation \a q.
212  *
213  * \param q Pointer to public implementaton.
214  */
215 HrMessagePrivate::HrMessagePrivate(HrMessage * const q)
217  , timestamp(static_cast<DateTime>(-1))
218  , fractionalTimestamp(0xFFFF)
219  , time256(0xFF)
220  , filteredBpm(0xFF)
221  , eventTimestamp(0xFFFFFFFF)
222  , eventTimestamp12(0xFF)
223 {
224  globalMessageNumber = MesgNum::Hr;
225 }
226 
227 /*!
228  * \internal
229  *
230  * Destroys the HrMessagePrivate object.
231  */
233 {
234 
235 }
236 
238  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
239 {
240  switch (fieldId) {
241  case 253: // See Profile.xlsx::Messages:hr.timestamp
242  if (!verify(data, baseType, 4, FitBaseType::Uint32, "hr.timestamp")) return false;
243  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
244  break;
245  case 0: // See Profile.xlsx::Messages:hr.fractionalTimestamp
246  if (!verify(data, baseType, 2, FitBaseType::Uint16, "hr.fractionalTimestamp")) return false;
247  this->fractionalTimestamp = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
248  break;
249  case 1: // See Profile.xlsx::Messages:hr.time256
250  if (!verify(data, baseType, 1, FitBaseType::Uint8, "hr.time256")) return false;
251  this->time256 = static_cast<quint8>(data.at(0));
252  break;
253  case 6: // See Profile.xlsx::Messages:hr.filteredBpm
254  if (!verify(data, baseType, 1, FitBaseType::Uint8, "hr.filteredBpm")) return false;
255  this->filteredBpm = static_cast<quint8>(data.at(0));
256  break;
257  case 9: // See Profile.xlsx::Messages:hr.eventTimestamp
258  if (!verify(data, baseType, 4, FitBaseType::Uint32, "hr.eventTimestamp")) return false;
259  this->eventTimestamp = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
260  break;
261  case 10: // See Profile.xlsx::Messages:hr.eventTimestamp12
262  if (!verify(data, baseType, 1, FitBaseType::Byte, "hr.eventTimestamp12")) return false;
263  this->eventTimestamp12 = static_cast<quint8>(data.at(0));
264  break;
265  default:
266  qWarning() << "ignoring unknown hr message field number" << fieldId << bigEndian;
267  // Fall through to return true, as its still 'safe' to continue parsing data messages.
268  }
269  return true;
270 }
271 
272 /// \endcond
273 
#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.
quint8 filteredBpm
The HrMessage FIT message's filteredBpm field.
Definition: hrmessage_p.h:59
virtual ~HrMessagePrivate()
Definition: hrmessage.cpp:232
quint8 time256
The HrMessage FIT message's time256 field.
Definition: hrmessage_p.h:54
quint8 eventTimestamp12
The HrMessage FIT message's eventTimestamp12 field.
Definition: hrmessage_p.h:69
DateTime timestamp
The HrMessage FIT message's timestamp field.
Definition: hrmessage_p.h:44
quint32 eventTimestamp
The HrMessage FIT message's eventTimestamp field.
Definition: hrmessage_p.h:64
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
Definition: hrmessage.cpp:237
quint16 fractionalTimestamp
The HrMessage FIT message's fractionalTimestamp field.
Definition: hrmessage_p.h:49
The HrMessage class represents a FIT HrMessage data message.
Definition: hrmessage.h:39
quint8 eventTimestamp12() const
Returns the HrMessage data message's eventTimestamp12 field's current value.
Definition: hrmessage.cpp:129
void setEventTimestamp12(const quint8 eventTimestamp12)
Sets the eventTimestamp12 field to eventTimestamp12.
Definition: hrmessage.cpp:190
void setEventTimestamp(const quint32 eventTimestamp)
Sets the eventTimestamp field to eventTimestamp.
Definition: hrmessage.cpp:180
quint8 filteredBpm() const
Returns the HrMessage data message's filteredBpm field's current value.
Definition: hrmessage.cpp:107
DateTime timestamp() const
Returns the HrMessage data message's timestamp field's current value.
Definition: hrmessage.cpp:74
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
Definition: hrmessage.cpp:140
quint32 eventTimestamp() const
Returns the HrMessage data message's eventTimestamp field's current value.
Definition: hrmessage.cpp:118
quint8 time256() const
Returns the HrMessage data message's time256 field's current value.
Definition: hrmessage.cpp:96
void setFilteredBpm(const quint8 filteredBpm)
Sets the filteredBpm field to filteredBpm.
Definition: hrmessage.cpp:170
void setTime256(const quint8 time256)
Sets the time256 field to time256.
Definition: hrmessage.cpp:160
HrMessage()
Constructs a HrMessage object.
Definition: hrmessage.cpp:52
void setFractionalTimestamp(const quint16 fractionalTimestamp)
Sets the fractionalTimestamp field to fractionalTimestamp.
Definition: hrmessage.cpp:150
quint16 fractionalTimestamp() const
Returns the HrMessage data message's fractionalTimestamp field's current value.
Definition: hrmessage.cpp:85
Declares the HrMessage class.
Declares the HrMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237