QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cameraeventmessage.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 CameraEventMessage, and CameraEventMessagePrivate classes.
28  */
29 
30 #include "cameraeventmessage.h"
31 #include "cameraeventmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class CameraEventMessage
40  *
41  * The CameraEventMessage class represents a FIT CameraEventMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a CameraEventMessage 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 CameraEventMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the CameraEventMessage data message's \c timestamp field's current value.
71  *
72  * Whole second part of the timestamp.
73  *
74  * \return the \c timestamp field value.
75  */
77 {
78  Q_D(const CameraEventMessage);
79  return d->timestamp;
80 }
81 
82 /*!
83  * Returns the CameraEventMessage data message's \c timestampMs field's current value.
84  *
85  * Millisecond part of the timestamp.
86  *
87  * \return the \c timestampMs field value.
88  */
90 {
91  Q_D(const CameraEventMessage);
92  return d->timestampMs;
93 }
94 
95 /*!
96  * Returns the CameraEventMessage data message's \c cameraEventType field's current value.
97  *
98  * \return the \c cameraEventType field value.
99  */
101 {
102  Q_D(const CameraEventMessage);
103  return d->cameraEventType;
104 }
105 
106 /*!
107  * Returns the CameraEventMessage data message's \c cameraFileUuid field's current value.
108  *
109  * \return the \c cameraFileUuid field value.
110  */
112 {
113  Q_D(const CameraEventMessage);
114  return d->cameraFileUuid;
115 }
116 
117 /*!
118  * Returns the CameraEventMessage data message's \c cameraOrientation field's current value.
119  *
120  * \return the \c cameraOrientation field value.
121  */
123 {
124  Q_D(const CameraEventMessage);
125  return d->cameraOrientation;
126 }
127 
128 /*!
129  * Sets the \c timestamp field to \a timestamp.
130  *
131  * \param timestamp The field value to set.
132  */
134 {
135  Q_D(CameraEventMessage);
136  d->timestamp = timestamp;
137 }
138 /*!
139  * Sets the \c timestampMs field to \a timestampMs.
140  *
141  * \param timestampMs The field value to set.
142  */
143 void CameraEventMessage::setTimestampMs(const quint16 timestampMs)
144 {
145  Q_D(CameraEventMessage);
146  d->timestampMs = timestampMs;
147 }
148 /*!
149  * Sets the \c cameraEventType field to \a cameraEventType.
150  *
151  * \param cameraEventType The field value to set.
152  */
154 {
155  Q_D(CameraEventMessage);
156  d->cameraEventType = cameraEventType;
157 }
158 /*!
159  * Sets the \c cameraFileUuid field to \a cameraFileUuid.
160  *
161  * \param cameraFileUuid The field value to set.
162  */
163 void CameraEventMessage::setCameraFileUuid(const QString cameraFileUuid)
164 {
165  Q_D(CameraEventMessage);
166  d->cameraFileUuid = cameraFileUuid;
167 }
168 /*!
169  * Sets the \c cameraOrientation field to \a cameraOrientation.
170  *
171  * \param cameraOrientation The field value to set.
172  */
174 {
175  Q_D(CameraEventMessage);
176  d->cameraOrientation = cameraOrientation;
177 }
178 
179 /// \cond internal
180 
181 /*!
182  * \internal
183  *
184  * \class CameraEventMessagePrivate
185  *
186  * The CameraEventMessagePrivate class provides private implementation for the CameraEventMessage.
187  *
188  * \sa CameraEventMessage
189  */
190 
191 /*!
192  * \internal
193  *
194  * Constructs a CameraEventMessagePrivate object with public implementation \a q.
195  *
196  * \param q Pointer to public implementaton.
197  */
198 CameraEventMessagePrivate::CameraEventMessagePrivate(CameraEventMessage * const q)
200  , timestamp(static_cast<DateTime>(-1))
201  , timestampMs(0xFFFF)
202  , cameraEventType(static_cast<CameraEventType>(-1))
203  , cameraOrientation(static_cast<CameraOrientationType>(-1))
204 {
205  globalMessageNumber = MesgNum::CameraEvent;
206 }
207 
208 /*!
209  * \internal
210  *
211  * Destroys the CameraEventMessagePrivate object.
212  */
214 {
215 
216 }
217 
219  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
220 {
221  switch (fieldId) {
222  case 253: // See Profile.xlsx::Messages:camera_event.timestamp
223  if (!verify(data, baseType, 4, FitBaseType::Uint32, "camera_event.timestamp")) return false;
224  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
225  break;
226  case 0: // See Profile.xlsx::Messages:camera_event.timestampMs
227  if (!verify(data, baseType, 2, FitBaseType::Uint16, "camera_event.timestampMs")) return false;
228  this->timestampMs = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
229  break;
230  case 1: // See Profile.xlsx::Messages:camera_event.cameraEventType
231  if (!verify(data, baseType, 1, FitBaseType::Enum, "camera_event.cameraEventType")) return false;
232  this->cameraEventType = static_cast<CameraEventType>(data.at(0));
233  break;
234  case 2: // See Profile.xlsx::Messages:camera_event.cameraFileUuid
235  if (!verify(data, baseType, 1, FitBaseType::String, "camera_event.cameraFileUuid")) return false;
236  this->cameraFileUuid = QString::fromUtf8(data);
237  break;
238  case 3: // See Profile.xlsx::Messages:camera_event.cameraOrientation
239  if (!verify(data, baseType, 1, FitBaseType::Enum, "camera_event.cameraOrientation")) return false;
240  this->cameraOrientation = static_cast<CameraOrientationType>(data.at(0));
241  break;
242  default:
243  qWarning() << "ignoring unknown camera_event message field number" << fieldId << bigEndian;
244  // Fall through to return true, as its still 'safe' to continue parsing data messages.
245  }
246  return true;
247 }
248 
249 /// \endcond
250 
#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
Declares the CameraEventMessage class.
Declares the CameraEventMessagePrivate class.
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 CameraEventMessage FIT message's timestamp field.
QString cameraFileUuid
The CameraEventMessage FIT message's cameraFileUuid field.
CameraEventType cameraEventType
The CameraEventMessage FIT message's cameraEventType field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
CameraOrientationType cameraOrientation
The CameraEventMessage FIT message's cameraOrientation field.
quint16 timestampMs
The CameraEventMessage FIT message's timestampMs field.
The CameraEventMessage class represents a FIT CameraEventMessage data message.
CameraEventMessage()
Constructs a CameraEventMessage object.
DateTime timestamp() const
Returns the CameraEventMessage data message's timestamp field's current value.
quint16 timestampMs() const
Returns the CameraEventMessage data message's timestampMs field's current value.
void setTimestampMs(const quint16 timestampMs)
Sets the timestampMs field to timestampMs.
void setCameraFileUuid(const QString cameraFileUuid)
Sets the cameraFileUuid field to cameraFileUuid.
CameraOrientationType cameraOrientation() const
Returns the CameraEventMessage data message's cameraOrientation field's current value.
void setCameraOrientation(const CameraOrientationType cameraOrientation)
Sets the cameraOrientation field to cameraOrientation.
QString cameraFileUuid() const
Returns the CameraEventMessage data message's cameraFileUuid field's current value.
void setCameraEventType(const CameraEventType cameraEventType)
Sets the cameraEventType field to cameraEventType.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
CameraEventType cameraEventType() const
Returns the CameraEventMessage data message's cameraEventType field's current value.
CameraEventType
Garmin FIT CameraEventType type.
Definition: types.h:2931
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
CameraOrientationType
Garmin FIT CameraOrientationType type.
Definition: types.h:3004
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237