sensorfw: datatypes/compass.h Source File

sensorfw

compass.h
Go to the documentation of this file.
1
27#ifndef COMPASS_H
28#define COMPASS_H
29
30#include <QDBusArgument>
31
32#include <datatypes/orientationdata.h>
33
37 class Compass : public QObject
38{
39public:
40 Q_OBJECT
41
42 Q_PROPERTY(int degrees READ degrees)
43 Q_PROPERTY(int level READ level)
44
45public:
46
50 Compass() {}
51
58 Compass(const CompassData& data, bool declinationCorrection = true);
59
65 Compass(const Compass& data);
66
73 Compass(const Compass& data, bool declinationCorrection);
74
79 const CompassData& data() const { return data_; }
80
85 int degrees() const { return data_.degrees_; }
86
91 int level() const { return data_.level_; }
92
98 Compass& operator=(const Compass& origin)
99 {
100 data_ = origin.data();
101 return *this;
102 }
103
110 bool operator==(const Compass& right) const
111 {
112 CompassData rdata = right.data();
113 return (data_.degrees_ == rdata.degrees_ &&
114 data_.level_ == rdata.level_ &&
115 data_.timestamp_ == rdata.timestamp_);
116 }
117
118private:
119 CompassData data_;
120
121 friend const QDBusArgument &operator>>(const QDBusArgument &argument, Compass& data);
122};
123
124 Q_DECLARE_METATYPE( Compass )
125
126
133inline QDBusArgument &operator<<(QDBusArgument &argument, const Compass &data)
134{
135 argument.beginStructure();
136 argument << data.data().timestamp_ << data.data().degrees_ << data.data().rawDegrees_ << data.data().correctedDegrees_ << data.data().level_;
137 argument.endStructure();
138 return argument;
139}
140
148 inline const QDBusArgument &operator>>(const QDBusArgument &argument, Compass &data)
149{
150 argument.beginStructure();
151 argument >> data.data_.timestamp_ >> data.data_.degrees_ >> data.data_.rawDegrees_ >> data.data_.correctedDegrees_ >> data.data_.level_;
152 argument.endStructure();
153 return argument;
154}
155
156#endif // COMPASS_H
CompassData
Datatype for compass measurements.
Definition: orientationdata.h:112
CompassData::level_
int level_
Magnetometer calibration level.
Definition: orientationdata.h:144
CompassData::degrees_
int degrees_
Angle to north which may be declination corrected or not.
Definition: orientationdata.h:141
CompassData::rawDegrees_
int rawDegrees_
Angle to north without declination correction.
Definition: orientationdata.h:142
CompassData::correctedDegrees_
int correctedDegrees_
Declination corrected angle to north.
Definition: orientationdata.h:143
Compass
QObject facade for CompassData.
Definition: compass.h:38
Compass::degrees
int degrees() const
Returns the value for degrees.
Definition: compass.h:85
Compass::degrees
int degrees
Definition: compass.h:42
Compass::Compass
Compass(const CompassData &data, bool declinationCorrection=true)
Copy constructor.
Compass::operator>>
friend const QDBusArgument & operator>>(const QDBusArgument &argument, Compass &data)
Unmarshall Compass data from the D-Bus argument.
Definition: compass.h:148
Compass::Compass
Compass()
Default constructor.
Definition: compass.h:50
Compass::Compass
Compass(const Compass &data)
Copy constructor.
Compass::operator==
bool operator==(const Compass &right) const
Comparison operator.
Definition: compass.h:110
Compass::level
int level() const
Returns the value for level.
Definition: compass.h:91
Compass::operator=
Compass & operator=(const Compass &origin)
Assignment operator.
Definition: compass.h:98
Compass::data
const CompassData & data() const
Returns the contained CompassData.
Definition: compass.h:79
Compass::level
int level
Definition: compass.h:43
Compass::Compass
Compass(const Compass &data, bool declinationCorrection)
Copy constructor.
TimedData::timestamp_
quint64 timestamp_
monotonic time (microsec)
Definition: genericdata.h:46
operator>>
const QDBusArgument & operator>>(const QDBusArgument &argument, Compass &data)
Unmarshall Compass data from the D-Bus argument.
Definition: compass.h:148
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(TMatrix)
orientationdata.h
Datatypes for different filters.