summaryrefslogtreecommitdiffstats
path: root/tradeshow/iot-sensortag/sensortagdataprovider.h
blob: 30e59e51c37b9613bfaa56c95cbdfa42faca8375 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the examples of Qt for Device Creation.
**
** $QT_BEGIN_LICENSE:BSD$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
**   * Redistributions of source code must retain the above copyright
**     notice, this list of conditions and the following disclaimer.
**   * Redistributions in binary form must reproduce the above copyright
**     notice, this list of conditions and the following disclaimer in
**     the documentation and/or other materials provided with the
**     distribution.
**   * Neither the name of The Qt Company Ltd nor the names of its
**     contributors may be used to endorse or promote products derived
**     from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef SENSORTAGDATAPROVIDER_H
#define SENSORTAGDATAPROVIDER_H
#include <QObject>
#include <QString>
#include <QColor>
#include <QQmlEngine>

class SensorTagDataProvider : public QObject
{
    Q_OBJECT
    Q_ENUMS(TagType)
    Q_ENUMS(ProviderState)
    Q_PROPERTY(ProviderState state READ state NOTIFY stateChanged)
    Q_PROPERTY(QString name MEMBER m_name CONSTANT)
    Q_PROPERTY(QString providerId MEMBER m_id CONSTANT)
    Q_PROPERTY(QString relativeHumidityString READ getRelativeHumidityString NOTIFY relativeHumidityChanged)
    Q_PROPERTY(double relativeHumidity READ getRelativeHumidity NOTIFY relativeHumidityChanged)
    Q_PROPERTY(double infraredAmbientTemperature READ getInfraredAmbientTemperature NOTIFY infraredAmbientTemperatureChanged)
    Q_PROPERTY(double infraredObjectTemperature READ getInfraredObjectTemperature NOTIFY infraredObjectTemperatureChanged)
    Q_PROPERTY(QString lightIntensityLuxString READ getLightIntensityLuxString NOTIFY lightIntensityChanged)
    Q_PROPERTY(double lightIntensityLux READ getLightIntensityLux NOTIFY lightIntensityChanged)
    Q_PROPERTY(double barometerCelsiusTemperature READ getBarometerCelsiusTemperature NOTIFY barometerCelsiusTemperatureChanged)
    Q_PROPERTY(QString barometerCelsiusTemperatureString READ getBarometerCelsiusTemperatureString NOTIFY barometerCelsiusTemperatureChanged)
    Q_PROPERTY(QString barometer_hPaString READ getBarometer_hPaString NOTIFY barometer_hPaChanged)
    Q_PROPERTY(double barometerTemperatureAverage READ getBarometerTemperatureAverage NOTIFY barometerCelsiusTemperatureAverageChanged)
    Q_PROPERTY(double barometerHPa READ getBarometer_hPa NOTIFY barometer_hPaChanged)
    Q_PROPERTY(float gyroscopeX_degPerSec READ getGyroscopeX_degPerSec NOTIFY gyroscopeDegPerSecChanged)
    Q_PROPERTY(float gyroscopeY_degPerSec READ getGyroscopeY_degPerSec NOTIFY gyroscopeDegPerSecChanged)
    Q_PROPERTY(float gyroscopeZ_degPerSec READ getGyroscopeZ_degPerSec NOTIFY gyroscopeDegPerSecChanged)
    Q_PROPERTY(int accelometer_mG_xAxis READ getAccelometer_mG_xAxis NOTIFY accelometerGChanged)
    Q_PROPERTY(int accelometer_mG_yAxis READ getAccelometer_mG_yAxis NOTIFY accelometerGChanged)
    Q_PROPERTY(int accelometer_mG_zAxis READ getAccelometer_mG_zAxis NOTIFY accelometerGChanged)
    Q_PROPERTY(float magnetometerMicroT_xAxis READ getMagnetometerMicroT_xAxis NOTIFY magnetometerMicroTChanged)
    Q_PROPERTY(float magnetometerMicroT_yAxis READ getMagnetometerMicroT_yAxis NOTIFY magnetometerMicroTChanged)
    Q_PROPERTY(float magnetometerMicroT_zAxis READ getMagnetometerMicroT_zAxis NOTIFY magnetometerMicroTChanged)
    Q_PROPERTY(float rotationX READ getRotationX NOTIFY rotationXChanged)
    Q_PROPERTY(float rotationY READ getRotationY NOTIFY rotationYChanged)
    Q_PROPERTY(float rotationZ READ getRotationZ NOTIFY rotationZChanged)

public:
    enum TagType {AmbientTemperature = 1 << 0,
                  ObjectTemperature = 1 << 1,
                  Humidity,
                  AirPressure = 1 << 2,
                  Light = 1 << 3,
                  Magnetometer = 1 << 4,
                  Rotation = 1 << 5};
    enum ProviderState {Disconnected = 0, Scanning, Connected, Error};

