QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
antrxmessage.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 AntRxMessage, and AntRxMessagePrivate classes.
28  */
29 
30 #include "antrxmessage.h"
31 #include "antrxmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class AntRxMessage
40  *
41  * The AntRxMessage class represents a FIT AntRxMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a AntRxMessage 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 AntRxMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the AntRxMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const AntRxMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the AntRxMessage data message's \c fractionalTimestamp field's current value.
82  *
83  * \return the \c fractionalTimestamp field value.
84  */
86 {
87  Q_D(const AntRxMessage);
88  return d->fractionalTimestamp;
89 }
90 
91 /*!
92  * Returns the AntRxMessage data message's \c mesgId field's current value.
93  *
94  * \return the \c mesgId field value.
95  */
96 quint8 AntRxMessage::mesgId() const
97 {
98  Q_D(const AntRxMessage);
99  return d->mesgId;
100 }
101 
102 /*!
103  * Returns the AntRxMessage data message's \c mesgData field's current value.
104  *
105  * \return the \c mesgData field value.
106  */
108 {
109  Q_D(const AntRxMessage);
110  return d->mesgData;
111 }
112 
113 /*!
114  * Returns the AntRxMessage data message's \c channelNumber field's current value.
115  *
116  * \return the \c channelNumber field value.
117  */
119 {
120  Q_D(const AntRxMessage);
121  return d->channelNumber;
122 }
123 
124 /*!
125  * Returns the AntRxMessage data message's \c data field's current value.
126  *
127  * \return the \c data field value.
128  */
129 quint8 AntRxMessage::data() const
130 {
131  Q_D(const AntRxMessage);
132  return d->data;
133 }
134 
135 /*!
136  * Sets the \c timestamp field to \a timestamp.
137  *
138  * \param timestamp The field value to set.
139  */
141 {
142  Q_D(AntRxMessage);
143  d->timestamp = timestamp;
144 }
145 /*!
146  * Sets the \c fractionalTimestamp field to \a fractionalTimestamp.
147  *
148  * \param fractionalTimestamp The field value to set.
149  */
150 void AntRxMessage::setFractionalTimestamp(const quint16 fractionalTimestamp)
151 {
152  Q_D(AntRxMessage);
153  d->fractionalTimestamp = fractionalTimestamp;
154 }
155 /*!
156  * Sets the \c mesgId field to \a mesgId.
157  *
158  * \param mesgId The field value to set.
159  */
160 void AntRxMessage::setMesgId(const quint8 mesgId)
161 {
162  Q_D(AntRxMessage);
163  d->mesgId = mesgId;
164 }
165 /*!
166  * Sets the \c mesgData field to \a mesgData.
167  *
168  * \param mesgData The field value to set.
169  */
170 void AntRxMessage::setMesgData(const quint8 mesgData)
171 {
172  Q_D(AntRxMessage);
173  d->mesgData = mesgData;
174 }
175 /*!
176  * Sets the \c channelNumber field to \a channelNumber.
177  *
178  * \param channelNumber The field value to set.
179  */
180 void AntRxMessage::setChannelNumber(const quint8 channelNumber)
181 {
182  Q_D(AntRxMessage);
183  d->channelNumber = channelNumber;
184 }
185 /*!
186  * Sets the \c data field to \a data.
187  *
188  * \param data The field value to set.
189  */
190 void AntRxMessage::setData(const quint8 data)
191 {
192  Q_D(AntRxMessage);
193  d->data = data;
194 }
195 
196 /// \cond internal
197 
198 /*!
199  * \internal
200  *
201  * \class AntRxMessagePrivate
202  *
203  * The AntRxMessagePrivate class provides private implementation for the AntRxMessage.
204  *
205  * \sa AntRxMessage
206  */
207 
208 /*!
209  * \internal
210  *
211  * Constructs a AntRxMessagePrivate object with public implementation \a q.
212  *
213  * \param q Pointer to public implementaton.
214  */
215 AntRxMessagePrivate::AntRxMessagePrivate(AntRxMessage * const q)
217  , timestamp(static_cast<DateTime>(-1))
218  , fractionalTimestamp(0xFFFF)
219  , mesgId(0xFF)
220  , mesgData(0xFF)
221  , channelNumber(0xFF)
222  , data(0xFF)
223 {
224  globalMessageNumber = MesgNum::AntRx;
225 }
226 
227 /*!
228  * \internal
229  *
230  * Destroys the AntRxMessagePrivate object.
231  */
233 {
234 
235 }
236 
238  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
239 {
240  switch (fieldId) {
241  case 253: // See Profile.xlsx::Messages:ant_rx.timestamp
242  if (!verify(data, baseType, 4, FitBaseType::Uint32, "ant_rx.timestamp")) return false;
243  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
244  break;
245  case 0: // See Profile.xlsx::Messages:ant_rx.fractionalTimestamp
246  if (!verify(data, baseType, 2, FitBaseType::Uint16, "ant_rx.fractionalTimestamp")) return false;
247  this->fractionalTimestamp = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
248  break;
249  case 1: // See Profile.xlsx::Messages:ant_rx.mesgId
250  if (!verify(data, baseType, 1, FitBaseType::Byte, "ant_rx.mesgId")) return false;
251  this->mesgId = static_cast<quint8>(data.at(0));
252  break;
253  case 2: // See Profile.xlsx::Messages:ant_rx.mesgData
254  if (!verify(data, baseType, 1, FitBaseType::Byte, "ant_rx.mesgData")) return false;
255  this->mesgData = static_cast<quint8>(data.at(0));
256  break;
257  case 3: // See Profile.xlsx::Messages:ant_rx.channelNumber
258  if (!verify(data, baseType, 1, FitBaseType::Uint8, "ant_rx.channelNumber")) return false;
259  this->channelNumber = static_cast<quint8>(data.at(0));
260  break;
261  case 4: // See Profile.xlsx::Messages:ant_rx.data
262  if (!verify(data, baseType, 1, FitBaseType::Byte, "ant_rx.data")) return false;
263  this->data = static_cast<quint8>(data.at(0));
264  break;
265  default:
266  qWarning() << "ignoring unknown ant_rx message field number" << fieldId << bigEndian;
267  // Fall through to return true, as its still 'safe' to continue parsing data messages.
268  }
269  return true;
270 }
271 
272 /// \endcond
273 
#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 AntRxMessage class.
Declares the AntRxMessagePrivate 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
quint16 fractionalTimestamp
The AntRxMessage FIT message's fractionalTimestamp field.
quint8 mesgData
The AntRxMessage FIT message's mesgData field.
quint8 channelNumber
The AntRxMessage FIT message's channelNumber field.
quint8 data
The AntRxMessage FIT message's data field.
quint8 mesgId
The AntRxMessage FIT message's mesgId field.
virtual ~AntRxMessagePrivate()
DateTime timestamp
The AntRxMessage FIT message's timestamp field.
The AntRxMessage class represents a FIT AntRxMessage data message.
Definition: antrxmessage.h:39
void setMesgData(const quint8 mesgData)
Sets the mesgData field to mesgData.
void setData(const quint8 data)
Sets the data field to data.
quint8 mesgId() const
Returns the AntRxMessage data message's mesgId field's current value.
DateTime timestamp() const
Returns the AntRxMessage data message's timestamp field's current value.
void setFractionalTimestamp(const quint16 fractionalTimestamp)
Sets the fractionalTimestamp field to fractionalTimestamp.
void setChannelNumber(const quint8 channelNumber)
Sets the channelNumber field to channelNumber.
quint8 mesgData() const
Returns the AntRxMessage data message's mesgData field's current value.
quint8 data() const
Returns the AntRxMessage data message's data field's current value.
quint16 fractionalTimestamp() const
Returns the AntRxMessage data message's fractionalTimestamp field's current value.
AntRxMessage()
Constructs a AntRxMessage object.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
quint8 channelNumber() const
Returns the AntRxMessage data message's channelNumber field's current value.
void setMesgId(const quint8 mesgId)
Sets the mesgId field to mesgId.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237