QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
schedulemessage.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 ScheduleMessage, and ScheduleMessagePrivate classes.
28  */
29 
30 #include "schedulemessage.h"
31 #include "schedulemessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class ScheduleMessage
40  *
41  * The ScheduleMessage class represents a FIT ScheduleMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a ScheduleMessage 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 ScheduleMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the ScheduleMessage data message's \c manufacturer field's current value.
71  *
72  * Corresponds to file_id of scheduled workout / course.
73  *
74  * \return the \c manufacturer field value.
75  */
77 {
78  Q_D(const ScheduleMessage);
79  return d->manufacturer;
80 }
81 
82 /*!
83  * Returns the ScheduleMessage data message's \c product field's current value.
84  *
85  * Corresponds to file_id of scheduled workout / course.
86  *
87  * \return the \c product field value.
88  */
89 quint16 ScheduleMessage::product() const
90 {
91  Q_D(const ScheduleMessage);
92  return d->product;
93 }
94 
95 /*!
96  * Returns the ScheduleMessage data message's \c serialNumber field's current value.
97  *
98  * Corresponds to file_id of scheduled workout / course.
99  *
100  * \return the \c serialNumber field value.
101  */
103 {
104  Q_D(const ScheduleMessage);
105  return d->serialNumber;
106 }
107 
108 /*!
109  * Returns the ScheduleMessage data message's \c timeCreated field's current value.
110  *
111  * Corresponds to file_id of scheduled workout / course.
112  *
113  * \return the \c timeCreated field value.
114  */
116 {
117  Q_D(const ScheduleMessage);
118  return d->timeCreated;
119 }
120 
121 /*!
122  * Returns the ScheduleMessage data message's \c completed field's current value.
123  *
124  * TRUE if this activity has been started
125  *
126  * \return the \c completed field value.
127  */
129 {
130  Q_D(const ScheduleMessage);
131  return d->completed;
132 }
133 
134 /*!
135  * Returns the ScheduleMessage data message's \c type field's current value.
136  *
137  * \return the \c type field value.
138  */
140 {
141  Q_D(const ScheduleMessage);
142  return d->type;
143 }
144 
145 /*!
146  * Returns the ScheduleMessage data message's \c scheduledTime field's current value.
147  *
148  * \return the \c scheduledTime field value.
149  */
151 {
152  Q_D(const ScheduleMessage);
153  return d->scheduledTime;
154 }
155 
156 /*!
157  * Sets the \c manufacturer field to \a manufacturer.
158  *
159  * \param manufacturer The field value to set.
160  */
162 {
163  Q_D(ScheduleMessage);
164  d->manufacturer = manufacturer;
165 }
166 /*!
167  * Sets the \c product field to \a product.
168  *
169  * \param product The field value to set.
170  */
171 void ScheduleMessage::setProduct(const quint16 product)
172 {
173  Q_D(ScheduleMessage);
174  d->product = product;
175 }
176 /*!
177  * Sets the \c serialNumber field to \a serialNumber.
178  *
179  * \param serialNumber The field value to set.
180  */
182 {
183  Q_D(ScheduleMessage);
184  d->serialNumber = serialNumber;
185 }
186 /*!
187  * Sets the \c timeCreated field to \a timeCreated.
188  *
189  * \param timeCreated The field value to set.
190  */
192 {
193  Q_D(ScheduleMessage);
194  d->timeCreated = timeCreated;
195 }
196 /*!
197  * Sets the \c completed field to \a completed.
198  *
199  * \param completed The field value to set.
200  */
201 void ScheduleMessage::setCompleted(const bool completed)
202 {
203  Q_D(ScheduleMessage);
204  d->completed = completed;
205 }
206 /*!
207  * Sets the \c type field to \a type.
208  *
209  * \param type The field value to set.
210  */
212 {
213  Q_D(ScheduleMessage);
214  d->type = type;
215 }
216 /*!
217  * Sets the \c scheduledTime field to \a scheduledTime.
218  *
219  * \param scheduledTime The field value to set.
220  */
222 {
223  Q_D(ScheduleMessage);
224  d->scheduledTime = scheduledTime;
225 }
226 
227 /// \cond internal
228 
229 /*!
230  * \internal
231  *
232  * \class ScheduleMessagePrivate
233  *
234  * The ScheduleMessagePrivate class provides private implementation for the ScheduleMessage.
235  *
236  * \sa ScheduleMessage
237  */
238 
239 /*!
240  * \internal
241  *
242  * Constructs a ScheduleMessagePrivate object with public implementation \a q.
243  *
244  * \param q Pointer to public implementaton.
245  */
246 ScheduleMessagePrivate::ScheduleMessagePrivate(ScheduleMessage * const q)
248  , manufacturer(static_cast<Manufacturer>(-1))
249  , product(0xFFFF)
250  , serialNumber(0)
251  , timeCreated(static_cast<DateTime>(-1))
252  , completed(static_cast<bool>(-1))
253  , type(static_cast<Schedule>(-1))
254  , scheduledTime(static_cast<LocalDateTime>(-1))
255 {
256  globalMessageNumber = MesgNum::Schedule;
257 }
258 
259 /*!
260  * \internal
261  *
262  * Destroys the ScheduleMessagePrivate object.
263  */
265 {
266 
267 }
268 
270  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
271 {
272  switch (fieldId) {
273  case 0: // See Profile.xlsx::Messages:schedule.manufacturer
274  if (!verify(data, baseType, 2, FitBaseType::Uint16, "schedule.manufacturer")) return false;
275  this->manufacturer = static_cast<Manufacturer>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
276  break;
277  case 1: // See Profile.xlsx::Messages:schedule.product
278  if (!verify(data, baseType, 2, FitBaseType::Uint16, "schedule.product")) return false;
279  this->product = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
280  break;
281  case 2: // See Profile.xlsx::Messages:schedule.serialNumber
282  if (!verify(data, baseType, 4, FitBaseType::Uint32z, "schedule.serialNumber")) return false;
283  this->serialNumber = static_cast<quint32z>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
284  break;
285  case 3: // See Profile.xlsx::Messages:schedule.timeCreated
286  if (!verify(data, baseType, 4, FitBaseType::Uint32, "schedule.timeCreated")) return false;
287  this->timeCreated = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
288  break;
289  case 4: // See Profile.xlsx::Messages:schedule.completed
290  if (!verify(data, baseType, 0, FitBaseType::Byte, "schedule.completed")) return false;
291  this->completed = static_cast<bool>(data.at(0));
292  break;
293  case 5: // See Profile.xlsx::Messages:schedule.type
294  if (!verify(data, baseType, 1, FitBaseType::Enum, "schedule.type")) return false;
295  this->type = static_cast<Schedule>(data.at(0));
296  break;
297  case 6: // See Profile.xlsx::Messages:schedule.scheduledTime
298  if (!verify(data, baseType, 4, FitBaseType::Uint32, "schedule.scheduledTime")) return false;
299  this->scheduledTime = static_cast<LocalDateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
300  break;
301  default:
302  qWarning() << "ignoring unknown schedule message field number" << fieldId << bigEndian;
303  // Fall through to return true, as its still 'safe' to continue parsing data messages.
304  }
305  return true;
306 }
307 
308 /// \endcond
309 
#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.
quint32z serialNumber
The ScheduleMessage FIT message's serialNumber field.
quint16 product
The ScheduleMessage FIT message's product field.
bool completed
The ScheduleMessage FIT message's completed field.
Schedule type
The ScheduleMessage FIT message's type field.
DateTime timeCreated
The ScheduleMessage FIT message's timeCreated field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
LocalDateTime scheduledTime
The ScheduleMessage FIT message's scheduledTime field.
Manufacturer manufacturer
The ScheduleMessage FIT message's manufacturer field.
The ScheduleMessage class represents a FIT ScheduleMessage data message.
bool completed() const
Returns the ScheduleMessage data message's completed field's current value.
void setManufacturer(const Manufacturer manufacturer)
Sets the manufacturer field to manufacturer.
LocalDateTime scheduledTime() const
Returns the ScheduleMessage data message's scheduledTime field's current value.
Schedule type() const
Returns the ScheduleMessage data message's type field's current value.
void setScheduledTime(const LocalDateTime scheduledTime)
Sets the scheduledTime field to scheduledTime.
void setProduct(const quint16 product)
Sets the product field to product.
quint16 product() const
Returns the ScheduleMessage data message's product field's current value.
ScheduleMessage()
Constructs a ScheduleMessage object.
void setSerialNumber(const quint32z serialNumber)
Sets the serialNumber field to serialNumber.
quint32z serialNumber() const
Returns the ScheduleMessage data message's serialNumber field's current value.
void setTimeCreated(const DateTime timeCreated)
Sets the timeCreated field to timeCreated.
Manufacturer manufacturer() const
Returns the ScheduleMessage data message's manufacturer field's current value.
DateTime timeCreated() const
Returns the ScheduleMessage data message's timeCreated field's current value.
void setType(const Schedule type)
Sets the type field to type.
void setCompleted(const bool completed)
Sets the completed field to completed.
Declares the ScheduleMessage class.
Declares the ScheduleMessagePrivate class.
LocalDateTime
Seconds since 00:00 Dec 31 1989 in local time zone.
Definition: types.h:250
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
Schedule
Garmin FIT Schedule type.
Definition: types.h:1432
Manufacturer
Garmin FIT Manufacturer type.
Definition: types.h:1484
quint32 quint32z
32-bit unsigned integer, with 0-is-invalid semantics.
Definition: types.h:47
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237