    explicit SensorTagDataProvider(QObject *parent = 0);
    SensorTagDataProvider(QString id, QObject *parent = 0);

    virtual bool startDataFetching() {return false;}
    virtual void endDataFetching() {}
    QString getRelativeHumidityString();
    double getRelativeHumidity();
    double getInfraredAmbientTemperature();
    double getInfraredObjectTemperature();
    QString getLightIntensityLuxString();
    double getLightIntensityLux();
    double getBarometerCelsiusTemperature();
    QString getBarometerCelsiusTemperatureString();
    double getBarometerTemperatureAverage();
    QString getBarometer_hPaString();
    double getBarometer_hPa();
    float getGyroscopeX_degPerSec();
    float getGyroscopeY_degPerSec();
    float getGyroscopeZ_degPerSec();
    float getAccelometer_mG_xAxis();
    float getAccelometer_mG_yAxis();
    float getAccelometer_mG_zAxis();
    float getMagnetometerMicroT_xAxis();
    float getMagnetometerMicroT_yAxis();
    float getMagnetometerMicroT_zAxis();
    float getRotationX();
    float getRotationY();
    float getRotationZ();

    Q_INVOKABLE int tagType() const;
    QString id() const;
    ProviderState state() const;
    void setState(ProviderState state);

    virtual QString providerName() const { return m_name;}
    virtual QString sensorType() const { return QString();}
    virtual QString versionString() const{ return QString();}


signals:
    void stateChanged();
    void relativeHumidityChanged();
    void infraredAmbientTemperatureChanged();
    void infraredObjectTemperatureChanged();
    void lightIntensityChanged();
    void barometerCelsiusTemperatureChanged();
    void barometerCelsiusTemperatureAverageChanged();
    void barometer_hPaChanged();
    void gyroscopeDegPerSecChanged();
    void accelometerGChanged();
    void magnetometerMicroTChanged();
    void rotationXChanged();
    void rotationYChanged();
    void rotationZChanged();
    void rotationValuesChanged();

protected:
    double humidity;
    double irAmbientTemperature;
    double irObjectTemperature;
    double lightIntensityLux;
    double barometerCelsiusTemperature;
    double barometerTemperatureAverage;
    double barometerHPa;
    //double temperatureAverage;
    float gyroscopeX_degPerSec;
    float gyroscopeY_degPerSec;
    float gyroscopeZ_degPerSec;
    int accelometer_mG_xAxis;
    int accelometer_mG_yAxis;
    int accelometer_mG_zAxis;
    float magnetometerMicroT_xAxis;
    float magnetometerMicroT_yAxis;
    float magnetometerMicroT_zAxis;
    float rotation_x;
    float rotation_y;
    float rotation_z;

    int m_tagType;
    QString m_id;
    QString m_name;
    ProviderState m_state;
};

Q_DECLARE_METATYPE(SensorTagDataProvider::TagType)
Q_DECLARE_METATYPE(SensorTagDataProvider::ProviderState)

#endif // SENSORTAGDATAPROVIDER_H