QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
weatherconditionsmessage.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 WeatherConditionsMessage, and WeatherConditionsMessagePrivate classes.
28  */
29 
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class WeatherConditionsMessage
40  *
41  * The WeatherConditionsMessage class represents a FIT WeatherConditionsMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a WeatherConditionsMessage 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 WeatherConditionsMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the WeatherConditionsMessage data message's \c timestamp field's current value.
71  *
72  * time of update for current conditions, else forecast time
73  *
74  * \return the \c timestamp field value.
75  */
77 {
78  Q_D(const WeatherConditionsMessage);
79  return d->timestamp;
80 }
81 
82 /*!
83  * Returns the WeatherConditionsMessage data message's \c weatherReport field's current value.
84  *
85  * Current or forecast
86  *
87  * \return the \c weatherReport field value.
88  */
90 {
91  Q_D(const WeatherConditionsMessage);
92  return d->weatherReport;
93 }
94 
95 /*!
96  * Returns the WeatherConditionsMessage data message's \c temperature field's current value.
97  *
98  * \return the \c temperature field value.
99  */
101 {
102  Q_D(const WeatherConditionsMessage);
103  return d->temperature;
104 }
105 
106 /*!
107  * Returns the WeatherConditionsMessage data message's \c condition field's current value.
108  *
109  * Corresponds to GSC Response weatherIcon field
110  *
111  * \return the \c condition field value.
112  */
114 {
115  Q_D(const WeatherConditionsMessage);
116  return d->condition;
117 }
118 
119 /*!
120  * Returns the WeatherConditionsMessage data message's \c windDirection field's current value.
121  *
122  * \return the \c windDirection field value.
123  */
125 {
126  Q_D(const WeatherConditionsMessage);
127  return d->windDirection;
128 }
129 
130 /*!
131  * Returns the WeatherConditionsMessage data message's \c windSpeed field's current value.
132  *
133  * \return the \c windSpeed field value.
134  */
136 {
137  Q_D(const WeatherConditionsMessage);
138  return d->windSpeed;
139 }
140 
141 /*!
142  * Returns the WeatherConditionsMessage data message's \c precipitationProbability field's current value.
143  *
144  * range 0-100
145  *
146  * \return the \c precipitationProbability field value.
147  */
149 {
150  Q_D(const WeatherConditionsMessage);
151  return d->precipitationProbability;
152 }
153 
154 /*!
155  * Returns the WeatherConditionsMessage data message's \c temperatureFeelsLike field's current value.
156  *
157  * Heat Index if GCS heatIdx above or equal to 90F or wind chill if GCS windChill below or
158  * equal to 32F
159  *
160  * \return the \c temperatureFeelsLike field value.
161  */
163 {
164  Q_D(const WeatherConditionsMessage);
165  return d->temperatureFeelsLike;
166 }
167 
168 /*!
169  * Returns the WeatherConditionsMessage data message's \c relativeHumidity field's current value.
170  *
171  * \return the \c relativeHumidity field value.
172  */
174 {
175  Q_D(const WeatherConditionsMessage);
176  return d->relativeHumidity;
177 }
178 
179 /*!
180  * Returns the WeatherConditionsMessage data message's \c location field's current value.
181  *
182  * string corresponding to GCS response location string
183  *
184  * \return the \c location field value.
185  */
187 {
188  Q_D(const WeatherConditionsMessage);
189  return d->location;
190 }
191 
192 /*!
193  * Returns the WeatherConditionsMessage data message's \c observedAtTime field's current value.
194  *
195  * \return the \c observedAtTime field value.
196  */
198 {
199  Q_D(const WeatherConditionsMessage);
200  return d->observedAtTime;
201 }
202 
203 /*!
204  * Returns the WeatherConditionsMessage data message's \c observedLocationLat field's current value.
205  *
206  * \return the \c observedLocationLat field value.
207  */
209 {
210  Q_D(const WeatherConditionsMessage);
211  return d->observedLocationLat;
212 }
213 
214 /*!
215  * Returns the WeatherConditionsMessage data message's \c observedLocationLong field's current value.
216  *
217  * \return the \c observedLocationLong field value.
218  */
220 {
221  Q_D(const WeatherConditionsMessage);
222  return d->observedLocationLong;
223 }
224 
225 /*!
226  * Returns the WeatherConditionsMessage data message's \c dayOfWeek field's current value.
227  *
228  * \return the \c dayOfWeek field value.
229  */
231 {
232  Q_D(const WeatherConditionsMessage);
233  return d->dayOfWeek;
234 }
235 
236 /*!
237  * Returns the WeatherConditionsMessage data message's \c highTemperature field's current value.
238  *
239  * \return the \c highTemperature field value.
240  */
242 {
243  Q_D(const WeatherConditionsMessage);
244  return d->highTemperature;
245 }
246 
247 /*!
248  * Returns the WeatherConditionsMessage data message's \c lowTemperature field's current value.
249  *
250  * \return the \c lowTemperature field value.
251  */
253 {
254  Q_D(const WeatherConditionsMessage);
255  return d->lowTemperature;
256 }
257 
258 /*!
259  * Sets the \c timestamp field to \a timestamp.
260  *
261  * \param timestamp The field value to set.
262  */
264 {
266  d->timestamp = timestamp;
267 }
268 /*!
269  * Sets the \c weatherReport field to \a weatherReport.
270  *
271  * \param weatherReport The field value to set.
272  */
274 {
276  d->weatherReport = weatherReport;
277 }
278 /*!
279  * Sets the \c temperature field to \a temperature.
280  *
281  * \param temperature The field value to set.
282  */
283 void WeatherConditionsMessage::setTemperature(const qint8 temperature)
284 {
286  d->temperature = temperature;
287 }
288 /*!
289  * Sets the \c condition field to \a condition.
290  *
291  * \param condition The field value to set.
292  */
294 {
296  d->condition = condition;
297 }
298 /*!
299  * Sets the \c windDirection field to \a windDirection.
300  *
301  * \param windDirection The field value to set.
302  */
303 void WeatherConditionsMessage::setWindDirection(const quint16 windDirection)
304 {
306  d->windDirection = windDirection;
307 }
308 /*!
309  * Sets the \c windSpeed field to \a windSpeed.
310  *
311  * \param windSpeed The field value to set.
312  */
313 void WeatherConditionsMessage::setWindSpeed(const quint16 windSpeed)
314 {
316  d->windSpeed = windSpeed;
317 }
318 /*!
319  * Sets the \c precipitationProbability field to \a precipitationProbability.
320  *
321  * \param precipitationProbability The field value to set.
322  */
323 void WeatherConditionsMessage::setPrecipitationProbability(const quint8 precipitationProbability)
324 {
326  d->precipitationProbability = precipitationProbability;
327 }
328 /*!
329  * Sets the \c temperatureFeelsLike field to \a temperatureFeelsLike.
330  *
331  * \param temperatureFeelsLike The field value to set.
332  */
333 void WeatherConditionsMessage::setTemperatureFeelsLike(const qint8 temperatureFeelsLike)
334 {
336  d->temperatureFeelsLike = temperatureFeelsLike;
337 }
338 /*!
339  * Sets the \c relativeHumidity field to \a relativeHumidity.
340  *
341  * \param relativeHumidity The field value to set.
342  */
343 void WeatherConditionsMessage::setRelativeHumidity(const quint8 relativeHumidity)
344 {
346  d->relativeHumidity = relativeHumidity;
347 }
348 /*!
349  * Sets the \c location field to \a location.
350  *
351  * \param location The field value to set.
352  */
353 void WeatherConditionsMessage::setLocation(const QString location)
354 {
356  d->location = location;
357 }
358 /*!
359  * Sets the \c observedAtTime field to \a observedAtTime.
360  *
361  * \param observedAtTime The field value to set.
362  */
364 {
366  d->observedAtTime = observedAtTime;
367 }
368 /*!
369  * Sets the \c observedLocationLat field to \a observedLocationLat.
370  *
371  * \param observedLocationLat The field value to set.
372  */
373 void WeatherConditionsMessage::setObservedLocationLat(const qint32 observedLocationLat)
374 {
376  d->observedLocationLat = observedLocationLat;
377 }
378 /*!
379  * Sets the \c observedLocationLong field to \a observedLocationLong.
380  *
381  * \param observedLocationLong The field value to set.
382  */
383 void WeatherConditionsMessage::setObservedLocationLong(const qint32 observedLocationLong)
384 {
386  d->observedLocationLong = observedLocationLong;
387 }
388 /*!
389  * Sets the \c dayOfWeek field to \a dayOfWeek.
390  *
391  * \param dayOfWeek The field value to set.
392  */
394 {
396  d->dayOfWeek = dayOfWeek;
397 }
398 /*!
399  * Sets the \c highTemperature field to \a highTemperature.
400  *
401  * \param highTemperature The field value to set.
402  */
403 void WeatherConditionsMessage::setHighTemperature(const qint8 highTemperature)
404 {
406  d->highTemperature = highTemperature;
407 }
408 /*!
409  * Sets the \c lowTemperature field to \a lowTemperature.
410  *
411  * \param lowTemperature The field value to set.
412  */
413 void WeatherConditionsMessage::setLowTemperature(const qint8 lowTemperature)
414 {
416  d->lowTemperature = lowTemperature;
417 }
418 
419 /// \cond internal
420 
421 /*!
422  * \internal
423  *
424  * \class WeatherConditionsMessagePrivate
425  *
426  * The WeatherConditionsMessagePrivate class provides private implementation for the WeatherConditionsMessage.
427  *
428  * \sa WeatherConditionsMessage
429  */
430 
431 /*!
432  * \internal
433  *
434  * Constructs a WeatherConditionsMessagePrivate object with public implementation \a q.
435  *
436  * \param q Pointer to public implementaton.
437  */
438 WeatherConditionsMessagePrivate::WeatherConditionsMessagePrivate(WeatherConditionsMessage * const q)
440  , timestamp(static_cast<DateTime>(-1))
441  , weatherReport(static_cast<WeatherReport>(-1))
442  , temperature(0x7F)
443  , condition(static_cast<WeatherStatus>(-1))
444  , windDirection(0xFFFF)
445  , windSpeed(0xFFFF)
446  , precipitationProbability(0xFF)
447  , temperatureFeelsLike(0x7F)
448  , relativeHumidity(0xFF)
449  , observedAtTime(static_cast<DateTime>(-1))
450  , observedLocationLat(0x7FFFFFFF)
451  , observedLocationLong(0x7FFFFFFF)
452  , dayOfWeek(static_cast<DayOfWeek>(-1))
453  , highTemperature(0x7F)
454  , lowTemperature(0x7F)
455 {
456  globalMessageNumber = MesgNum::WeatherConditions;
457 }
458 
459 /*!
460  * \internal
461  *
462  * Destroys the WeatherConditionsMessagePrivate object.
463  */
465 {
466 
467 }
468 
470  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
471 {
472  switch (fieldId) {
473  case 253: // See Profile.xlsx::Messages:weather_conditions.timestamp
474  if (!verify(data, baseType, 4, FitBaseType::Uint32, "weather_conditions.timestamp")) return false;
475  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
476  break;
477  case 0: // See Profile.xlsx::Messages:weather_conditions.weatherReport
478  if (!verify(data, baseType, 1, FitBaseType::Enum, "weather_conditions.weatherReport")) return false;
479  this->weatherReport = static_cast<WeatherReport>(data.at(0));
480  break;
481  case 1: // See Profile.xlsx::Messages:weather_conditions.temperature
482  if (!verify(data, baseType, 1, FitBaseType::Sint8, "weather_conditions.temperature")) return false;
483  this->temperature = static_cast<qint8>(data.at(0));
484  break;
485  case 2: // See Profile.xlsx::Messages:weather_conditions.condition
486  if (!verify(data, baseType, 1, FitBaseType::Enum, "weather_conditions.condition")) return false;
487  this->condition = static_cast<WeatherStatus>(data.at(0));
488  break;
489  case 3: // See Profile.xlsx::Messages:weather_conditions.windDirection
490  if (!verify(data, baseType, 2, FitBaseType::Uint16, "weather_conditions.windDirection")) return false;
491  this->windDirection = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
492  break;
493  case 4: // See Profile.xlsx::Messages:weather_conditions.windSpeed
494  if (!verify(data, baseType, 2, FitBaseType::Uint16, "weather_conditions.windSpeed")) return false;
495  this->windSpeed = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
496  break;
497  case 5: // See Profile.xlsx::Messages:weather_conditions.precipitationProbability
498  if (!verify(data, baseType, 1, FitBaseType::Uint8, "weather_conditions.precipitationProbability")) return false;
499  this->precipitationProbability = static_cast<quint8>(data.at(0));
500  break;
501  case 6: // See Profile.xlsx::Messages:weather_conditions.temperatureFeelsLike
502  if (!verify(data, baseType, 1, FitBaseType::Sint8, "weather_conditions.temperatureFeelsLike")) return false;
503  this->temperatureFeelsLike = static_cast<qint8>(data.at(0));
504  break;
505  case 7: // See Profile.xlsx::Messages:weather_conditions.relativeHumidity
506  if (!verify(data, baseType, 1, FitBaseType::Uint8, "weather_conditions.relativeHumidity")) return false;
507  this->relativeHumidity = static_cast<quint8>(data.at(0));
508  break;
509  case 8: // See Profile.xlsx::Messages:weather_conditions.location
510  if (!verify(data, baseType, 1, FitBaseType::String, "weather_conditions.location")) return false;
511  this->location = QString::fromUtf8(data);
512  break;
513  case 9: // See Profile.xlsx::Messages:weather_conditions.observedAtTime
514  if (!verify(data, baseType, 4, FitBaseType::Uint32, "weather_conditions.observedAtTime")) return false;
515  this->observedAtTime = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
516  break;
517  case 10: // See Profile.xlsx::Messages:weather_conditions.observedLocationLat
518  if (!verify(data, baseType, 4, FitBaseType::Sint32, "weather_conditions.observedLocationLat")) return false;
519  this->observedLocationLat = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
520  break;
521  case 11: // See Profile.xlsx::Messages:weather_conditions.observedLocationLong
522  if (!verify(data, baseType, 4, FitBaseType::Sint32, "weather_conditions.observedLocationLong")) return false;
523  this->observedLocationLong = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
524  break;
525  case 12: // See Profile.xlsx::Messages:weather_conditions.dayOfWeek
526  if (!verify(data, baseType, 1, FitBaseType::Enum, "weather_conditions.dayOfWeek")) return false;
527  this->dayOfWeek = static_cast<DayOfWeek>(data.at(0));
528  break;
529  case 13: // See Profile.xlsx::Messages:weather_conditions.highTemperature
530  if (!verify(data, baseType, 1, FitBaseType::Sint8, "weather_conditions.highTemperature")) return false;
531  this->highTemperature = static_cast<qint8>(data.at(0));
532  break;
533  case 14: // See Profile.xlsx::Messages:weather_conditions.lowTemperature
534  if (!verify(data, baseType, 1, FitBaseType::Sint8, "weather_conditions.lowTemperature")) return false;
535  this->lowTemperature = static_cast<qint8>(data.at(0));
536  break;
537  default:
538  qWarning() << "ignoring unknown weather_conditions message field number" << fieldId << bigEndian;
539  // Fall through to return true, as its still 'safe' to continue parsing data messages.
540  }
541  return true;
542 }
543 
544 /// \endcond
545 
#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 observedAtTime
The WeatherConditionsMessage FIT message's observedAtTime field.
qint32 observedLocationLong
The WeatherConditionsMessage FIT message's observedLocationLong field.
DayOfWeek dayOfWeek
The WeatherConditionsMessage FIT message's dayOfWeek field.
qint8 temperatureFeelsLike
The WeatherConditionsMessage FIT message's temperatureFeelsLike field.
WeatherReport weatherReport
The WeatherConditionsMessage FIT message's weatherReport field.
quint8 precipitationProbability
The WeatherConditionsMessage FIT message's precipitationProbability field.
quint16 windDirection
The WeatherConditionsMessage FIT message's windDirection field.
QString location
The WeatherConditionsMessage FIT message's location field.
qint32 observedLocationLat
The WeatherConditionsMessage FIT message's observedLocationLat field.
WeatherStatus condition
The WeatherConditionsMessage FIT message's condition field.
qint8 temperature
The WeatherConditionsMessage FIT message's temperature field.
quint8 relativeHumidity
The WeatherConditionsMessage FIT message's relativeHumidity field.
quint16 windSpeed
The WeatherConditionsMessage FIT message's windSpeed field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
DateTime timestamp
The WeatherConditionsMessage FIT message's timestamp field.
qint8 lowTemperature
The WeatherConditionsMessage FIT message's lowTemperature field.
qint8 highTemperature
The WeatherConditionsMessage FIT message's highTemperature field.
The WeatherConditionsMessage class represents a FIT WeatherConditionsMessage data message.
qint32 observedLocationLat() const
Returns the WeatherConditionsMessage data message's observedLocationLat field's current value.
void setCondition(const WeatherStatus condition)
Sets the condition field to condition.
void setWindSpeed(const quint16 windSpeed)
Sets the windSpeed field to windSpeed.
quint16 windDirection() const
Returns the WeatherConditionsMessage data message's windDirection field's current value.
void setTemperature(const qint8 temperature)
Sets the temperature field to temperature.
void setWindDirection(const quint16 windDirection)
Sets the windDirection field to windDirection.
WeatherConditionsMessage()
Constructs a WeatherConditionsMessage object.
qint32 observedLocationLong() const
Returns the WeatherConditionsMessage data message's observedLocationLong field's current value.
WeatherReport weatherReport() const
Returns the WeatherConditionsMessage data message's weatherReport field's current value.
void setPrecipitationProbability(const quint8 precipitationProbability)
Sets the precipitationProbability field to precipitationProbability.
quint8 precipitationProbability() const
Returns the WeatherConditionsMessage data message's precipitationProbability field's current value.
qint8 temperatureFeelsLike() const
Returns the WeatherConditionsMessage data message's temperatureFeelsLike field's current value.
qint8 lowTemperature() const
Returns the WeatherConditionsMessage data message's lowTemperature field's current value.
void setLowTemperature(const qint8 lowTemperature)
Sets the lowTemperature field to lowTemperature.
DateTime timestamp() const
Returns the WeatherConditionsMessage data message's timestamp field's current value.
DateTime observedAtTime() const
Returns the WeatherConditionsMessage data message's observedAtTime field's current value.
quint16 windSpeed() const
Returns the WeatherConditionsMessage data message's windSpeed field's current value.
void setObservedLocationLong(const qint32 observedLocationLong)
Sets the observedLocationLong field to observedLocationLong.
DayOfWeek dayOfWeek() const
Returns the WeatherConditionsMessage data message's dayOfWeek field's current value.
void setHighTemperature(const qint8 highTemperature)
Sets the highTemperature field to highTemperature.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
WeatherStatus condition() const
Returns the WeatherConditionsMessage data message's condition field's current value.
void setDayOfWeek(const DayOfWeek dayOfWeek)
Sets the dayOfWeek field to dayOfWeek.
void setLocation(const QString location)
Sets the location field to location.
quint8 relativeHumidity() const
Returns the WeatherConditionsMessage data message's relativeHumidity field's current value.
void setRelativeHumidity(const quint8 relativeHumidity)
Sets the relativeHumidity field to relativeHumidity.
qint8 temperature() const
Returns the WeatherConditionsMessage data message's temperature field's current value.
void setTemperatureFeelsLike(const qint8 temperatureFeelsLike)
Sets the temperatureFeelsLike field to temperatureFeelsLike.
void setObservedLocationLat(const qint32 observedLocationLat)
Sets the observedLocationLat field to observedLocationLat.
void setWeatherReport(const WeatherReport weatherReport)
Sets the weatherReport field to weatherReport.
QString location() const
Returns the WeatherConditionsMessage data message's location field's current value.
qint8 highTemperature() const
Returns the WeatherConditionsMessage data message's highTemperature field's current value.
void setObservedAtTime(const DateTime observedAtTime)
Sets the observedAtTime field to observedAtTime.
WeatherStatus
Garmin FIT WeatherStatus type.
Definition: types.h:2484
WeatherReport
Garmin FIT WeatherReport type.
Definition: types.h:2468
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DayOfWeek
Garmin FIT DayOfWeek type.
Definition: types.h:2405
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237
Declares the WeatherConditionsMessage class.
Declares the WeatherConditionsMessagePrivate class.