QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
eventmessage.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 EventMessage, and EventMessagePrivate classes.
28  */
29 
30 #include "eventmessage.h"
31 #include "eventmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class EventMessage
40  *
41  * The EventMessage class represents a FIT EventMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a EventMessage 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 EventMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the EventMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const EventMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the EventMessage data message's \c event field's current value.
82  *
83  * \return the \c event field value.
84  */
86 {
87  Q_D(const EventMessage);
88  return d->event;
89 }
90 
91 /*!
92  * Returns the EventMessage data message's \c eventType field's current value.
93  *
94  * \return the \c eventType field value.
95  */
97 {
98  Q_D(const EventMessage);
99  return d->eventType;
100 }
101 
102 /*!
103  * Returns the EventMessage data message's \c data16 field's current value.
104  *
105  * \return the \c data16 field value.
106  */
107 quint16 EventMessage::data16() const
108 {
109  Q_D(const EventMessage);
110  return d->data16;
111 }
112 
113 /*!
114  * Returns the EventMessage data message's \c data field's current value.
115  *
116  * \return the \c data field value.
117  */
118 quint32 EventMessage::data() const
119 {
120  Q_D(const EventMessage);
121  return d->data;
122 }
123 
124 /*!
125  * Returns the EventMessage data message's \c eventGroup field's current value.
126  *
127  * \return the \c eventGroup field value.
128  */
130 {
131  Q_D(const EventMessage);
132  return d->eventGroup;
133 }
134 
135 /*!
136  * Returns the EventMessage data message's \c score field's current value.
137  *
138  * Do not populate directly. Autogenerated by decoder for sport_point subfield components
139  *
140  * \return the \c score field value.
141  */
142 quint16 EventMessage::score() const
143 {
144  Q_D(const EventMessage);
145  return d->score;
146 }
147 
148 /*!
149  * Returns the EventMessage data message's \c opponentScore field's current value.
150  *
151  * Do not populate directly. Autogenerated by decoder for sport_point subfield components
152  *
153  * \return the \c opponentScore field value.
154  */
156 {
157  Q_D(const EventMessage);
158  return d->opponentScore;
159 }
160 
161 /*!
162  * Returns the EventMessage data message's \c frontGearNum field's current value.
163  *
164  * Do not populate directly. Autogenerated by decoder for gear_change subfield components.
165  * Front gear number. 1 is innermost.
166  *
167  * \return the \c frontGearNum field value.
168  */
170 {
171  Q_D(const EventMessage);
172  return d->frontGearNum;
173 }
174 
175 /*!
176  * Returns the EventMessage data message's \c frontGear field's current value.
177  *
178  * Do not populate directly. Autogenerated by decoder for gear_change subfield components.
179  * Number of front teeth.
180  *
181  * \return the \c frontGear field value.
182  */
184 {
185  Q_D(const EventMessage);
186  return d->frontGear;
187 }
188 
189 /*!
190  * Returns the EventMessage data message's \c rearGearNum field's current value.
191  *
192  * Do not populate directly. Autogenerated by decoder for gear_change subfield components. Rear
193  * gear number. 1 is innermost.
194  *
195  * \return the \c rearGearNum field value.
196  */
198 {
199  Q_D(const EventMessage);
200  return d->rearGearNum;
201 }
202 
203 /*!
204  * Returns the EventMessage data message's \c rearGear field's current value.
205  *
206  * Do not populate directly. Autogenerated by decoder for gear_change subfield components.
207  * Number of rear teeth.
208  *
209  * \return the \c rearGear field value.
210  */
212 {
213  Q_D(const EventMessage);
214  return d->rearGear;
215 }
216 
217 /*!
218  * Returns the EventMessage data message's \c deviceIndex field's current value.
219  *
220  * \return the \c deviceIndex field value.
221  */
223 {
224  Q_D(const EventMessage);
225  return d->deviceIndex;
226 }
227 
228 /*!
229  * Returns the EventMessage data message's \c radarThreatLevelMax field's current value.
230  *
231  * Do not populate directly. Autogenerated by decoder for threat_alert subfield components.
232  *
233  * \return the \c radarThreatLevelMax field value.
234  */
236 {
237  Q_D(const EventMessage);
238  return d->radarThreatLevelMax;
239 }
240 
241 /*!
242  * Returns the EventMessage data message's \c radarThreatCount field's current value.
243  *
244  * Do not populate directly. Autogenerated by decoder for threat_alert subfield components.
245  *
246  * \return the \c radarThreatCount field value.
247  */
249 {
250  Q_D(const EventMessage);
251  return d->radarThreatCount;
252 }
253 
254 /*!
255  * Sets the \c timestamp field to \a timestamp.
256  *
257  * \param timestamp The field value to set.
258  */
260 {
261  Q_D(EventMessage);
262  d->timestamp = timestamp;
263 }
264 /*!
265  * Sets the \c event field to \a event.
266  *
267  * \param event The field value to set.
268  */
269 void EventMessage::setEvent(const Event event)
270 {
271  Q_D(EventMessage);
272  d->event = event;
273 }
274 /*!
275  * Sets the \c eventType field to \a eventType.
276  *
277  * \param eventType The field value to set.
278  */
280 {
281  Q_D(EventMessage);
282  d->eventType = eventType;
283 }
284 /*!
285  * Sets the \c data16 field to \a data16.
286  *
287  * \param data16 The field value to set.
288  */
289 void EventMessage::setData16(const quint16 data16)
290 {
291  Q_D(EventMessage);
292  d->data16 = data16;
293 }
294 /*!
295  * Sets the \c data field to \a data.
296  *
297  * \param data The field value to set.
298  */
299 void EventMessage::setData(const quint32 data)
300 {
301  Q_D(EventMessage);
302  d->data = data;
303 }
304 /*!
305  * Sets the \c eventGroup field to \a eventGroup.
306  *
307  * \param eventGroup The field value to set.
308  */
309 void EventMessage::setEventGroup(const quint8 eventGroup)
310 {
311  Q_D(EventMessage);
312  d->eventGroup = eventGroup;
313 }
314 /*!
315  * Sets the \c score field to \a score.
316  *
317  * \param score The field value to set.
318  */
319 void EventMessage::setScore(const quint16 score)
320 {
321  Q_D(EventMessage);
322  d->score = score;
323 }
324 /*!
325  * Sets the \c opponentScore field to \a opponentScore.
326  *
327  * \param opponentScore The field value to set.
328  */
329 void EventMessage::setOpponentScore(const quint16 opponentScore)
330 {
331  Q_D(EventMessage);
332  d->opponentScore = opponentScore;
333 }
334 /*!
335  * Sets the \c frontGearNum field to \a frontGearNum.
336  *
337  * \param frontGearNum The field value to set.
338  */
339 void EventMessage::setFrontGearNum(const quint8z frontGearNum)
340 {
341  Q_D(EventMessage);
342  d->frontGearNum = frontGearNum;
343 }
344 /*!
345  * Sets the \c frontGear field to \a frontGear.
346  *
347  * \param frontGear The field value to set.
348  */
349 void EventMessage::setFrontGear(const quint8z frontGear)
350 {
351  Q_D(EventMessage);
352  d->frontGear = frontGear;
353 }
354 /*!
355  * Sets the \c rearGearNum field to \a rearGearNum.
356  *
357  * \param rearGearNum The field value to set.
358  */
359 void EventMessage::setRearGearNum(const quint8z rearGearNum)
360 {
361  Q_D(EventMessage);
362  d->rearGearNum = rearGearNum;
363 }
364 /*!
365  * Sets the \c rearGear field to \a rearGear.
366  *
367  * \param rearGear The field value to set.
368  */
369 void EventMessage::setRearGear(const quint8z rearGear)
370 {
371  Q_D(EventMessage);
372  d->rearGear = rearGear;
373 }
374 /*!
375  * Sets the \c deviceIndex field to \a deviceIndex.
376  *
377  * \param deviceIndex The field value to set.
378  */
380 {
381  Q_D(EventMessage);
382  d->deviceIndex = deviceIndex;
383 }
384 /*!
385  * Sets the \c radarThreatLevelMax field to \a radarThreatLevelMax.
386  *
387  * \param radarThreatLevelMax The field value to set.
388  */
390 {
391  Q_D(EventMessage);
392  d->radarThreatLevelMax = radarThreatLevelMax;
393 }
394 /*!
395  * Sets the \c radarThreatCount field to \a radarThreatCount.
396  *
397  * \param radarThreatCount The field value to set.
398  */
399 void EventMessage::setRadarThreatCount(const quint8 radarThreatCount)
400 {
401  Q_D(EventMessage);
402  d->radarThreatCount = radarThreatCount;
403 }
404 
405 /// \cond internal
406 
407 /*!
408  * \internal
409  *
410  * \class EventMessagePrivate
411  *
412  * The EventMessagePrivate class provides private implementation for the EventMessage.
413  *
414  * \sa EventMessage
415  */
416 
417 /*!
418  * \internal
419  *
420  * Constructs a EventMessagePrivate object with public implementation \a q.
421  *
422  * \param q Pointer to public implementaton.
423  */
424 EventMessagePrivate::EventMessagePrivate(EventMessage * const q)
426  , timestamp(static_cast<DateTime>(-1))
427  , event(static_cast<Event>(-1))
428  , eventType(static_cast<EventType>(-1))
429  , data16(0xFFFF)
430  , data(0xFFFFFFFF)
431  , eventGroup(0xFF)
432  , score(0xFFFF)
433  , opponentScore(0xFFFF)
434  , frontGearNum(static_cast<quint8z>(-1))
435  , frontGear(static_cast<quint8z>(-1))
436  , rearGearNum(static_cast<quint8z>(-1))
437  , rearGear(static_cast<quint8z>(-1))
438  , deviceIndex(static_cast<DeviceIndex>(-1))
439  , radarThreatLevelMax(static_cast<RadarThreatLevelType>(-1))
440  , radarThreatCount(0xFF)
441 {
442  globalMessageNumber = MesgNum::Event;
443 }
444 
445 /*!
446  * \internal
447  *
448  * Destroys the EventMessagePrivate object.
449  */
451 {
452 
453 }
454 
456  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
457 {
458  switch (fieldId) {
459  case 253: // See Profile.xlsx::Messages:event.timestamp
460  if (!verify(data, baseType, 4, FitBaseType::Uint32, "event.timestamp")) return false;
461  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
462  break;
463  case 0: // See Profile.xlsx::Messages:event.event
464  if (!verify(data, baseType, 1, FitBaseType::Enum, "event.event")) return false;
465  this->event = static_cast<Event>(data.at(0));
466  break;
467  case 1: // See Profile.xlsx::Messages:event.eventType
468  if (!verify(data, baseType, 1, FitBaseType::Enum, "event.eventType")) return false;
469  this->eventType = static_cast<EventType>(data.at(0));
470  break;
471  case 2: // See Profile.xlsx::Messages:event.data16
472  if (!verify(data, baseType, 2, FitBaseType::Uint16, "event.data16")) return false;
473  this->data16 = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
474  break;
475  case 3: // See Profile.xlsx::Messages:event.data
476  if (!verify(data, baseType, 4, FitBaseType::Uint32, "event.data")) return false;
477  this->data = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
478  break;
479  case 4: // See Profile.xlsx::Messages:event.eventGroup
480  if (!verify(data, baseType, 1, FitBaseType::Uint8, "event.eventGroup")) return false;
481  this->eventGroup = static_cast<quint8>(data.at(0));
482  break;
483  case 7: // See Profile.xlsx::Messages:event.score
484  if (!verify(data, baseType, 2, FitBaseType::Uint16, "event.score")) return false;
485  this->score = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
486  break;
487  case 8: // See Profile.xlsx::Messages:event.opponentScore
488  if (!verify(data, baseType, 2, FitBaseType::Uint16, "event.opponentScore")) return false;
489  this->opponentScore = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
490  break;
491  case 9: // See Profile.xlsx::Messages:event.frontGearNum
492  if (!verify(data, baseType, 1, FitBaseType::Uint8z, "event.frontGearNum")) return false;
493  this->frontGearNum = static_cast<quint8z>(data.at(0));
494  break;
495  case 10: // See Profile.xlsx::Messages:event.frontGear
496  if (!verify(data, baseType, 1, FitBaseType::Uint8z, "event.frontGear")) return false;
497  this->frontGear = static_cast<quint8z>(data.at(0));
498  break;
499  case 11: // See Profile.xlsx::Messages:event.rearGearNum
500  if (!verify(data, baseType, 1, FitBaseType::Uint8z, "event.rearGearNum")) return false;
501  this->rearGearNum = static_cast<quint8z>(data.at(0));
502  break;
503  case 12: // See Profile.xlsx::Messages:event.rearGear
504  if (!verify(data, baseType, 1, FitBaseType::Uint8z, "event.rearGear")) return false;
505  this->rearGear = static_cast<quint8z>(data.at(0));
506  break;
507  case 13: // See Profile.xlsx::Messages:event.deviceIndex
508  if (!verify(data, baseType, 1, FitBaseType::Uint8, "event.deviceIndex")) return false;
509  this->deviceIndex = static_cast<DeviceIndex>(data.at(0));
510  break;
511  case 21: // See Profile.xlsx::Messages:event.radarThreatLevelMax
512  if (!verify(data, baseType, 1, FitBaseType::Enum, "event.radarThreatLevelMax")) return false;
513  this->radarThreatLevelMax = static_cast<RadarThreatLevelType>(data.at(0));
514  break;
515  case 22: // See Profile.xlsx::Messages:event.radarThreatCount
516  if (!verify(data, baseType, 1, FitBaseType::Uint8, "event.radarThreatCount")) return false;
517  this->radarThreatCount = static_cast<quint8>(data.at(0));
518  break;
519  default:
520  qWarning() << "ignoring unknown event message field number" << fieldId << bigEndian;
521  // Fall through to return true, as its still 'safe' to continue parsing data messages.
522  }
523  return true;
524 }
525 
526 /// \endcond
527 
#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.
DateTime timestamp
The EventMessage FIT message's timestamp field.
quint8z frontGearNum
The EventMessage FIT message's frontGearNum field.
quint8 radarThreatCount
The EventMessage FIT message's radarThreatCount field.
virtual ~EventMessagePrivate()
EventType eventType
The EventMessage FIT message's eventType field.
RadarThreatLevelType radarThreatLevelMax
The EventMessage FIT message's radarThreatLevelMax field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
quint8z rearGearNum
The EventMessage FIT message's rearGearNum field.
quint16 score
The EventMessage FIT message's score field.
quint8z frontGear
The EventMessage FIT message's frontGear field.
quint8 eventGroup
The EventMessage FIT message's eventGroup field.
quint16 opponentScore
The EventMessage FIT message's opponentScore field.
quint32 data
The EventMessage FIT message's data field.
quint8z rearGear
The EventMessage FIT message's rearGear field.
quint16 data16
The EventMessage FIT message's data16 field.
DeviceIndex deviceIndex
The EventMessage FIT message's deviceIndex field.
The EventMessage class represents a FIT EventMessage data message.
Definition: eventmessage.h:39
quint8z rearGear() const
Returns the EventMessage data message's rearGear field's current value.
quint16 data16() const
Returns the EventMessage data message's data16 field's current value.
EventMessage()
Constructs a EventMessage object.
EventType eventType() const
Returns the EventMessage data message's eventType field's current value.
quint32 data() const
Returns the EventMessage data message's data field's current value.
DeviceIndex deviceIndex() const
Returns the EventMessage data message's deviceIndex field's current value.
DateTime timestamp() const
Returns the EventMessage data message's timestamp field's current value.
void setRadarThreatLevelMax(const RadarThreatLevelType radarThreatLevelMax)
Sets the radarThreatLevelMax field to radarThreatLevelMax.
quint8z frontGearNum() const
Returns the EventMessage data message's frontGearNum field's current value.
void setRearGearNum(const quint8z rearGearNum)
Sets the rearGearNum field to rearGearNum.
void setFrontGear(const quint8z frontGear)
Sets the frontGear field to frontGear.
quint8z frontGear() const
Returns the EventMessage data message's frontGear field's current value.
void setRadarThreatCount(const quint8 radarThreatCount)
Sets the radarThreatCount field to radarThreatCount.
void setData16(const quint16 data16)
Sets the data16 field to data16.
Event event() const
Returns the EventMessage data message's event field's current value.
void setEventType(const EventType eventType)
Sets the eventType field to eventType.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
quint8 eventGroup() const
Returns the EventMessage data message's eventGroup field's current value.
void setRearGear(const quint8z rearGear)
Sets the rearGear field to rearGear.
void setDeviceIndex(const DeviceIndex deviceIndex)
Sets the deviceIndex field to deviceIndex.
void setData(const quint32 data)
Sets the data field to data.
RadarThreatLevelType radarThreatLevelMax() const
Returns the EventMessage data message's radarThreatLevelMax field's current value.
void setFrontGearNum(const quint8z frontGearNum)
Sets the frontGearNum field to frontGearNum.
quint16 opponentScore() const
Returns the EventMessage data message's opponentScore field's current value.
quint16 score() const
Returns the EventMessage data message's score field's current value.
void setEventGroup(const quint8 eventGroup)
Sets the eventGroup field to eventGroup.
void setOpponentScore(const quint16 opponentScore)
Sets the opponentScore field to opponentScore.
quint8 radarThreatCount() const
Returns the EventMessage data message's radarThreatCount field's current value.
quint8z rearGearNum() const
Returns the EventMessage data message's rearGearNum field's current value.
void setEvent(const Event event)
Sets the event field to event.
void setScore(const quint16 score)
Sets the score field to score.
Declares the EventMessage class.
Declares the EventMessagePrivate class.
EventType
Garmin FIT EventType type.
Definition: types.h:1182
RadarThreatLevelType
Garmin FIT RadarThreatLevelType type.
Definition: types.h:5307
DeviceIndex
Garmin FIT DeviceIndex type.
Definition: types.h:278
Event
Garmin FIT Event type.
Definition: types.h:1133
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
QTFIT_BEGIN_NAMESPACE typedef quint8 quint8z
8-bit unsigned integer, with 0-is-invalid semantics.
Definition: types.h:45
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237