sensorfw: datatypes/magneticfield.h Source File

sensorfw

magneticfield.h
Go to the documentation of this file.
1
28#ifndef MAGNETICFIELDDATA_H
29#define MAGNETICFIELDDATA_H
30
31#include <QDBusArgument>
32#include <datatypes/orientationdata.h>
33
37 class MagneticField : public QObject
38{
39public:
40 Q_OBJECT;
41
42public:
43
47 MagneticField() : QObject() {}
48
54 MagneticField(const CalibratedMagneticFieldData& calibratedData) : QObject() {
55 data_.timestamp_ = calibratedData.timestamp_;
56 data_.level_ = calibratedData.level_;
57 data_.x_ = calibratedData.x_;
58 data_.y_ = calibratedData.y_;
59 data_.z_ = calibratedData.z_;
60 data_.rx_ = calibratedData.rx_;
61 data_.ry_ = calibratedData.ry_;
62 data_.rz_ = calibratedData.rz_;
63 }
64
70 MagneticField(const MagneticField& data) : QObject() {
71 data_.timestamp_ = data.data_.timestamp_;
72 data_.level_ = data.data_.level_;
73 data_.x_ = data.data_.x_;
74 data_.y_ = data.data_.y_;
75 data_.z_ = data.data_.z_;
76 data_.rx_ = data.data_.rx_;
77 data_.ry_ = data.data_.ry_;
78 data_.rz_ = data.data_.rz_;
79 }
80
86 const CalibratedMagneticFieldData& data() const { return data_; }
87
93 MagneticField& operator=(const MagneticField& origin)
94 {
95 data_.timestamp_ = origin.data_.timestamp_;
96 data_.level_ = origin.data_.level_;
97 data_.x_ = origin.data_.x_;
98 data_.y_ = origin.data_.y_;
99 data_.z_ = origin.data_.z_;
100 data_.rx_ = origin.data_.rx_;
101 data_.ry_ = origin.data_.ry_;
102 data_.rz_ = origin.data_.rz_;
103
104 return *this;
105 }
106
113 bool operator==(const MagneticField& right) const
114 {
115 CalibratedMagneticFieldData rdata = right.data();
116 return (data_.x_ == rdata.x_ &&
117 data_.y_ == rdata.y_ &&
118 data_.z_ == rdata.z_ &&
119 data_.rx_ == rdata.rx_ &&
120 data_.ry_ == rdata.ry_ &&
121 data_.rz_ == rdata.rz_ &&
122 data_.level_ == rdata.level_ &&
123 data_.timestamp_ == rdata.timestamp_);
124 }
125
130 int x() const { return data_.x_; }
131
136 int y() const { return data_.y_; }
137
142 int z() const { return data_.z_; }
143
148 int rx() const { return data_.rx_; }
149
154 int ry() const { return data_.ry_; }
155
160 int rz() const { return data_.rz_; }
161
166 int level() const { return data_.level_; }
167
172 const quint64& timestamp() const { return data_.timestamp_; }
173
174private:
175 CalibratedMagneticFieldData data_;
177 friend const QDBusArgument &operator>>(const QDBusArgument &argument, MagneticField& data);
178};
179
180 Q_DECLARE_METATYPE( MagneticField )
181
182
189inline QDBusArgument &operator<<(QDBusArgument &argument, const MagneticField &data)
190{
191 argument.beginStructure();
192 argument << data.data().timestamp_ << data.data().level_;
193 argument << data.data().x_ << data.data().y_ << data.data().z_;
194 argument << data.data().rx_ << data.data().ry_ << data.data().rz_;
195 argument.endStructure();
196 return argument;
197}
198
206 inline const QDBusArgument &operator>>(const QDBusArgument &argument, MagneticField &data)
207{
208 argument.beginStructure();
209 argument >> data.data_.timestamp_ >> data.data_.level_;
210 argument >> data.data_.x_ >> data.data_.y_ >> data.data_.z_;
211 argument >> data.data_.rx_ >> data.data_.ry_ >> data.data_.rz_;
212 argument.endStructure();
213 return argument;
214}
215
216#endif // MAGNETICFIELDDATA_H
CalibratedMagneticFieldData
Datatype for calibrated magnetometer measurements.
Definition orientationdata.h:59
CalibratedMagneticFieldData::rz_
int rz_
raw Z coordinate value
Definition orientationdata.h:104
CalibratedMagneticFieldData::y_
int y_
Y coordinate value.
Definition orientationdata.h:100
CalibratedMagneticFieldData::x_
int x_
X coordinate value.
Definition orientationdata.h:99
CalibratedMagneticFieldData::rx_
int rx_
raw X coordinate value
Definition orientationdata.h:102
CalibratedMagneticFieldData::ry_
int ry_
raw Y coordinate value
Definition orientationdata.h:103
CalibratedMagneticFieldData::level_
int level_
Magnetometer calibration level.
Definition orientationdata.h:105
CalibratedMagneticFieldData::z_
int z_
Z coordinate value.
Definition orientationdata.h:101
MagneticField
QObject facade for CalibratedMagneticFieldData.
Definition magneticfield.h:38
MagneticField::rz
int rz() const
Returns the raw value for Z.
Definition magneticfield.h:160
MagneticField::z
int z() const
Returns the value for Z.
Definition magneticfield.h:142
MagneticField::level
int level() const
Returns the magnetometer calibration level.
Definition magneticfield.h:166
MagneticField::MagneticField
MagneticField(const MagneticField &data)
Copy constructor.
Definition magneticfield.h:70
MagneticField::y
int y() const
Returns the value for Y.
Definition magneticfield.h:136
MagneticField::operator>>
friend const QDBusArgument & operator>>(const QDBusArgument &argument, MagneticField &data)
Unmarshall MagneticField data from the D-Bus argument.
Definition magneticfield.h:206
MagneticField::operator==
bool operator==(const MagneticField &right) const
Comparison operator.
Definition magneticfield.h:113
MagneticField::MagneticField
MagneticField(const CalibratedMagneticFieldData &calibratedData)
Constructor.
Definition magneticfield.h:54
MagneticField::x
int x() const
Returns the value for X.
Definition magneticfield.h:130
MagneticField::MagneticField
MagneticField()
Default constructor.
Definition magneticfield.h:47
MagneticField::rx
int rx() const
Returns the raw value for X.
Definition magneticfield.h:148
MagneticField::data
const CalibratedMagneticFieldData & data() const
Accessor for contained CalibratedMagneticFieldData.
Definition magneticfield.h:86
MagneticField::ry
int ry() const
Returns the raw value for Y.
Definition magneticfield.h:154
MagneticField::timestamp
const quint64 & timestamp() const
Returns the timestamp of sample as monotonic time (microsec).
Definition magneticfield.h:172
MagneticField::operator=
MagneticField & operator=(const MagneticField &origin)
Assignment operator.
Definition magneticfield.h:93
TimedData::timestamp_
quint64 timestamp_
monotonic time (microsec)
Definition genericdata.h:46
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(TMatrix)
operator>>
const QDBusArgument & operator>>(const QDBusArgument &argument, MagneticField &data)
Unmarshall MagneticField data from the D-Bus argument.
Definition magneticfield.h:206
orientationdata.h
Datatypes for different filters.