QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gpsmetadatamessage.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 GpsMetadataMessage, and GpsMetadataMessagePrivate classes.
28  */
29 
30 #include "gpsmetadatamessage.h"
31 #include "gpsmetadatamessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class GpsMetadataMessage
40  *
41  * The GpsMetadataMessage class represents a FIT GpsMetadataMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a GpsMetadataMessage 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 GpsMetadataMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the GpsMetadataMessage data message's \c timestamp field's current value.
71  *
72  * Whole second part of the timestamp.
73  *
74  * \return the \c timestamp field value.
75  */
77 {
78  Q_D(const GpsMetadataMessage);
79  return d->timestamp;
80 }
81 
82 /*!
83  * Returns the GpsMetadataMessage data message's \c timestampMs field's current value.
84  *
85  * Millisecond part of the timestamp.
86  *
87  * \return the \c timestampMs field value.
88  */
90 {
91  Q_D(const GpsMetadataMessage);
92  return d->timestampMs;
93 }
94 
95 /*!
96  * Returns the GpsMetadataMessage data message's \c positionLat field's current value.
97  *
98  * \return the \c positionLat field value.
99  */
101 {
102  Q_D(const GpsMetadataMessage);
103  return d->positionLat;
104 }
105 
106 /*!
107  * Returns the GpsMetadataMessage data message's \c positionLong field's current value.
108  *
109  * \return the \c positionLong field value.
110  */
112 {
113  Q_D(const GpsMetadataMessage);
114  return d->positionLong;
115 }
116 
117 /*!
118  * Returns the GpsMetadataMessage data message's \c enhancedAltitude field's current value.
119  *
120  * \return the \c enhancedAltitude field value.
121  */
123 {
124  Q_D(const GpsMetadataMessage);
125  return d->enhancedAltitude;
126 }
127 
128 /*!
129  * Returns the GpsMetadataMessage data message's \c enhancedSpeed field's current value.
130  *
131  * \return the \c enhancedSpeed field value.
132  */
134 {
135  Q_D(const GpsMetadataMessage);
136  return d->enhancedSpeed;
137 }
138 
139 /*!
140  * Returns the GpsMetadataMessage data message's \c heading field's current value.
141  *
142  * \return the \c heading field value.
143  */
145 {
146  Q_D(const GpsMetadataMessage);
147  return d->heading;
148 }
149 
150 /*!
151  * Returns the GpsMetadataMessage data message's \c utcTimestamp field's current value.
152  *
153  * Used to correlate UTC to system time if the timestamp of the message is in system time. This
154  * UTC time is derived from the GPS data.
155  *
156  * \return the \c utcTimestamp field value.
157  */
159 {
160  Q_D(const GpsMetadataMessage);
161  return d->utcTimestamp;
162 }
163 
164 /*!
165  * Returns the GpsMetadataMessage data message's \c velocity field's current value.
166  *
167  * velocity[0] is lon velocity. Velocity[1] is lat velocity. Velocity[2] is altitude velocity.
168  *
169  * \return the \c velocity field value.
170  */
172 {
173  Q_D(const GpsMetadataMessage);
174  return d->velocity;
175 }
176 
177 /*!
178  * Sets the \c timestamp field to \a timestamp.
179  *
180  * \param timestamp The field value to set.
181  */
183 {
184  Q_D(GpsMetadataMessage);
185  d->timestamp = timestamp;
186 }
187 /*!
188  * Sets the \c timestampMs field to \a timestampMs.
189  *
190  * \param timestampMs The field value to set.
191  */
192 void GpsMetadataMessage::setTimestampMs(const quint16 timestampMs)
193 {
194  Q_D(GpsMetadataMessage);
195  d->timestampMs = timestampMs;
196 }
197 /*!
198  * Sets the \c positionLat field to \a positionLat.
199  *
200  * \param positionLat The field value to set.
201  */
202 void GpsMetadataMessage::setPositionLat(const qint32 positionLat)
203 {
204  Q_D(GpsMetadataMessage);
205  d->positionLat = positionLat;
206 }
207 /*!
208  * Sets the \c positionLong field to \a positionLong.
209  *
210  * \param positionLong The field value to set.
211  */
212 void GpsMetadataMessage::setPositionLong(const qint32 positionLong)
213 {
214  Q_D(GpsMetadataMessage);
215  d->positionLong = positionLong;
216 }
217 /*!
218  * Sets the \c enhancedAltitude field to \a enhancedAltitude.
219  *
220  * \param enhancedAltitude The field value to set.
221  */
222 void GpsMetadataMessage::setEnhancedAltitude(const quint32 enhancedAltitude)
223 {
224  Q_D(GpsMetadataMessage);
225  d->enhancedAltitude = enhancedAltitude;
226 }
227 /*!
228  * Sets the \c enhancedSpeed field to \a enhancedSpeed.
229  *
230  * \param enhancedSpeed The field value to set.
231  */
232 void GpsMetadataMessage::setEnhancedSpeed(const quint32 enhancedSpeed)
233 {
234  Q_D(GpsMetadataMessage);
235  d->enhancedSpeed = enhancedSpeed;
236 }
237 /*!
238  * Sets the \c heading field to \a heading.
239  *
240  * \param heading The field value to set.
241  */
242 void GpsMetadataMessage::setHeading(const quint16 heading)
243 {
244  Q_D(GpsMetadataMessage);
245  d->heading = heading;
246 }
247 /*!
248  * Sets the \c utcTimestamp field to \a utcTimestamp.
249  *
250  * \param utcTimestamp The field value to set.
251  */
253 {
254  Q_D(GpsMetadataMessage);
255  d->utcTimestamp = utcTimestamp;
256 }
257 /*!
258  * Sets the \c velocity field to \a velocity.
259  *
260  * \param velocity The field value to set.
261  */
262 void GpsMetadataMessage::setVelocity(const qint16 velocity)
263 {
264  Q_D(GpsMetadataMessage);
265  d->velocity = velocity;
266 }
267 
268 /// \cond internal
269 
270 /*!
271  * \internal
272  *
273  * \class GpsMetadataMessagePrivate
274  *
275  * The GpsMetadataMessagePrivate class provides private implementation for the GpsMetadataMessage.
276  *
277  * \sa GpsMetadataMessage
278  */
279 
280 /*!
281  * \internal
282  *
283  * Constructs a GpsMetadataMessagePrivate object with public implementation \a q.
284  *
285  * \param q Pointer to public implementaton.
286  */
287 GpsMetadataMessagePrivate::GpsMetadataMessagePrivate(GpsMetadataMessage * const q)
289  , timestamp(static_cast<DateTime>(-1))
290  , timestampMs(0xFFFF)
291  , positionLat(0x7FFFFFFF)
292  , positionLong(0x7FFFFFFF)
293  , enhancedAltitude(0xFFFFFFFF)
294  , enhancedSpeed(0xFFFFFFFF)
295  , heading(0xFFFF)
296  , utcTimestamp(static_cast<DateTime>(-1))
297  , velocity(0x7FFF)
298 {
299  globalMessageNumber = MesgNum::GpsMetadata;
300 }
301 
302 /*!
303  * \internal
304  *
305  * Destroys the GpsMetadataMessagePrivate object.
306  */
308 {
309 
310 }
311 
313  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
314 {
315  switch (fieldId) {
316  case 253: // See Profile.xlsx::Messages:gps_metadata.timestamp
317  if (!verify(data, baseType, 4, FitBaseType::Uint32, "gps_metadata.timestamp")) return false;
318  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
319  break;
320  case 0: // See Profile.xlsx::Messages:gps_metadata.timestampMs
321  if (!verify(data, baseType, 2, FitBaseType::Uint16, "gps_metadata.timestampMs")) return false;
322  this->timestampMs = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
323  break;
324  case 1: // See Profile.xlsx::Messages:gps_metadata.positionLat
325  if (!verify(data, baseType, 4, FitBaseType::Sint32, "gps_metadata.positionLat")) return false;
326  this->positionLat = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
327  break;
328  case 2: // See Profile.xlsx::Messages:gps_metadata.positionLong
329  if (!verify(data, baseType, 4, FitBaseType::Sint32, "gps_metadata.positionLong")) return false;
330  this->positionLong = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
331  break;
332  case 3: // See Profile.xlsx::Messages:gps_metadata.enhancedAltitude
333  if (!verify(data, baseType, 4, FitBaseType::Uint32, "gps_metadata.enhancedAltitude")) return false;
334  this->enhancedAltitude = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
335  break;
336  case 4: // See Profile.xlsx::Messages:gps_metadata.enhancedSpeed
337  if (!verify(data, baseType, 4, FitBaseType::Uint32, "gps_metadata.enhancedSpeed")) return false;
338  this->enhancedSpeed = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
339  break;
340  case 5: // See Profile.xlsx::Messages:gps_metadata.heading
341  if (!verify(data, baseType, 2, FitBaseType::Uint16, "gps_metadata.heading")) return false;
342  this->heading = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
343  break;
344  case 6: // See Profile.xlsx::Messages:gps_metadata.utcTimestamp
345  if (!verify(data, baseType, 4, FitBaseType::Uint32, "gps_metadata.utcTimestamp")) return false;
346  this->utcTimestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
347  break;
348  case 7: // See Profile.xlsx::Messages:gps_metadata.velocity
349  if (!verify(data, baseType, 2, FitBaseType::Sint16, "gps_metadata.velocity")) return false;
350  this->velocity = static_cast<qint16>(bigEndian ? qFromBigEndian< qint16>(data) : qFromLittleEndian< qint16>(data));
351  break;
352  default:
353  qWarning() << "ignoring unknown gps_metadata message field number" << fieldId << bigEndian;
354  // Fall through to return true, as its still 'safe' to continue parsing data messages.
355  }
356  return true;
357 }
358 
359 /// \endcond
360 
#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.
quint32 enhancedAltitude
The GpsMetadataMessage FIT message's enhancedAltitude field.
quint16 timestampMs
The GpsMetadataMessage FIT message's timestampMs field.
quint16 heading
The GpsMetadataMessage FIT message's heading field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
quint32 enhancedSpeed
The GpsMetadataMessage FIT message's enhancedSpeed field.
DateTime timestamp
The GpsMetadataMessage FIT message's timestamp field.
qint32 positionLat
The GpsMetadataMessage FIT message's positionLat field.
qint16 velocity
The GpsMetadataMessage FIT message's velocity field.
DateTime utcTimestamp
The GpsMetadataMessage FIT message's utcTimestamp field.
qint32 positionLong
The GpsMetadataMessage FIT message's positionLong field.
The GpsMetadataMessage class represents a FIT GpsMetadataMessage data message.
quint32 enhancedSpeed() const
Returns the GpsMetadataMessage data message's enhancedSpeed field's current value.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
void setHeading(const quint16 heading)
Sets the heading field to heading.
qint16 velocity() const
Returns the GpsMetadataMessage data message's velocity field's current value.
void setPositionLat(const qint32 positionLat)
Sets the positionLat field to positionLat.
void setEnhancedAltitude(const quint32 enhancedAltitude)
Sets the enhancedAltitude field to enhancedAltitude.
void setVelocity(const qint16 velocity)
Sets the velocity field to velocity.
void setEnhancedSpeed(const quint32 enhancedSpeed)
Sets the enhancedSpeed field to enhancedSpeed.
quint16 timestampMs() const
Returns the GpsMetadataMessage data message's timestampMs field's current value.
void setTimestampMs(const quint16 timestampMs)
Sets the timestampMs field to timestampMs.
quint16 heading() const
Returns the GpsMetadataMessage data message's heading field's current value.
qint32 positionLat() const
Returns the GpsMetadataMessage data message's positionLat field's current value.
qint32 positionLong() const
Returns the GpsMetadataMessage data message's positionLong field's current value.
DateTime utcTimestamp() const
Returns the GpsMetadataMessage data message's utcTimestamp field's current value.
void setUtcTimestamp(const DateTime utcTimestamp)
Sets the utcTimestamp field to utcTimestamp.
DateTime timestamp() const
Returns the GpsMetadataMessage data message's timestamp field's current value.
void setPositionLong(const qint32 positionLong)
Sets the positionLong field to positionLong.
GpsMetadataMessage()
Constructs a GpsMetadataMessage object.
quint32 enhancedAltitude() const
Returns the GpsMetadataMessage data message's enhancedAltitude field's current value.
Declares the GpsMetadataMessage class.
Declares the GpsMetadataMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237