QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
jumpmessage.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 JumpMessage, and JumpMessagePrivate classes.
28  */
29 
30 #include "jumpmessage.h"
31 #include "jumpmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class JumpMessage
40  *
41  * The JumpMessage class represents a FIT JumpMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a JumpMessage 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 JumpMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the JumpMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const JumpMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the JumpMessage data message's \c distance field's current value.
82  *
83  * \return the \c distance field value.
84  */
85 float JumpMessage::distance() const
86 {
87  Q_D(const JumpMessage);
88  return d->distance;
89 }
90 
91 /*!
92  * Returns the JumpMessage data message's \c height field's current value.
93  *
94  * \return the \c height field value.
95  */
96 float JumpMessage::height() const
97 {
98  Q_D(const JumpMessage);
99  return d->height;
100 }
101 
102 /*!
103  * Returns the JumpMessage data message's \c rotations field's current value.
104  *
105  * \return the \c rotations field value.
106  */
108 {
109  Q_D(const JumpMessage);
110  return d->rotations;
111 }
112 
113 /*!
114  * Returns the JumpMessage data message's \c hangTime field's current value.
115  *
116  * \return the \c hangTime field value.
117  */
119 {
120  Q_D(const JumpMessage);
121  return d->hangTime;
122 }
123 
124 /*!
125  * Returns the JumpMessage data message's \c score field's current value.
126  *
127  * A score for a jump calculated based on hang time, rotations, and distance.
128  *
129  * \return the \c score field value.
130  */
131 float JumpMessage::score() const
132 {
133  Q_D(const JumpMessage);
134  return d->score;
135 }
136 
137 /*!
138  * Returns the JumpMessage data message's \c positionLat field's current value.
139  *
140  * \return the \c positionLat field value.
141  */
143 {
144  Q_D(const JumpMessage);
145  return d->positionLat;
146 }
147 
148 /*!
149  * Returns the JumpMessage data message's \c positionLong field's current value.
150  *
151  * \return the \c positionLong field value.
152  */
154 {
155  Q_D(const JumpMessage);
156  return d->positionLong;
157 }
158 
159 /*!
160  * Returns the JumpMessage data message's \c speed field's current value.
161  *
162  * \return the \c speed field value.
163  */
164 quint16 JumpMessage::speed() const
165 {
166  Q_D(const JumpMessage);
167  return d->speed;
168 }
169 
170 /*!
171  * Returns the JumpMessage data message's \c enhancedSpeed field's current value.
172  *
173  * \return the \c enhancedSpeed field value.
174  */
176 {
177  Q_D(const JumpMessage);
178  return d->enhancedSpeed;
179 }
180 
181 /*!
182  * Sets the \c timestamp field to \a timestamp.
183  *
184  * \param timestamp The field value to set.
185  */
186 void JumpMessage::setTimestamp(const DateTime timestamp)
187 {
188  Q_D(JumpMessage);
189  d->timestamp = timestamp;
190 }
191 /*!
192  * Sets the \c distance field to \a distance.
193  *
194  * \param distance The field value to set.
195  */
196 void JumpMessage::setDistance(const float distance)
197 {
198  Q_D(JumpMessage);
199  d->distance = distance;
200 }
201 /*!
202  * Sets the \c height field to \a height.
203  *
204  * \param height The field value to set.
205  */
206 void JumpMessage::setHeight(const float height)
207 {
208  Q_D(JumpMessage);
209  d->height = height;
210 }
211 /*!
212  * Sets the \c rotations field to \a rotations.
213  *
214  * \param rotations The field value to set.
215  */
216 void JumpMessage::setRotations(const quint8 rotations)
217 {
218  Q_D(JumpMessage);
219  d->rotations = rotations;
220 }
221 /*!
222  * Sets the \c hangTime field to \a hangTime.
223  *
224  * \param hangTime The field value to set.
225  */
226 void JumpMessage::setHangTime(const float hangTime)
227 {
228  Q_D(JumpMessage);
229  d->hangTime = hangTime;
230 }
231 /*!
232  * Sets the \c score field to \a score.
233  *
234  * \param score The field value to set.
235  */
236 void JumpMessage::setScore(const float score)
237 {
238  Q_D(JumpMessage);
239  d->score = score;
240 }
241 /*!
242  * Sets the \c positionLat field to \a positionLat.
243  *
244  * \param positionLat The field value to set.
245  */
246 void JumpMessage::setPositionLat(const qint32 positionLat)
247 {
248  Q_D(JumpMessage);
249  d->positionLat = positionLat;
250 }
251 /*!
252  * Sets the \c positionLong field to \a positionLong.
253  *
254  * \param positionLong The field value to set.
255  */
256 void JumpMessage::setPositionLong(const qint32 positionLong)
257 {
258  Q_D(JumpMessage);
259  d->positionLong = positionLong;
260 }
261 /*!
262  * Sets the \c speed field to \a speed.
263  *
264  * \param speed The field value to set.
265  */
266 void JumpMessage::setSpeed(const quint16 speed)
267 {
268  Q_D(JumpMessage);
269  d->speed = speed;
270 }
271 /*!
272  * Sets the \c enhancedSpeed field to \a enhancedSpeed.
273  *
274  * \param enhancedSpeed The field value to set.
275  */
276 void JumpMessage::setEnhancedSpeed(const quint32 enhancedSpeed)
277 {
278  Q_D(JumpMessage);
279  d->enhancedSpeed = enhancedSpeed;
280 }
281 
282 /// \cond internal
283 
284 /*!
285  * \internal
286  *
287  * \class JumpMessagePrivate
288  *
289  * The JumpMessagePrivate class provides private implementation for the JumpMessage.
290  *
291  * \sa JumpMessage
292  */
293 
294 /*!
295  * \internal
296  *
297  * Constructs a JumpMessagePrivate object with public implementation \a q.
298  *
299  * \param q Pointer to public implementaton.
300  */
301 JumpMessagePrivate::JumpMessagePrivate(JumpMessage * const q)
303  , timestamp(static_cast<DateTime>(-1))
304  , distance(static_cast<float>(-1))
305  , height(static_cast<float>(-1))
306  , rotations(0xFF)
307  , hangTime(static_cast<float>(-1))
308  , score(static_cast<float>(-1))
309  , positionLat(0x7FFFFFFF)
310  , positionLong(0x7FFFFFFF)
311  , speed(0xFFFF)
312  , enhancedSpeed(0xFFFFFFFF)
313 {
314  globalMessageNumber = MesgNum::Jump;
315 }
316 
317 /*!
318  * \internal
319  *
320  * Destroys the JumpMessagePrivate object.
321  */
323 {
324 
325 }
326 
328  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
329 {
330  switch (fieldId) {
331  case 253: // See Profile.xlsx::Messages:jump.timestamp
332  if (!verify(data, baseType, 4, FitBaseType::Uint32, "jump.timestamp")) return false;
333  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
334  break;
335  case 0: // See Profile.xlsx::Messages:jump.distance
336  if (!verify(data, baseType, 4, FitBaseType::Float32, "jump.distance")) return false;
337  #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
338  { // Qt's from-endian functions have no float/double specialisations prior to Qt 5.12.
339  const quint32 localEndian = bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data);
340  static_assert(sizeof(localEndian) == 4, "src not expected size");
341  static_assert(sizeof(this->distance) == 4, "src and dst not the same size");
342  memcpy(&this->distance, &localEndian, data.size());
343  }
344  #else
345  this->distance = static_cast<float>(bigEndian ? qFromBigEndian<float>(data) : qFromLittleEndian<float>(data));
346  #endif
347  break;
348  case 1: // See Profile.xlsx::Messages:jump.height
349  if (!verify(data, baseType, 4, FitBaseType::Float32, "jump.height")) return false;
350  #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
351  { // Qt's from-endian functions have no float/double specialisations prior to Qt 5.12.
352  const quint32 localEndian = bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data);
353  static_assert(sizeof(localEndian) == 4, "src not expected size");
354  static_assert(sizeof(this->height) == 4, "src and dst not the same size");
355  memcpy(&this->height, &localEndian, data.size());
356  }
357  #else
358  this->height = static_cast<float>(bigEndian ? qFromBigEndian<float>(data) : qFromLittleEndian<float>(data));
359  #endif
360  break;
361  case 2: // See Profile.xlsx::Messages:jump.rotations
362  if (!verify(data, baseType, 1, FitBaseType::Uint8, "jump.rotations")) return false;
363  this->rotations = static_cast<quint8>(data.at(0));
364  break;
365  case 3: // See Profile.xlsx::Messages:jump.hangTime
366  if (!verify(data, baseType, 4, FitBaseType::Float32, "jump.hangTime")) return false;
367  #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
368  { // Qt's from-endian functions have no float/double specialisations prior to Qt 5.12.
369  const quint32 localEndian = bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data);
370  static_assert(sizeof(localEndian) == 4, "src not expected size");
371  static_assert(sizeof(this->hangTime) == 4, "src and dst not the same size");
372  memcpy(&this->hangTime, &localEndian, data.size());
373  }
374  #else
375  this->hangTime = static_cast<float>(bigEndian ? qFromBigEndian<float>(data) : qFromLittleEndian<float>(data));
376  #endif
377  break;
378  case 4: // See Profile.xlsx::Messages:jump.score
379  if (!verify(data, baseType, 4, FitBaseType::Float32, "jump.score")) return false;
380  #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
381  { // Qt's from-endian functions have no float/double specialisations prior to Qt 5.12.
382  const quint32 localEndian = bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data);
383  static_assert(sizeof(localEndian) == 4, "src not expected size");
384  static_assert(sizeof(this->score) == 4, "src and dst not the same size");
385  memcpy(&this->score, &localEndian, data.size());
386  }
387  #else
388  this->score = static_cast<float>(bigEndian ? qFromBigEndian<float>(data) : qFromLittleEndian<float>(data));
389  #endif
390  break;
391  case 5: // See Profile.xlsx::Messages:jump.positionLat
392  if (!verify(data, baseType, 4, FitBaseType::Sint32, "jump.positionLat")) return false;
393  this->positionLat = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
394  break;
395  case 6: // See Profile.xlsx::Messages:jump.positionLong
396  if (!verify(data, baseType, 4, FitBaseType::Sint32, "jump.positionLong")) return false;
397  this->positionLong = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
398  break;
399  case 7: // See Profile.xlsx::Messages:jump.speed
400  if (!verify(data, baseType, 2, FitBaseType::Uint16, "jump.speed")) return false;
401  this->speed = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
402  break;
403  case 8: // See Profile.xlsx::Messages:jump.enhancedSpeed
404  if (!verify(data, baseType, 4, FitBaseType::Uint32, "jump.enhancedSpeed")) return false;
405  this->enhancedSpeed = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
406  break;
407  default:
408  qWarning() << "ignoring unknown jump message field number" << fieldId << bigEndian;
409  // Fall through to return true, as its still 'safe' to continue parsing data messages.
410  }
411  return true;
412 }
413 
414 /// \endcond
415 
#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.
float score
The JumpMessage FIT message's score field.
Definition: jumpmessage_p.h:71
quint32 enhancedSpeed
The JumpMessage FIT message's enhancedSpeed field.
Definition: jumpmessage_p.h:91
float height
The JumpMessage FIT message's height field.
Definition: jumpmessage_p.h:54
quint8 rotations
The JumpMessage FIT message's rotations field.
Definition: jumpmessage_p.h:59
float distance
The JumpMessage FIT message's distance field.
Definition: jumpmessage_p.h:49
qint32 positionLong
The JumpMessage FIT message's positionLong field.
Definition: jumpmessage_p.h:81
float hangTime
The JumpMessage FIT message's hangTime field.
Definition: jumpmessage_p.h:64
quint16 speed
The JumpMessage FIT message's speed field.
Definition: jumpmessage_p.h:86
qint32 positionLat
The JumpMessage FIT message's positionLat field.
Definition: jumpmessage_p.h:76
virtual ~JumpMessagePrivate()
DateTime timestamp
The JumpMessage FIT message's timestamp field.
Definition: jumpmessage_p.h:44
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
The JumpMessage class represents a FIT JumpMessage data message.
Definition: jumpmessage.h:39
void setDistance(const float distance)
Sets the distance field to distance.
void setHangTime(const float hangTime)
Sets the hangTime field to hangTime.
float score() const
Returns the JumpMessage data message's score field's current value.
quint32 enhancedSpeed() const
Returns the JumpMessage data message's enhancedSpeed field's current value.
DateTime timestamp() const
Returns the JumpMessage data message's timestamp field's current value.
Definition: jumpmessage.cpp:74
void setRotations(const quint8 rotations)
Sets the rotations field to rotations.
quint8 rotations() const
Returns the JumpMessage data message's rotations field's current value.
float height() const
Returns the JumpMessage data message's height field's current value.
Definition: jumpmessage.cpp:96
float distance() const
Returns the JumpMessage data message's distance field's current value.
Definition: jumpmessage.cpp:85
void setSpeed(const quint16 speed)
Sets the speed field to speed.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
qint32 positionLong() const
Returns the JumpMessage data message's positionLong field's current value.
JumpMessage()
Constructs a JumpMessage object.
Definition: jumpmessage.cpp:52
qint32 positionLat() const
Returns the JumpMessage data message's positionLat field's current value.
void setEnhancedSpeed(const quint32 enhancedSpeed)
Sets the enhancedSpeed field to enhancedSpeed.
quint16 speed() const
Returns the JumpMessage data message's speed field's current value.
void setPositionLat(const qint32 positionLat)
Sets the positionLat field to positionLat.
void setPositionLong(const qint32 positionLong)
Sets the positionLong field to positionLong.
float hangTime() const
Returns the JumpMessage data message's hangTime field's current value.
void setHeight(const float height)
Sets the height field to height.
void setScore(const float score)
Sets the score field to score.
Declares the JumpMessage class.
Declares the JumpMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237