QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
barometerdatamessage.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 BarometerDataMessage, and BarometerDataMessagePrivate classes.
28  */
29 
30 #include "barometerdatamessage.h"
31 #include "barometerdatamessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class BarometerDataMessage
40  *
41  * The BarometerDataMessage class represents a FIT BarometerDataMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a BarometerDataMessage 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 BarometerDataMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the BarometerDataMessage 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 BarometerDataMessage);
79  return d->timestamp;
80 }
81 
82 /*!
83  * Returns the BarometerDataMessage 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 BarometerDataMessage);
92  return d->timestampMs;
93 }
94 
95 /*!
96  * Returns the BarometerDataMessage data message's \c sampleTimeOffset field's current value.
97  *
98  * Each time in the array describes the time at which the barometer sample with the
99  * corrosponding index was taken. The samples may span across seconds. Array size must match the
100  * number of samples in baro_cal
101  *
102  * \return the \c sampleTimeOffset field value.
103  */
105 {
106  Q_D(const BarometerDataMessage);
107  return d->sampleTimeOffset;
108 }
109 
110 /*!
111  * Returns the BarometerDataMessage data message's \c baroPres field's current value.
112  *
113  * These are the raw ADC reading. The samples may span across seconds. A conversion will need to
114  * be done on this data once read.
115  *
116  * \return the \c baroPres field value.
117  */
119 {
120  Q_D(const BarometerDataMessage);
121  return d->baroPres;
122 }
123 
124 /*!
125  * Sets the \c timestamp field to \a timestamp.
126  *
127  * \param timestamp The field value to set.
128  */
130 {
132  d->timestamp = timestamp;
133 }
134 /*!
135  * Sets the \c timestampMs field to \a timestampMs.
136  *
137  * \param timestampMs The field value to set.
138  */
139 void BarometerDataMessage::setTimestampMs(const quint16 timestampMs)
140 {
142  d->timestampMs = timestampMs;
143 }
144 /*!
145  * Sets the \c sampleTimeOffset field to \a sampleTimeOffset.
146  *
147  * \param sampleTimeOffset The field value to set.
148  */
149 void BarometerDataMessage::setSampleTimeOffset(const quint16 sampleTimeOffset)
150 {
152  d->sampleTimeOffset = sampleTimeOffset;
153 }
154 /*!
155  * Sets the \c baroPres field to \a baroPres.
156  *
157  * \param baroPres The field value to set.
158  */
159 void BarometerDataMessage::setBaroPres(const quint32 baroPres)
160 {
162  d->baroPres = baroPres;
163 }
164 
165 /// \cond internal
166 
167 /*!
168  * \internal
169  *
170  * \class BarometerDataMessagePrivate
171  *
172  * The BarometerDataMessagePrivate class provides private implementation for the BarometerDataMessage.
173  *
174  * \sa BarometerDataMessage
175  */
176 
177 /*!
178  * \internal
179  *
180  * Constructs a BarometerDataMessagePrivate object with public implementation \a q.
181  *
182  * \param q Pointer to public implementaton.
183  */
184 BarometerDataMessagePrivate::BarometerDataMessagePrivate(BarometerDataMessage * const q)
186  , timestamp(static_cast<DateTime>(-1))
187  , timestampMs(0xFFFF)
188  , sampleTimeOffset(0xFFFF)
189  , baroPres(0xFFFFFFFF)
190 {
191  globalMessageNumber = MesgNum::BarometerData;
192 }
193 
194 /*!
195  * \internal
196  *
197  * Destroys the BarometerDataMessagePrivate object.
198  */
200 {
201 
202 }
203 
205  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
206 {
207  switch (fieldId) {
208  case 253: // See Profile.xlsx::Messages:barometer_data.timestamp
209  if (!verify(data, baseType, 4, FitBaseType::Uint32, "barometer_data.timestamp")) return false;
210  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
211  break;
212  case 0: // See Profile.xlsx::Messages:barometer_data.timestampMs
213  if (!verify(data, baseType, 2, FitBaseType::Uint16, "barometer_data.timestampMs")) return false;
214  this->timestampMs = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
215  break;
216  case 1: // See Profile.xlsx::Messages:barometer_data.sampleTimeOffset
217  if (!verify(data, baseType, 2, FitBaseType::Uint16, "barometer_data.sampleTimeOffset")) return false;
218  this->sampleTimeOffset = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
219  break;
220  case 2: // See Profile.xlsx::Messages:barometer_data.baroPres
221  if (!verify(data, baseType, 4, FitBaseType::Uint32, "barometer_data.baroPres")) return false;
222  this->baroPres = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
223  break;
224  default:
225  qWarning() << "ignoring unknown barometer_data message field number" << fieldId << bigEndian;
226  // Fall through to return true, as its still 'safe' to continue parsing data messages.
227  }
228  return true;
229 }
230 
231 /// \endcond
232 
#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
Declares the BarometerDataMessage class.
Declares the BarometerDataMessagePrivate class.
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.
DateTime timestamp
The BarometerDataMessage FIT message's timestamp field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
quint16 sampleTimeOffset
The BarometerDataMessage FIT message's sampleTimeOffset field.
quint16 timestampMs
The BarometerDataMessage FIT message's timestampMs field.
quint32 baroPres
The BarometerDataMessage FIT message's baroPres field.
The BarometerDataMessage class represents a FIT BarometerDataMessage data message.
quint32 baroPres() const
Returns the BarometerDataMessage data message's baroPres field's current value.
DateTime timestamp() const
Returns the BarometerDataMessage data message's timestamp field's current value.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
quint16 timestampMs() const
Returns the BarometerDataMessage data message's timestampMs field's current value.
void setSampleTimeOffset(const quint16 sampleTimeOffset)
Sets the sampleTimeOffset field to sampleTimeOffset.
quint16 sampleTimeOffset() const
Returns the BarometerDataMessage data message's sampleTimeOffset field's current value.
void setBaroPres(const quint32 baroPres)
Sets the baroPres field to baroPres.
BarometerDataMessage()
Constructs a BarometerDataMessage object.
void setTimestampMs(const quint16 timestampMs)
Sets the timestampMs field to timestampMs.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237