QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
weatheralertmessage.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 WeatherAlertMessage, and WeatherAlertMessagePrivate classes.
28  */
29 
30 #include "weatheralertmessage.h"
31 #include "weatheralertmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class WeatherAlertMessage
40  *
41  * The WeatherAlertMessage class represents a FIT WeatherAlertMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a WeatherAlertMessage 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 WeatherAlertMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the WeatherAlertMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const WeatherAlertMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the WeatherAlertMessage data message's \c reportId field's current value.
82  *
83  * Unique identifier from GCS report ID string, length is 12
84  *
85  * \return the \c reportId field value.
86  */
88 {
89  Q_D(const WeatherAlertMessage);
90  return d->reportId;
91 }
92 
93 /*!
94  * Returns the WeatherAlertMessage data message's \c issueTime field's current value.
95  *
96  * Time alert was issued
97  *
98  * \return the \c issueTime field value.
99  */
101 {
102  Q_D(const WeatherAlertMessage);
103  return d->issueTime;
104 }
105 
106 /*!
107  * Returns the WeatherAlertMessage data message's \c expireTime field's current value.
108  *
109  * Time alert expires
110  *
111  * \return the \c expireTime field value.
112  */
114 {
115  Q_D(const WeatherAlertMessage);
116  return d->expireTime;
117 }
118 
119 /*!
120  * Returns the WeatherAlertMessage data message's \c severity field's current value.
121  *
122  * Warning, Watch, Advisory, Statement
123  *
124  * \return the \c severity field value.
125  */
127 {
128  Q_D(const WeatherAlertMessage);
129  return d->severity;
130 }
131 
132 /*!
133  * Returns the WeatherAlertMessage data message's \c type field's current value.
134  *
135  * Tornado, Severe Thunderstorm, etc.
136  *
137  * \return the \c type field value.
138  */
140 {
141  Q_D(const WeatherAlertMessage);
142  return d->type;
143 }
144 
145 /*!
146  * Sets the \c timestamp field to \a timestamp.
147  *
148  * \param timestamp The field value to set.
149  */
151 {
152  Q_D(WeatherAlertMessage);
153  d->timestamp = timestamp;
154 }
155 /*!
156  * Sets the \c reportId field to \a reportId.
157  *
158  * \param reportId The field value to set.
159  */
160 void WeatherAlertMessage::setReportId(const QString reportId)
161 {
162  Q_D(WeatherAlertMessage);
163  d->reportId = reportId;
164 }
165 /*!
166  * Sets the \c issueTime field to \a issueTime.
167  *
168  * \param issueTime The field value to set.
169  */
171 {
172  Q_D(WeatherAlertMessage);
173  d->issueTime = issueTime;
174 }
175 /*!
176  * Sets the \c expireTime field to \a expireTime.
177  *
178  * \param expireTime The field value to set.
179  */
181 {
182  Q_D(WeatherAlertMessage);
183  d->expireTime = expireTime;
184 }
185 /*!
186  * Sets the \c severity field to \a severity.
187  *
188  * \param severity The field value to set.
189  */
191 {
192  Q_D(WeatherAlertMessage);
193  d->severity = severity;
194 }
195 /*!
196  * Sets the \c type field to \a type.
197  *
198  * \param type The field value to set.
199  */
201 {
202  Q_D(WeatherAlertMessage);
203  d->type = type;
204 }
205 
206 /// \cond internal
207 
208 /*!
209  * \internal
210  *
211  * \class WeatherAlertMessagePrivate
212  *
213  * The WeatherAlertMessagePrivate class provides private implementation for the WeatherAlertMessage.
214  *
215  * \sa WeatherAlertMessage
216  */
217 
218 /*!
219  * \internal
220  *
221  * Constructs a WeatherAlertMessagePrivate object with public implementation \a q.
222  *
223  * \param q Pointer to public implementaton.
224  */
225 WeatherAlertMessagePrivate::WeatherAlertMessagePrivate(WeatherAlertMessage * const q)
227  , timestamp(static_cast<DateTime>(-1))
228  , issueTime(static_cast<DateTime>(-1))
229  , expireTime(static_cast<DateTime>(-1))
230  , severity(static_cast<WeatherSeverity>(-1))
231  , type(static_cast<WeatherSevereType>(-1))
232 {
233  globalMessageNumber = MesgNum::WeatherAlert;
234 }
235 
236 /*!
237  * \internal
238  *
239  * Destroys the WeatherAlertMessagePrivate object.
240  */
242 {
243 
244 }
245 
247  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
248 {
249  switch (fieldId) {
250  case 253: // See Profile.xlsx::Messages:weather_alert.timestamp
251  if (!verify(data, baseType, 4, FitBaseType::Uint32, "weather_alert.timestamp")) return false;
252  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
253  break;
254  case 0: // See Profile.xlsx::Messages:weather_alert.reportId
255  if (!verify(data, baseType, 1, FitBaseType::String, "weather_alert.reportId")) return false;
256  this->reportId = QString::fromUtf8(data);
257  break;
258  case 1: // See Profile.xlsx::Messages:weather_alert.issueTime
259  if (!verify(data, baseType, 4, FitBaseType::Uint32, "weather_alert.issueTime")) return false;
260  this->issueTime = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
261  break;
262  case 2: // See Profile.xlsx::Messages:weather_alert.expireTime
263  if (!verify(data, baseType, 4, FitBaseType::Uint32, "weather_alert.expireTime")) return false;
264  this->expireTime = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
265  break;
266  case 3: // See Profile.xlsx::Messages:weather_alert.severity
267  if (!verify(data, baseType, 1, FitBaseType::Enum, "weather_alert.severity")) return false;
268  this->severity = static_cast<WeatherSeverity>(data.at(0));
269  break;
270  case 4: // See Profile.xlsx::Messages:weather_alert.type
271  if (!verify(data, baseType, 1, FitBaseType::Enum, "weather_alert.type")) return false;
272  this->type = static_cast<WeatherSevereType>(data.at(0));
273  break;
274  default:
275  qWarning() << "ignoring unknown weather_alert message field number" << fieldId << bigEndian;
276  // Fall through to return true, as its still 'safe' to continue parsing data messages.
277  }
278  return true;
279 }
280 
281 /// \endcond
282 
#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 WeatherAlertMessage FIT message's timestamp field.
WeatherSeverity severity
The WeatherAlertMessage FIT message's severity field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
WeatherSevereType type
The WeatherAlertMessage FIT message's type field.
DateTime expireTime
The WeatherAlertMessage FIT message's expireTime field.
DateTime issueTime
The WeatherAlertMessage FIT message's issueTime field.
QString reportId
The WeatherAlertMessage FIT message's reportId field.
The WeatherAlertMessage class represents a FIT WeatherAlertMessage data message.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
DateTime issueTime() const
Returns the WeatherAlertMessage data message's issueTime field's current value.
DateTime timestamp() const
Returns the WeatherAlertMessage data message's timestamp field's current value.
void setType(const WeatherSevereType type)
Sets the type field to type.
WeatherSeverity severity() const
Returns the WeatherAlertMessage data message's severity field's current value.
void setReportId(const QString reportId)
Sets the reportId field to reportId.
DateTime expireTime() const
Returns the WeatherAlertMessage data message's expireTime field's current value.
void setExpireTime(const DateTime expireTime)
Sets the expireTime field to expireTime.
void setSeverity(const WeatherSeverity severity)
Sets the severity field to severity.
WeatherAlertMessage()
Constructs a WeatherAlertMessage object.
QString reportId() const
Returns the WeatherAlertMessage data message's reportId field's current value.
WeatherSevereType type() const
Returns the WeatherAlertMessage data message's type field's current value.
void setIssueTime(const DateTime issueTime)
Sets the issueTime field to issueTime.
WeatherSevereType
Garmin FIT WeatherSevereType type.
Definition: types.h:2534
WeatherSeverity
Garmin FIT WeatherSeverity type.
Definition: types.h:2517
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237
Declares the WeatherAlertMessage class.
Declares the WeatherAlertMessagePrivate class.