QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
divealarmmessage.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 DiveAlarmMessage, and DiveAlarmMessagePrivate classes.
28  */
29 
30 #include "divealarmmessage.h"
31 #include "divealarmmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class DiveAlarmMessage
40  *
41  * The DiveAlarmMessage class represents a FIT DiveAlarmMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a DiveAlarmMessage 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 DiveAlarmMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the DiveAlarmMessage data message's \c messageIndex field's current value.
71  *
72  * Index of the alarm
73  *
74  * \return the \c messageIndex field value.
75  */
77 {
78  Q_D(const DiveAlarmMessage);
79  return d->messageIndex;
80 }
81 
82 /*!
83  * Returns the DiveAlarmMessage data message's \c depth field's current value.
84  *
85  * \return the \c depth field value.
86  */
87 quint32 DiveAlarmMessage::depth() const
88 {
89  Q_D(const DiveAlarmMessage);
90  return d->depth;
91 }
92 
93 /*!
94  * Returns the DiveAlarmMessage data message's \c time field's current value.
95  *
96  * \return the \c time field value.
97  */
98 qint32 DiveAlarmMessage::time() const
99 {
100  Q_D(const DiveAlarmMessage);
101  return d->time;
102 }
103 
104 /*!
105  * Returns the DiveAlarmMessage data message's \c enabled field's current value.
106  *
107  * \return the \c enabled field value.
108  */
110 {
111  Q_D(const DiveAlarmMessage);
112  return d->enabled;
113 }
114 
115 /*!
116  * Returns the DiveAlarmMessage data message's \c alarmType field's current value.
117  *
118  * \return the \c alarmType field value.
119  */
121 {
122  Q_D(const DiveAlarmMessage);
123  return d->alarmType;
124 }
125 
126 /*!
127  * Returns the DiveAlarmMessage data message's \c sound field's current value.
128  *
129  * \return the \c sound field value.
130  */
132 {
133  Q_D(const DiveAlarmMessage);
134  return d->sound;
135 }
136 
137 /*!
138  * Returns the DiveAlarmMessage data message's \c diveTypes field's current value.
139  *
140  * \return the \c diveTypes field value.
141  */
143 {
144  Q_D(const DiveAlarmMessage);
145  return d->diveTypes;
146 }
147 
148 /*!
149  * Sets the \c messageIndex field to \a messageIndex.
150  *
151  * \param messageIndex The field value to set.
152  */
154 {
155  Q_D(DiveAlarmMessage);
156  d->messageIndex = messageIndex;
157 }
158 /*!
159  * Sets the \c depth field to \a depth.
160  *
161  * \param depth The field value to set.
162  */
163 void DiveAlarmMessage::setDepth(const quint32 depth)
164 {
165  Q_D(DiveAlarmMessage);
166  d->depth = depth;
167 }
168 /*!
169  * Sets the \c time field to \a time.
170  *
171  * \param time The field value to set.
172  */
173 void DiveAlarmMessage::setTime(const qint32 time)
174 {
175  Q_D(DiveAlarmMessage);
176  d->time = time;
177 }
178 /*!
179  * Sets the \c enabled field to \a enabled.
180  *
181  * \param enabled The field value to set.
182  */
183 void DiveAlarmMessage::setEnabled(const bool enabled)
184 {
185  Q_D(DiveAlarmMessage);
186  d->enabled = enabled;
187 }
188 /*!
189  * Sets the \c alarmType field to \a alarmType.
190  *
191  * \param alarmType The field value to set.
192  */
194 {
195  Q_D(DiveAlarmMessage);
196  d->alarmType = alarmType;
197 }
198 /*!
199  * Sets the \c sound field to \a sound.
200  *
201  * \param sound The field value to set.
202  */
204 {
205  Q_D(DiveAlarmMessage);
206  d->sound = sound;
207 }
208 /*!
209  * Sets the \c diveTypes field to \a diveTypes.
210  *
211  * \param diveTypes The field value to set.
212  */
214 {
215  Q_D(DiveAlarmMessage);
216  d->diveTypes = diveTypes;
217 }
218 
219 /// \cond internal
220 
221 /*!
222  * \internal
223  *
224  * \class DiveAlarmMessagePrivate
225  *
226  * The DiveAlarmMessagePrivate class provides private implementation for the DiveAlarmMessage.
227  *
228  * \sa DiveAlarmMessage
229  */
230 
231 /*!
232  * \internal
233  *
234  * Constructs a DiveAlarmMessagePrivate object with public implementation \a q.
235  *
236  * \param q Pointer to public implementaton.
237  */
238 DiveAlarmMessagePrivate::DiveAlarmMessagePrivate(DiveAlarmMessage * const q)
240  , messageIndex(static_cast<MessageIndex>(-1))
241  , depth(0xFFFFFFFF)
242  , time(0x7FFFFFFF)
243  , enabled(static_cast<bool>(-1))
244  , alarmType(static_cast<DiveAlarmType>(-1))
245  , sound(static_cast<Tone>(-1))
246  , diveTypes(static_cast<SubSport>(-1))
247 {
248  globalMessageNumber = MesgNum::DiveAlarm;
249 }
250 
251 /*!
252  * \internal
253  *
254  * Destroys the DiveAlarmMessagePrivate object.
255  */
257 {
258 
259 }
260 
262  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
263 {
264  switch (fieldId) {
265  case 254: // See Profile.xlsx::Messages:dive_alarm.messageIndex
266  if (!verify(data, baseType, 2, FitBaseType::Uint16, "dive_alarm.messageIndex")) return false;
267  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
268  break;
269  case 0: // See Profile.xlsx::Messages:dive_alarm.depth
270  if (!verify(data, baseType, 4, FitBaseType::Uint32, "dive_alarm.depth")) return false;
271  this->depth = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
272  break;
273  case 1: // See Profile.xlsx::Messages:dive_alarm.time
274  if (!verify(data, baseType, 4, FitBaseType::Sint32, "dive_alarm.time")) return false;
275  this->time = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
276  break;
277  case 2: // See Profile.xlsx::Messages:dive_alarm.enabled
278  if (!verify(data, baseType, 0, FitBaseType::Byte, "dive_alarm.enabled")) return false;
279  this->enabled = static_cast<bool>(data.at(0));
280  break;
281  case 3: // See Profile.xlsx::Messages:dive_alarm.alarmType
282  if (!verify(data, baseType, 1, FitBaseType::Enum, "dive_alarm.alarmType")) return false;
283  this->alarmType = static_cast<DiveAlarmType>(data.at(0));
284  break;
285  case 4: // See Profile.xlsx::Messages:dive_alarm.sound
286  if (!verify(data, baseType, 1, FitBaseType::Enum, "dive_alarm.sound")) return false;
287  this->sound = static_cast<Tone>(data.at(0));
288  break;
289  case 5: // See Profile.xlsx::Messages:dive_alarm.diveTypes
290  if (!verify(data, baseType, 1, FitBaseType::Enum, "dive_alarm.diveTypes")) return false;
291  this->diveTypes = static_cast<SubSport>(data.at(0));
292  break;
293  default:
294  qWarning() << "ignoring unknown dive_alarm message field number" << fieldId << bigEndian;
295  // Fall through to return true, as its still 'safe' to continue parsing data messages.
296  }
297  return true;
298 }
299 
300 /// \endcond
301 
#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
quint32 depth
The DiveAlarmMessage FIT message's depth field.
Tone sound
The DiveAlarmMessage FIT message's sound field.
MessageIndex messageIndex
The DiveAlarmMessage FIT message's messageIndex field.
qint32 time
The DiveAlarmMessage FIT message's time field.
bool enabled
The DiveAlarmMessage FIT message's enabled field.
SubSport diveTypes
The DiveAlarmMessage FIT message's diveTypes field.
DiveAlarmType alarmType
The DiveAlarmMessage FIT message's alarmType field.
The DiveAlarmMessage class represents a FIT DiveAlarmMessage data message.
DiveAlarmType alarmType() const
Returns the DiveAlarmMessage data message's alarmType field's current value.
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
bool enabled() const
Returns the DiveAlarmMessage data message's enabled field's current value.
void setAlarmType(const DiveAlarmType alarmType)
Sets the alarmType field to alarmType.
void setSound(const Tone sound)
Sets the sound field to sound.
MessageIndex messageIndex() const
Returns the DiveAlarmMessage data message's messageIndex field's current value.
quint32 depth() const
Returns the DiveAlarmMessage data message's depth field's current value.
void setDiveTypes(const SubSport diveTypes)
Sets the diveTypes field to diveTypes.
DiveAlarmMessage()
Constructs a DiveAlarmMessage object.
Tone sound() const
Returns the DiveAlarmMessage data message's sound field's current value.
void setTime(const qint32 time)
Sets the time field to time.
SubSport diveTypes() const
Returns the DiveAlarmMessage data message's diveTypes field's current value.
void setEnabled(const bool enabled)
Sets the enabled field to enabled.
qint32 time() const
Returns the DiveAlarmMessage data message's time field's current value.
void setDepth(const quint32 depth)
Sets the depth field to depth.
Declares the DiveAlarmMessage class.
Declares the DiveAlarmMessagePrivate class.
Tone
Garmin FIT Tone type.
Definition: types.h:1235
DiveAlarmType
Garmin FIT DiveAlarmType type.
Definition: types.h:5235
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263
SubSport
Garmin FIT SubSport type.
Definition: types.h:881