QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
anttxmessage.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 AntTxMessage, and AntTxMessagePrivate classes.
28  */
29 
30 #include "anttxmessage.h"
31 #include "anttxmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class AntTxMessage
40  *
41  * The AntTxMessage class represents a FIT AntTxMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a AntTxMessage 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 AntTxMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the AntTxMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const AntTxMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the AntTxMessage data message's \c fractionalTimestamp field's current value.
82  *
83  * \return the \c fractionalTimestamp field value.
84  */
86 {
87  Q_D(const AntTxMessage);
88  return d->fractionalTimestamp;
89 }
90 
91 /*!
92  * Returns the AntTxMessage data message's \c mesgId field's current value.
93  *
94  * \return the \c mesgId field value.
95  */
96 quint8 AntTxMessage::mesgId() const
97 {
98  Q_D(const AntTxMessage);
99  return d->mesgId;
100 }
101 
102 /*!
103  * Returns the AntTxMessage data message's \c mesgData field's current value.
104  *
105  * \return the \c mesgData field value.
106  */
108 {
109  Q_D(const AntTxMessage);
110  return d->mesgData;
111 }
112 
113 /*!
114  * Returns the AntTxMessage data message's \c channelNumber field's current value.
115  *
116  * \return the \c channelNumber field value.
117  */
119 {
120  Q_D(const AntTxMessage);
121  return d->channelNumber;
122 }
123 
124 /*!
125  * Returns the AntTxMessage data message's \c data field's current value.
126  *
127  * \return the \c data field value.
128  */
129 quint8 AntTxMessage::data() const
130 {
131  Q_D(const AntTxMessage);
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(AntTxMessage);
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 AntTxMessage::setFractionalTimestamp(const quint16 fractionalTimestamp)
151 {
152  Q_D(AntTxMessage);
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 AntTxMessage::setMesgId(const quint8 mesgId)
161 {
162  Q_D(AntTxMessage);
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 AntTxMessage::setMesgData(const quint8 mesgData)
171 {
172  Q_D(AntTxMessage);
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 AntTxMessage::setChannelNumber(const quint8 channelNumber)
181 {
182  Q_D(AntTxMessage);
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 AntTxMessage::setData(const quint8 data)
191 {
192  Q_D(AntTxMessage);
193  d->data = data;
194 }
195 
196 /// \cond internal
197 
198 /*!
199  * \internal
200  *
201  * \class AntTxMessagePrivate
202  *
203  * The AntTxMessagePrivate class provides private implementation for the AntTxMessage.
204  *
205  * \sa AntTxMessage
206  */
207 
208 /*!
209  * \internal
210  *
211  * Constructs a AntTxMessagePrivate object with public implementation \a q.
212  *
213  * \param q Pointer to public implementaton.
214  */
215 AntTxMessagePrivate::AntTxMessagePrivate(AntTxMessage * 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::AntTx;
225 }
226 
227 /*!
228  * \internal
229  *
230  * Destroys the AntTxMessagePrivate 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_tx.timestamp
242  if (!verify(data, baseType, 4, FitBaseType::Uint32, "ant_tx.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_tx.fractionalTimestamp
246  if (!verify(data, baseType, 2, FitBaseType::Uint16, "ant_tx.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_tx.mesgId
250  if (!verify(data, baseType, 1, FitBaseType::Byte, "ant_tx.mesgId")) return false;
251  this->mesgId = static_cast<quint8>(data.at(0));
252  break;
253  case 2: // See Profile.xlsx::Messages:ant_tx.mesgData
254  if (!verify(data, baseType, 1, FitBaseType::Byte, "ant_tx.mesgData")) return false;
255  this->mesgData = static_cast<quint8>(data.at(0));
256  break;
257  case 3: // See Profile.xlsx::Messages:ant_tx.channelNumber
258  if (!verify(data, baseType, 1, FitBaseType::Uint8, "ant_tx.channelNumber")) return false;
259  this->channelNumber = static_cast<quint8>(data.at(0));
260  break;
261  case 4: // See Profile.xlsx::Messages:ant_tx.data
262  if (!verify(data, baseType, 1, FitBaseType::Byte, "ant_tx.data")) return false;
263  this->data = static_cast<quint8>(data.at(0));
264  break;
265  default:
266  qWarning() << "ignoring unknown ant_tx 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 AntTxMessage class.
Declares the AntTxMessagePrivate 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.
quint8 mesgData
The AntTxMessage FIT message's mesgData field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
virtual ~AntTxMessagePrivate()
quint16 fractionalTimestamp
The AntTxMessage FIT message's fractionalTimestamp field.
quint8 data
The AntTxMessage FIT message's data field.
DateTime timestamp
The AntTxMessage FIT message's timestamp field.
quint8 channelNumber
The AntTxMessage FIT message's channelNumber field.
quint8 mesgId
The AntTxMessage FIT message's mesgId field.
The AntTxMessage class represents a FIT AntTxMessage data message.
Definition: anttxmessage.h:39
void setMesgId(const quint8 mesgId)
Sets the mesgId field to mesgId.
quint8 mesgId() const
Returns the AntTxMessage data message's mesgId field's current value.
void setFractionalTimestamp(const quint16 fractionalTimestamp)
Sets the fractionalTimestamp field to fractionalTimestamp.
quint8 data() const
Returns the AntTxMessage data message's data field's current value.
DateTime timestamp() const
Returns the AntTxMessage data message's timestamp field's current value.
void setChannelNumber(const quint8 channelNumber)
Sets the channelNumber field to channelNumber.
quint8 channelNumber() const
Returns the AntTxMessage data message's channelNumber field's current value.
quint16 fractionalTimestamp() const
Returns the AntTxMessage data message's fractionalTimestamp field's current value.
void setData(const quint8 data)
Sets the data field to data.
void setMesgData(const quint8 mesgData)
Sets the mesgData field to mesgData.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
AntTxMessage()
Constructs a AntTxMessage object.
quint8 mesgData() const
Returns the AntTxMessage data message's mesgData field's current value.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237