QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
nmeasentencemessage.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 NmeaSentenceMessage, and NmeaSentenceMessagePrivate classes.
28  */
29 
30 #include "nmeasentencemessage.h"
31 #include "nmeasentencemessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class NmeaSentenceMessage
40  *
41  * The NmeaSentenceMessage class represents a FIT NmeaSentenceMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a NmeaSentenceMessage 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 NmeaSentenceMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the NmeaSentenceMessage 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 NmeaSentenceMessage);
79  return d->timestamp;
80 }
81 
82 /*!
83  * Returns the NmeaSentenceMessage 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 NmeaSentenceMessage);
92  return d->timestampMs;
93 }
94 
95 /*!
96  * Returns the NmeaSentenceMessage data message's \c sentence field's current value.
97  *
98  * NMEA sentence
99  *
100  * \return the \c sentence field value.
101  */
103 {
104  Q_D(const NmeaSentenceMessage);
105  return d->sentence;
106 }
107 
108 /*!
109  * Sets the \c timestamp field to \a timestamp.
110  *
111  * \param timestamp The field value to set.
112  */
114 {
115  Q_D(NmeaSentenceMessage);
116  d->timestamp = timestamp;
117 }
118 /*!
119  * Sets the \c timestampMs field to \a timestampMs.
120  *
121  * \param timestampMs The field value to set.
122  */
123 void NmeaSentenceMessage::setTimestampMs(const quint16 timestampMs)
124 {
125  Q_D(NmeaSentenceMessage);
126  d->timestampMs = timestampMs;
127 }
128 /*!
129  * Sets the \c sentence field to \a sentence.
130  *
131  * \param sentence The field value to set.
132  */
133 void NmeaSentenceMessage::setSentence(const QString sentence)
134 {
135  Q_D(NmeaSentenceMessage);
136  d->sentence = sentence;
137 }
138 
139 /// \cond internal
140 
141 /*!
142  * \internal
143  *
144  * \class NmeaSentenceMessagePrivate
145  *
146  * The NmeaSentenceMessagePrivate class provides private implementation for the NmeaSentenceMessage.
147  *
148  * \sa NmeaSentenceMessage
149  */
150 
151 /*!
152  * \internal
153  *
154  * Constructs a NmeaSentenceMessagePrivate object with public implementation \a q.
155  *
156  * \param q Pointer to public implementaton.
157  */
158 NmeaSentenceMessagePrivate::NmeaSentenceMessagePrivate(NmeaSentenceMessage * const q)
160  , timestamp(static_cast<DateTime>(-1))
161  , timestampMs(0xFFFF)
162 {
163  globalMessageNumber = MesgNum::NmeaSentence;
164 }
165 
166 /*!
167  * \internal
168  *
169  * Destroys the NmeaSentenceMessagePrivate object.
170  */
172 {
173 
174 }
175 
177  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
178 {
179  switch (fieldId) {
180  case 253: // See Profile.xlsx::Messages:nmea_sentence.timestamp
181  if (!verify(data, baseType, 4, FitBaseType::Uint32, "nmea_sentence.timestamp")) return false;
182  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
183  break;
184  case 0: // See Profile.xlsx::Messages:nmea_sentence.timestampMs
185  if (!verify(data, baseType, 2, FitBaseType::Uint16, "nmea_sentence.timestampMs")) return false;
186  this->timestampMs = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
187  break;
188  case 1: // See Profile.xlsx::Messages:nmea_sentence.sentence
189  if (!verify(data, baseType, 1, FitBaseType::String, "nmea_sentence.sentence")) return false;
190  this->sentence = QString::fromUtf8(data);
191  break;
192  default:
193  qWarning() << "ignoring unknown nmea_sentence message field number" << fieldId << bigEndian;
194  // Fall through to return true, as its still 'safe' to continue parsing data messages.
195  }
196  return true;
197 }
198 
199 /// \endcond
200 
#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 NmeaSentenceMessage FIT message's timestamp field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
quint16 timestampMs
The NmeaSentenceMessage FIT message's timestampMs field.
QString sentence
The NmeaSentenceMessage FIT message's sentence field.
The NmeaSentenceMessage class represents a FIT NmeaSentenceMessage data message.
DateTime timestamp() const
Returns the NmeaSentenceMessage data message's timestamp field's current value.
void setSentence(const QString sentence)
Sets the sentence field to sentence.
QString sentence() const
Returns the NmeaSentenceMessage data message's sentence field's current value.
quint16 timestampMs() const
Returns the NmeaSentenceMessage data message's timestampMs field's current value.
NmeaSentenceMessage()
Constructs a NmeaSentenceMessage object.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
void setTimestampMs(const quint16 timestampMs)
Sets the timestampMs field to timestampMs.
Declares the NmeaSentenceMessage class.
Declares the NmeaSentenceMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237