QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
aviationattitudemessage.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 AviationAttitudeMessage, and AviationAttitudeMessagePrivate classes.
28  */
29 
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class AviationAttitudeMessage
40  *
41  * The AviationAttitudeMessage class represents a FIT AviationAttitudeMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a AviationAttitudeMessage 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 AviationAttitudeMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the AviationAttitudeMessage data message's \c timestamp field's current value.
71  *
72  * Timestamp message was output
73  *
74  * \return the \c timestamp field value.
75  */
77 {
78  Q_D(const AviationAttitudeMessage);
79  return d->timestamp;
80 }
81 
82 /*!
83  * Returns the AviationAttitudeMessage data message's \c timestampMs field's current value.
84  *
85  * Fractional part of timestamp, added to timestamp
86  *
87  * \return the \c timestampMs field value.
88  */
90 {
91  Q_D(const AviationAttitudeMessage);
92  return d->timestampMs;
93 }
94 
95 /*!
96  * Returns the AviationAttitudeMessage data message's \c systemTime field's current value.
97  *
98  * System time associated with sample expressed in ms.
99  *
100  * \return the \c systemTime field value.
101  */
103 {
104  Q_D(const AviationAttitudeMessage);
105  return d->systemTime;
106 }
107 
108 /*!
109  * Returns the AviationAttitudeMessage data message's \c pitch field's current value.
110  *
111  * Range -PI/2 to +PI/2
112  *
113  * \return the \c pitch field value.
114  */
116 {
117  Q_D(const AviationAttitudeMessage);
118  return d->pitch;
119 }
120 
121 /*!
122  * Returns the AviationAttitudeMessage data message's \c roll field's current value.
123  *
124  * Range -PI to +PI
125  *
126  * \return the \c roll field value.
127  */
129 {
130  Q_D(const AviationAttitudeMessage);
131  return d->roll;
132 }
133 
134 /*!
135  * Returns the AviationAttitudeMessage data message's \c accelLateral field's current value.
136  *
137  * Range -78.4 to +78.4 (-8 Gs to 8 Gs)
138  *
139  * \return the \c accelLateral field value.
140  */
142 {
143  Q_D(const AviationAttitudeMessage);
144  return d->accelLateral;
145 }
146 
147 /*!
148  * Returns the AviationAttitudeMessage data message's \c accelNormal field's current value.
149  *
150  * Range -78.4 to +78.4 (-8 Gs to 8 Gs)
151  *
152  * \return the \c accelNormal field value.
153  */
155 {
156  Q_D(const AviationAttitudeMessage);
157  return d->accelNormal;
158 }
159 
160 /*!
161  * Returns the AviationAttitudeMessage data message's \c turnRate field's current value.
162  *
163  * Range -8.727 to +8.727 (-500 degs/sec to +500 degs/sec)
164  *
165  * \return the \c turnRate field value.
166  */
168 {
169  Q_D(const AviationAttitudeMessage);
170  return d->turnRate;
171 }
172 
173 /*!
174  * Returns the AviationAttitudeMessage data message's \c stage field's current value.
175  *
176  * \return the \c stage field value.
177  */
179 {
180  Q_D(const AviationAttitudeMessage);
181  return d->stage;
182 }
183 
184 /*!
185  * Returns the AviationAttitudeMessage data message's \c attitudeStageComplete field's current value.
186  *
187  * The percent complete of the current attitude stage. Set to 0 for attitude stages 0, 1 and 2
188  * and to 100 for attitude stage 3 by AHRS modules that do not support it. Range - 100
189  *
190  * \return the \c attitudeStageComplete field value.
191  */
193 {
194  Q_D(const AviationAttitudeMessage);
195  return d->attitudeStageComplete;
196 }
197 
198 /*!
199  * Returns the AviationAttitudeMessage data message's \c track field's current value.
200  *
201  * Track Angle/Heading Range 0 - 2pi
202  *
203  * \return the \c track field value.
204  */
206 {
207  Q_D(const AviationAttitudeMessage);
208  return d->track;
209 }
210 
211 /*!
212  * Returns the AviationAttitudeMessage data message's \c validity field's current value.
213  *
214  * \return the \c validity field value.
215  */
217 {
218  Q_D(const AviationAttitudeMessage);
219  return d->validity;
220 }
221 
222 /*!
223  * Sets the \c timestamp field to \a timestamp.
224  *
225  * \param timestamp The field value to set.
226  */
228 {
230  d->timestamp = timestamp;
231 }
232 /*!
233  * Sets the \c timestampMs field to \a timestampMs.
234  *
235  * \param timestampMs The field value to set.
236  */
237 void AviationAttitudeMessage::setTimestampMs(const quint16 timestampMs)
238 {
240  d->timestampMs = timestampMs;
241 }
242 /*!
243  * Sets the \c systemTime field to \a systemTime.
244  *
245  * \param systemTime The field value to set.
246  */
247 void AviationAttitudeMessage::setSystemTime(const quint32 systemTime)
248 {
250  d->systemTime = systemTime;
251 }
252 /*!
253  * Sets the \c pitch field to \a pitch.
254  *
255  * \param pitch The field value to set.
256  */
257 void AviationAttitudeMessage::setPitch(const qint16 pitch)
258 {
260  d->pitch = pitch;
261 }
262 /*!
263  * Sets the \c roll field to \a roll.
264  *
265  * \param roll The field value to set.
266  */
267 void AviationAttitudeMessage::setRoll(const qint16 roll)
268 {
270  d->roll = roll;
271 }
272 /*!
273  * Sets the \c accelLateral field to \a accelLateral.
274  *
275  * \param accelLateral The field value to set.
276  */
277 void AviationAttitudeMessage::setAccelLateral(const qint16 accelLateral)
278 {
280  d->accelLateral = accelLateral;
281 }
282 /*!
283  * Sets the \c accelNormal field to \a accelNormal.
284  *
285  * \param accelNormal The field value to set.
286  */
287 void AviationAttitudeMessage::setAccelNormal(const qint16 accelNormal)
288 {
290  d->accelNormal = accelNormal;
291 }
292 /*!
293  * Sets the \c turnRate field to \a turnRate.
294  *
295  * \param turnRate The field value to set.
296  */
297 void AviationAttitudeMessage::setTurnRate(const qint16 turnRate)
298 {
300  d->turnRate = turnRate;
301 }
302 /*!
303  * Sets the \c stage field to \a stage.
304  *
305  * \param stage The field value to set.
306  */
308 {
310  d->stage = stage;
311 }
312 /*!
313  * Sets the \c attitudeStageComplete field to \a attitudeStageComplete.
314  *
315  * \param attitudeStageComplete The field value to set.
316  */
317 void AviationAttitudeMessage::setAttitudeStageComplete(const quint8 attitudeStageComplete)
318 {
320  d->attitudeStageComplete = attitudeStageComplete;
321 }
322 /*!
323  * Sets the \c track field to \a track.
324  *
325  * \param track The field value to set.
326  */
327 void AviationAttitudeMessage::setTrack(const quint16 track)
328 {
330  d->track = track;
331 }
332 /*!
333  * Sets the \c validity field to \a validity.
334  *
335  * \param validity The field value to set.
336  */
338 {
340  d->validity = validity;
341 }
342 
343 /// \cond internal
344 
345 /*!
346  * \internal
347  *
348  * \class AviationAttitudeMessagePrivate
349  *
350  * The AviationAttitudeMessagePrivate class provides private implementation for the AviationAttitudeMessage.
351  *
352  * \sa AviationAttitudeMessage
353  */
354 
355 /*!
356  * \internal
357  *
358  * Constructs a AviationAttitudeMessagePrivate object with public implementation \a q.
359  *
360  * \param q Pointer to public implementaton.
361  */
362 AviationAttitudeMessagePrivate::AviationAttitudeMessagePrivate(AviationAttitudeMessage * const q)
364  , timestamp(static_cast<DateTime>(-1))
365  , timestampMs(0xFFFF)
366  , systemTime(0xFFFFFFFF)
367  , pitch(0x7FFF)
368  , roll(0x7FFF)
369  , accelLateral(0x7FFF)
370  , accelNormal(0x7FFF)
371  , turnRate(0x7FFF)
372  , stage(static_cast<AttitudeStage>(-1))
373  , attitudeStageComplete(0xFF)
374  , track(0xFFFF)
375  , validity(static_cast<AttitudeValidity>(-1))
376 {
377  globalMessageNumber = MesgNum::AviationAttitude;
378 }
379 
380 /*!
381  * \internal
382  *
383  * Destroys the AviationAttitudeMessagePrivate object.
384  */
386 {
387 
388 }
389 
391  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
392 {
393  switch (fieldId) {
394  case 253: // See Profile.xlsx::Messages:aviation_attitude.timestamp
395  if (!verify(data, baseType, 4, FitBaseType::Uint32, "aviation_attitude.timestamp")) return false;
396  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
397  break;
398  case 0: // See Profile.xlsx::Messages:aviation_attitude.timestampMs
399  if (!verify(data, baseType, 2, FitBaseType::Uint16, "aviation_attitude.timestampMs")) return false;
400  this->timestampMs = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
401  break;
402  case 1: // See Profile.xlsx::Messages:aviation_attitude.systemTime
403  if (!verify(data, baseType, 4, FitBaseType::Uint32, "aviation_attitude.systemTime")) return false;
404  this->systemTime = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
405  break;
406  case 2: // See Profile.xlsx::Messages:aviation_attitude.pitch
407  if (!verify(data, baseType, 2, FitBaseType::Sint16, "aviation_attitude.pitch")) return false;
408  this->pitch = static_cast<qint16>(bigEndian ? qFromBigEndian< qint16>(data) : qFromLittleEndian< qint16>(data));
409  break;
410  case 3: // See Profile.xlsx::Messages:aviation_attitude.roll
411  if (!verify(data, baseType, 2, FitBaseType::Sint16, "aviation_attitude.roll")) return false;
412  this->roll = static_cast<qint16>(bigEndian ? qFromBigEndian< qint16>(data) : qFromLittleEndian< qint16>(data));
413  break;
414  case 4: // See Profile.xlsx::Messages:aviation_attitude.accelLateral
415  if (!verify(data, baseType, 2, FitBaseType::Sint16, "aviation_attitude.accelLateral")) return false;
416  this->accelLateral = static_cast<qint16>(bigEndian ? qFromBigEndian< qint16>(data) : qFromLittleEndian< qint16>(data));
417  break;
418  case 5: // See Profile.xlsx::Messages:aviation_attitude.accelNormal
419  if (!verify(data, baseType, 2, FitBaseType::Sint16, "aviation_attitude.accelNormal")) return false;
420  this->accelNormal = static_cast<qint16>(bigEndian ? qFromBigEndian< qint16>(data) : qFromLittleEndian< qint16>(data));
421  break;
422  case 6: // See Profile.xlsx::Messages:aviation_attitude.turnRate
423  if (!verify(data, baseType, 2, FitBaseType::Sint16, "aviation_attitude.turnRate")) return false;
424  this->turnRate = static_cast<qint16>(bigEndian ? qFromBigEndian< qint16>(data) : qFromLittleEndian< qint16>(data));
425  break;
426  case 7: // See Profile.xlsx::Messages:aviation_attitude.stage
427  if (!verify(data, baseType, 1, FitBaseType::Enum, "aviation_attitude.stage")) return false;
428  this->stage = static_cast<AttitudeStage>(data.at(0));
429  break;
430  case 8: // See Profile.xlsx::Messages:aviation_attitude.attitudeStageComplete
431  if (!verify(data, baseType, 1, FitBaseType::Uint8, "aviation_attitude.attitudeStageComplete")) return false;
432  this->attitudeStageComplete = static_cast<quint8>(data.at(0));
433  break;
434  case 9: // See Profile.xlsx::Messages:aviation_attitude.track
435  if (!verify(data, baseType, 2, FitBaseType::Uint16, "aviation_attitude.track")) return false;
436  this->track = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
437  break;
438  case 10: // See Profile.xlsx::Messages:aviation_attitude.validity
439  if (!verify(data, baseType, 2, FitBaseType::Uint16, "aviation_attitude.validity")) return false;
440  this->validity = static_cast<AttitudeValidity>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
441  break;
442  default:
443  qWarning() << "ignoring unknown aviation_attitude message field number" << fieldId << bigEndian;
444  // Fall through to return true, as its still 'safe' to continue parsing data messages.
445  }
446  return true;
447 }
448 
449 /// \endcond
450 
#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 AviationAttitudeMessage class.
Declares the AviationAttitudeMessagePrivate 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.
qint16 accelNormal
The AviationAttitudeMessage FIT message's accelNormal field.
quint16 track
The AviationAttitudeMessage FIT message's track field.
quint8 attitudeStageComplete
The AviationAttitudeMessage FIT message's attitudeStageComplete field.
qint16 roll
The AviationAttitudeMessage FIT message's roll field.
qint16 turnRate
The AviationAttitudeMessage FIT message's turnRate field.
quint16 timestampMs
The AviationAttitudeMessage FIT message's timestampMs field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
qint16 pitch
The AviationAttitudeMessage FIT message's pitch field.
DateTime timestamp
The AviationAttitudeMessage FIT message's timestamp field.
qint16 accelLateral
The AviationAttitudeMessage FIT message's accelLateral field.
AttitudeValidity validity
The AviationAttitudeMessage FIT message's validity field.
AttitudeStage stage
The AviationAttitudeMessage FIT message's stage field.
quint32 systemTime
The AviationAttitudeMessage FIT message's systemTime field.
The AviationAttitudeMessage class represents a FIT AviationAttitudeMessage data message.
void setSystemTime(const quint32 systemTime)
Sets the systemTime field to systemTime.
void setPitch(const qint16 pitch)
Sets the pitch field to pitch.
void setAttitudeStageComplete(const quint8 attitudeStageComplete)
Sets the attitudeStageComplete field to attitudeStageComplete.
qint16 pitch() const
Returns the AviationAttitudeMessage data message's pitch field's current value.
qint16 roll() const
Returns the AviationAttitudeMessage data message's roll field's current value.
void setTrack(const quint16 track)
Sets the track field to track.
qint16 turnRate() const
Returns the AviationAttitudeMessage data message's turnRate field's current value.
AttitudeValidity validity() const
Returns the AviationAttitudeMessage data message's validity field's current value.
void setRoll(const qint16 roll)
Sets the roll field to roll.
void setTimestampMs(const quint16 timestampMs)
Sets the timestampMs field to timestampMs.
void setAccelLateral(const qint16 accelLateral)
Sets the accelLateral field to accelLateral.
void setAccelNormal(const qint16 accelNormal)
Sets the accelNormal field to accelNormal.
quint32 systemTime() const
Returns the AviationAttitudeMessage data message's systemTime field's current value.
void setValidity(const AttitudeValidity validity)
Sets the validity field to validity.
AviationAttitudeMessage()
Constructs a AviationAttitudeMessage object.
quint16 track() const
Returns the AviationAttitudeMessage data message's track field's current value.
DateTime timestamp() const
Returns the AviationAttitudeMessage data message's timestamp field's current value.
qint16 accelNormal() const
Returns the AviationAttitudeMessage data message's accelNormal field's current value.
qint16 accelLateral() const
Returns the AviationAttitudeMessage data message's accelLateral field's current value.
void setStage(const AttitudeStage stage)
Sets the stage field to stage.
quint16 timestampMs() const
Returns the AviationAttitudeMessage data message's timestampMs field's current value.
quint8 attitudeStageComplete() const
Returns the AviationAttitudeMessage data message's attitudeStageComplete field's current value.
void setTurnRate(const qint16 turnRate)
Sets the turnRate field to turnRate.
AttitudeStage stage() const
Returns the AviationAttitudeMessage data message's stage field's current value.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
AttitudeValidity
Garmin FIT AttitudeValidity type.
Definition: types.h:3036
AttitudeStage
Garmin FIT AttitudeStage type.
Definition: types.h:3020
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237