QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
stresslevelmessage.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 StressLevelMessage, and StressLevelMessagePrivate classes.
28  */
29 
30 #include "stresslevelmessage.h"
31 #include "stresslevelmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class StressLevelMessage
40  *
41  * The StressLevelMessage class represents a FIT StressLevelMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a StressLevelMessage 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 StressLevelMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the StressLevelMessage data message's \c stressLevelValue field's current value.
71  *
72  * \return the \c stressLevelValue field value.
73  */
75 {
76  Q_D(const StressLevelMessage);
77  return d->stressLevelValue;
78 }
79 
80 /*!
81  * Returns the StressLevelMessage data message's \c stressLevelTime field's current value.
82  *
83  * Time stress score was calculated
84  *
85  * \return the \c stressLevelTime field value.
86  */
88 {
89  Q_D(const StressLevelMessage);
90  return d->stressLevelTime;
91 }
92 
93 /*!
94  * Sets the \c stressLevelValue field to \a stressLevelValue.
95  *
96  * \param stressLevelValue The field value to set.
97  */
98 void StressLevelMessage::setStressLevelValue(const qint16 stressLevelValue)
99 {
100  Q_D(StressLevelMessage);
101  d->stressLevelValue = stressLevelValue;
102 }
103 /*!
104  * Sets the \c stressLevelTime field to \a stressLevelTime.
105  *
106  * \param stressLevelTime The field value to set.
107  */
109 {
110  Q_D(StressLevelMessage);
111  d->stressLevelTime = stressLevelTime;
112 }
113 
114 /// \cond internal
115 
116 /*!
117  * \internal
118  *
119  * \class StressLevelMessagePrivate
120  *
121  * The StressLevelMessagePrivate class provides private implementation for the StressLevelMessage.
122  *
123  * \sa StressLevelMessage
124  */
125 
126 /*!
127  * \internal
128  *
129  * Constructs a StressLevelMessagePrivate object with public implementation \a q.
130  *
131  * \param q Pointer to public implementaton.
132  */
133 StressLevelMessagePrivate::StressLevelMessagePrivate(StressLevelMessage * const q)
135  , stressLevelValue(0x7FFF)
136  , stressLevelTime(static_cast<DateTime>(-1))
137 {
138  globalMessageNumber = MesgNum::StressLevel;
139 }
140 
141 /*!
142  * \internal
143  *
144  * Destroys the StressLevelMessagePrivate object.
145  */
147 {
148 
149 }
150 
152  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
153 {
154  switch (fieldId) {
155  case 0: // See Profile.xlsx::Messages:stress_level.stressLevelValue
156  if (!verify(data, baseType, 2, FitBaseType::Sint16, "stress_level.stressLevelValue")) return false;
157  this->stressLevelValue = static_cast<qint16>(bigEndian ? qFromBigEndian< qint16>(data) : qFromLittleEndian< qint16>(data));
158  break;
159  case 1: // See Profile.xlsx::Messages:stress_level.stressLevelTime
160  if (!verify(data, baseType, 4, FitBaseType::Uint32, "stress_level.stressLevelTime")) return false;
161  this->stressLevelTime = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
162  break;
163  default:
164  qWarning() << "ignoring unknown stress_level message field number" << fieldId << bigEndian;
165  // Fall through to return true, as its still 'safe' to continue parsing data messages.
166  }
167  return true;
168 }
169 
170 /// \endcond
171 
#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.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
qint16 stressLevelValue
The StressLevelMessage FIT message's stressLevelValue field.
DateTime stressLevelTime
The StressLevelMessage FIT message's stressLevelTime field.
The StressLevelMessage class represents a FIT StressLevelMessage data message.
DateTime stressLevelTime() const
Returns the StressLevelMessage data message's stressLevelTime field's current value.
void setStressLevelValue(const qint16 stressLevelValue)
Sets the stressLevelValue field to stressLevelValue.
void setStressLevelTime(const DateTime stressLevelTime)
Sets the stressLevelTime field to stressLevelTime.
qint16 stressLevelValue() const
Returns the StressLevelMessage data message's stressLevelValue field's current value.
StressLevelMessage()
Constructs a StressLevelMessage object.
Declares the StressLevelMessage class.
Declares the StressLevelMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237