QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
monitoringinfomessage.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 MonitoringInfoMessage, and MonitoringInfoMessagePrivate classes.
28  */
29 
30 #include "monitoringinfomessage.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class MonitoringInfoMessage
40  *
41  * The MonitoringInfoMessage class represents a FIT MonitoringInfoMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a MonitoringInfoMessage 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 MonitoringInfoMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the MonitoringInfoMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const MonitoringInfoMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the MonitoringInfoMessage data message's \c localTimestamp field's current value.
82  *
83  * Use to convert activity timestamps to local time if device does not support time zone and
84  * daylight savings time correction.
85  *
86  * \return the \c localTimestamp field value.
87  */
89 {
90  Q_D(const MonitoringInfoMessage);
91  return d->localTimestamp;
92 }
93 
94 /*!
95  * Returns the MonitoringInfoMessage data message's \c activityType field's current value.
96  *
97  * \return the \c activityType field value.
98  */
100 {
101  Q_D(const MonitoringInfoMessage);
102  return d->activityType;
103 }
104 
105 /*!
106  * Returns the MonitoringInfoMessage data message's \c cyclesToDistance field's current value.
107  *
108  * Indexed by activity_type
109  *
110  * \return the \c cyclesToDistance field value.
111  */
113 {
114  Q_D(const MonitoringInfoMessage);
115  return d->cyclesToDistance;
116 }
117 
118 /*!
119  * Returns the MonitoringInfoMessage data message's \c cyclesToCalories field's current value.
120  *
121  * Indexed by activity_type
122  *
123  * \return the \c cyclesToCalories field value.
124  */
126 {
127  Q_D(const MonitoringInfoMessage);
128  return d->cyclesToCalories;
129 }
130 
131 /*!
132  * Returns the MonitoringInfoMessage data message's \c restingMetabolicRate field's current value.
133  *
134  * \return the \c restingMetabolicRate field value.
135  */
137 {
138  Q_D(const MonitoringInfoMessage);
139  return d->restingMetabolicRate;
140 }
141 
142 /*!
143  * Sets the \c timestamp field to \a timestamp.
144  *
145  * \param timestamp The field value to set.
146  */
148 {
150  d->timestamp = timestamp;
151 }
152 /*!
153  * Sets the \c localTimestamp field to \a localTimestamp.
154  *
155  * \param localTimestamp The field value to set.
156  */
158 {
160  d->localTimestamp = localTimestamp;
161 }
162 /*!
163  * Sets the \c activityType field to \a activityType.
164  *
165  * \param activityType The field value to set.
166  */
168 {
170  d->activityType = activityType;
171 }
172 /*!
173  * Sets the \c cyclesToDistance field to \a cyclesToDistance.
174  *
175  * \param cyclesToDistance The field value to set.
176  */
177 void MonitoringInfoMessage::setCyclesToDistance(const quint16 cyclesToDistance)
178 {
180  d->cyclesToDistance = cyclesToDistance;
181 }
182 /*!
183  * Sets the \c cyclesToCalories field to \a cyclesToCalories.
184  *
185  * \param cyclesToCalories The field value to set.
186  */
187 void MonitoringInfoMessage::setCyclesToCalories(const quint16 cyclesToCalories)
188 {
190  d->cyclesToCalories = cyclesToCalories;
191 }
192 /*!
193  * Sets the \c restingMetabolicRate field to \a restingMetabolicRate.
194  *
195  * \param restingMetabolicRate The field value to set.
196  */
197 void MonitoringInfoMessage::setRestingMetabolicRate(const quint16 restingMetabolicRate)
198 {
200  d->restingMetabolicRate = restingMetabolicRate;
201 }
202 
203 /// \cond internal
204 
205 /*!
206  * \internal
207  *
208  * \class MonitoringInfoMessagePrivate
209  *
210  * The MonitoringInfoMessagePrivate class provides private implementation for the MonitoringInfoMessage.
211  *
212  * \sa MonitoringInfoMessage
213  */
214 
215 /*!
216  * \internal
217  *
218  * Constructs a MonitoringInfoMessagePrivate object with public implementation \a q.
219  *
220  * \param q Pointer to public implementaton.
221  */
222 MonitoringInfoMessagePrivate::MonitoringInfoMessagePrivate(MonitoringInfoMessage * const q)
224  , timestamp(static_cast<DateTime>(-1))
225  , localTimestamp(static_cast<LocalDateTime>(-1))
226  , activityType(static_cast<ActivityType>(-1))
227  , cyclesToDistance(0xFFFF)
228  , cyclesToCalories(0xFFFF)
229  , restingMetabolicRate(0xFFFF)
230 {
231  globalMessageNumber = MesgNum::MonitoringInfo;
232 }
233 
234 /*!
235  * \internal
236  *
237  * Destroys the MonitoringInfoMessagePrivate object.
238  */
240 {
241 
242 }
243 
245  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
246 {
247  switch (fieldId) {
248  case 253: // See Profile.xlsx::Messages:monitoring_info.timestamp
249  if (!verify(data, baseType, 4, FitBaseType::Uint32, "monitoring_info.timestamp")) return false;
250  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
251  break;
252  case 0: // See Profile.xlsx::Messages:monitoring_info.localTimestamp
253  if (!verify(data, baseType, 4, FitBaseType::Uint32, "monitoring_info.localTimestamp")) return false;
254  this->localTimestamp = static_cast<LocalDateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
255  break;
256  case 1: // See Profile.xlsx::Messages:monitoring_info.activityType
257  if (!verify(data, baseType, 1, FitBaseType::Enum, "monitoring_info.activityType")) return false;
258  this->activityType = static_cast<ActivityType>(data.at(0));
259  break;
260  case 3: // See Profile.xlsx::Messages:monitoring_info.cyclesToDistance
261  if (!verify(data, baseType, 2, FitBaseType::Uint16, "monitoring_info.cyclesToDistance")) return false;
262  this->cyclesToDistance = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
263  break;
264  case 4: // See Profile.xlsx::Messages:monitoring_info.cyclesToCalories
265  if (!verify(data, baseType, 2, FitBaseType::Uint16, "monitoring_info.cyclesToCalories")) return false;
266  this->cyclesToCalories = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
267  break;
268  case 5: // See Profile.xlsx::Messages:monitoring_info.restingMetabolicRate
269  if (!verify(data, baseType, 2, FitBaseType::Uint16, "monitoring_info.restingMetabolicRate")) return false;
270  this->restingMetabolicRate = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
271  break;
272  default:
273  qWarning() << "ignoring unknown monitoring_info message field number" << fieldId << bigEndian;
274  // Fall through to return true, as its still 'safe' to continue parsing data messages.
275  }
276  return true;
277 }
278 
279 /// \endcond
280 
#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 cyclesToCalories
The MonitoringInfoMessage FIT message's cyclesToCalories field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
quint16 restingMetabolicRate
The MonitoringInfoMessage FIT message's restingMetabolicRate field.
DateTime timestamp
The MonitoringInfoMessage FIT message's timestamp field.
quint16 cyclesToDistance
The MonitoringInfoMessage FIT message's cyclesToDistance field.
LocalDateTime localTimestamp
The MonitoringInfoMessage FIT message's localTimestamp field.
ActivityType activityType
The MonitoringInfoMessage FIT message's activityType field.
The MonitoringInfoMessage class represents a FIT MonitoringInfoMessage data message.
quint16 cyclesToDistance() const
Returns the MonitoringInfoMessage data message's cyclesToDistance field's current value.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
MonitoringInfoMessage()
Constructs a MonitoringInfoMessage object.
void setCyclesToDistance(const quint16 cyclesToDistance)
Sets the cyclesToDistance field to cyclesToDistance.
void setActivityType(const ActivityType activityType)
Sets the activityType field to activityType.
void setRestingMetabolicRate(const quint16 restingMetabolicRate)
Sets the restingMetabolicRate field to restingMetabolicRate.
quint16 restingMetabolicRate() const
Returns the MonitoringInfoMessage data message's restingMetabolicRate field's current value.
void setLocalTimestamp(const LocalDateTime localTimestamp)
Sets the localTimestamp field to localTimestamp.
LocalDateTime localTimestamp() const
Returns the MonitoringInfoMessage data message's localTimestamp field's current value.
ActivityType activityType() const
Returns the MonitoringInfoMessage data message's activityType field's current value.
DateTime timestamp() const
Returns the MonitoringInfoMessage data message's timestamp field's current value.
quint16 cyclesToCalories() const
Returns the MonitoringInfoMessage data message's cyclesToCalories field's current value.
void setCyclesToCalories(const quint16 cyclesToCalories)
Sets the cyclesToCalories field to cyclesToCalories.
Declares the MonitoringInfoMessage class.
Declares the MonitoringInfoMessagePrivate class.
LocalDateTime
Seconds since 00:00 Dec 31 1989 in local time zone.
Definition: types.h:250
ActivityType
Garmin FIT ActivityType type.
Definition: types.h:2281
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237