QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
activitymessage.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 ActivityMessage, and ActivityMessagePrivate classes.
28  */
29 
30 #include "activitymessage.h"
31 #include "activitymessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class ActivityMessage
40  *
41  * The ActivityMessage class represents a FIT ActivityMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a ActivityMessage 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 ActivityMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the ActivityMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const ActivityMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the ActivityMessage data message's \c totalTimerTime field's current value.
82  *
83  * Exclude pauses
84  *
85  * \return the \c totalTimerTime field value.
86  */
88 {
89  Q_D(const ActivityMessage);
90  return d->totalTimerTime;
91 }
92 
93 /*!
94  * Returns the ActivityMessage data message's \c numSessions field's current value.
95  *
96  * \return the \c numSessions field value.
97  */
99 {
100  Q_D(const ActivityMessage);
101  return d->numSessions;
102 }
103 
104 /*!
105  * Returns the ActivityMessage data message's \c type field's current value.
106  *
107  * \return the \c type field value.
108  */
110 {
111  Q_D(const ActivityMessage);
112  return d->type;
113 }
114 
115 /*!
116  * Returns the ActivityMessage data message's \c event field's current value.
117  *
118  * \return the \c event field value.
119  */
121 {
122  Q_D(const ActivityMessage);
123  return d->event;
124 }
125 
126 /*!
127  * Returns the ActivityMessage data message's \c eventType field's current value.
128  *
129  * \return the \c eventType field value.
130  */
132 {
133  Q_D(const ActivityMessage);
134  return d->eventType;
135 }
136 
137 /*!
138  * Returns the ActivityMessage data message's \c localTimestamp field's current value.
139  *
140  * timestamp epoch expressed in local time, used to convert activity timestamps to local time
141  *
142  * \return the \c localTimestamp field value.
143  */
145 {
146  Q_D(const ActivityMessage);
147  return d->localTimestamp;
148 }
149 
150 /*!
151  * Returns the ActivityMessage data message's \c eventGroup field's current value.
152  *
153  * \return the \c eventGroup field value.
154  */
156 {
157  Q_D(const ActivityMessage);
158  return d->eventGroup;
159 }
160 
161 /*!
162  * Sets the \c timestamp field to \a timestamp.
163  *
164  * \param timestamp The field value to set.
165  */
167 {
168  Q_D(ActivityMessage);
169  d->timestamp = timestamp;
170 }
171 /*!
172  * Sets the \c totalTimerTime field to \a totalTimerTime.
173  *
174  * \param totalTimerTime The field value to set.
175  */
176 void ActivityMessage::setTotalTimerTime(const quint32 totalTimerTime)
177 {
178  Q_D(ActivityMessage);
179  d->totalTimerTime = totalTimerTime;
180 }
181 /*!
182  * Sets the \c numSessions field to \a numSessions.
183  *
184  * \param numSessions The field value to set.
185  */
186 void ActivityMessage::setNumSessions(const quint16 numSessions)
187 {
188  Q_D(ActivityMessage);
189  d->numSessions = numSessions;
190 }
191 /*!
192  * Sets the \c type field to \a type.
193  *
194  * \param type The field value to set.
195  */
197 {
198  Q_D(ActivityMessage);
199  d->type = type;
200 }
201 /*!
202  * Sets the \c event field to \a event.
203  *
204  * \param event The field value to set.
205  */
207 {
208  Q_D(ActivityMessage);
209  d->event = event;
210 }
211 /*!
212  * Sets the \c eventType field to \a eventType.
213  *
214  * \param eventType The field value to set.
215  */
217 {
218  Q_D(ActivityMessage);
219  d->eventType = eventType;
220 }
221 /*!
222  * Sets the \c localTimestamp field to \a localTimestamp.
223  *
224  * \param localTimestamp The field value to set.
225  */
227 {
228  Q_D(ActivityMessage);
229  d->localTimestamp = localTimestamp;
230 }
231 /*!
232  * Sets the \c eventGroup field to \a eventGroup.
233  *
234  * \param eventGroup The field value to set.
235  */
236 void ActivityMessage::setEventGroup(const quint8 eventGroup)
237 {
238  Q_D(ActivityMessage);
239  d->eventGroup = eventGroup;
240 }
241 
242 /// \cond internal
243 
244 /*!
245  * \internal
246  *
247  * \class ActivityMessagePrivate
248  *
249  * The ActivityMessagePrivate class provides private implementation for the ActivityMessage.
250  *
251  * \sa ActivityMessage
252  */
253 
254 /*!
255  * \internal
256  *
257  * Constructs a ActivityMessagePrivate object with public implementation \a q.
258  *
259  * \param q Pointer to public implementaton.
260  */
261 ActivityMessagePrivate::ActivityMessagePrivate(ActivityMessage * const q)
263  , timestamp(static_cast<DateTime>(-1))
264  , totalTimerTime(0xFFFFFFFF)
265  , numSessions(0xFFFF)
266  , type(static_cast<Activity>(-1))
267  , event(static_cast<Event>(-1))
268  , eventType(static_cast<EventType>(-1))
269  , localTimestamp(static_cast<LocalDateTime>(-1))
270  , eventGroup(0xFF)
271 {
272  globalMessageNumber = MesgNum::Activity;
273 }
274 
275 /*!
276  * \internal
277  *
278  * Destroys the ActivityMessagePrivate object.
279  */
281 {
282 
283 }
284 
286  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
287 {
288  switch (fieldId) {
289  case 253: // See Profile.xlsx::Messages:activity.timestamp
290  if (!verify(data, baseType, 4, FitBaseType::Uint32, "activity.timestamp")) return false;
291  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
292  break;
293  case 0: // See Profile.xlsx::Messages:activity.totalTimerTime
294  if (!verify(data, baseType, 4, FitBaseType::Uint32, "activity.totalTimerTime")) return false;
295  this->totalTimerTime = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
296  break;
297  case 1: // See Profile.xlsx::Messages:activity.numSessions
298  if (!verify(data, baseType, 2, FitBaseType::Uint16, "activity.numSessions")) return false;
299  this->numSessions = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
300  break;
301  case 2: // See Profile.xlsx::Messages:activity.type
302  if (!verify(data, baseType, 1, FitBaseType::Enum, "activity.type")) return false;
303  this->type = static_cast<Activity>(data.at(0));
304  break;
305  case 3: // See Profile.xlsx::Messages:activity.event
306  if (!verify(data, baseType, 1, FitBaseType::Enum, "activity.event")) return false;
307  this->event = static_cast<Event>(data.at(0));
308  break;
309  case 4: // See Profile.xlsx::Messages:activity.eventType
310  if (!verify(data, baseType, 1, FitBaseType::Enum, "activity.eventType")) return false;
311  this->eventType = static_cast<EventType>(data.at(0));
312  break;
313  case 5: // See Profile.xlsx::Messages:activity.localTimestamp
314  if (!verify(data, baseType, 4, FitBaseType::Uint32, "activity.localTimestamp")) return false;
315  this->localTimestamp = static_cast<LocalDateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
316  break;
317  case 6: // See Profile.xlsx::Messages:activity.eventGroup
318  if (!verify(data, baseType, 1, FitBaseType::Uint8, "activity.eventGroup")) return false;
319  this->eventGroup = static_cast<quint8>(data.at(0));
320  break;
321  default:
322  qWarning() << "ignoring unknown activity message field number" << fieldId << bigEndian;
323  // Fall through to return true, as its still 'safe' to continue parsing data messages.
324  }
325  return true;
326 }
327 
328 /// \endcond
329 
#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 ActivityMessage class.
Declares the ActivityMessagePrivate 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.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
Activity type
The ActivityMessage FIT message's type field.
quint8 eventGroup
The ActivityMessage FIT message's eventGroup field.
DateTime timestamp
The ActivityMessage FIT message's timestamp field.
quint32 totalTimerTime
The ActivityMessage FIT message's totalTimerTime field.
quint16 numSessions
The ActivityMessage FIT message's numSessions field.
EventType eventType
The ActivityMessage FIT message's eventType field.
LocalDateTime localTimestamp
The ActivityMessage FIT message's localTimestamp field.
The ActivityMessage class represents a FIT ActivityMessage data message.
void setNumSessions(const quint16 numSessions)
Sets the numSessions field to numSessions.
DateTime timestamp() const
Returns the ActivityMessage data message's timestamp field's current value.
void setEventType(const EventType eventType)
Sets the eventType field to eventType.
Event event() const
Returns the ActivityMessage data message's event field's current value.
void setTotalTimerTime(const quint32 totalTimerTime)
Sets the totalTimerTime field to totalTimerTime.
void setLocalTimestamp(const LocalDateTime localTimestamp)
Sets the localTimestamp field to localTimestamp.
LocalDateTime localTimestamp() const
Returns the ActivityMessage data message's localTimestamp field's current value.
void setType(const Activity type)
Sets the type field to type.
void setEventGroup(const quint8 eventGroup)
Sets the eventGroup field to eventGroup.
ActivityMessage()
Constructs a ActivityMessage object.
quint32 totalTimerTime() const
Returns the ActivityMessage data message's totalTimerTime field's current value.
void setEvent(const Event event)
Sets the event field to event.
quint16 numSessions() const
Returns the ActivityMessage data message's numSessions field's current value.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
Activity type() const
Returns the ActivityMessage data message's type field's current value.
EventType eventType() const
Returns the ActivityMessage data message's eventType field's current value.
quint8 eventGroup() const
Returns the ActivityMessage data message's eventGroup field's current value.
LocalDateTime
Seconds since 00:00 Dec 31 1989 in local time zone.
Definition: types.h:250
EventType
Garmin FIT EventType type.
Definition: types.h:1182
Event
Garmin FIT Event type.
Definition: types.h:1133
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
Activity
Garmin FIT Activity type.
Definition: types.h:980
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237