QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
climbpromessage.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 ClimbProMessage, and ClimbProMessagePrivate classes.
28  */
29 
30 #include "climbpromessage.h"
31 #include "climbpromessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class ClimbProMessage
40  *
41  * The ClimbProMessage class represents a FIT ClimbProMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a ClimbProMessage 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 ClimbProMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the ClimbProMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const ClimbProMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the ClimbProMessage data message's \c positionLat field's current value.
82  *
83  * \return the \c positionLat field value.
84  */
86 {
87  Q_D(const ClimbProMessage);
88  return d->positionLat;
89 }
90 
91 /*!
92  * Returns the ClimbProMessage data message's \c positionLong field's current value.
93  *
94  * \return the \c positionLong field value.
95  */
97 {
98  Q_D(const ClimbProMessage);
99  return d->positionLong;
100 }
101 
102 /*!
103  * Returns the ClimbProMessage data message's \c climbProEvent field's current value.
104  *
105  * \return the \c climbProEvent field value.
106  */
108 {
109  Q_D(const ClimbProMessage);
110  return d->climbProEvent;
111 }
112 
113 /*!
114  * Returns the ClimbProMessage data message's \c climbNumber field's current value.
115  *
116  * \return the \c climbNumber field value.
117  */
119 {
120  Q_D(const ClimbProMessage);
121  return d->climbNumber;
122 }
123 
124 /*!
125  * Returns the ClimbProMessage data message's \c climbCategory field's current value.
126  *
127  * \return the \c climbCategory field value.
128  */
130 {
131  Q_D(const ClimbProMessage);
132  return d->climbCategory;
133 }
134 
135 /*!
136  * Returns the ClimbProMessage data message's \c currentDist field's current value.
137  *
138  * \return the \c currentDist field value.
139  */
141 {
142  Q_D(const ClimbProMessage);
143  return d->currentDist;
144 }
145 
146 /*!
147  * Sets the \c timestamp field to \a timestamp.
148  *
149  * \param timestamp The field value to set.
150  */
152 {
153  Q_D(ClimbProMessage);
154  d->timestamp = timestamp;
155 }
156 /*!
157  * Sets the \c positionLat field to \a positionLat.
158  *
159  * \param positionLat The field value to set.
160  */
161 void ClimbProMessage::setPositionLat(const qint32 positionLat)
162 {
163  Q_D(ClimbProMessage);
164  d->positionLat = positionLat;
165 }
166 /*!
167  * Sets the \c positionLong field to \a positionLong.
168  *
169  * \param positionLong The field value to set.
170  */
171 void ClimbProMessage::setPositionLong(const qint32 positionLong)
172 {
173  Q_D(ClimbProMessage);
174  d->positionLong = positionLong;
175 }
176 /*!
177  * Sets the \c climbProEvent field to \a climbProEvent.
178  *
179  * \param climbProEvent The field value to set.
180  */
182 {
183  Q_D(ClimbProMessage);
184  d->climbProEvent = climbProEvent;
185 }
186 /*!
187  * Sets the \c climbNumber field to \a climbNumber.
188  *
189  * \param climbNumber The field value to set.
190  */
191 void ClimbProMessage::setClimbNumber(const quint16 climbNumber)
192 {
193  Q_D(ClimbProMessage);
194  d->climbNumber = climbNumber;
195 }
196 /*!
197  * Sets the \c climbCategory field to \a climbCategory.
198  *
199  * \param climbCategory The field value to set.
200  */
201 void ClimbProMessage::setClimbCategory(const quint8 climbCategory)
202 {
203  Q_D(ClimbProMessage);
204  d->climbCategory = climbCategory;
205 }
206 /*!
207  * Sets the \c currentDist field to \a currentDist.
208  *
209  * \param currentDist The field value to set.
210  */
211 void ClimbProMessage::setCurrentDist(const float currentDist)
212 {
213  Q_D(ClimbProMessage);
214  d->currentDist = currentDist;
215 }
216 
217 /// \cond internal
218 
219 /*!
220  * \internal
221  *
222  * \class ClimbProMessagePrivate
223  *
224  * The ClimbProMessagePrivate class provides private implementation for the ClimbProMessage.
225  *
226  * \sa ClimbProMessage
227  */
228 
229 /*!
230  * \internal
231  *
232  * Constructs a ClimbProMessagePrivate object with public implementation \a q.
233  *
234  * \param q Pointer to public implementaton.
235  */
236 ClimbProMessagePrivate::ClimbProMessagePrivate(ClimbProMessage * const q)
238  , timestamp(static_cast<DateTime>(-1))
239  , positionLat(0x7FFFFFFF)
240  , positionLong(0x7FFFFFFF)
241  , climbProEvent(static_cast<ClimbProEvent>(-1))
242  , climbNumber(0xFFFF)
243  , climbCategory(0xFF)
244  , currentDist(static_cast<float>(-1))
245 {
246  globalMessageNumber = MesgNum::ClimbPro;
247 }
248 
249 /*!
250  * \internal
251  *
252  * Destroys the ClimbProMessagePrivate object.
253  */
255 {
256 
257 }
258 
260  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
261 {
262  switch (fieldId) {
263  case 253: // See Profile.xlsx::Messages:climb_pro.timestamp
264  if (!verify(data, baseType, 4, FitBaseType::Uint32, "climb_pro.timestamp")) return false;
265  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
266  break;
267  case 0: // See Profile.xlsx::Messages:climb_pro.positionLat
268  if (!verify(data, baseType, 4, FitBaseType::Sint32, "climb_pro.positionLat")) return false;
269  this->positionLat = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
270  break;
271  case 1: // See Profile.xlsx::Messages:climb_pro.positionLong
272  if (!verify(data, baseType, 4, FitBaseType::Sint32, "climb_pro.positionLong")) return false;
273  this->positionLong = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
274  break;
275  case 2: // See Profile.xlsx::Messages:climb_pro.climbProEvent
276  if (!verify(data, baseType, 1, FitBaseType::Enum, "climb_pro.climbProEvent")) return false;
277  this->climbProEvent = static_cast<ClimbProEvent>(data.at(0));
278  break;
279  case 3: // See Profile.xlsx::Messages:climb_pro.climbNumber
280  if (!verify(data, baseType, 2, FitBaseType::Uint16, "climb_pro.climbNumber")) return false;
281  this->climbNumber = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
282  break;
283  case 4: // See Profile.xlsx::Messages:climb_pro.climbCategory
284  if (!verify(data, baseType, 1, FitBaseType::Uint8, "climb_pro.climbCategory")) return false;
285  this->climbCategory = static_cast<quint8>(data.at(0));
286  break;
287  case 5: // See Profile.xlsx::Messages:climb_pro.currentDist
288  if (!verify(data, baseType, 4, FitBaseType::Float32, "climb_pro.currentDist")) return false;
289  #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
290  { // Qt's from-endian functions have no float/double specialisations prior to Qt 5.12.
291  const quint32 localEndian = bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data);
292  static_assert(sizeof(localEndian) == 4, "src not expected size");
293  static_assert(sizeof(this->currentDist) == 4, "src and dst not the same size");
294  memcpy(&this->currentDist, &localEndian, data.size());
295  }
296  #else
297  this->currentDist = static_cast<float>(bigEndian ? qFromBigEndian<float>(data) : qFromLittleEndian<float>(data));
298  #endif
299  break;
300  default:
301  qWarning() << "ignoring unknown climb_pro message field number" << fieldId << bigEndian;
302  // Fall through to return true, as its still 'safe' to continue parsing data messages.
303  }
304  return true;
305 }
306 
307 /// \endcond
308 
#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.
quint16 climbNumber
The ClimbProMessage FIT message's climbNumber field.
qint32 positionLat
The ClimbProMessage FIT message's positionLat field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
quint8 climbCategory
The ClimbProMessage FIT message's climbCategory field.
qint32 positionLong
The ClimbProMessage FIT message's positionLong field.
float currentDist
The ClimbProMessage FIT message's currentDist field.
ClimbProEvent climbProEvent
The ClimbProMessage FIT message's climbProEvent field.
DateTime timestamp
The ClimbProMessage FIT message's timestamp field.
The ClimbProMessage class represents a FIT ClimbProMessage data message.
void setClimbProEvent(const ClimbProEvent climbProEvent)
Sets the climbProEvent field to climbProEvent.
void setClimbCategory(const quint8 climbCategory)
Sets the climbCategory field to climbCategory.
DateTime timestamp() const
Returns the ClimbProMessage data message's timestamp field's current value.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
float currentDist() const
Returns the ClimbProMessage data message's currentDist field's current value.
void setPositionLat(const qint32 positionLat)
Sets the positionLat field to positionLat.
qint32 positionLat() const
Returns the ClimbProMessage data message's positionLat field's current value.
qint32 positionLong() const
Returns the ClimbProMessage data message's positionLong field's current value.
ClimbProEvent climbProEvent() const
Returns the ClimbProMessage data message's climbProEvent field's current value.
void setPositionLong(const qint32 positionLong)
Sets the positionLong field to positionLong.
ClimbProMessage()
Constructs a ClimbProMessage object.
quint8 climbCategory() const
Returns the ClimbProMessage data message's climbCategory field's current value.
void setCurrentDist(const float currentDist)
Sets the currentDist field to currentDist.
quint16 climbNumber() const
Returns the ClimbProMessage data message's climbNumber field's current value.
void setClimbNumber(const quint16 climbNumber)
Sets the climbNumber field to climbNumber.
Declares the ClimbProMessage class.
Declares the ClimbProMessagePrivate class.
ClimbProEvent
Garmin FIT ClimbProEvent type.
Definition: types.h:5277
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237